2009-11-25 14:51:24 +03:00
|
|
|
/*
|
2010-01-12 23:24:10 +03:00
|
|
|
* Copyright 2009-2010, Stephan Aßmus <supertippi@gmx.de>. All rights reserved.
|
2009-11-25 17:24:52 +03:00
|
|
|
* Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
|
2010-01-12 23:24:10 +03:00
|
|
|
* Copyright 2008, Maurice Kalinowski. All rights reserved.
|
|
|
|
* Copyright 2004-2007, Marcus Overhagen. All rights reserved.
|
2009-11-25 17:24:52 +03:00
|
|
|
*
|
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
|
|
|
|
2018-11-25 13:59:45 +03:00
|
|
|
#include <Decoder.h>
|
|
|
|
#include <Reader.h>
|
2003-11-24 01:19:21 +03:00
|
|
|
|
2009-11-25 14:51:24 +03:00
|
|
|
|
2018-11-26 15:18:35 +03:00
|
|
|
namespace BCodecKit {
|
2003-11-24 01:19:21 +03:00
|
|
|
|
2009-11-25 17:24:52 +03:00
|
|
|
|
2018-11-18 14:53:14 +03:00
|
|
|
struct stream_info;
|
2003-11-24 02:50:27 +03:00
|
|
|
|
2009-11-25 17:24:52 +03:00
|
|
|
|
2018-11-25 14:40:49 +03:00
|
|
|
class BMediaExtractor {
|
2003-11-24 01:19:21 +03:00
|
|
|
public:
|
2018-11-25 14:40:49 +03:00
|
|
|
BMediaExtractor(BDataIO* source, int32 flags);
|
|
|
|
~BMediaExtractor();
|
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
|
|
|
|
2016-03-26 00:18:15 +03:00
|
|
|
BDataIO* Source() const;
|
|
|
|
|
2009-11-25 14:51:24 +03:00
|
|
|
void GetFileFormatInfo(
|
|
|
|
media_file_format* fileFormat) const;
|
2003-11-24 01:19:21 +03:00
|
|
|
|
2018-11-21 18:55:02 +03:00
|
|
|
status_t GetMetaData(BMetaData* data) const;
|
2018-11-22 11:48:04 +03:00
|
|
|
status_t GetStreamMetaData(int32 stream,
|
|
|
|
BMetaData* data) const;
|
2008-05-08 01:09:56 +04:00
|
|
|
|
2018-11-22 11:19:15 +03:00
|
|
|
int32 CountStreams();
|
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
|
|
|
|
2010-01-12 23:24:10 +03:00
|
|
|
status_t Seek(int32 stream, uint32 seekTo,
|
|
|
|
int64* _frame, bigtime_t* _time);
|
2009-11-25 14:51:24 +03:00
|
|
|
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
|
|
|
|
2018-11-25 14:40:49 +03:00
|
|
|
status_t CreateDecoder(int32 stream, BDecoder** _decoder,
|
2009-11-25 14:51:24 +03:00
|
|
|
media_codec_info* codecInfo);
|
2003-11-24 02:50:27 +03:00
|
|
|
|
2018-11-22 11:48:04 +03:00
|
|
|
// TODO: Explore if would be better to add a Start/Stop
|
|
|
|
// methods pair to MediaExtractor.
|
2017-07-24 12:50:06 +03:00
|
|
|
void StopProcessing();
|
|
|
|
|
2004-10-24 18:21:34 +04:00
|
|
|
private:
|
2016-03-26 00:18:15 +03:00
|
|
|
void _Init(BDataIO* source, int32 flags);
|
|
|
|
|
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
|
|
|
|
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;
|
2018-11-25 14:40:49 +03:00
|
|
|
BReader* 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;
|
2018-10-28 18:14:25 +03:00
|
|
|
|
|
|
|
uint32 fReserved[5];
|
2003-11-24 01:19:21 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-11-26 15:18:35 +03:00
|
|
|
} // namespace BCodecKit
|
|
|
|
|
2003-11-24 01:19:21 +03:00
|
|
|
|
2009-11-25 14:51:24 +03:00
|
|
|
#endif // _MEDIA_EXTRACTOR_H
|