Accidently used its own PluginManager object instead of the global one.

Implemented BMediaDecoder::GetDecoderInfo().
Changed the documentation style to something doxygen can read.
Added some ToDo comments.
Some minor style changes.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6249 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2004-01-23 09:15:47 +00:00
parent a0a20160cd
commit 001103576a
+61 -38
View File
@@ -9,7 +9,7 @@
#include "DataExchange.h" #include "DataExchange.h"
#include "debug.h" #include "debug.h"
static PluginManager _plugin_manager; extern PluginManager _plugin_manager;
/************************************************************* /*************************************************************
* public BMediaDecoder * public BMediaDecoder
@@ -82,7 +82,9 @@ BMediaDecoder::InitCheck() const
return fInitStatus; return fInitStatus;
} }
static DecoderPlugin * GetDecoderPlugin(const media_format * format)
static DecoderPlugin *
GetDecoderPlugin(const media_format * format)
{ {
server_get_decoder_for_format_request request; server_get_decoder_for_format_request request;
server_get_decoder_for_format_reply reply; server_get_decoder_for_format_reply reply;
@@ -112,6 +114,9 @@ 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; status_t result;
fNeedsInit = false; fNeedsInit = false;
fInitStatus = B_NO_INIT; fInitStatus = B_NO_INIT;
@@ -134,8 +139,10 @@ BMediaDecoder::SetTo(const media_format *in_format,
} }
// ask the server for the id'th plugin // ask the server for the id'th plugin
static DecoderPlugin * GetDecoderPlugin(int32 id) static DecoderPlugin *
GetDecoderPlugin(int32 id)
{ {
// ToDo: should be moved into the PluginManager
if (id == 0) { if (id == 0) {
return NULL; return NULL;
} }
@@ -160,17 +167,21 @@ 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; return fInitStatus = B_OK;
} }
/* SetInputFormat() sets the input data format to in_format.
Unlike SetTo(), the SetInputFormat() function does not /** SetInputFormat() sets the input data format to in_format.
select a codec, so the currently-selected codec will * Unlike SetTo(), the SetInputFormat() function does not
continue to be used. You should only use SetInputFormat() * select a codec, so the currently-selected codec will
to refine the format settings if it will not require the * continue to be used. You should only use SetInputFormat()
use of a different decoder. */ * to refine the format settings if it will not require the
* use of a different decoder.
*/
status_t status_t
BMediaDecoder::SetInputFormat(const media_format *in_format, BMediaDecoder::SetInputFormat(const media_format *in_format,
const void *in_info, const void *in_info,
@@ -178,40 +189,46 @@ BMediaDecoder::SetInputFormat(const media_format *in_format,
{ {
if (fNeedsInit) if (fNeedsInit)
DoLateInit(); DoLateInit();
if (fInitStatus != B_OK) { 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);
} }
/* SetOutputFormat() sets the format the decoder should output.
On return, the output_format is changed to match the actual /** SetOutputFormat() sets the format the decoder should output.
format that will be output; this can be different if you * On return, the output_format is changed to match the actual
specified any wildcards. */ * format that will be output; this can be different if you
* specified any wildcards.
*/
status_t status_t
BMediaDecoder::SetOutputFormat(media_format *output_format) BMediaDecoder::SetOutputFormat(media_format *output_format)
{ {
if (fNeedsInit) if (fNeedsInit)
DoLateInit(); DoLateInit();
if (fInitStatus != B_OK) { if (fInitStatus != B_OK)
return fInitStatus; return fInitStatus;
}
return fDecoder->NegotiateOutputFormat(output_format); return fDecoder->NegotiateOutputFormat(output_format);
} }
/* Decodes a chunk of media data into the output buffer specified
by out_buffer. On return, out_frameCount is set to indicate how
many frames of data were decoded, and out_mh is the header for
the decoded buffer. The media_decode_info structure info is used
on input to specify decoding parameters.
The amount of data decoded is part of the format determined by /** Decodes a chunk of media data into the output buffer specified
SetTo() or SetInputFormat(). For audio, it's the buffer_size. * by out_buffer. On return, out_frameCount is set to indicate how
For video, it's one frame, which is height*row_bytes. The data * many frames of data were decoded, and out_mh is the header for
to be decoded will be fetched from the source by the decoder * the decoded buffer. The media_decode_info structure info is used
add-on calling the derived class' GetNextChunk() function. */ * on input to specify decoding parameters.
*
* The amount of data decoded is part of the format determined by
* SetTo() or SetInputFormat(). For audio, it's the buffer_size.
* For video, it's one frame, which is height*row_bytes. The data
* to be decoded will be fetched from the source by the decoder
* add-on calling the derived class' GetNextChunk() function.
*/
status_t status_t
BMediaDecoder::Decode(void *out_buffer, BMediaDecoder::Decode(void *out_buffer,
int64 *out_frameCount, int64 *out_frameCount,
@@ -220,23 +237,30 @@ BMediaDecoder::Decode(void *out_buffer,
{ {
if (fNeedsInit) if (fNeedsInit)
DoLateInit(); DoLateInit();
if (fInitStatus != B_OK) { 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 *out_info) const BMediaDecoder::GetDecoderInfo(media_codec_info *outInfo) const
{ {
if (fNeedsInit) if (fNeedsInit)
const_cast<BMediaDecoder *>(this)->DoLateInit(); const_cast<BMediaDecoder *>(this)->DoLateInit();
if (fInitStatus != B_OK) { 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");
} }
UNIMPLEMENTED();
out_info->id = fDecoderPluginID; outInfo->id = fDecoderPluginID;
out_info->sub_id = fDecoderID; outInfo->sub_id = fDecoderID;
return B_OK; return B_OK;
} }
@@ -265,8 +289,7 @@ BMediaDecoder::DoLateInit()
delete fInitInfo; delete fInitInfo;
fInitFormat = 0; fInitFormat = 0;
fInitInfo = 0; fInitInfo = 0;
} } else if (fInitMCI) {
else if (fInitMCI) {
SetTo(fInitMCI); SetTo(fInitMCI);
delete fInitMCI; delete fInitMCI;
fInitMCI = 0; fInitMCI = 0;
@@ -337,9 +360,9 @@ status_t BMediaBufferDecoder::GetNextChunk(const void **chunkData,
size_t *chunkLen, 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;