Re-wrote MediaFormats.h header.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31978 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-07-30 16:34:06 +00:00
parent b96533c256
commit ee9408a18d
+167 -93
View File
@@ -1,102 +1,149 @@
/* MediaFormats.h */ /*
/* Copyright 1998 Be Incorporated. All rights reserved. */ * Copyright 2009, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT license.
#if !defined(_MEDIA_TYPES_H) */
#ifndef _MEDIA_TYPES_H
#define _MEDIA_TYPES_H #define _MEDIA_TYPES_H
#if defined(__cplusplus) #ifdef __cplusplus
#include <MediaDefs.h> # include <MediaDefs.h>
#include <Messenger.h> # include <Messenger.h>
#include <List.h> # include <List.h>
#include <Locker.h> # include <Locker.h>
#endif #endif
struct media_codec_info { struct media_codec_info {
char pretty_name[96]; // eg: "SuperSqueeze Encoder by Foo Inc" char pretty_name[96]; /* eg: "SuperSqueeze Encoder by Foo Inc" */
char short_name[32]; // eg: "supersqueeze" char short_name[32]; /* eg: "supersqueeze" */
int32 id; // opaque id passed to BMediaFile::CreateTrack int32 id; /* opaque id passed to
BMediaFile::CreateTrack() */
int32 sub_id; int32 sub_id;
int32 pad[63]; int32 pad[63];
}; };
// /*! \brief Use this to iterate through the available encoders for a given file
// Use this to iterate through the available encoders for a file format. format.
// \param cookie A pointer to a preallocated cookie, which you need
status_t get_next_encoder(int32 *cookie, to initialize to \c 0 before calling this function
const media_file_format *fileFormat,// this comes from get_next_file_format() the first time.
const media_format *inFormat, // this is the type of data given to the encoder \param fileFormat A pointer to a valid media_file_format structure
media_format *_outFormat, // this is the type of data encoder will output as can be obtained through get_next_file_format().
media_codec_info *_codecInfo); // information about the encoder \param inputFormat This is the type of data given to the encoder.
\param _outputFormat This is the type of data the encoder will output.
\param _codecInfo Pointer to a preallocated media_codec_info structure,
information about the encoder is placed there.
status_t get_next_encoder( \return
int32 *cookie, - \c B_OK: Everything went fine.
const media_file_format *fileFormat,// this comes from get_next_file_format() - \c B_BAD_INDEX: There are no more encoders.
// pass NULL if you don't care */
const media_format *inFormat, // this is the type of data given to the status_t get_next_encoder(int32* cookie, const media_file_format* fileFormat,
// encoder, wildcards are accepted const media_format* inputFormat, media_format* _outputFormat,
const media_format *_outFormat, // this is the type of data encoder media_codec_info* _codecInfo);
// you want the encoder to output.
// Wildcards are accepted
media_codec_info *codecInfo, // information about the encoder
media_format *_acceptedInputFormat, // this is the type of data that the
// encoder will accept as input.
// Wildcards in input_format will be
// specialized here.
media_format *_acceptedOutputFormat // this is the type of data that the
// encoder will output.
// Wildcards in output_format will be
// specialized here.
);
status_t get_next_encoder(int32 *cookie, media_codec_info *_codecInfo); /*! \brief Use this to iterate through the available encoders with
restrictions to the input and output media_format while the
encoders can specialize wildcards in the media_formats.
\param cookie A pointer to a preallocated cookie, which you need
to initialize to \c 0 before calling this function
the first time.
\param fileFormat A pointer to a valid media_file_format structure
as can be obtained through get_next_file_format().
You can pass \c NULL if you don't care.
\param inputFormat This is the type of data given to the encoder,
wildcards are accepted.
\param outputFormat This is the type of data you want the encoder to
output. Wildcards are accepted.
\param _codecInfo Pointer to a preallocated media_codec_info structure,
information about the encoder is placed there.
\param _acceptedInputFormat This is the type of data that the encoder will
accept as input. Wildcards in \a inFormat will be
specialized here.
\param _acceptedOutputFormat This is the type of data that the encoder will
output. Wildcards in \a _outFormat will be specialized
here.
\return
- \c B_OK: Everything went fine.
- \c B_BAD_INDEX: There are no more encoders.
*/
status_t get_next_encoder(int32* cookie, const media_file_format* fileFormat,
const media_format* inputFormat, const media_format* outputFormat,
media_codec_info* _codecInfo, media_format* _acceptedInputFormat,
media_format* _acceptedOutputFormat);
/*! \brief Iterate over the all the available encoders without media_format
restrictions.
\param cookie A pointer to a preallocated cookie, which you need
to initialize to \c 0 before calling this function
the first time.
\param _codecInfo Pointer to a preallocated media_codec_info structure,
information about the encoder is placed there.
\return
- \c B_OK: Everything went fine.
- \c B_BAD_INDEX: There are no more encoders.
*/
status_t get_next_encoder(int32* cookie, media_codec_info* _codecInfo);
enum media_file_accept_format_flags { enum media_file_accept_format_flags {
B_MEDIA_REJECT_WILDCARDS = 0x1 B_MEDIA_REJECT_WILDCARDS = 0x1
}; };
bool does_file_accept_format(const media_file_format *fileFormat, bool does_file_accept_format(const media_file_format* fileFormat,
media_format *format, uint32 flags = 0); media_format* format, uint32 flags = 0);
typedef struct { typedef struct {
uint8 data[16]; uint8 data[16];
} GUID; } GUID;
enum beos_format { enum beos_format {
B_BEOS_FORMAT_RAW_AUDIO = 'rawa', B_BEOS_FORMAT_RAW_AUDIO = 'rawa',
B_BEOS_FORMAT_RAW_VIDEO = 'rawv' B_BEOS_FORMAT_RAW_VIDEO = 'rawv'
}; };
typedef struct { typedef struct {
int32 format; int32 format;
} media_beos_description; } media_beos_description;
typedef struct { typedef struct {
uint32 codec; uint32 codec;
uint32 vendor; uint32 vendor;
} media_quicktime_description; } media_quicktime_description;
typedef struct { typedef struct {
uint32 codec; uint32 codec;
} media_avi_description; } media_avi_description;
typedef struct { typedef struct {
uint32 id; uint32 id;
} media_avr_description; } media_avr_description;
typedef struct { typedef struct {
GUID guid; GUID guid;
} media_asf_description; } media_asf_description;
enum mpeg_id { enum mpeg_id {
B_MPEG_ANY = 0, B_MPEG_ANY = 0,
B_MPEG_1_AUDIO_LAYER_1 = 0x101, B_MPEG_1_AUDIO_LAYER_1 = 0x101,
B_MPEG_1_AUDIO_LAYER_2 = 0x102, B_MPEG_1_AUDIO_LAYER_2 = 0x102,
B_MPEG_1_AUDIO_LAYER_3 = 0x103, // "MP3" B_MPEG_1_AUDIO_LAYER_3 = 0x103, /* "MP3" */
B_MPEG_1_VIDEO = 0x111, B_MPEG_1_VIDEO = 0x111,
B_MPEG_2_AUDIO_LAYER_1 = 0x201, B_MPEG_2_AUDIO_LAYER_1 = 0x201,
B_MPEG_2_AUDIO_LAYER_2 = 0x202, B_MPEG_2_AUDIO_LAYER_2 = 0x202,
@@ -106,29 +153,37 @@ enum mpeg_id {
B_MPEG_2_5_AUDIO_LAYER_2 = 0x302, B_MPEG_2_5_AUDIO_LAYER_2 = 0x302,
B_MPEG_2_5_AUDIO_LAYER_3 = 0x303, B_MPEG_2_5_AUDIO_LAYER_3 = 0x303,
}; };
typedef struct { typedef struct {
uint32 id; uint32 id;
} media_mpeg_description; } media_mpeg_description;
typedef struct { typedef struct {
uint32 codec; uint32 codec;
} media_wav_description; } media_wav_description;
typedef struct { typedef struct {
uint32 codec; uint32 codec;
} media_aiff_description; } media_aiff_description;
typedef struct { typedef struct {
uint32 file_format; uint32 file_format;
uint32 codec; uint32 codec;
} media_misc_description; } media_misc_description;
typedef struct _media_format_description { typedef struct _media_format_description {
#if defined(__cplusplus) #ifdef __cplusplus
_media_format_description(); _media_format_description();
~_media_format_description(); ~_media_format_description();
_media_format_description(const _media_format_description & other); _media_format_description(
_media_format_description & operator=(const _media_format_description & other); const _media_format_description& other);
_media_format_description& operator=(
const _media_format_description& other);
#endif #endif
media_format_family family; media_format_family family;
uint32 _reserved_[3]; uint32 _reserved_[3];
@@ -151,65 +206,84 @@ typedef struct _media_format_description {
class BMediaFormats { class BMediaFormats {
public: public:
BMediaFormats(); BMediaFormats();
virtual ~BMediaFormats(); virtual ~BMediaFormats();
status_t InitCheck(); status_t InitCheck();
// Make sure you memset() your descs to 0 before you start filling // Make sure you memset() your descs to 0 before you start filling
// them in! Else you may register some bogus value. // them in! Else you may register some bogus value.
enum make_format_flags { enum make_format_flags {
B_EXCLUSIVE = 0x1, // Fail if this format has already been registered B_EXCLUSIVE = 0x1, // Fail if this format has already been
B_NO_MERGE = 0x2, // Don't re-number any formats if there are multiple // registered.
// clashing previous registrations, but fail instead
B_SET_DEFAULT = 0x4 // Set the first format to be the default for the
// format family (when registering more than one in
// the same family). Only use in Encoder add-ons.
};
status_t MakeFormatFor(const media_format_description *descriptions, B_NO_MERGE = 0x2, // Don't re-number any formats if there are
int32 descriptionCount, media_format *inOutFormat, // multiple clashing previous registrations,
uint32 flags = 0, void * _reserved = 0); // but fail instead.
status_t GetFormatFor(const media_format_description &description,
media_format *_outFormat);
status_t GetCodeFor(const media_format &format, B_SET_DEFAULT = 0x4 // Set the first format to be the default for
media_format_family family, media_format_description *_outDescription); // the format family (when registering more
// than one in the same family). Only use in
// Encoder add-ons.
};
status_t RewindFormats(); status_t MakeFormatFor(const media_format_description*
status_t GetNextFormat(media_format *_outFormat, descriptions, int32 descriptionCount,
media_format_description *_outDescription); media_format* _inOutFormat,
uint32 flags = 0, void* _reserved = 0);
// You need to lock/unlock (only) when using RewindFormats()/GetNextFormat() status_t GetFormatFor(const media_format_description&
bool Lock(); description, media_format* _outFormat);
void Unlock();
// convenience functions status_t GetCodeFor(const media_format& format,
static status_t GetBeOSFormatFor(uint32 fourcc, media_format_family family,
media_format *_outFormat, media_type type = B_MEDIA_UNKNOWN_TYPE); media_format_description* _outDescription);
static status_t GetAVIFormatFor(uint32 fourcc,
media_format *_outFormat, media_type type = B_MEDIA_UNKNOWN_TYPE);
static status_t GetQuicktimeFormatFor(uint32 vendor, uint32 fourcc,
media_format *_outFormat, media_type type = B_MEDIA_UNKNOWN_TYPE);
/* --- begin deprecated API --- */ status_t RewindFormats();
status_t GetNextFormat(media_format* _outFormat,
media_format_description* _outDescription);
status_t MakeFormatFor(const media_format_description &description, // You need to lock/unlock (only) when using
const media_format &inFormat, media_format *_outFormat); // RewindFormats()/GetNextFormat().
bool Lock();
void Unlock();
private: // convenience functions
int32 fIteratorIndex; static status_t GetBeOSFormatFor(uint32 fourcc,
uint32 _reserved[30]; media_format* _outFormat,
media_type type = B_MEDIA_UNKNOWN_TYPE);
static status_t GetAVIFormatFor(uint32 fourcc,
media_format* _outFormat,
media_type type = B_MEDIA_UNKNOWN_TYPE);
static status_t GetQuicktimeFormatFor(uint32 vendor,
uint32 fourcc, media_format* _outFormat,
media_type type = B_MEDIA_UNKNOWN_TYPE);
// Deprecated:
status_t MakeFormatFor(const media_format_description&
description, const media_format& inFormat,
media_format* _outFormat);
private:
int32 fIteratorIndex;
uint32 _reserved[30];
}; };
bool operator==(const media_format_description & a, const media_format_description & b);
bool operator<(const media_format_description & a, const media_format_description & b);
bool operator==(const GUID & a, const GUID & b); bool operator==(const media_format_description& a,
bool operator<(const GUID & a, const GUID & b); const media_format_description& b);
bool operator<(const media_format_description& a,
const media_format_description& b);
bool operator==(const GUID& a, const GUID& b);
bool operator<(const GUID& a, const GUID& b);
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* _MEDIA_TYPES_H */ #endif /* _MEDIA_TYPES_H */