2009-11-25 14:51:24 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2004-2007, Marcus Overhagen. All rights reserved.
|
|
|
|
* Copyright 2008, Maurice Kalinowski. All rights reserved.
|
2009-11-25 17:24:52 +03:00
|
|
|
* Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
|
|
|
|
*
|
2009-11-25 14:51:24 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2003-11-24 01:19:21 +03:00
|
|
|
#ifndef _MEDIA_EXTRACTOR_H
|
|
|
|
#define _MEDIA_EXTRACTOR_H
|
|
|
|
|
2009-11-25 14:51:24 +03:00
|
|
|
|
2003-11-24 01:19:21 +03:00
|
|
|
#include "ReaderPlugin.h"
|
|
|
|
#include "DecoderPlugin.h"
|
|
|
|
|
2009-11-25 14:51:24 +03:00
|
|
|
|
2003-11-24 01:19:21 +03:00
|
|
|
namespace BPrivate {
|
|
|
|
namespace media {
|
|
|
|
|
2009-11-25 17:24:52 +03:00
|
|
|
|
2004-11-21 03:11:39 +03:00
|
|
|
class ChunkCache;
|
2009-11-25 17:24:52 +03:00
|
|
|
struct chunk_buffer;
|
|
|
|
|
2004-11-21 03:11:39 +03:00
|
|
|
|
2009-11-25 14:51:24 +03:00
|
|
|
struct stream_info {
|
2003-11-24 02:50:27 +03:00
|
|
|
status_t status;
|
2009-11-25 14:51:24 +03:00
|
|
|
void* cookie;
|
2004-02-29 23:09:42 +03:00
|
|
|
bool hasCookie;
|
2009-11-25 14:51:24 +03:00
|
|
|
const void* infoBuffer;
|
2005-06-30 04:24:06 +04:00
|
|
|
size_t infoBufferSize;
|
2009-11-25 14:51:24 +03:00
|
|
|
ChunkCache* chunkCache;
|
2009-11-25 17:24:52 +03:00
|
|
|
chunk_buffer* lastChunk;
|
2003-11-24 02:50:27 +03:00
|
|
|
media_format encodedFormat;
|
|
|
|
};
|
|
|
|
|
2009-11-25 17:24:52 +03:00
|
|
|
|
2009-11-25 14:51:24 +03:00
|
|
|
class MediaExtractor {
|
2003-11-24 01:19:21 +03:00
|
|
|
public:
|
2009-11-25 14:51:24 +03:00
|
|
|
MediaExtractor(BDataIO* source, int32 flags);
|
|
|
|
~MediaExtractor();
|
2003-11-24 01:19:21 +03:00
|
|
|
|
2009-11-25 14:51:24 +03:00
|
|
|
status_t InitCheck();
|
2008-05-08 01:09:56 +04:00
|
|
|
|
2009-11-25 14:51:24 +03:00
|
|
|
void GetFileFormatInfo(
|
|
|
|
media_file_format* fileFormat) const;
|
2003-11-24 01:19:21 +03:00
|
|
|
|
2009-11-25 14:51:24 +03:00
|
|
|
int32 StreamCount();
|
2008-05-08 01:09:56 +04:00
|
|
|
|
2009-11-25 14:51:24 +03:00
|
|
|
const char* Copyright();
|
2008-05-08 01:09:56 +04:00
|
|
|
|
2009-11-25 14:51:24 +03:00
|
|
|
const media_format* EncodedFormat(int32 stream);
|
|
|
|
int64 CountFrames(int32 stream) const;
|
|
|
|
bigtime_t Duration(int32 stream) const;
|
2003-11-24 01:19:21 +03:00
|
|
|
|
2009-11-25 14:51:24 +03:00
|
|
|
status_t Seek(int32 stream, uint32 seekTo, int64* _frame,
|
|
|
|
bigtime_t* _time);
|
|
|
|
status_t FindKeyFrame(int32 stream, uint32 seekTo,
|
|
|
|
int64* _frame, bigtime_t* _time) const;
|
2008-05-08 01:09:56 +04:00
|
|
|
|
2009-11-25 14:51:24 +03:00
|
|
|
status_t GetNextChunk(int32 stream,
|
|
|
|
const void** _chunkBuffer,
|
|
|
|
size_t* _chunkSize,
|
|
|
|
media_header* mediaHeader);
|
2003-11-24 01:19:21 +03:00
|
|
|
|
2009-11-25 14:51:24 +03:00
|
|
|
status_t CreateDecoder(int32 stream, Decoder** _decoder,
|
|
|
|
media_codec_info* codecInfo);
|
2003-11-24 02:50:27 +03:00
|
|
|
|
2004-10-24 18:21:34 +04:00
|
|
|
private:
|
2009-11-25 17:24:52 +03:00
|
|
|
void _RecycleLastChunk(stream_info& info);
|
2009-11-25 14:51:24 +03:00
|
|
|
static int32 _ExtractorEntry(void* arg);
|
|
|
|
void _ExtractorThread();
|
2003-11-24 02:50:27 +03:00
|
|
|
|
|
|
|
private:
|
2009-11-25 14:51:24 +03:00
|
|
|
status_t fInitStatus;
|
2008-05-08 01:09:56 +04:00
|
|
|
|
2009-11-25 14:51:24 +03:00
|
|
|
sem_id fExtractorWaitSem;
|
|
|
|
thread_id fExtractorThread;
|
2008-05-08 01:09:56 +04:00
|
|
|
|
2009-11-25 14:51:24 +03:00
|
|
|
BDataIO* fSource;
|
|
|
|
Reader* fReader;
|
2008-05-08 01:09:56 +04:00
|
|
|
|
2009-11-25 14:51:24 +03:00
|
|
|
stream_info* fStreamInfo;
|
|
|
|
int32 fStreamCount;
|
2003-11-24 02:50:27 +03:00
|
|
|
|
2009-11-25 14:51:24 +03:00
|
|
|
media_file_format fFileFormat;
|
2003-11-24 01:19:21 +03:00
|
|
|
};
|
|
|
|
|
2009-11-25 14:51:24 +03:00
|
|
|
} // namespace media
|
|
|
|
} // namespace BPrivate
|
2003-11-24 01:19:21 +03:00
|
|
|
|
|
|
|
using namespace BPrivate::media;
|
|
|
|
|
2009-11-25 14:51:24 +03:00
|
|
|
#endif // _MEDIA_EXTRACTOR_H
|