factored out description and default format construction and made them available through ogg, use these in case BMediaFormats fails -- like it does with the tobias streams for right now
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6271 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
#ifndef _OGG_SPEEX_FORMATS_H
|
||||||
|
#define _OGG_SPEEX_FORMATS_H
|
||||||
|
|
||||||
|
#include <MediaFormats.h>
|
||||||
|
#include <ogg/ogg.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* speex descriptions/formats
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
static media_format_description
|
||||||
|
speex_description()
|
||||||
|
{
|
||||||
|
media_format_description description;
|
||||||
|
description.family = B_MISC_FORMAT_FAMILY;
|
||||||
|
description.u.misc.file_format = 'OggS';
|
||||||
|
description.u.misc.codec = 'Spee';
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_speex_media_raw_audio_format(media_raw_audio_format * output)
|
||||||
|
{
|
||||||
|
output->format = media_raw_audio_format::B_AUDIO_FLOAT;
|
||||||
|
output->byte_order = B_MEDIA_HOST_ENDIAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static media_format
|
||||||
|
speex_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, "Spee", 4);
|
||||||
|
format.u.encoded_audio.frame_size = sizeof(ogg_packet);
|
||||||
|
init_speex_media_raw_audio_format(&format.u.encoded_audio.output);
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif _OGG_SPEEX_FORMATS_H
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include "OggSpeexFormats.h"
|
||||||
#include "OggSpeexStream.h"
|
#include "OggSpeexStream.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -89,10 +90,7 @@ OggSpeexStream::GetStreamInfo(int64 *frameCount, bigtime_t *duration,
|
|||||||
SpeexHeader * header = (SpeexHeader *)data;
|
SpeexHeader * header = (SpeexHeader *)data;
|
||||||
|
|
||||||
// get the format for the description
|
// get the format for the description
|
||||||
media_format_description description;
|
media_format_description description = speex_description();
|
||||||
description.family = B_MISC_FORMAT_FAMILY;
|
|
||||||
description.u.misc.file_format = 'OggS';
|
|
||||||
description.u.misc.codec = 'Spee';
|
|
||||||
BMediaFormats formats;
|
BMediaFormats formats;
|
||||||
result = formats.InitCheck();
|
result = formats.InitCheck();
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
@@ -104,7 +102,8 @@ OggSpeexStream::GetStreamInfo(int64 *frameCount, bigtime_t *duration,
|
|||||||
result = formats.GetFormatFor(description, format);
|
result = formats.GetFormatFor(description, format);
|
||||||
formats.Unlock();
|
formats.Unlock();
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
return result;
|
*format = speex_encoded_media_format();
|
||||||
|
// ignore error, allow user to use ReadChunk interface
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill out format from header packet
|
// fill out format from header packet
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#ifndef _OGG_TOBIAS_FORMATS_H
|
||||||
|
#define _OGG_TOBIAS_FORMATS_H
|
||||||
|
|
||||||
|
#include <MediaFormats.h>
|
||||||
|
#include <ogg/ogg.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* tobias descriptions/formats
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
static media_format_description
|
||||||
|
tobias_description()
|
||||||
|
{
|
||||||
|
media_format_description description;
|
||||||
|
description.family = B_AVI_FORMAT_FAMILY;
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_tobias_media_raw_video_format(media_raw_video_format * output)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static media_format
|
||||||
|
tobias_encoded_media_format()
|
||||||
|
{
|
||||||
|
media_format format;
|
||||||
|
format.type = B_MEDIA_ENCODED_VIDEO;
|
||||||
|
format.u.encoded_audio.frame_size = sizeof(ogg_packet);
|
||||||
|
init_tobias_media_raw_video_format(&format.u.encoded_video.output);
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif _OGG_TOBIAS_FORMATS_H
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include "OggTobiasFormats.h"
|
||||||
#include "OggTobiasStream.h"
|
#include "OggTobiasStream.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -104,8 +105,7 @@ OggTobiasStream::GetStreamInfo(int64 *frameCount, bigtime_t *duration,
|
|||||||
tobias_stream_header * header = (tobias_stream_header *)data;
|
tobias_stream_header * header = (tobias_stream_header *)data;
|
||||||
|
|
||||||
// get the format for the description
|
// get the format for the description
|
||||||
media_format_description description;
|
media_format_description description = tobias_description();
|
||||||
description.family = B_AVI_FORMAT_FAMILY;
|
|
||||||
description.u.avi.codec = header->subtype[0] << 24 | header->subtype[1] << 16
|
description.u.avi.codec = header->subtype[0] << 24 | header->subtype[1] << 16
|
||||||
| header->subtype[2] << 8 | header->subtype[3];
|
| header->subtype[2] << 8 | header->subtype[3];
|
||||||
BMediaFormats formats;
|
BMediaFormats formats;
|
||||||
@@ -119,11 +119,11 @@ OggTobiasStream::GetStreamInfo(int64 *frameCount, bigtime_t *duration,
|
|||||||
result = formats.GetFormatFor(description, format);
|
result = formats.GetFormatFor(description, format);
|
||||||
formats.Unlock();
|
formats.Unlock();
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
return result;
|
*format = tobias_encoded_media_format();
|
||||||
|
// ignore error, allow user to use ReadChunk interface
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill out format from header packet
|
// fill out format from header packet
|
||||||
format->type = B_MEDIA_ENCODED_VIDEO;
|
|
||||||
format->user_data_type = B_CODEC_TYPE_INFO;
|
format->user_data_type = B_CODEC_TYPE_INFO;
|
||||||
strncpy((char*)format->user_data, header->subtype, 4);
|
strncpy((char*)format->user_data, header->subtype, 4);
|
||||||
format->u.encoded_video.frame_size
|
format->u.encoded_video.frame_size
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
#ifndef _OGG_VORBIS_FORMATS_H
|
||||||
|
#define _OGG_VORBIS_FORMATS_H
|
||||||
|
|
||||||
|
#include <MediaFormats.h>
|
||||||
|
#include <ogg/ogg.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* vorbis descriptions/formats
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
static media_format_description
|
||||||
|
vorbis_description()
|
||||||
|
{
|
||||||
|
media_format_description description;
|
||||||
|
description.family = B_MISC_FORMAT_FAMILY;
|
||||||
|
description.u.misc.file_format = 'OggS';
|
||||||
|
description.u.misc.codec = 'vorb';
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_vorbis_media_raw_audio_format(media_raw_audio_format * output)
|
||||||
|
{
|
||||||
|
output->format = media_raw_audio_format::B_AUDIO_FLOAT;
|
||||||
|
output->byte_order = B_MEDIA_HOST_ENDIAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static media_format
|
||||||
|
vorbis_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, "vorb", 4);
|
||||||
|
format.u.encoded_audio.frame_size = sizeof(ogg_packet);
|
||||||
|
init_vorbis_media_raw_audio_format(&format.u.encoded_audio.output);
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif _OGG_VORBIS_FORMATS_H
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include "OggVorbisFormats.h"
|
||||||
#include "OggVorbisStream.h"
|
#include "OggVorbisStream.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -132,10 +133,7 @@ OggVorbisStream::GetStreamInfo(int64 *frameCount, bigtime_t *duration,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get the format for the description
|
// get the format for the description
|
||||||
media_format_description description;
|
media_format_description description = vorbis_description();
|
||||||
description.family = B_MISC_FORMAT_FAMILY;
|
|
||||||
description.u.misc.file_format = 'OggS';
|
|
||||||
description.u.misc.codec = 'vorb';
|
|
||||||
BMediaFormats formats;
|
BMediaFormats formats;
|
||||||
result = formats.InitCheck();
|
result = formats.InitCheck();
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
@@ -147,7 +145,8 @@ OggVorbisStream::GetStreamInfo(int64 *frameCount, bigtime_t *duration,
|
|||||||
result = formats.GetFormatFor(description, format);
|
result = formats.GetFormatFor(description, format);
|
||||||
formats.Unlock();
|
formats.Unlock();
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
return result;
|
*format = vorbis_encoded_media_format();
|
||||||
|
// ignore error, allow user to use ReadChunk interface
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill out format from header packet
|
// fill out format from header packet
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ SubDir OBOS_TOP src add-ons media plugins speex ;
|
|||||||
|
|
||||||
UsePrivateHeaders media ;
|
UsePrivateHeaders media ;
|
||||||
|
|
||||||
|
SubDirHdrs $(SUBDIR) .. ogg ;
|
||||||
SubDirHdrs $(SUBDIR) .. ogg libogg ;
|
SubDirHdrs $(SUBDIR) .. ogg libogg ;
|
||||||
SubDirHdrs $(SUBDIR) libspeex ;
|
SubDirHdrs $(SUBDIR) libspeex ;
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "ogg/ogg.h"
|
#include "ogg/ogg.h"
|
||||||
#include "speexCodecPlugin.h"
|
#include "speexCodecPlugin.h"
|
||||||
#include "speexCodecDefaults.h"
|
#include "speexCodecDefaults.h"
|
||||||
|
#include "OggSpeexFormats.h"
|
||||||
|
|
||||||
#define TRACE_THIS 1
|
#define TRACE_THIS 1
|
||||||
#if TRACE_THIS
|
#if TRACE_THIS
|
||||||
@@ -27,43 +28,6 @@ AudioBufferSize(media_raw_audio_format * raf, bigtime_t buffer_duration = 50000
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* speex descriptions/formats
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
static media_format_description
|
|
||||||
speex_description()
|
|
||||||
{
|
|
||||||
media_format_description description;
|
|
||||||
description.family = B_MISC_FORMAT_FAMILY;
|
|
||||||
description.u.misc.file_format = 'OggS';
|
|
||||||
description.u.misc.codec = 'Spee';
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
init_speex_media_raw_audio_format(media_raw_audio_format * output)
|
|
||||||
{
|
|
||||||
output->format = media_raw_audio_format::B_AUDIO_FLOAT;
|
|
||||||
output->byte_order = B_MEDIA_HOST_ENDIAN;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static media_format
|
|
||||||
speex_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, "Spee", 4);
|
|
||||||
format.u.encoded_audio.frame_size = sizeof(ogg_packet);
|
|
||||||
init_speex_media_raw_audio_format(&format.u.encoded_audio.output);
|
|
||||||
return format;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static media_format
|
static media_format
|
||||||
speex_decoded_media_format()
|
speex_decoded_media_format()
|
||||||
{
|
{
|
||||||
@@ -106,8 +70,8 @@ SpeexDecoder::~SpeexDecoder()
|
|||||||
void
|
void
|
||||||
SpeexDecoder::GetCodecInfo(media_codec_info &info)
|
SpeexDecoder::GetCodecInfo(media_codec_info &info)
|
||||||
{
|
{
|
||||||
strncpy(info.short_name, "speex", sizeof(info.short_name));
|
strncpy(info.short_name, "speex-libspeex", sizeof(info.short_name));
|
||||||
strncpy(info.pretty_name, "speex decoder, by Andrew Bachmann, based on libspeex", sizeof(info.pretty_name));
|
strncpy(info.pretty_name, "speex decoder [libspeex], by Andrew Bachmann", sizeof(info.pretty_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ SubDir OBOS_TOP src add-ons media plugins vorbis ;
|
|||||||
|
|
||||||
UsePrivateHeaders media ;
|
UsePrivateHeaders media ;
|
||||||
|
|
||||||
|
SubDirHdrs $(SUBDIR) .. ogg ;
|
||||||
SubDirHdrs $(SUBDIR) .. ogg libogg ;
|
SubDirHdrs $(SUBDIR) .. ogg libogg ;
|
||||||
SubDirHdrs $(SUBDIR) libvorbis vorbis ;
|
SubDirHdrs $(SUBDIR) libvorbis vorbis ;
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <MediaRoster.h>
|
#include <MediaRoster.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "vorbisCodecPlugin.h"
|
#include "vorbisCodecPlugin.h"
|
||||||
|
#include "OggVorbisFormats.h"
|
||||||
|
|
||||||
#define TRACE_THIS 1
|
#define TRACE_THIS 1
|
||||||
#if TRACE_THIS
|
#if TRACE_THIS
|
||||||
@@ -25,43 +26,6 @@ AudioBufferSize(media_raw_audio_format * raf, bigtime_t buffer_duration = 50000
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* vorbis descriptions/formats
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
static media_format_description
|
|
||||||
vorbis_description()
|
|
||||||
{
|
|
||||||
media_format_description description;
|
|
||||||
description.family = B_MISC_FORMAT_FAMILY;
|
|
||||||
description.u.misc.file_format = 'OggS';
|
|
||||||
description.u.misc.codec = 'vorb';
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
init_vorbis_media_raw_audio_format(media_raw_audio_format * output)
|
|
||||||
{
|
|
||||||
output->format = media_raw_audio_format::B_AUDIO_FLOAT;
|
|
||||||
output->byte_order = B_MEDIA_HOST_ENDIAN;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static media_format
|
|
||||||
vorbis_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, "vorb", 4);
|
|
||||||
format.u.encoded_audio.frame_size = sizeof(ogg_packet);
|
|
||||||
init_vorbis_media_raw_audio_format(&format.u.encoded_audio.output);
|
|
||||||
return format;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static media_format
|
static media_format
|
||||||
vorbis_decoded_media_format()
|
vorbis_decoded_media_format()
|
||||||
{
|
{
|
||||||
@@ -98,8 +62,8 @@ VorbisDecoder::~VorbisDecoder()
|
|||||||
void
|
void
|
||||||
VorbisDecoder::GetCodecInfo(media_codec_info &info)
|
VorbisDecoder::GetCodecInfo(media_codec_info &info)
|
||||||
{
|
{
|
||||||
strncpy(info.short_name, "vorbis", sizeof(info.short_name));
|
strncpy(info.short_name, "vorbis-libvorbis", sizeof(info.short_name));
|
||||||
strncpy(info.pretty_name, "vorbis decoder, by Andrew Bachmann, based on libvorbis", sizeof(info.pretty_name));
|
strncpy(info.pretty_name, "vorbis decoder [libvorbis], by Andrew Bachmann", sizeof(info.pretty_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user