tolerate more badness from BMediaFormats, added theora formats, cleaned up theora header parsing

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6272 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
shatty 2004-01-25 07:58:23 +00:00
parent d1d448fc86
commit fff3b1f17b
5 changed files with 55 additions and 37 deletions

View File

@ -93,14 +93,9 @@ OggSpeexStream::GetStreamInfo(int64 *frameCount, bigtime_t *duration,
media_format_description description = speex_description();
BMediaFormats formats;
result = formats.InitCheck();
if (result != B_OK) {
return result;
if (result == B_OK) {
result = formats.GetFormatFor(description, format);
}
if (!formats.Lock()) {
return B_ERROR;
}
result = formats.GetFormatFor(description, format);
formats.Unlock();
if (result != B_OK) {
*format = speex_encoded_media_format();
// ignore error, allow user to use ReadChunk interface

View File

@ -0,0 +1,42 @@
#ifndef _OGG_THEORA_FORMATS_H
#define _OGG_THEORA_FORMATS_H
#include <MediaFormats.h>
#include <ogg/ogg.h>
#include <string.h>
/*
* theora descriptions/formats
*/
static media_format_description
theora_description()
{
media_format_description description;
description.family = B_MISC_FORMAT_FAMILY;
description.u.misc.file_format = 'OggS';
description.u.misc.codec = 'theo';
return description;
}
static void
init_theora_media_raw_video_format(media_raw_video_format * output)
{
}
static media_format
theora_encoded_media_format()
{
media_format format;
format.type = B_MEDIA_ENCODED_AUDIO;
format.user_data_type = B_CODEC_TYPE_INFO;
strncpy((char*)format.user_data, "theo", 4);
init_theora_media_raw_video_format(&format.u.encoded_video.output);
return format;
}
#endif _OGG_THEORA_FORMATS_H

View File

@ -1,3 +1,4 @@
#include "OggTheoraFormats.h"
#include "OggTheoraStream.h"
#include <ogg/ogg.h>
#include <stdio.h>
@ -134,7 +135,7 @@ OggTheoraStream::IsValidHeader(const ogg_packet & packet)
OggTheoraStream::OggTheoraStream(long serialno)
: OggStream(serialno)
{
TRACE("OggTheoraStream::OggTheoraStream\n");
}
OggTheoraStream::~OggTheoraStream()
@ -181,28 +182,18 @@ OggTheoraStream::GetStreamInfo(int64 *frameCount, bigtime_t *duration,
}
// get the format for the description
media_format_description description;
description.family = B_MISC_FORMAT_FAMILY;
description.u.misc.file_format = 'OggS';
description.u.misc.codec = 'theo';
media_format_description description = theora_description();
BMediaFormats formats;
result = formats.InitCheck();
if (result != B_OK) {
return result;
if (result == B_OK) {
result = formats.GetFormatFor(description, format);
}
if (!formats.Lock()) {
return B_ERROR;
}
result = formats.GetFormatFor(description, format);
formats.Unlock();
if (result != B_OK) {
return result;
*format = theora_encoded_media_format();
// ignore error, allow user to use ReadChunk interface
}
// fill out format from header packet
format->type = B_MEDIA_ENCODED_VIDEO;
format->user_data_type = B_CODEC_TYPE_INFO;
strncpy((char*)format->user_data, "theo", 4);
format->u.encoded_video.frame_size = info.frame_width * info.frame_height ;
format->u.encoded_video.output.display.line_width = info.frame_width;
format->u.encoded_video.output.display.line_count = info.frame_height;

View File

@ -110,14 +110,9 @@ OggTobiasStream::GetStreamInfo(int64 *frameCount, bigtime_t *duration,
| header->subtype[2] << 8 | header->subtype[3];
BMediaFormats formats;
result = formats.InitCheck();
if (result != B_OK) {
return result;
if (result == B_OK) {
result = formats.GetFormatFor(description, format);
}
if (!formats.Lock()) {
return B_ERROR;
}
result = formats.GetFormatFor(description, format);
formats.Unlock();
if (result != B_OK) {
*format = tobias_encoded_media_format();
// ignore error, allow user to use ReadChunk interface

View File

@ -136,14 +136,9 @@ OggVorbisStream::GetStreamInfo(int64 *frameCount, bigtime_t *duration,
media_format_description description = vorbis_description();
BMediaFormats formats;
result = formats.InitCheck();
if (result != B_OK) {
return result;
if (result == B_OK) {
result = formats.GetFormatFor(description, format);
}
if (!formats.Lock()) {
return B_ERROR;
}
result = formats.GetFormatFor(description, format);
formats.Unlock();
if (result != B_OK) {
*format = vorbis_encoded_media_format();
// ignore error, allow user to use ReadChunk interface