本文整理汇总了C++中BMediaFormats类的典型用法代码示例。如果您正苦于以下问题:C++ BMediaFormats类的具体用法?C++ BMediaFormats怎么用?C++ BMediaFormats使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BMediaFormats类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: register_media_formats
status_t OpenSoundDevice::register_media_formats()
{
status_t err;
int i, count;
BMediaFormats formats;
if (formats.InitCheck() < B_OK)
return formats.InitCheck();
media_format format;
for (i = 0; gSupportedFormats[i]; i++) {
media_format_description desc[10];
err = count = get_media_format_description_for(gSupportedFormats[i], desc, 10);
if (err < 1)
continue;
if (gSupportedFormats[i] & AFMT_SUPPORTED_PCM) {
format.type = B_MEDIA_RAW_AUDIO;
format.u.raw_audio = media_multi_audio_format::wildcard;
} else {
format.type = B_MEDIA_ENCODED_AUDIO;
format.u.encoded_audio = media_encoded_audio_format::wildcard;
}
err = formats.MakeFormatFor(desc, count, &format);
PRINT(("OpenSoundDevice::register_media_formats: MakeFormatFor: %s\n", strerror(err)));
}
return B_OK;
};
示例2:
status_t
MusePackPlugin::GetSupportedFormats(media_format ** formats, size_t * count)
{
media_format_description description;
description.family = B_MISC_FORMAT_FAMILY;
description.u.misc.file_format = 'mpc ';
description.u.misc.codec = 'MPC7';
// 7 is the most recent stream version
media_format format;
format.type = B_MEDIA_ENCODED_AUDIO;
format.u.encoded_audio = media_encoded_audio_format::wildcard;
BMediaFormats mediaFormats;
status_t result = mediaFormats.InitCheck();
if (result != B_OK) {
return result;
}
result = mediaFormats.MakeFormatFor(&description, 1, &format);
if (result != B_OK) {
return result;
}
muse_pack_formats[0] = format;
*formats = muse_pack_formats;
*count = 1;
return B_OK;
}
示例3:
status_t
RawDecoderPlugin::GetSupportedFormats(media_format ** formats, size_t * count)
{
BMediaFormats mediaFormats;
media_format_description description;
media_format format;
// audio decoder
description.family = B_BEOS_FORMAT_FAMILY;
description.u.beos.format = B_BEOS_FORMAT_RAW_AUDIO;
format.type = B_MEDIA_RAW_AUDIO;
format.u.raw_audio = media_multi_audio_format::wildcard;
status_t status = mediaFormats.MakeFormatFor(&description, 1, &format);
if (status < B_OK)
return status;
raw_formats[0] = format;
// video decoder
description.u.beos.format = B_BEOS_FORMAT_RAW_VIDEO;
format.type = B_MEDIA_RAW_VIDEO;
format.u.raw_video = media_raw_video_format::wildcard;
status = mediaFormats.MakeFormatFor(&description, 1, &format);
if (status < B_OK)
return status;
raw_formats[1] = format;
*formats = raw_formats;
*count = 2;
return B_OK;
}
示例4: sizeof
status_t
mp3DecoderPlugin::GetSupportedFormats(media_format ** formats, size_t * count)
{
const mpeg_id ids[] = {
B_MPEG_1_AUDIO_LAYER_1,
B_MPEG_1_AUDIO_LAYER_2,
B_MPEG_1_AUDIO_LAYER_3, // "MP3"
B_MPEG_2_AUDIO_LAYER_1,
B_MPEG_2_AUDIO_LAYER_2,
B_MPEG_2_AUDIO_LAYER_3,
B_MPEG_2_5_AUDIO_LAYER_1,
B_MPEG_2_5_AUDIO_LAYER_2,
B_MPEG_2_5_AUDIO_LAYER_3,
};
const size_t otherIDs = 6;
const size_t numIDs = otherIDs + sizeof(ids) / sizeof(mpeg_id);
media_format_description descriptions[numIDs];
descriptions[0].family = B_WAV_FORMAT_FAMILY;
descriptions[0].u.wav.codec = 0x0050;
descriptions[1].family = B_WAV_FORMAT_FAMILY;
descriptions[1].u.wav.codec = 0x0055;
descriptions[2].family = B_QUICKTIME_FORMAT_FAMILY;
descriptions[2].u.quicktime.codec = '.mp3';
descriptions[3].family = B_QUICKTIME_FORMAT_FAMILY;
descriptions[3].u.quicktime.codec = '3pm.';
descriptions[4].family = B_AVI_FORMAT_FAMILY;
descriptions[4].u.avi.codec = '.mp3';
descriptions[5].family = B_AVI_FORMAT_FAMILY;
descriptions[5].u.avi.codec = '3pm.';
for (size_t i = otherIDs; i < numIDs; i++) {
descriptions[i].family = B_MPEG_FORMAT_FAMILY;
descriptions[i].u.mpeg.id = ids[i-otherIDs];
}
media_format format;
format.type = B_MEDIA_ENCODED_AUDIO;
format.u.encoded_audio = media_encoded_audio_format::wildcard;
format.u.encoded_audio.output.format = media_raw_audio_format::B_AUDIO_SHORT;
format.u.encoded_audio.output.byte_order = B_MEDIA_HOST_ENDIAN;
BMediaFormats mediaFormats;
status_t result = mediaFormats.InitCheck();
if (result != B_OK) {
return result;
}
result = mediaFormats.MakeFormatFor(descriptions, numIDs, &format);
if (result != B_OK) {
return result;
}
mp3_formats[0] = format;
*formats = mp3_formats;
*count = 1;
return result;
}
示例5: PRINT
status_t
XvidPlugin::GetSupportedFormats(media_format** _mediaFormatArray, size_t *_count)
{
PRINT(("XvidDecoder::register_decoder()\n"));
static bool codecsRegistered = false;
if (codecsRegistered)
return B_OK;
codecsRegistered = true;
PRINT(("XvidDecoder: registering %d codecs\n", gSupportedCodecsCount));
media_format_description descr[gSupportedCodecsCount];
for (int i = 0; i < gSupportedCodecsCount; i++) {
descr[i].family = gCodecTable[i].family;
switch(descr[i].family) {
case B_AVI_FORMAT_FAMILY:
descr[i].u.avi.codec = gCodecTable[i].fourcc;
break;
case B_MPEG_FORMAT_FAMILY:
descr[i].u.mpeg.id = gCodecTable[i].fourcc;
break;
case B_QUICKTIME_FORMAT_FAMILY:
descr[i].u.quicktime.codec = gCodecTable[i].fourcc;
break;
default:
break;
}
}
BMediaFormats formats;
for (int i = 0; i < gSupportedCodecsCount; i++) {
media_format format;
format.type = B_MEDIA_ENCODED_VIDEO;
format.u.encoded_video = media_encoded_video_format::wildcard;
format.require_flags = 0;
format.deny_flags = B_MEDIA_MAUI_UNDEFINED_FLAGS;
status_t err = formats.MakeFormatFor(&descr[i], 1, &format);
if (err < B_OK) {
fprintf(stderr, "XvidDecoder: BMediaFormats::MakeFormatFor: "
"error %s\n", strerror(err));
continue;
}
gXvidFormats[i] = format;
}
*_mediaFormatArray = gXvidFormats;
*_count = gSupportedCodecsCount;
return B_OK;
}
示例6: build_decoder_formats
status_t
build_decoder_formats(media_format** _formats, size_t* _count)
{
BMediaFormats mediaFormats;
if (mediaFormats.InitCheck() != B_OK)
return B_ERROR;
int32 index = 0;
AVCodec* codec = NULL;
while ((codec = av_codec_next(codec)) != NULL) {
if (index >= sMaxFormatCount) {
fprintf(stderr, "Maximum format count reached for auto-generated "
"AVCodec to media_format mapping, but there are still more "
"AVCodecs compiled into libavcodec!\n");
break;
}
media_format format;
// Determine media type
switch (codec->type) {
case AVMEDIA_TYPE_VIDEO:
format.type = B_MEDIA_ENCODED_VIDEO;
break;
case AVMEDIA_TYPE_AUDIO:
format.type = B_MEDIA_ENCODED_AUDIO;
break;
default:
// ignore this AVCodec
continue;
}
media_format_description description;
memset(&description, 0, sizeof(description));
// Hard-code everything to B_MISC_FORMAT_FAMILY to ease matching
// later on.
description.family = B_MISC_FORMAT_FAMILY;
description.u.misc.file_format = 'ffmp';
description.u.misc.codec = codec->id;
format.require_flags = 0;
format.deny_flags = B_MEDIA_MAUI_UNDEFINED_FLAGS;
if (mediaFormats.MakeFormatFor(&description, 1, &format) != B_OK)
return B_ERROR;
gAVCodecFormats[index] = format;
index++;
}
*_formats = gAVCodecFormats;
*_count = index;
return B_OK;
}
示例7: register_encoder
void register_encoder()
{
status_t err;
media_format tempFormat, mediaFormat;
media_format_description formatDescription;
BMediaFormats formatObject;
formatObject.Lock();
/* register as a WAV codec */
memset(&mediaFormat, 0, sizeof(media_format));
mediaFormat.type = B_MEDIA_ENCODED_AUDIO;
mediaFormat.u.encoded_audio = media_encoded_audio_format::wildcard;
memset(&formatDescription, 0, sizeof(media_format_description));
formatDescription.family = B_WAV_FORMAT_FAMILY;
formatDescription.u.wav.codec = WAVE_FORMAT_MPEG;
err = formatObject.MakeFormatFor(formatDescription, mediaFormat, &tempFormat);
if (err == B_MEDIA_DUPLICATE_FORMAT)
formatObject.GetFormatFor(formatDescription, &tempFormat);
s_wavFormat = tempFormat;
/* register as a MPEG codec */
memset(&mediaFormat, 0, sizeof(media_format));
mediaFormat.type = B_MEDIA_ENCODED_AUDIO;
mediaFormat.u.encoded_audio = media_encoded_audio_format::wildcard;
memset(&formatDescription, 0, sizeof(media_format_description));
formatDescription.family = B_MPEG_FORMAT_FAMILY;
formatDescription.u.mpeg.id = B_MPEG_1_AUDIO_LAYER_3;
err = formatObject.MakeFormatFor(formatDescription, mediaFormat, &tempFormat);
if (err == B_MEDIA_DUPLICATE_FORMAT)
formatObject.GetFormatFor(formatDescription, &tempFormat);
s_mpegFormat = tempFormat;
formatObject.Unlock();
}
示例8:
status_t
BMediaFormats::GetBeOSFormatFor(uint32 format,
media_format* _format, media_type type)
{
BMediaFormats formats;
media_format_description description;
description.family = B_BEOS_FORMAT_FAMILY;
description.u.beos.format = format;
status_t status = formats.GetFormatFor(description, _format);
if (status < B_OK)
return status;
if (type != B_MEDIA_UNKNOWN_TYPE && type != _format->type)
return B_BAD_TYPE;
return B_OK;
}
示例9: get_text_format
static status_t
get_text_format(tobias_stream_header * header, media_format * format)
{
TRACE(" get_text_format\n");
// get the format for the description
media_format_description description = tobias_text_description();
BMediaFormats formats;
status_t result = formats.InitCheck();
if (result == B_OK) {
result = formats.GetFormatFor(description, format);
}
if (result != B_OK) {
*format = tobias_text_encoded_media_format();
// ignore error, allow user to use ReadChunk interface
}
// fill out format from header packet
return B_OK;
}
示例10: get_media_format_for
status_t OpenSoundDevice::get_media_format_for(int fmt, media_format &format)
{
status_t err;
BMediaFormats formats;
if (formats.InitCheck() < B_OK)
return formats.InitCheck();
/* shortcut for raw */
if (fmt & AFMT_SUPPORTED_PCM) {
format = media_format();
format.type = B_MEDIA_RAW_AUDIO;
format.u.raw_audio = media_raw_audio_format::wildcard;
return B_OK;
}
media_format_description desc;
err = get_media_format_description_for(fmt, &desc);
if (err < B_OK)
return err;
err = formats.GetFormatFor(desc, &format);
return err;
};
示例11: UNIMPLEMENTED
status_t
BMediaFormats::GetAVIFormatFor(uint32 codec,
media_format* _format, media_type type)
{
UNIMPLEMENTED();
BMediaFormats formats;
media_format_description description;
description.family = B_AVI_FORMAT_FAMILY;
description.u.avi.codec = codec;
status_t status = formats.GetFormatFor(description, _format);
if (status < B_OK)
return status;
if (type != B_MEDIA_UNKNOWN_TYPE && type != _format->type)
return B_BAD_TYPE;
return B_OK;
}
示例12: get_video_format
static status_t
get_video_format(tobias_stream_header * header, media_format * format)
{
TRACE(" get_video_format\n");
// get the format for the description
media_format_description description = tobias_video_description();
description.u.avi.codec = header->subtype[3] << 24 | header->subtype[2] << 16
| header->subtype[1] << 8 | header->subtype[0];
BMediaFormats formats;
status_t result = formats.InitCheck();
if (result == B_OK) {
result = formats.GetFormatFor(description, format);
}
if (result != B_OK) {
*format = tobias_video_encoded_media_format();
// ignore error, allow user to use ReadChunk interface
}
// fill out format from header packet
format->user_data_type = B_CODEC_TYPE_INFO;
strncpy((char*)format->user_data, header->subtype, 4);
format->u.encoded_video.frame_size
= header->video.width * header->video.height;
format->u.encoded_video.output.field_rate = 10000000.0 / header->time_unit;
format->u.encoded_video.output.interlace = 1;
format->u.encoded_video.output.first_active = 0;
format->u.encoded_video.output.last_active = header->video.height - 1;
format->u.encoded_video.output.orientation = B_VIDEO_TOP_LEFT_RIGHT;
format->u.encoded_video.output.pixel_width_aspect = 1;
format->u.encoded_video.output.pixel_height_aspect = 1;
format->u.encoded_video.output.display.line_width = header->video.width;
format->u.encoded_video.output.display.line_count = header->video.height;
format->u.encoded_video.output.display.bytes_per_row = 0;
format->u.encoded_video.output.display.pixel_offset = 0;
format->u.encoded_video.output.display.line_offset = 0;
format->u.encoded_video.output.display.flags = 0;
// TODO: wring more info out of the headers
return B_OK;
}
示例13: get_audio_format
static status_t
get_audio_format(tobias_stream_header * header, media_format * format)
{
TRACE(" get_audio_format\n");
// get the format for the description
media_format_description description = tobias_audio_description();
unsigned int wav_id = 0;
sscanf(header->subtype, "%04x", &wav_id);
description.u.wav.codec = wav_id;
BMediaFormats formats;
status_t result = formats.InitCheck();
if (result == B_OK) {
result = formats.GetFormatFor(description, format);
}
if (result != B_OK) {
*format = tobias_audio_encoded_media_format();
// ignore error, allow user to use ReadChunk interface
}
// fill out format from header packet
format->user_data_type = B_CODEC_TYPE_INFO;
strncpy((char*)format->user_data, header->subtype, 4);
format->u.encoded_audio.bit_rate = header->audio.avgbytespersec * 8;
if (header->audio.channels == 1) {
format->u.encoded_audio.multi_info.channel_mask = B_CHANNEL_LEFT;
} else {
format->u.encoded_audio.multi_info.channel_mask = B_CHANNEL_LEFT | B_CHANNEL_RIGHT;
}
format->u.encoded_audio.output.frame_rate = header->samples_per_unit * 10000000.0 / header->time_unit;
format->u.encoded_audio.output.channel_count = header->audio.channels;
format->u.encoded_audio.output.buffer_size
= AudioBufferSize(&format->u.encoded_audio.output);
// TODO: wring more info out of the headers
return B_OK;
}
示例14: register_avcodec_tags
status_t
register_avcodec_tags(media_format_family family, const char *avname, int &index)
{
AVInputFormat *inputFormat = av_find_input_format(avname);
if (inputFormat == NULL)
return B_MEDIA_NO_HANDLER;
BMediaFormats mediaFormats;
if (mediaFormats.InitCheck() != B_OK)
return B_ERROR;
for (int tagSet = 0; inputFormat->codec_tag[tagSet]; tagSet++) {
const AVCodecTag *tags = inputFormat->codec_tag[tagSet];
if (tags == NULL)
continue;
for (; tags->id != CODEC_ID_NONE; tags++) {
// XXX: we might want to keep some strange PCM codecs too...
// skip unwanted codec tags
if (tags->tag == CODEC_ID_RAWVIDEO
|| (tags->tag >= CODEC_ID_PCM_S16LE
&& tags->tag < CODEC_ID_ADPCM_IMA_QT)
|| tags->tag >= CODEC_ID_DVD_SUBTITLE)
continue;
if (index >= sMaxFormatCount) {
fprintf(stderr, "Maximum format count reached for auto-generated "
"AVCodec to media_format mapping, but there are still more "
"AVCodecs compiled into libavcodec!\n");
break;
}
media_format format;
// Determine media type
if (tags->tag < CODEC_ID_PCM_S16LE)
format.type = B_MEDIA_ENCODED_VIDEO;
else
format.type = B_MEDIA_ENCODED_AUDIO;
media_format_description description;
memset(&description, 0, sizeof(description));
// Hard-code everything to B_MISC_FORMAT_FAMILY to ease matching
// later on.
description.family = family;
switch (family) {
case B_AIFF_FORMAT_FAMILY:
description.u.aiff.codec = tags->tag;
break;
case B_AVI_FORMAT_FAMILY:
description.u.avi.codec = tags->tag;
break;
case B_MPEG_FORMAT_FAMILY:
description.u.mpeg.id = tags->tag;
break;
case B_QUICKTIME_FORMAT_FAMILY:
description.u.quicktime.codec = tags->tag;
break;
case B_WAV_FORMAT_FAMILY:
description.u.wav.codec = tags->tag;
break;
default:
break;
}
format.require_flags = 0;
format.deny_flags = B_MEDIA_MAUI_UNDEFINED_FLAGS;
if (mediaFormats.MakeFormatFor(&description, 1, &format) != B_OK)
return B_ERROR;
gAVCodecFormats[index] = format;
index++;
}
}
return B_OK;
}
示例15: if
status_t
XvidDecoder::Setup(media_format* inputFormat, const void* inInfo,
size_t inSize)
{
if (inputFormat == NULL)
return B_BAD_VALUE;
if (inputFormat->type != B_MEDIA_ENCODED_VIDEO)
return B_BAD_VALUE;
// PRINT(("%p->XvidDecoder::Setup()\n", this));
//#if DEBUG
// char buffer[1024];
// string_for_format(*inputFormat, buffer, sizeof(buffer));
// PRINT((" inputFormat=%s\n", buffer));
// PRINT((" inSize=%d\n", inSize));
// print_hex((uchar*)inInfo, inSize);
// PRINT((" user_data_type=%08lx\n", (int)inputFormat->user_data_type));
// print_hex((uchar*)inputFormat->user_data, 48);
//#endif
uint32 codecID = 0;
media_format_family familyID = B_ANY_FORMAT_FAMILY;
// hacky... get the exact 4CC from there if it's in, to help xvid
// handle broken files
// if ((inputFormat->user_data_type == B_CODEC_TYPE_INFO)
// && !memcmp(inputFormat->user_data, "AVI ", 4)) {
// codecID = ((uint32*)inputFormat->user_data)[1];
// familyID = B_AVI_FORMAT_FAMILY;
// PRINT(("XvidDecoder::Setup() - AVI 4CC: %4s\n",
// inputFormat->user_data + 4));
// }
if (codecID == 0) {
BMediaFormats formats;
media_format_description descr;
if (formats.GetCodeFor(*inputFormat, B_QUICKTIME_FORMAT_FAMILY,
&descr) == B_OK) {
codecID = descr.u.quicktime.codec;
familyID = B_QUICKTIME_FORMAT_FAMILY;
#if PRINT_FOURCC
uint32 bigEndianID = B_HOST_TO_BENDIAN_INT32(codecID);
printf("%p->XvidDecoder::Setup() - QT 4CC: %.4s\n", this,
(const char*)&bigEndianID);
#endif
} else if (formats.GetCodeFor(*inputFormat, B_AVI_FORMAT_FAMILY,
&descr) == B_OK) {
codecID = descr.u.avi.codec;
familyID = B_AVI_FORMAT_FAMILY;
#if PRINT_FOURCC
uint32 bigEndianID = B_HOST_TO_BENDIAN_INT32(codecID);
printf("%p->XvidDecoder::Setup() - AVI 4CC: %.4s\n", this,
(const char*)&bigEndianID);
#endif
} else if (formats.GetCodeFor(*inputFormat, B_MPEG_FORMAT_FAMILY,
&descr) == B_OK) {
codecID = descr.u.mpeg.id;
familyID = B_MPEG_FORMAT_FAMILY;
#if PRINT_FOURCC
printf("%p->XvidDecoder::Setup() - MPEG ID: %ld\n", this, codecID);
#endif
}
}
if (codecID == 0)
return B_ERROR;
for (int32 i = 0; i < gSupportedCodecsCount; i++) {
if (gCodecTable[i].family == familyID
&& gCodecTable[i].fourcc == codecID) {
PRINT(("%p->XvidDecoder::Setup() - found codec in the table "
"at %ld.\n", this, i));
fIndexInCodecTable = i;
fInputFormat = *inputFormat;
return B_OK;
}
}
#if PRINT_FOURCC
printf("%p->XvidDecoder::Setup() - no matching codec found in the "
"table.\n", this);
#endif
return B_ERROR;
}