haiku/headers/os/codec/MetaData.h
Barrett17 e98351d3bc MetaData: Revert types to uint32 and define framerate as float
* Adds some missing methods signatures.
* integer vs float framerate is a longstanging debate. In theory,
in digital a/v there should not be need for floating point framerates.
This is because unless the software is run on exoteric hardware, there
is not need for it. Unfortunately, some legacy from the past like the
29.7 hz debate (NTSC) still may need to work under floating point framerates.
Even if in pratice it'd be run at 30 hz anyway.
* In theory, to handle all those correctly we should use a rational framerate,
however most code should be rewritten to support that correctly, and
it'd add some excessive complexities.
* All integer types are reverted back to unsigned ones. There's really
no reason to use signed integers there, and more importantly the danger
for integer underflows and the attached security concerns is very big.
2018-12-27 12:26:45 +01:00

148 lines
4.6 KiB
C++

/*
* Copyright 2018, Dario Casalinuovo. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _META_DATA_H
#define _META_DATA_H
#include <Message.h>
namespace BCodecKit {
// Playback capabilities
extern const char* kCanPause; // bool
extern const char* kCanSeekBackward; // bool
extern const char* kCanSeekForward; // bool
extern const char* kCanSeek; // bool
// Bitrates
extern const char* kAudioBitRate; // uint32 (bps)
extern const char* kVideoBitRate; // uint32 (bps)
extern const char* kAudioSampleRate; // float (hz)
extern const char* kVideoFrameRate; // float (hz)
// RFC2046 and RFC4281
extern const char* kMimeType; // BString
extern const char* kAudioCodec; // BString
extern const char* kVideoCodec; // BString
extern const char* kVideoHeight; // uint32
extern const char* kVideoWidth; // uint32
extern const char* kNumTracks; // uint32
extern const char* kDrmCrippled; // bool
// Stuff needed to fully describe the BMediaFormat
extern const char* kMediaType; // media_type
// Audio stuff
extern const char* kChannelCount; // uint32
extern const char* kAudioFormat; // uint32
extern const char* kByteOrder; // uint32
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
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
extern const char* kColorSpace; // color_space
extern const char* kOrientation; // uint32
// 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
extern const char* kAlbumArtist; // BString
extern const char* kAuthor; // BString
extern const char* kPerformer; // BString
extern const char* kComposer; // BString
extern const char* kGenre; // BString
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
extern const char* kDuration; // uint32 (ms)
extern const char* kRating; // BString
// TODO: BBitmap? uint8 array? url?
//extern const char* kAlbumArt
extern const char* kCDTrackNum; // uint32
extern const char* kCDTrackMax; // uint32
extern const char* kChapter; // BMetaData
extern const char* kChapterStart; // uint64
extern const char* kChapterEnd; // uint64
// Others
extern const char* kProgramData; // BMetaData
// TODO: Fully honour this:
// https://wiki.multimedia.cx/index.php?title=FFmpeg_Metadata
class BMetaData {
public:
BMetaData();
BMetaData(const BMessage& msg);
virtual ~BMetaData();
// Woah. It seems we need BValue there.
bool SetString(const char* key, const BString& value);
bool SetBool(const char* key, bool value);
bool SetUInt32(const char* key, uint32 value);
bool SetUInt64(const char* key, uint64 value);
bool SetFloat(const char* key, float value);
bool GetString(const char* key, BString* value) const;
bool GetBool(const char* key, bool* value) const;
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;
// 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);
bool HasMetaData(const char* key, uint32 index = 0);
bool RemoveMetaData(const char* key, uint32 index = 0);
bool RemoveValue(const char* key);
// Clean up all keys
void MakeEmpty();
bool IsEmpty();
// Retain ownership of the object, be careful with that
// that's why we need to introduce smart pointers!
const BMessage* Message();
BMetaData& operator=(const BMetaData& other);
private:
// TODO: padding
BMessage* fMessage;
BMetaData(const BMetaData&);
};
} // namespace BCodecKit
#endif // _META_DATA_H