1 #ifndef _MEDIA_EXTRACTOR_H 2 #define _MEDIA_EXTRACTOR_H 3 4 #include "ReaderPlugin.h" 5 #include "DecoderPlugin.h" 6 7 namespace BPrivate { 8 namespace media { 9 10 class ChunkCache; 11 12 struct stream_info 13 { 14 status_t status; 15 void * cookie; 16 bool hasCookie; 17 const void * infoBuffer; 18 size_t infoBufferSize; 19 ChunkCache * chunkCache; 20 media_format encodedFormat; 21 }; 22 23 class MediaExtractor 24 { 25 public: 26 MediaExtractor(BDataIO * source, int32 flags); 27 ~MediaExtractor(); 28 29 status_t InitCheck(); 30 31 void GetFileFormatInfo(media_file_format *mfi) const; 32 33 int32 StreamCount(); 34 35 const media_format * EncodedFormat(int32 stream); 36 int64 CountFrames(int32 stream) const; 37 bigtime_t Duration(int32 stream) const; 38 39 status_t Seek(int32 stream, uint32 seekTo, 40 int64 *frame, bigtime_t *time); 41 42 status_t GetNextChunk(int32 stream, 43 const void **chunkBuffer, size_t *chunkSize, 44 media_header *mediaHeader); 45 46 status_t CreateDecoder(int32 stream, Decoder **decoder, media_codec_info *mci); 47 48 private: 49 static int32 extractor_thread(void *arg); 50 void ExtractorThread(); 51 52 private: 53 status_t fErr; 54 55 sem_id fExtractorWaitSem; 56 thread_id fExtractorThread; 57 volatile bool fTerminateExtractor; 58 59 BDataIO *fSource; 60 Reader *fReader; 61 62 stream_info * fStreamInfo; 63 int32 fStreamCount; 64 65 media_file_format fMff; 66 }; 67 68 }; // namespace media 69 }; // namespace BPrivate 70 71 using namespace BPrivate::media; 72 73 #endif 74