use user_data for ogg_packet and pass raw data pointer through chunkBuffer
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9495 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
a13f233057
commit
8b6368d31b
|
@ -0,0 +1,10 @@
|
|||
#ifndef _OGG_FORMATS_H
|
||||
#define _OGG_FORMATS_H
|
||||
|
||||
//! for use in media_misc_description.file_format
|
||||
const uint32 OGG_FILE_FORMAT = 'OggS';
|
||||
|
||||
//! for use in media_header.user_data_type
|
||||
const uint32 OGG_PACKET_DATA_TYPE = 'OggP';
|
||||
|
||||
#endif _OGG_FORMATS_H
|
|
@ -2,6 +2,7 @@
|
|||
#include "OggSpeexSeekable.h"
|
||||
#include "OggTobiasSeekable.h"
|
||||
#include "OggVorbisSeekable.h"
|
||||
#include "OggFormats.h"
|
||||
#include <Autolock.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -247,7 +248,7 @@ OggSeekable::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.file_format = OGG_FILE_FORMAT;
|
||||
description.u.misc.codec = four_bytes;
|
||||
BMediaFormats formats;
|
||||
result = formats.InitCheck();
|
||||
|
@ -448,21 +449,25 @@ OggSeekable::Seek(uint32 seekTo, int64 *frame, bigtime_t *time)
|
|||
return B_OK;
|
||||
}*/
|
||||
|
||||
|
||||
status_t
|
||||
OggSeekable::GetNextChunk(void **chunkBuffer, int32 *chunkSize,
|
||||
media_header *mediaHeader)
|
||||
{
|
||||
ogg_packet packet;
|
||||
BAutolock autolock(fPositionLock);
|
||||
status_t result = GetPacket(&fChunkPacket);
|
||||
status_t result = GetPacket(&packet);
|
||||
*chunkBuffer = packet.packet;
|
||||
*chunkSize = packet.bytes;
|
||||
packet.packet = NULL;
|
||||
assert(sizeof(ogg_packet) <= sizeof(mediaHeader->user_data));
|
||||
mediaHeader->user_data_type = OGG_PACKET_DATA_TYPE;
|
||||
memcpy(mediaHeader->user_data, &packet, sizeof(ogg_packet));
|
||||
if (result != B_OK) {
|
||||
TRACE("OggSeekable::GetNextChunk failed: GetPacket = %s\n", strerror(result));
|
||||
return result;
|
||||
}
|
||||
*chunkBuffer = &fChunkPacket;
|
||||
*chunkSize = sizeof(fChunkPacket);
|
||||
if (fChunkPacket.granulepos > 0) {
|
||||
fCurrentFrame = fChunkPacket.granulepos - fFirstGranulepos;
|
||||
if (packet.granulepos > 0) {
|
||||
fCurrentFrame = packet.granulepos - fFirstGranulepos;
|
||||
fCurrentTime = (bigtime_t)((fCurrentFrame * 1000000LL) / fFrameRate);
|
||||
mediaHeader->start_time = fCurrentTime;
|
||||
} else {
|
||||
|
|
|
@ -40,7 +40,6 @@ protected:
|
|||
|
||||
// subclass pull input function
|
||||
status_t GetPacket(ogg_packet * packet);
|
||||
ogg_packet fChunkPacket;
|
||||
|
||||
protected:
|
||||
int64 fCurrentFrame;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <MediaFormats.h>
|
||||
#include <ogg/ogg.h>
|
||||
#include <string.h>
|
||||
#include <OggFormats.h>
|
||||
|
||||
/*
|
||||
* speex descriptions/formats
|
||||
|
@ -15,7 +16,7 @@ speex_description()
|
|||
{
|
||||
media_format_description description;
|
||||
description.family = B_MISC_FORMAT_FAMILY;
|
||||
description.u.misc.file_format = 'OggS';
|
||||
description.u.misc.file_format = OGG_FILE_FORMAT;
|
||||
description.u.misc.codec = 'Spee';
|
||||
return description;
|
||||
}
|
||||
|
|
|
@ -179,18 +179,3 @@ OggSpeexSeekable::GetStreamInfo(int64 *frameCount, bigtime_t *duration,
|
|||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
OggSpeexSeekable::GetNextChunk(void **chunkBuffer, int32 *chunkSize,
|
||||
media_header *mediaHeader)
|
||||
{
|
||||
status_t result = inherited::GetNextChunk(chunkBuffer, chunkSize, mediaHeader);
|
||||
if (result != B_OK) {
|
||||
TRACE("OggSpeexSeekable::GetNextChunk failed: GetNextChunk = %s\n", strerror(result));
|
||||
return result;
|
||||
}
|
||||
*chunkSize = ((ogg_packet*)*chunkBuffer)->bytes;
|
||||
*chunkBuffer = ((ogg_packet*)*chunkBuffer)->packet;
|
||||
return B_OK;
|
||||
}
|
||||
|
|
|
@ -16,8 +16,6 @@ public:
|
|||
|
||||
virtual status_t GetStreamInfo(int64 *frameCount, bigtime_t *duration,
|
||||
media_format *format);
|
||||
virtual status_t GetNextChunk(void **chunkBuffer, int32 *chunkSize,
|
||||
media_header *mediaHeader);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "OggTheoraStream.h"
|
||||
#include "OggTobiasStream.h"
|
||||
#include "OggVorbisStream.h"
|
||||
#include "OggFormats.h"
|
||||
#include <Autolock.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -107,7 +108,7 @@ OggStream::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.file_format = OGG_FILE_FORMAT;
|
||||
description.u.misc.codec = four_bytes;
|
||||
BMediaFormats formats;
|
||||
result = formats.InitCheck();
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <MediaFormats.h>
|
||||
#include <ogg/ogg.h>
|
||||
#include <string.h>
|
||||
#include <OggFormats.h>
|
||||
|
||||
/*
|
||||
* theora descriptions/formats
|
||||
|
@ -15,7 +16,7 @@ theora_description()
|
|||
{
|
||||
media_format_description description;
|
||||
description.family = B_MISC_FORMAT_FAMILY;
|
||||
description.u.misc.file_format = 'OggS';
|
||||
description.u.misc.file_format = OGG_FILE_FORMAT;
|
||||
description.u.misc.codec = 'theo';
|
||||
return description;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <MediaFormats.h>
|
||||
#include <ogg/ogg.h>
|
||||
#include <string.h>
|
||||
#include "OggFormats.h"
|
||||
|
||||
/*
|
||||
* tobias descriptions/formats
|
||||
|
@ -47,7 +48,7 @@ tobias_text_description()
|
|||
{
|
||||
media_format_description description;
|
||||
description.family = B_MISC_FORMAT_FAMILY;
|
||||
description.u.misc.file_format = 'OggS';
|
||||
description.u.misc.file_format = OGG_FILE_FORMAT;
|
||||
description.u.misc.codec = 'text';
|
||||
return description;
|
||||
}
|
||||
|
|
|
@ -266,8 +266,6 @@ OggTobiasSeekable::GetNextChunk(void **chunkBuffer, int32 *chunkSize,
|
|||
TRACE("OggTobiasSeekable::GetNextChunk failed: GetNextChunk = %s\n", strerror(result));
|
||||
return result;
|
||||
}
|
||||
*chunkSize = ((ogg_packet*)*chunkBuffer)->bytes;
|
||||
*chunkBuffer = ((ogg_packet*)*chunkBuffer)->packet;
|
||||
bool keyframe = ((uint*)chunkBuffer)[0] & (1 << 3); // ??
|
||||
if (fMediaFormat.type == B_MEDIA_ENCODED_VIDEO) {
|
||||
mediaHeader->type = fMediaFormat.type;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <MediaFormats.h>
|
||||
#include <ogg/ogg.h>
|
||||
#include <string.h>
|
||||
#include "OggFormats.h"
|
||||
|
||||
/*
|
||||
* vorbis descriptions/formats
|
||||
|
@ -15,7 +16,7 @@ vorbis_description()
|
|||
{
|
||||
media_format_description description;
|
||||
description.family = B_MISC_FORMAT_FAMILY;
|
||||
description.u.misc.file_format = 'OggS';
|
||||
description.u.misc.file_format = OGG_FILE_FORMAT;
|
||||
description.u.misc.codec = 'vorb';
|
||||
return description;
|
||||
}
|
||||
|
|
|
@ -189,8 +189,8 @@ VorbisDecoder::Decode(void *buffer, int64 *frameCount,
|
|||
TRACE("VorbisDecoder::Decode: GetNextChunk failed\n");
|
||||
return status;
|
||||
}
|
||||
if (chunkSize != sizeof(ogg_packet)) {
|
||||
TRACE("VorbisDecoder::Decode: chunk not ogg_packet-sized\n");
|
||||
if (mh.user_data_type != OGG_PACKET_DATA_TYPE) {
|
||||
TRACE("VorbisDecoder::Decode: chunk missing ogg_packet data");
|
||||
return B_ERROR;
|
||||
}
|
||||
if (!synced) {
|
||||
|
@ -199,7 +199,8 @@ VorbisDecoder::Decode(void *buffer, int64 *frameCount,
|
|||
synced = true;
|
||||
}
|
||||
}
|
||||
ogg_packet * packet = static_cast<ogg_packet*>(chunkBuffer);
|
||||
ogg_packet * packet = reinterpret_cast<ogg_packet*>(mh.user_data);
|
||||
packet->packet = static_cast<unsigned char *>(chunkBuffer);
|
||||
if (vorbis_synthesis(&fBlock, packet)==0) {
|
||||
vorbis_synthesis_blockin(&fDspState,&fBlock);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue