summaryrefslogtreecommitdiff
path: root/database
diff options
context:
space:
mode:
authorDenis Loh <denis.loh@gmail.com>2009-12-29 19:34:50 +0100
committerDenis Loh <denis.loh@gmail.com>2009-12-29 19:34:50 +0100
commit60db82604cd0ab407e857b9f11d9588f9076333b (patch)
tree11cc9c5f4a5b4a784727eccfecb9e5cca2c69ac3 /database
parent2d245fcabb385347359759de8e6c40ce16e43cab (diff)
downloadvdr-plugin-upnp-60db82604cd0ab407e857b9f11d9588f9076333b.tar.gz
vdr-plugin-upnp-60db82604cd0ab407e857b9f11d9588f9076333b.tar.bz2
Added mpeg4 p2 profiles
Diffstat (limited to 'database')
-rw-r--r--database/object.cpp4
-rw-r--r--database/object.h12
-rw-r--r--database/resources.cpp115
3 files changed, 66 insertions, 65 deletions
diff --git a/database/object.cpp b/database/object.cpp
index f6875f9..5ab355d 100644
--- a/database/object.cpp
+++ b/database/object.cpp
@@ -35,10 +35,6 @@ cUPnPResource::cUPnPResource(){
this->mContentType = NULL;
}
-off64_t cUPnPResource::getFileSize() const {
- return (this->mSize) ? this->mSize : (off64_t)-1;
-}
-
time_t cUPnPResource::getLastModification() const {
time_t Time;
const cRecording* Recording;
diff --git a/database/object.h b/database/object.h
index 245a617..9c2c133 100644
--- a/database/object.h
+++ b/database/object.h
@@ -137,7 +137,7 @@ private:
cString mProtocolInfo;
cString mContentType;
cString mImportURI;
- unsigned long mSize;
+ off64_t mSize;
unsigned int mBitrate;
unsigned int mSampleFrequency;
unsigned int mBitsPerSample;
@@ -212,14 +212,6 @@ public:
*/
int getResourceType() const { return this->mResourceType; }
/**
- * Get the size
- *
- * Returns the resource size or -1 if its unknown
- *
- * @return the resource size or -1 if unknown
- */
- unsigned long getSize() const { return this->mSize; }
- /**
* Get the file size
*
* Returns the file size in bytes of the resource or 0 if its unknown or a
@@ -227,7 +219,7 @@ public:
*
* @return the file size
*/
- off64_t getFileSize() const;
+ off64_t getFileSize() const { return this->mSize; };
/**
* Get the last modification
*
diff --git a/database/resources.cpp b/database/resources.cpp
index 8f0dec4..646560a 100644
--- a/database/resources.cpp
+++ b/database/resources.cpp
@@ -90,24 +90,45 @@ cUPnPResource* cUPnPResources::getResource(unsigned int ResourceID){
}
int cUPnPResources::createFromRecording(cUPnPClassVideoItem* Object, cRecording* Recording){
- cString VideoFile = cString::sprintf(VDR_RECORDFILE_PATTERN_TS, Recording->FileName(), 1);
-
- cAudioVideoDetector* Detector = new cAudioVideoDetector();
-
- // TODO: add DLNA-Support to detector
-
- cString ContentType = "video/mpeg";
- cString ProtocolInfo = "http-get:*:video/mpeg:*";
+ if(!Object || !Recording){
+ ERROR("Invalid input arguments");
+ return -1;
+ }
- cUPnPResource* Resource = this->mMediator->newResource(Object, UPNP_RESOURCE_RECORDING, Recording->FileName(), ContentType, ProtocolInfo);
+ cAudioVideoDetector* Detector = new cAudioVideoDetector(Recording);
- if(Detector->detectVideoProperties(Resource, VideoFile)){
+ if(Detector->detectProperties()){
ERROR("Error while detecting video properties");
+ delete Detector;
return -1;
}
+ if(!Detector->getDLNAProfile()){
+ ERROR("No DLNA profile found for Recording %s", Recording->Name());
+ delete Detector;
+ return -1;
+ }
+
+ const char* ProtocolInfo = cDlna::getInstance()->getProtocolInfo(Detector->getDLNAProfile());
+
+ MESSAGE(VERBOSE_METADATA, "Protocol info: %s", ProtocolInfo);
+
+ cString ResourceFile = Recording->FileName();
+ cUPnPResource* Resource = this->mMediator->newResource(Object, UPNP_RESOURCE_RECORDING,ResourceFile, Detector->getDLNAProfile()->mime, ProtocolInfo);
+ Resource->mBitrate = Detector->getBitrate();
+ Resource->mBitsPerSample = Detector->getBitsPerSample();
+ Resource->mDuration = duration(Detector->getDuration());
+ Resource->mResolution = (Detector->getWidth() && Detector->getHeight()) ? *cString::sprintf("%dx%d",Detector->getWidth(), Detector->getHeight()) : NULL;
+ Resource->mSampleFrequency = Detector->getSampleFrequency();
+ Resource->mSize = Detector->getFileSize();
+ Resource->mNrAudioChannels = Detector->getNumberOfAudioChannels();
+ Resource->mImportURI = NULL;
+ Resource->mColorDepth = 0;
+ Object->addResource(Resource);
+ this->mMediator->saveResource(Resource);
+ this->mResources->Add(Resource, Resource->getID());
+
delete Detector;
- MESSAGE(VERBOSE_SDK, "To be continued, may it work with DLNA?! Guess, not!");
return 0;
}
@@ -122,53 +143,45 @@ int cUPnPResources::createFromChannel(cUPnPClassVideoBroadcast* Object, cChannel
return -1;
}
- DLNAProfile* Profile = cDlna::getInstance()->getProfileOfChannel(Channel);
+ cAudioVideoDetector* Detector = new cAudioVideoDetector(Channel);
+
+ if(!Detector->detectProperties()){
+ ERROR("Cannot detect channel properties");
+ delete Detector;
+ return -1;
+ }
- if(!Profile){
- ERROR("No profile found for Channel %s", *Channel->GetChannelID().ToString());
+ if(!Detector->getDLNAProfile()){
+ ERROR("No DLNA profile found for Channel %s", *Channel->GetChannelID().ToString());
+ delete Detector;
return -1;
}
- const char* ProtocolInfo = cDlna::getInstance()->getProtocolInfo(Profile);
+ const char* ProtocolInfo = cDlna::getInstance()->getProtocolInfo(Detector->getDLNAProfile());
MESSAGE(VERBOSE_METADATA, "Protocol info: %s", ProtocolInfo);
- // Adapted from streamdev
+ // Index which may be used to indicate different resources with same channel ID
+ // For instance a different DVB card
+ // Not used yet.
int index = 0;
- for(int i=0; Channel->Apid(i)!=0; i++, index++){
- MESSAGE(VERBOSE_METADATA, "Analog channel %d", i);
- cString ResourceFile = cString::sprintf("%s:%d", *Channel->GetChannelID().ToString(), index);
- cUPnPResource* Resource = this->mMediator->newResource(Object, UPNP_RESOURCE_CHANNEL,ResourceFile, Profile->mime, ProtocolInfo);
- Resource->mBitrate = 0;
- Resource->mBitsPerSample = 0;
- Resource->mColorDepth = 0;
- Resource->mDuration = NULL;
- Resource->mImportURI = NULL;
- Resource->mResolution = NULL;
- Resource->mSampleFrequency = 0;
- Resource->mSize = 0;
- Resource->mNrAudioChannels = 0;
- Object->addResource(Resource);
- this->mMediator->saveResource(Resource);
- this->mResources->Add(Resource, Resource->getID());
- }
- for(int i=0; Channel->Dpid(i)!=0; i++, index++){
- MESSAGE(VERBOSE_METADATA, "Digital channel %d", i);
- cString ResourceFile = cString::sprintf("%s:%d", *Channel->GetChannelID().ToString(), index);
- cUPnPResource* Resource = this->mMediator->newResource(Object, UPNP_RESOURCE_CHANNEL,ResourceFile, Profile->mime, ProtocolInfo);
- Resource->mBitrate = 0;
- Resource->mBitsPerSample = 0;
- Resource->mColorDepth = 0;
- Resource->mDuration = NULL;
- Resource->mImportURI = NULL;
- Resource->mResolution = NULL;
- Resource->mSampleFrequency = 0;
- Resource->mSize = 0;
- Object->addResource(Resource);
- this->mMediator->saveResource(Resource);
- this->mResources->Add(Resource, Resource->getID());
- }
+
+ cString ResourceFile = cString::sprintf("%s:%d", *Channel->GetChannelID().ToString(), index);
+ cUPnPResource* Resource = this->mMediator->newResource(Object, UPNP_RESOURCE_CHANNEL,ResourceFile, Detector->getDLNAProfile()->mime, ProtocolInfo);
+ Resource->mBitrate = Detector->getBitrate();
+ Resource->mBitsPerSample = Detector->getBitsPerSample();
+ Resource->mDuration = duration(Detector->getDuration());
+ Resource->mResolution = (Detector->getWidth() && Detector->getHeight()) ? *cString::sprintf("%dx%d",Detector->getWidth(), Detector->getHeight()) : NULL;
+ Resource->mSampleFrequency = Detector->getSampleFrequency();
+ Resource->mSize = Detector->getFileSize();
+ Resource->mNrAudioChannels = Detector->getNumberOfAudioChannels();
+ Resource->mImportURI = NULL;
+ Resource->mColorDepth = 0;
+ Object->addResource(Resource);
+ this->mMediator->saveResource(Resource);
+ this->mResources->Add(Resource, Resource->getID());
+ delete Detector;
return 0;
}
@@ -205,7 +218,7 @@ cUPnPResource* cUPnPResourceMediator::getResource(unsigned int ResourceID){
Resource->mResource = Value;
}
else if(!strcasecmp(SQLITE_COL_SIZE, Column)){
- Resource->mSize = *Value?atol(Value):0;
+ Resource->mSize = (off64_t)(*Value?atol(Value):0);
}
else if(!strcasecmp(SQLITE_COL_DURATION, Column)){
Resource->mDuration = Value;
@@ -243,7 +256,7 @@ int cUPnPResourceMediator::saveResource(cUPnPResource* Resource){
cString Format = "UPDATE %s SET %s=%Q,"
"%s=%Q,"
"%s=%Q,"
- "%s=%ld,"
+ "%s=%lld,"
"%s=%Q,"
"%s=%d,"
"%s=%d,"