fixed GetNextChunk not connected bug
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6671 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -45,7 +45,7 @@ class BMediaDecoder {
|
|||||||
BMediaDecoder(const BMediaDecoder &);
|
BMediaDecoder(const BMediaDecoder &);
|
||||||
BMediaDecoder & operator=(const BMediaDecoder &);
|
BMediaDecoder & operator=(const BMediaDecoder &);
|
||||||
|
|
||||||
void DoLateInit();
|
status_t AttachToDecoder();
|
||||||
|
|
||||||
BPrivate::media::Decoder *fDecoder;
|
BPrivate::media::Decoder *fDecoder;
|
||||||
int32 fDecoderID;
|
int32 fDecoderID;
|
||||||
@@ -57,11 +57,10 @@ class BMediaDecoder {
|
|||||||
media_format * fInitFormat;
|
media_format * fInitFormat;
|
||||||
char * fInitInfo;
|
char * fInitInfo;
|
||||||
size_t fInitInfoSize;
|
size_t fInitInfoSize;
|
||||||
media_codec_info * fInitMCI;
|
|
||||||
|
|
||||||
/* fbc data and virtuals */
|
/* fbc data and virtuals */
|
||||||
|
|
||||||
uint32 _reserved_BMediaDecoder_[25];
|
uint32 _reserved_BMediaDecoder_[26];
|
||||||
|
|
||||||
virtual status_t _Reserved_BMediaDecoder_0(int32 arg, ...);
|
virtual status_t _Reserved_BMediaDecoder_0(int32 arg, ...);
|
||||||
virtual status_t _Reserved_BMediaDecoder_1(int32 arg, ...);
|
virtual status_t _Reserved_BMediaDecoder_1(int32 arg, ...);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* AUTHOR: Marcus Overhagen
|
* AUTHOR: Andrew Bachmann, Marcus Overhagen
|
||||||
* FILE: MediaDecoder.cpp
|
* FILE: MediaDecoder.cpp
|
||||||
* DESCR:
|
* DESCR:
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
@@ -16,32 +16,31 @@ extern PluginManager _plugin_manager;
|
|||||||
*************************************************************/
|
*************************************************************/
|
||||||
|
|
||||||
BMediaDecoder::BMediaDecoder()
|
BMediaDecoder::BMediaDecoder()
|
||||||
: fDecoder(0),
|
: fDecoder(NULL),
|
||||||
fDecoderID(0),
|
fDecoderID(0),
|
||||||
fDecoderPlugin(0),
|
fDecoderPlugin(NULL),
|
||||||
fDecoderPluginID(0),
|
fDecoderPluginID(0),
|
||||||
fInitStatus(B_NO_INIT),
|
fInitStatus(B_NO_INIT),
|
||||||
fNeedsInit(false),
|
fNeedsInit(false),
|
||||||
fInitFormat(0),
|
fInitFormat(NULL),
|
||||||
fInitInfo(0),
|
fInitInfo(NULL),
|
||||||
fInitInfoSize(0),
|
fInitInfoSize(0)
|
||||||
fInitMCI(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMediaDecoder::BMediaDecoder(const media_format *in_format,
|
BMediaDecoder::BMediaDecoder(const media_format *in_format,
|
||||||
const void *info,
|
const void *info,
|
||||||
size_t info_size)
|
size_t info_size)
|
||||||
: fDecoder(0),
|
: fDecoder(NULL),
|
||||||
fDecoderID(0),
|
fDecoderID(0),
|
||||||
fDecoderPlugin(0),
|
fDecoderPlugin(NULL),
|
||||||
fDecoderPluginID(0),
|
fDecoderPluginID(0),
|
||||||
fInitStatus(B_NO_INIT),
|
fInitStatus(B_NO_INIT),
|
||||||
fNeedsInit(true),
|
fNeedsInit(true),
|
||||||
fInitFormat(new media_format(*in_format)),
|
fInitFormat(new media_format(*in_format)),
|
||||||
fInitInfo(0),
|
fInitInfo(NULL),
|
||||||
fInitInfoSize(0),
|
fInitInfoSize(0)
|
||||||
fInitMCI(0)
|
|
||||||
{
|
{
|
||||||
if (info_size) {
|
if (info_size) {
|
||||||
fInitInfoSize = info_size;
|
fInitInfoSize = info_size;
|
||||||
@@ -50,35 +49,39 @@ BMediaDecoder::BMediaDecoder(const media_format *in_format,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMediaDecoder::BMediaDecoder(const media_codec_info *mci)
|
BMediaDecoder::BMediaDecoder(const media_codec_info *mci)
|
||||||
: fDecoder(0),
|
: fDecoder(NULL),
|
||||||
fDecoderID(0),
|
fDecoderID(0),
|
||||||
fDecoderPlugin(0),
|
fDecoderPlugin(NULL),
|
||||||
fDecoderPluginID(0),
|
fDecoderPluginID(0),
|
||||||
fInitStatus(B_NO_INIT),
|
fInitStatus(B_NO_INIT),
|
||||||
fNeedsInit(true),
|
fNeedsInit(false),
|
||||||
fInitFormat(0),
|
fInitFormat(NULL),
|
||||||
fInitInfo(0),
|
fInitInfo(NULL),
|
||||||
fInitInfoSize(0),
|
fInitInfoSize(0)
|
||||||
fInitMCI(new media_codec_info(*mci))
|
|
||||||
{
|
{
|
||||||
|
SetTo(mci);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* virtual */
|
/* virtual */
|
||||||
BMediaDecoder::~BMediaDecoder()
|
BMediaDecoder::~BMediaDecoder()
|
||||||
{
|
{
|
||||||
delete fDecoder;
|
delete fDecoder;
|
||||||
delete fInitFormat;
|
delete fInitFormat;
|
||||||
delete fInitInfo;
|
delete fInitInfo;
|
||||||
delete fInitMCI;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMediaDecoder::InitCheck() const
|
BMediaDecoder::InitCheck() const
|
||||||
{
|
{
|
||||||
if (fNeedsInit)
|
if (fNeedsInit) {
|
||||||
const_cast<BMediaDecoder *>(this)->DoLateInit();
|
// casting away const: yes this solution does suck
|
||||||
|
// it is necessary while decoders need to call GetNextChunk in Setup
|
||||||
|
const_cast<BMediaDecoder*>(this)->SetTo(fInitFormat, fInitInfo, fInitInfoSize);
|
||||||
|
}
|
||||||
return fInitStatus;
|
return fInitStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,10 +117,6 @@ BMediaDecoder::SetTo(const media_format *in_format,
|
|||||||
const void *info,
|
const void *info,
|
||||||
size_t info_size)
|
size_t info_size)
|
||||||
{
|
{
|
||||||
// ToDo: should be moved into the PluginManager, or better yet, use
|
|
||||||
// the existing function _CreateDecoder()
|
|
||||||
|
|
||||||
status_t result;
|
|
||||||
fNeedsInit = false;
|
fNeedsInit = false;
|
||||||
fInitStatus = B_NO_INIT;
|
fInitStatus = B_NO_INIT;
|
||||||
delete fDecoder;
|
delete fDecoder;
|
||||||
@@ -131,18 +130,17 @@ BMediaDecoder::SetTo(const media_format *in_format,
|
|||||||
}
|
}
|
||||||
fDecoder = decoder;
|
fDecoder = decoder;
|
||||||
// fDecoderID = mci->sub_id;
|
// fDecoderID = mci->sub_id;
|
||||||
result = SetInputFormat(in_format,info,info_size);
|
if ((fInitStatus = AttachToDecoder()) != B_OK) {
|
||||||
if (result != B_OK) {
|
return fInitStatus;
|
||||||
return fInitStatus = result;
|
|
||||||
}
|
}
|
||||||
return fInitStatus = B_OK;
|
fInitStatus = SetInputFormat(in_format,info,info_size);
|
||||||
|
return fInitStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ask the server for the id'th plugin
|
// ask the server for the id'th plugin
|
||||||
static DecoderPlugin *
|
static DecoderPlugin *
|
||||||
GetDecoderPlugin(int32 id)
|
GetDecoderPlugin(int32 id)
|
||||||
{
|
{
|
||||||
// ToDo: should be moved into the PluginManager
|
|
||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -156,7 +154,6 @@ GetDecoderPlugin(int32 id)
|
|||||||
status_t
|
status_t
|
||||||
BMediaDecoder::SetTo(const media_codec_info *mci)
|
BMediaDecoder::SetTo(const media_codec_info *mci)
|
||||||
{
|
{
|
||||||
fNeedsInit = false;
|
|
||||||
fInitStatus = B_NO_INIT;
|
fInitStatus = B_NO_INIT;
|
||||||
delete fDecoder;
|
delete fDecoder;
|
||||||
DecoderPlugin * plugin = GetDecoderPlugin(mci->id);
|
DecoderPlugin * plugin = GetDecoderPlugin(mci->id);
|
||||||
@@ -167,10 +164,12 @@ BMediaDecoder::SetTo(const media_codec_info *mci)
|
|||||||
if (decoder == NULL) {
|
if (decoder == NULL) {
|
||||||
return fInitStatus = B_ERROR;
|
return fInitStatus = B_ERROR;
|
||||||
}
|
}
|
||||||
// ToDo: what's the sub_id used for? - asks Axel.
|
|
||||||
fDecoder = decoder;
|
fDecoder = decoder;
|
||||||
fDecoderID = mci->sub_id;
|
fDecoderID = mci->sub_id;
|
||||||
return fInitStatus = B_OK;
|
if ((fInitStatus = AttachToDecoder()) != B_OK) {
|
||||||
|
return fInitStatus;
|
||||||
|
}
|
||||||
|
return fInitStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -187,11 +186,9 @@ BMediaDecoder::SetInputFormat(const media_format *in_format,
|
|||||||
const void *in_info,
|
const void *in_info,
|
||||||
size_t in_size)
|
size_t in_size)
|
||||||
{
|
{
|
||||||
if (fNeedsInit)
|
if (InitCheck() != B_OK) {
|
||||||
DoLateInit();
|
|
||||||
if (fInitStatus != B_OK)
|
|
||||||
return fInitStatus;
|
return fInitStatus;
|
||||||
|
}
|
||||||
printf("DISCARDING FORMAT %s\n",__PRETTY_FUNCTION__);
|
printf("DISCARDING FORMAT %s\n",__PRETTY_FUNCTION__);
|
||||||
media_format format = *in_format;
|
media_format format = *in_format;
|
||||||
return fDecoder->Setup(&format,in_info,in_size);
|
return fDecoder->Setup(&format,in_info,in_size);
|
||||||
@@ -207,11 +204,9 @@ BMediaDecoder::SetInputFormat(const media_format *in_format,
|
|||||||
status_t
|
status_t
|
||||||
BMediaDecoder::SetOutputFormat(media_format *output_format)
|
BMediaDecoder::SetOutputFormat(media_format *output_format)
|
||||||
{
|
{
|
||||||
if (fNeedsInit)
|
if (InitCheck() != B_OK) {
|
||||||
DoLateInit();
|
|
||||||
if (fInitStatus != B_OK)
|
|
||||||
return fInitStatus;
|
return fInitStatus;
|
||||||
|
}
|
||||||
return fDecoder->NegotiateOutputFormat(output_format);
|
return fDecoder->NegotiateOutputFormat(output_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,32 +230,22 @@ BMediaDecoder::Decode(void *out_buffer,
|
|||||||
media_header *out_mh,
|
media_header *out_mh,
|
||||||
media_decode_info *info)
|
media_decode_info *info)
|
||||||
{
|
{
|
||||||
if (fNeedsInit)
|
if (InitCheck() != B_OK) {
|
||||||
DoLateInit();
|
|
||||||
if (fInitStatus != B_OK)
|
|
||||||
return fInitStatus;
|
return fInitStatus;
|
||||||
|
}
|
||||||
return fDecoder->Decode(out_buffer,out_frameCount,out_mh,info);
|
return fDecoder->Decode(out_buffer,out_frameCount,out_mh,info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMediaDecoder::GetDecoderInfo(media_codec_info *outInfo) const
|
BMediaDecoder::GetDecoderInfo(media_codec_info *out_info) const
|
||||||
{
|
{
|
||||||
if (fNeedsInit)
|
if (InitCheck() != B_OK) {
|
||||||
const_cast<BMediaDecoder *>(this)->DoLateInit();
|
|
||||||
if (fInitStatus != B_OK)
|
|
||||||
return fInitStatus;
|
return fInitStatus;
|
||||||
|
|
||||||
if (fDecoder != NULL)
|
|
||||||
fDecoder->GetCodecInfo(outInfo);
|
|
||||||
else {
|
|
||||||
strcpy(outInfo->short_name, "unknown");
|
|
||||||
strcpy(outInfo->pretty_name, "unknown");
|
|
||||||
}
|
}
|
||||||
|
fDecoder->GetCodecInfo(out_info);
|
||||||
outInfo->id = fDecoderPluginID;
|
out_info->id = fDecoderPluginID;
|
||||||
outInfo->sub_id = fDecoderID;
|
out_info->sub_id = fDecoderID;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,20 +265,28 @@ BMediaDecoder::BMediaDecoder(const BMediaDecoder &);
|
|||||||
BMediaDecoder::BMediaDecoder & operator=(const BMediaDecoder &);
|
BMediaDecoder::BMediaDecoder & operator=(const BMediaDecoder &);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
status_t
|
||||||
BMediaDecoder::DoLateInit()
|
BMediaDecoder::AttachToDecoder()
|
||||||
{
|
{
|
||||||
if (fInitFormat) {
|
class MediaDecoderChunkProvider : public ChunkProvider {
|
||||||
SetTo(fInitFormat, fInitInfo, fInitInfoSize);
|
private:
|
||||||
delete fInitFormat;
|
BMediaDecoder * fDecoder;
|
||||||
delete fInitInfo;
|
public:
|
||||||
fInitFormat = 0;
|
MediaDecoderChunkProvider(BMediaDecoder * decoder) {
|
||||||
fInitInfo = 0;
|
fDecoder = decoder;
|
||||||
} else if (fInitMCI) {
|
}
|
||||||
SetTo(fInitMCI);
|
virtual status_t GetNextChunk(void **chunkBuffer, int32 *chunkSize,
|
||||||
delete fInitMCI;
|
media_header *mediaHeader) {
|
||||||
fInitMCI = 0;
|
const void ** buffer = const_cast<const void**>(chunkBuffer);
|
||||||
|
size_t * size = reinterpret_cast<size_t*>(chunkSize);
|
||||||
|
return fDecoder->GetNextChunk(buffer,size,mediaHeader);
|
||||||
|
}
|
||||||
|
} * provider = new MediaDecoderChunkProvider(this);
|
||||||
|
if (provider == NULL) {
|
||||||
|
return B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
fDecoder->Setup(provider);
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -324,6 +317,7 @@ BMediaBufferDecoder::BMediaBufferDecoder()
|
|||||||
buffer_size = 0;
|
buffer_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMediaBufferDecoder::BMediaBufferDecoder(const media_format *in_format,
|
BMediaBufferDecoder::BMediaBufferDecoder(const media_format *in_format,
|
||||||
const void *info,
|
const void *info,
|
||||||
size_t info_size)
|
size_t info_size)
|
||||||
@@ -332,12 +326,14 @@ BMediaBufferDecoder::BMediaBufferDecoder(const media_format *in_format,
|
|||||||
buffer_size = 0;
|
buffer_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMediaBufferDecoder::BMediaBufferDecoder(const media_codec_info *mci)
|
BMediaBufferDecoder::BMediaBufferDecoder(const media_codec_info *mci)
|
||||||
: BMediaDecoder(mci)
|
: BMediaDecoder(mci)
|
||||||
{
|
{
|
||||||
buffer_size = 0;
|
buffer_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMediaBufferDecoder::DecodeBuffer(const void *input_buffer,
|
BMediaBufferDecoder::DecodeBuffer(const void *input_buffer,
|
||||||
size_t input_size,
|
size_t input_size,
|
||||||
@@ -351,18 +347,19 @@ BMediaBufferDecoder::DecodeBuffer(const void *input_buffer,
|
|||||||
return Decode(out_buffer,out_frameCount,out_mh,info);
|
return Decode(out_buffer,out_frameCount,out_mh,info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************
|
/*************************************************************
|
||||||
* protected BMediaBufferDecoder
|
* protected BMediaBufferDecoder
|
||||||
*************************************************************/
|
*************************************************************/
|
||||||
|
|
||||||
/* virtual */
|
/* virtual */
|
||||||
status_t BMediaBufferDecoder::GetNextChunk(const void **chunkData,
|
status_t
|
||||||
size_t *chunkLen,
|
BMediaBufferDecoder::GetNextChunk(const void **chunkData, size_t *chunkLen,
|
||||||
media_header *mh)
|
media_header *mh)
|
||||||
{
|
{
|
||||||
if (!buffer_size)
|
if (!buffer_size) {
|
||||||
return B_LAST_BUFFER_ERROR;
|
return B_LAST_BUFFER_ERROR;
|
||||||
|
}
|
||||||
*chunkData = buffer;
|
*chunkData = buffer;
|
||||||
*chunkLen = buffer_size;
|
*chunkLen = buffer_size;
|
||||||
buffer_size = 0;
|
buffer_size = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user