| |   |
| 25 | 25 | #include <strigi/fieldtypes.h> |
| 26 | 26 | #include <strigi/textutils.h> |
| 27 | 27 | #include <strigi/rdfnamespaces.h> |
| #include <strigi/strigi_thread.h> |
| 28 | 29 | extern "C" { |
| 29 | 30 | #include <libavcodec/avcodec.h> |
| 30 | 31 | #include <libavformat/avformat.h> |
| … | … | |
| 34 | 34 | #include <cstring> |
| 35 | 35 | #include <iostream> |
| 36 | 36 | #include <sstream> |
| #include <cassert> |
| 37 | 38 | using namespace Strigi; |
| 38 | 39 | using namespace std; |
| 39 | 40 | |
| … | … | |
| 55 | 55 | signed char analyze(AnalysisResult& idx, ::InputStream* in); |
| 56 | 56 | }; |
| 57 | 57 | |
| STRIGI_MUTEX_DEFINE(mutex); |
|
| static int |
| lockmgr(void **mtx, enum AVLockOp op) { |
| // pre-allocating a single mutex is the only way to get it to work without changing strigi_thread.h |
| assert( (*mtx == &mutex) || (op == AV_LOCK_CREATE) ); |
| switch(op) { |
| case AV_LOCK_CREATE: |
| *mtx = &mutex; |
| return !!STRIGI_MUTEX_INIT(&mutex); |
| case AV_LOCK_OBTAIN: |
| return !!STRIGI_MUTEX_LOCK(&mutex); |
| case AV_LOCK_RELEASE: |
| return !!STRIGI_MUTEX_UNLOCK(&mutex); |
| case AV_LOCK_DESTROY: |
| STRIGI_MUTEX_DESTROY(&mutex); |
| return 0; |
| } |
| return 1; |
| } |
|
| 58 | 79 | class STRIGI_PLUGIN_API FFMPEGEndAnalyzerFactory : public StreamEndAnalyzerFactory { |
| 59 | 80 | friend class FFMPEGEndAnalyzer; |
| public: |
| FFMPEGEndAnalyzerFactory() { |
| av_lockmgr_register(lockmgr); |
| av_register_all(); |
| } |
| 60 | 86 | private: |
| ~FFMPEGEndAnalyzerFactory() { |
| av_lockmgr_register(NULL); |
| } |
| 61 | 90 | StreamEndAnalyzer* newInstance() const { |
| av_register_all(); |
| 63 | 91 | return new FFMPEGEndAnalyzer(this); |
| 64 | 92 | } |
| 65 | 93 | const char* name() const { |
| … | … | |
| 221 | 221 | // Unfortunately you can't save probe results in checkHeader because it's const |
| 222 | 222 | bool |
| 223 | 223 | FFMPEGEndAnalyzer::checkHeader(const char* header, int32_t headersize) const { |
| |
| // A workaround to let internal MP3, OGG and FLAC analyzers take priority |
| if ((headersize>=64) && ( |
| (strncmp("ID3", header, 3) == 0 && ((unsigned char)header[3]) <= 4 && header[5] == 0) |
| || ((readLittleEndianUInt32(header) == 0x43614c66) && ((readLittleEndianUInt32(header+4) & 0xFFFFFF7F) == 0x22000000)) |
| || (!strcmp("OggS", header) && !strcmp("vorbis", header+29) && !strcmp("OggS", header+58))) ) |
| return false; |
| |
| 224 | 232 | AVProbeData pd; |
| 225 | 233 | pd.buf = (unsigned char*)header; |
| 226 | 234 | pd.buf_size = headersize; |
| … | … | |
| 249 | 249 | handle subtitles |
| 250 | 250 | */ |
| 251 | 251 | |
| extern "C" { |
| 253 | 252 | int read_data(void *opaque, uint8_t *buf, int buf_size) { |
| 254 | 253 | cout<<"READ"; |
| 255 | 254 | InputStream *s = (InputStream *) opaque; |
| … | … | |
| 286 | 286 | int64_t t= s->reset(target); |
| 287 | 287 | cout<<t<<"\n"<<flush; |
| 288 | 288 | return (t == target ? target : -1); |
| } |
| 290 | 289 | } |
| 291 | 290 | |
| 292 | 291 | int64_t const no_bitrate = 0x8000000000000000ULL; |