2018-11-18 18:57:12 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2018, Dario Casalinuovo. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _META_DATA_H
|
|
|
|
#define _META_DATA_H
|
|
|
|
|
2018-11-21 18:51:19 +03:00
|
|
|
|
2018-11-18 18:57:12 +03:00
|
|
|
#include <Message.h>
|
|
|
|
|
|
|
|
|
2018-11-26 15:18:35 +03:00
|
|
|
namespace BCodecKit {
|
2018-11-18 18:57:12 +03:00
|
|
|
|
|
|
|
|
2018-11-21 14:45:09 +03:00
|
|
|
// Playback capabilities
|
|
|
|
extern const char* kCanPause; // bool
|
|
|
|
extern const char* kCanSeekBackward; // bool
|
|
|
|
extern const char* kCanSeekForward; // bool
|
|
|
|
extern const char* kCanSeek; // bool
|
|
|
|
|
|
|
|
// Bitrates
|
2018-12-27 14:16:11 +03:00
|
|
|
extern const char* kAudioBitRate; // uint32 (bps)
|
|
|
|
extern const char* kVideoBitRate; // uint32 (bps)
|
|
|
|
extern const char* kAudioSampleRate; // float (hz)
|
|
|
|
extern const char* kVideoFrameRate; // float (hz)
|
2018-11-21 14:45:09 +03:00
|
|
|
|
|
|
|
// RFC2046 and RFC4281
|
|
|
|
extern const char* kMimeType; // BString
|
|
|
|
extern const char* kAudioCodec; // BString
|
|
|
|
extern const char* kVideoCodec; // BString
|
2018-12-27 14:16:11 +03:00
|
|
|
extern const char* kVideoHeight; // uint32
|
|
|
|
extern const char* kVideoWidth; // uint32
|
|
|
|
extern const char* kNumTracks; // uint32
|
2018-11-21 14:45:09 +03:00
|
|
|
extern const char* kDrmCrippled; // bool
|
|
|
|
|
2018-12-26 14:31:07 +03:00
|
|
|
// Stuff needed to fully describe the BMediaFormat
|
|
|
|
extern const char* kMediaType; // media_type
|
|
|
|
// Audio stuff
|
2018-12-27 14:16:11 +03:00
|
|
|
extern const char* kChannelCount; // uint32
|
|
|
|
extern const char* kAudioFormat; // uint32
|
|
|
|
extern const char* kByteOrder; // uint32
|
2018-12-26 14:31:07 +03:00
|
|
|
extern const char* kBufferSize; // size_t
|
|
|
|
// This is also BMediaFormat stuff, but mostly video
|
|
|
|
// NOTE: video width/height are defined as per RFC mentioned above
|
2018-12-27 14:16:11 +03:00
|
|
|
extern const char* kLineWidth; // uint32
|
|
|
|
extern const char* kLineCount; // uint32
|
|
|
|
extern const char* kBytesPerRow; // uint32
|
|
|
|
extern const char* kPixelOffset; // uint32
|
|
|
|
extern const char* kLineOffset; // uint32
|
2018-12-26 14:31:07 +03:00
|
|
|
extern const char* kColorSpace; // color_space
|
2018-12-27 14:16:11 +03:00
|
|
|
extern const char* kOrientation; // uint32
|
2018-12-26 14:31:07 +03:00
|
|
|
|
2018-11-21 14:45:09 +03:00
|
|
|
// General use attributes
|
|
|
|
extern const char* kTitle; // BString
|
|
|
|
extern const char* kComment; // BString
|
|
|
|
extern const char* kCopyright; // BString
|
|
|
|
extern const char* kAlbum; // BString
|
|
|
|
extern const char* kArtist; // BString
|
2018-11-21 18:51:19 +03:00
|
|
|
extern const char* kAlbumArtist; // BString
|
2018-11-21 14:45:09 +03:00
|
|
|
extern const char* kAuthor; // BString
|
2018-11-21 18:51:19 +03:00
|
|
|
extern const char* kPerformer; // BString
|
2018-11-21 14:45:09 +03:00
|
|
|
extern const char* kComposer; // BString
|
|
|
|
extern const char* kGenre; // BString
|
2018-11-21 18:51:19 +03:00
|
|
|
extern const char* kYear; // BString
|
|
|
|
extern const char* kEncodedBy; // BString
|
|
|
|
extern const char* kLanguage; // BString
|
|
|
|
extern const char* kDisc; // BString
|
|
|
|
extern const char* kPublisher; // BString
|
|
|
|
extern const char* kEncoder; // BString
|
|
|
|
extern const char* kTrack;
|
|
|
|
extern const char* kDate; // BString
|
2018-12-27 14:16:11 +03:00
|
|
|
extern const char* kDuration; // uint32 (ms)
|
2018-11-21 14:45:09 +03:00
|
|
|
extern const char* kRating; // BString
|
2018-11-21 18:51:19 +03:00
|
|
|
// TODO: BBitmap? uint8 array? url?
|
|
|
|
//extern const char* kAlbumArt
|
2018-12-27 14:16:11 +03:00
|
|
|
extern const char* kCDTrackNum; // uint32
|
|
|
|
extern const char* kCDTrackMax; // uint32
|
2018-11-18 18:57:12 +03:00
|
|
|
|
2018-11-21 18:51:19 +03:00
|
|
|
extern const char* kChapter; // BMetaData
|
2018-12-27 14:16:11 +03:00
|
|
|
extern const char* kChapterStart; // uint64
|
|
|
|
extern const char* kChapterEnd; // uint64
|
2018-11-21 18:51:19 +03:00
|
|
|
|
|
|
|
// Others
|
|
|
|
extern const char* kProgramData; // BMetaData
|
|
|
|
|
2018-12-01 14:23:04 +03:00
|
|
|
// TODO: Fully honour this:
|
|
|
|
// https://wiki.multimedia.cx/index.php?title=FFmpeg_Metadata
|
|
|
|
|
2018-11-18 18:57:12 +03:00
|
|
|
|
2018-12-27 17:15:25 +03:00
|
|
|
/**
|
|
|
|
* @brief BMetaData stores the media metadata.
|
|
|
|
*
|
|
|
|
* The metadata model is sparse and each key can occur at most once,
|
|
|
|
* except for BMetaData itself.
|
|
|
|
* The key is an integer and the value is the actual metadata.
|
|
|
|
* The client of this class is required to know in advance the type
|
|
|
|
* of a particular metadata key.
|
|
|
|
*/
|
2018-11-18 18:57:12 +03:00
|
|
|
class BMetaData {
|
|
|
|
public:
|
|
|
|
BMetaData();
|
2018-11-21 14:45:09 +03:00
|
|
|
BMetaData(const BMessage& msg);
|
2018-11-21 18:51:19 +03:00
|
|
|
virtual ~BMetaData();
|
2018-11-21 14:45:09 +03:00
|
|
|
|
2018-11-18 18:57:12 +03:00
|
|
|
// Woah. It seems we need BValue there.
|
2018-11-21 14:45:09 +03:00
|
|
|
bool SetString(const char* key, const BString& value);
|
|
|
|
bool SetBool(const char* key, bool value);
|
2018-12-27 14:16:11 +03:00
|
|
|
bool SetUInt32(const char* key, uint32 value);
|
|
|
|
bool SetUInt64(const char* key, uint64 value);
|
|
|
|
bool SetFloat(const char* key, float value);
|
2018-11-18 18:57:12 +03:00
|
|
|
|
2018-11-21 14:45:09 +03:00
|
|
|
bool GetString(const char* key, BString* value) const;
|
|
|
|
bool GetBool(const char* key, bool* value) const;
|
2018-12-27 14:16:11 +03:00
|
|
|
bool GetUInt32(const char* key, uint32* value) const;
|
|
|
|
bool GetUInt64(const char* key, uint64* value) const;
|
|
|
|
bool GetFloat(const char* key, float* value);
|
|
|
|
|
|
|
|
bool HasString(const char* key) const;
|
|
|
|
bool HasBool(const char* key) const;
|
|
|
|
bool HasUInt32(const char* key) const;
|
|
|
|
bool HasUInt64(const char* key) const;
|
|
|
|
bool HasFloat(const char* key) const;
|
2018-11-21 18:51:19 +03:00
|
|
|
|
|
|
|
// We allow embedding BMetaData into BMetaData. The BMetaData field
|
|
|
|
// is the only one allowed to have more occurrences for a single key
|
|
|
|
// so an index attribute is given for retrieving it.
|
|
|
|
bool AddMetaData(const char* key, BMetaData* data);
|
|
|
|
bool GetMetaData(const char* key, BMetaData* data,
|
|
|
|
uint32 index = 0);
|
2018-12-27 14:16:11 +03:00
|
|
|
bool HasMetaData(const char* key, uint32 index = 0);
|
|
|
|
bool RemoveMetaData(const char* key, uint32 index = 0);
|
2018-11-18 18:57:12 +03:00
|
|
|
|
2018-11-21 14:45:09 +03:00
|
|
|
bool RemoveValue(const char* key);
|
2018-11-18 18:57:12 +03:00
|
|
|
|
|
|
|
// Clean up all keys
|
2018-11-21 14:45:09 +03:00
|
|
|
void MakeEmpty();
|
|
|
|
bool IsEmpty();
|
2018-11-18 18:57:12 +03:00
|
|
|
|
2018-11-21 14:45:09 +03:00
|
|
|
// Retain ownership of the object, be careful with that
|
|
|
|
// that's why we need to introduce smart pointers!
|
2018-11-21 18:51:19 +03:00
|
|
|
const BMessage* Message();
|
2018-11-18 18:57:12 +03:00
|
|
|
|
2018-11-22 11:19:15 +03:00
|
|
|
BMetaData& operator=(const BMetaData& other);
|
|
|
|
|
2018-11-18 18:57:12 +03:00
|
|
|
private:
|
|
|
|
// TODO: padding
|
|
|
|
BMessage* fMessage;
|
|
|
|
|
|
|
|
BMetaData(const BMetaData&);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-11-26 15:18:35 +03:00
|
|
|
} // namespace BCodecKit
|
|
|
|
|
2018-11-18 18:57:12 +03:00
|
|
|
|
|
|
|
#endif // _META_DATA_H
|