Implemented an API to get arbitrary meta-data about

BMediaFiles and about BMediaTracks in BMessages. As an
example, one can get chapter meta-data or the language
name of an audio-track.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38685 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2010-09-17 08:04:26 +00:00
parent cefc9ef227
commit 7cd3a2490b
8 changed files with 89 additions and 1 deletions

View File

@ -24,6 +24,7 @@ namespace BPrivate {
// forward declarations // forward declarations
class BMediaTrack; class BMediaTrack;
class BMessage;
class BParameterWeb; class BParameterWeb;
class BView; class BView;
@ -79,6 +80,12 @@ public:
status_t GetFileFormatInfo( status_t GetFileFormatInfo(
media_file_format* mfi) const; media_file_format* mfi) const;
// Returns in _data hierarchical meta-data about the stream.
// The fields in the message shall follow a defined naming-scheme,
// such that applications can find the same information in different
// types of files.
status_t GetMetaData(BMessage* _data) const;
// //
// These functions are for read-only access to a media file. // These functions are for read-only access to a media file.
// The data is read using the BMediaTrack object. // The data is read using the BMediaTrack object.

View File

@ -16,6 +16,7 @@ namespace BPrivate { namespace media {
class MediaWriter; class MediaWriter;
} } } }
class BMessage;
class BView; class BView;
class BParameterWeb; class BParameterWeb;
@ -90,6 +91,12 @@ public:
int64 CountFrames() const; int64 CountFrames() const;
bigtime_t Duration() const; bigtime_t Duration() const;
// Returns in _data hierarchical meta-data about the track.
// The fields in the message shall follow a defined naming-scheme,
// such that applications can find the same information in different
// types of tracks.
status_t GetMetaData(BMessage* _data) const;
// CurrentFrame and CurrentTime return the current position (expressed in // CurrentFrame and CurrentTime return the current position (expressed in
// microseconds) within the track, expressed in frame index and time. // microseconds) within the track, expressed in frame index and time.

View File

@ -43,6 +43,7 @@ public:
void GetFileFormatInfo( void GetFileFormatInfo(
media_file_format* fileFormat) const; media_file_format* fileFormat) const;
status_t GetMetaData(BMessage* _data) const;
int32 StreamCount(); int32 StreamCount();
@ -65,6 +66,9 @@ public:
status_t CreateDecoder(int32 stream, Decoder** _decoder, status_t CreateDecoder(int32 stream, Decoder** _decoder,
media_codec_info* codecInfo); media_codec_info* codecInfo);
status_t GetStreamMetaData(int32 stream,
BMessage* _data) const;
private: private:
void _RecycleLastChunk(stream_info& info); void _RecycleLastChunk(stream_info& info);
static int32 _ExtractorEntry(void* arg); static int32 _ExtractorEntry(void* arg);

View File

@ -23,6 +23,7 @@ public:
virtual status_t Sniff(int32* streamCount) = 0; virtual status_t Sniff(int32* streamCount) = 0;
virtual void GetFileFormatInfo(media_file_format* mff) = 0; virtual void GetFileFormatInfo(media_file_format* mff) = 0;
virtual status_t GetMetaData(BMessage* _data);
virtual status_t AllocateCookie(int32 streamNumber, virtual status_t AllocateCookie(int32 streamNumber,
void** cookie) = 0; void** cookie) = 0;
@ -42,6 +43,9 @@ public:
const void** chunkBuffer, size_t* chunkSize, const void** chunkBuffer, size_t* chunkSize,
media_header* mediaHeader) = 0; media_header* mediaHeader) = 0;
virtual status_t GetStreamMetaData(void* cookie,
BMessage* _data);
BDataIO* Source() const; BDataIO* Source() const;
virtual status_t Perform(perform_code code, void* data); virtual status_t Perform(perform_code code, void* data);

View File

@ -178,6 +178,14 @@ MediaExtractor::GetFileFormatInfo(media_file_format* fileFormat) const
} }
status_t
MediaExtractor::GetMetaData(BMessage* _data) const
{
CALLED();
return fReader->GetMetaData(_data);
}
int32 int32
MediaExtractor::StreamCount() MediaExtractor::StreamCount()
{ {
@ -376,6 +384,18 @@ MediaExtractor::CreateDecoder(int32 stream, Decoder** _decoder,
} }
status_t
MediaExtractor::GetStreamMetaData(int32 stream, BMessage* _data) const
{
const stream_info& info = fStreamInfo[stream];
if (info.status != B_OK)
return info.status;
return fReader->GetStreamMetaData(fStreamInfo[stream].cookie, _data);
}
void void
MediaExtractor::_RecycleLastChunk(stream_info& info) MediaExtractor::_RecycleLastChunk(stream_info& info)
{ {

View File

@ -129,7 +129,6 @@ BMediaFile::InitCheck() const
} }
// Get info about the underlying file format.
status_t status_t
BMediaFile::GetFileFormatInfo(media_file_format* mfi) const BMediaFile::GetFileFormatInfo(media_file_format* mfi) const
{ {
@ -143,6 +142,20 @@ BMediaFile::GetFileFormatInfo(media_file_format* mfi) const
} }
status_t
BMediaFile::GetMetaData(BMessage* _data) const
{
if (fExtractor == NULL)
return B_NO_INIT;
if (_data == NULL)
return B_BAD_VALUE;
_data->MakeEmpty();
return fExtractor->GetMetaData(_data);
}
const char* const char*
BMediaFile::Copyright() const BMediaFile::Copyright() const
{ {

View File

@ -233,6 +233,21 @@ BMediaTrack::DecodedFormat(media_format *inout_format, uint32 flags)
} }
status_t
BMediaTrack::GetMetaData(BMessage* _data) const
{
CALLED();
if (fExtractor == NULL)
return B_NO_INIT;
if (_data == NULL)
return B_BAD_VALUE;
_data->MakeEmpty();
return fExtractor->GetStreamMetaData(fStream, _data);
}
int64 int64
BMediaTrack::CountFrames() const BMediaTrack::CountFrames() const
{ {

View File

@ -1,4 +1,7 @@
/* /*
* Copyright 2009-2010, Stephan Aßmus <superstippi@gmx.de>.
* Distributed under the terms of the MIT License.
*
* Copyright 2004, Marcus Overhagen. All rights reserved. * Copyright 2004, Marcus Overhagen. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@ -21,6 +24,13 @@ Reader::~Reader()
} }
status_t
Reader::GetMetaData(BMessage* _data)
{
return B_NOT_SUPPORTED;
}
status_t status_t
Reader::Seek(void* cookie, uint32 flags, int64* frame, bigtime_t* time) Reader::Seek(void* cookie, uint32 flags, int64* frame, bigtime_t* time)
{ {
@ -35,6 +45,13 @@ Reader::FindKeyFrame(void* cookie, uint32 flags, int64* frame, bigtime_t* time)
} }
status_t
Reader::GetStreamMetaData(void* cookie, BMessage* _data)
{
return B_NOT_SUPPORTED;
}
BDataIO* BDataIO*
Reader::Source() const Reader::Source() const
{ {
@ -55,6 +72,7 @@ Reader::Perform(perform_code code, void* _data)
return B_OK; return B_OK;
} }
void Reader::_ReservedReader1() {} void Reader::_ReservedReader1() {}
void Reader::_ReservedReader2() {} void Reader::_ReservedReader2() {}
void Reader::_ReservedReader3() {} void Reader::_ReservedReader3() {}