diff options
-rw-r--r-- | database/metadata.cpp | 3 | ||||
-rw-r--r-- | database/object.cpp | 58 | ||||
-rw-r--r-- | misc/avdetector.cpp | 66 | ||||
-rw-r--r-- | misc/avdetector.h | 22 | ||||
-rw-r--r-- | misc/avdetector.o | bin | 0 -> 41580 bytes |
5 files changed, 119 insertions, 30 deletions
diff --git a/database/metadata.cpp b/database/metadata.cpp index 6966602..bf99e82 100644 --- a/database/metadata.cpp +++ b/database/metadata.cpp @@ -36,6 +36,7 @@ cMediaDatabase::cMediaDatabase(){ this->mFactory->registerMediator(UPNP_CLASS_CONTAINER, new cUPnPContainerMediator(this)); this->mFactory->registerMediator(UPNP_CLASS_VIDEO, new cUPnPVideoItemMediator(this)); this->mFactory->registerMediator(UPNP_CLASS_VIDEOBC, new cUPnPVideoBroadcastMediator(this)); + this->mFactory->registerMediator(UPNP_CLASS_MOVIE, new cUPnPMovieMediator(this)); } cMediaDatabase::~cMediaDatabase(){ @@ -336,7 +337,7 @@ int cMediaDatabase::loadRecordings(){ inList = (MovieItem && Records->getObject(MovieItem->getID())) ? true : false; - if(inList){ + if(!inList){ noResource = false; const cRecordingInfo* RecInfo = Recording->Info(); diff --git a/database/object.cpp b/database/object.cpp index 0587f6a..6683dd2 100644 --- a/database/object.cpp +++ b/database/object.cpp @@ -942,35 +942,35 @@ int cUPnPClassMovie::setDVDRegionCode(int RegionCode){ int cUPnPClassMovie::setStorageMedium(const char* StorageMedium){ if(!StorageMedium) this->mStorageMedium = UPNP_STORAGE_UNKNOWN; else if( - strcasecmp(StorageMedium,UPNP_STORAGE_CD_DA) || - strcasecmp(StorageMedium,UPNP_STORAGE_CD_R) || - strcasecmp(StorageMedium,UPNP_STORAGE_CD_ROM) || - strcasecmp(StorageMedium,UPNP_STORAGE_CD_RW) || - strcasecmp(StorageMedium,UPNP_STORAGE_DAT) || - strcasecmp(StorageMedium,UPNP_STORAGE_DV) || - strcasecmp(StorageMedium,UPNP_STORAGE_DVD_AUDIO) || - strcasecmp(StorageMedium,UPNP_STORAGE_DVD_RAM) || - strcasecmp(StorageMedium,UPNP_STORAGE_DVD_ROM) || - strcasecmp(StorageMedium,UPNP_STORAGE_DVD_RW_MINUS) || - strcasecmp(StorageMedium,UPNP_STORAGE_DVD_RW_PLUS) || - strcasecmp(StorageMedium,UPNP_STORAGE_DVD_R_MINUS) || - strcasecmp(StorageMedium,UPNP_STORAGE_DVD_VIDEO) || - strcasecmp(StorageMedium,UPNP_STORAGE_D_VHS) || - strcasecmp(StorageMedium,UPNP_STORAGE_HDD) || - strcasecmp(StorageMedium,UPNP_STORAGE_HI8) || - strcasecmp(StorageMedium,UPNP_STORAGE_LD) || - strcasecmp(StorageMedium,UPNP_STORAGE_MD_AUDIO) || - strcasecmp(StorageMedium,UPNP_STORAGE_MD_PICTURE) || - strcasecmp(StorageMedium,UPNP_STORAGE_MICRO_MV) || - strcasecmp(StorageMedium,UPNP_STORAGE_MINI_DV) || - strcasecmp(StorageMedium,UPNP_STORAGE_NETWORK) || - strcasecmp(StorageMedium,UPNP_STORAGE_SACD) || - strcasecmp(StorageMedium,UPNP_STORAGE_S_VHS) || - strcasecmp(StorageMedium,UPNP_STORAGE_UNKNOWN) || - strcasecmp(StorageMedium,UPNP_STORAGE_VHS) || - strcasecmp(StorageMedium,UPNP_STORAGE_VHSC) || - strcasecmp(StorageMedium,UPNP_STORAGE_VIDEO8) || - strcasecmp(StorageMedium,UPNP_STORAGE_VIDEO_CD) || + strcasecmp(StorageMedium,UPNP_STORAGE_CD_DA) && + strcasecmp(StorageMedium,UPNP_STORAGE_CD_R) && + strcasecmp(StorageMedium,UPNP_STORAGE_CD_ROM) && + strcasecmp(StorageMedium,UPNP_STORAGE_CD_RW) && + strcasecmp(StorageMedium,UPNP_STORAGE_DAT) && + strcasecmp(StorageMedium,UPNP_STORAGE_DV) && + strcasecmp(StorageMedium,UPNP_STORAGE_DVD_AUDIO) && + strcasecmp(StorageMedium,UPNP_STORAGE_DVD_RAM) && + strcasecmp(StorageMedium,UPNP_STORAGE_DVD_ROM) && + strcasecmp(StorageMedium,UPNP_STORAGE_DVD_RW_MINUS) && + strcasecmp(StorageMedium,UPNP_STORAGE_DVD_RW_PLUS) && + strcasecmp(StorageMedium,UPNP_STORAGE_DVD_R_MINUS) && + strcasecmp(StorageMedium,UPNP_STORAGE_DVD_VIDEO) && + strcasecmp(StorageMedium,UPNP_STORAGE_D_VHS) && + strcasecmp(StorageMedium,UPNP_STORAGE_HDD) && + strcasecmp(StorageMedium,UPNP_STORAGE_HI8) && + strcasecmp(StorageMedium,UPNP_STORAGE_LD) && + strcasecmp(StorageMedium,UPNP_STORAGE_MD_AUDIO) && + strcasecmp(StorageMedium,UPNP_STORAGE_MD_PICTURE) && + strcasecmp(StorageMedium,UPNP_STORAGE_MICRO_MV) && + strcasecmp(StorageMedium,UPNP_STORAGE_MINI_DV) && + strcasecmp(StorageMedium,UPNP_STORAGE_NETWORK) && + strcasecmp(StorageMedium,UPNP_STORAGE_SACD) && + strcasecmp(StorageMedium,UPNP_STORAGE_S_VHS) && + strcasecmp(StorageMedium,UPNP_STORAGE_UNKNOWN) && + strcasecmp(StorageMedium,UPNP_STORAGE_VHS) && + strcasecmp(StorageMedium,UPNP_STORAGE_VHSC) && + strcasecmp(StorageMedium,UPNP_STORAGE_VIDEO8) && + strcasecmp(StorageMedium,UPNP_STORAGE_VIDEO_CD) && strcasecmp(StorageMedium,UPNP_STORAGE_W_VHS) ){ ERROR("Invalid storage type: %s", StorageMedium); diff --git a/misc/avdetector.cpp b/misc/avdetector.cpp new file mode 100644 index 0000000..d66988e --- /dev/null +++ b/misc/avdetector.cpp @@ -0,0 +1,66 @@ +/* + * File: avdetector.cpp + * Author: savop + * + * Created on 26. Oktober 2009, 13:01 + */ + +#include "avdetector.h" +extern "C" { +#include <libavformat/avformat.h> +#include <libavcodec/avcodec.h> +} + +using namespace std; + +int cAudioVideoDetector::detectVideoProperties(cUPnPResource* Resource, const char* Filename){ +// // Register avformat + av_register_all(); + + AVFormatContext *FormatCtx = NULL; + if(av_open_input_file(&FormatCtx, Filename, NULL, 0, NULL)){ + ERROR("AVDetector: Error while opening file %s", Filename); + return -1; + } + + if(av_find_stream_info(FormatCtx)<0){ + ERROR("AVDetector: Cannot find the stream information"); + return -1; + } + +#ifdef DEBUG + dump_format(FormatCtx, 0, Filename, 0); +#endif + + unsigned int i; int videoStream = -1; + + AVCodecContext *CodecCtx = NULL; + for(i = 0; i < FormatCtx->nb_streams; i++){ + if(FormatCtx->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO){ + videoStream = i; + break; + } + } + if(videoStream == -1){ + ERROR("AVDetector: No video stream found"); + return -1; + } + + CodecCtx = FormatCtx->streams[videoStream]->codec; + + AVCodec* Codec = avcodec_find_decoder(CodecCtx->codec_id); + + unsigned int width = CodecCtx->width; + unsigned int height = CodecCtx->height; + unsigned int bitrate = CodecCtx->bit_rate; + const char* codecName = (Codec)?Codec->name:"unknown"; + + MESSAGE("AVDetector: %s-stream %dx%d at %d bit/s", codecName, width, height, bitrate); + + Resource->mBitrate = bitrate; + Resource->mSampleFrequency = CodecCtx->sample_rate; + Resource->mResolution = cString::sprintf("%dx%d", width, height); + + return 0; + +} diff --git a/misc/avdetector.h b/misc/avdetector.h new file mode 100644 index 0000000..0b8bb81 --- /dev/null +++ b/misc/avdetector.h @@ -0,0 +1,22 @@ +/* + * File: avdetector.h + * Author: savop + * + * Created on 26. Oktober 2009, 13:02 + */ + +#ifndef _AVDETECTOR_H +#define _AVDETECTOR_H + +#include "../database/object.h" + +class cAudioVideoDetector { +public: + cAudioVideoDetector(){}; + virtual ~cAudioVideoDetector(){}; + int detectVideoProperties(cUPnPResource* Resource, const char* Filename); +private: +}; + +#endif /* _AVDETECTOR_H */ + diff --git a/misc/avdetector.o b/misc/avdetector.o Binary files differnew file mode 100644 index 0000000..130619d --- /dev/null +++ b/misc/avdetector.o |