1218a8c03SAugustin Cavalier /* 2218a8c03SAugustin Cavalier * Copyright 2009-2010, Stephan Aßmus <supertippi@gmx.de>. All rights reserved. 3218a8c03SAugustin Cavalier * Copyright 2009, Axel Dörfler, axeld@pinc-software.de. 4218a8c03SAugustin Cavalier * Copyright 2008, Maurice Kalinowski. All rights reserved. 5218a8c03SAugustin Cavalier * Copyright 2004-2007, Marcus Overhagen. All rights reserved. 6218a8c03SAugustin Cavalier * 7218a8c03SAugustin Cavalier * Distributed under the terms of the MIT License. 8218a8c03SAugustin Cavalier */ 9218a8c03SAugustin Cavalier #ifndef _MEDIA_EXTRACTOR_H 10218a8c03SAugustin Cavalier #define _MEDIA_EXTRACTOR_H 11218a8c03SAugustin Cavalier 12218a8c03SAugustin Cavalier 13218a8c03SAugustin Cavalier #include "ReaderPlugin.h" 14218a8c03SAugustin Cavalier #include "DecoderPlugin.h" 15218a8c03SAugustin Cavalier 16218a8c03SAugustin Cavalier 17218a8c03SAugustin Cavalier namespace BPrivate { 18218a8c03SAugustin Cavalier namespace media { 19218a8c03SAugustin Cavalier 20218a8c03SAugustin Cavalier 21218a8c03SAugustin Cavalier class ChunkCache; 22218a8c03SAugustin Cavalier struct chunk_buffer; 23218a8c03SAugustin Cavalier 24218a8c03SAugustin Cavalier 25218a8c03SAugustin Cavalier struct stream_info { 26218a8c03SAugustin Cavalier status_t status; 27218a8c03SAugustin Cavalier void* cookie; 28218a8c03SAugustin Cavalier bool hasCookie; 29218a8c03SAugustin Cavalier const void* infoBuffer; 30218a8c03SAugustin Cavalier size_t infoBufferSize; 31218a8c03SAugustin Cavalier ChunkCache* chunkCache; 32218a8c03SAugustin Cavalier chunk_buffer* lastChunk; 33218a8c03SAugustin Cavalier media_format encodedFormat; 34218a8c03SAugustin Cavalier }; 35218a8c03SAugustin Cavalier 36218a8c03SAugustin Cavalier 37218a8c03SAugustin Cavalier class MediaExtractor { 38218a8c03SAugustin Cavalier public: 39218a8c03SAugustin Cavalier MediaExtractor(BDataIO* source, int32 flags); 40218a8c03SAugustin Cavalier 41218a8c03SAugustin Cavalier ~MediaExtractor(); 42218a8c03SAugustin Cavalier 43218a8c03SAugustin Cavalier status_t InitCheck(); 44218a8c03SAugustin Cavalier 45218a8c03SAugustin Cavalier void GetFileFormatInfo( 46218a8c03SAugustin Cavalier media_file_format* fileFormat) const; 47218a8c03SAugustin Cavalier status_t GetMetaData(BMessage* _data) const; 48218a8c03SAugustin Cavalier 49218a8c03SAugustin Cavalier int32 StreamCount(); 50218a8c03SAugustin Cavalier 51218a8c03SAugustin Cavalier const char* Copyright(); 52218a8c03SAugustin Cavalier 53218a8c03SAugustin Cavalier const media_format* EncodedFormat(int32 stream); 54218a8c03SAugustin Cavalier int64 CountFrames(int32 stream) const; 55218a8c03SAugustin Cavalier bigtime_t Duration(int32 stream) const; 56218a8c03SAugustin Cavalier 57218a8c03SAugustin Cavalier status_t Seek(int32 stream, uint32 seekTo, 58218a8c03SAugustin Cavalier int64* _frame, bigtime_t* _time); 59218a8c03SAugustin Cavalier status_t FindKeyFrame(int32 stream, uint32 seekTo, 60218a8c03SAugustin Cavalier int64* _frame, bigtime_t* _time) const; 61218a8c03SAugustin Cavalier 62218a8c03SAugustin Cavalier status_t GetNextChunk(int32 stream, 63218a8c03SAugustin Cavalier const void** _chunkBuffer, 64218a8c03SAugustin Cavalier size_t* _chunkSize, 65218a8c03SAugustin Cavalier media_header* mediaHeader); 66218a8c03SAugustin Cavalier 67218a8c03SAugustin Cavalier status_t CreateDecoder(int32 stream, Decoder** _decoder, 68218a8c03SAugustin Cavalier media_codec_info* codecInfo); 69218a8c03SAugustin Cavalier 70218a8c03SAugustin Cavalier status_t GetStreamMetaData(int32 stream, 71218a8c03SAugustin Cavalier BMessage* _data) const; 72218a8c03SAugustin Cavalier 73218a8c03SAugustin Cavalier void StopProcessing(); 74218a8c03SAugustin Cavalier 75218a8c03SAugustin Cavalier 76218a8c03SAugustin Cavalier private: 77218a8c03SAugustin Cavalier void _Init(BDataIO* source, int32 flags); 78218a8c03SAugustin Cavalier 79218a8c03SAugustin Cavalier void _RecycleLastChunk(stream_info& info); 80218a8c03SAugustin Cavalier static int32 _ExtractorEntry(void* arg); 81218a8c03SAugustin Cavalier void _ExtractorThread(); 82*6b49a15bSAlexander von Gluck IV size_t _CalculateChunkBuffer(int32 stream); 83218a8c03SAugustin Cavalier 84218a8c03SAugustin Cavalier private: 85218a8c03SAugustin Cavalier status_t fInitStatus; 86218a8c03SAugustin Cavalier 87218a8c03SAugustin Cavalier sem_id fExtractorWaitSem; 88218a8c03SAugustin Cavalier thread_id fExtractorThread; 89218a8c03SAugustin Cavalier 90218a8c03SAugustin Cavalier BDataIO* fSource; 91218a8c03SAugustin Cavalier Reader* fReader; 92218a8c03SAugustin Cavalier 93218a8c03SAugustin Cavalier stream_info* fStreamInfo; 94218a8c03SAugustin Cavalier int32 fStreamCount; 95218a8c03SAugustin Cavalier 96218a8c03SAugustin Cavalier media_file_format fFileFormat; 97218a8c03SAugustin Cavalier }; 98218a8c03SAugustin Cavalier 99218a8c03SAugustin Cavalier } // namespace media 100218a8c03SAugustin Cavalier } // namespace BPrivate 101218a8c03SAugustin Cavalier 102218a8c03SAugustin Cavalier using namespace BPrivate::media; 103218a8c03SAugustin Cavalier 104218a8c03SAugustin Cavalier #endif // _MEDIA_EXTRACTOR_H 105