BCodecRoster: Add useful functionality from MediaFormats

This commit is contained in:
Barrett17 2018-11-27 11:33:11 +01:00
parent d33bd9ec7b
commit fe9542fdb5
4 changed files with 70 additions and 7 deletions

View File

@ -30,9 +30,6 @@ public:
static status_t InstantiateDecoder(BDecoder** decoder,
const media_codec_info& mci);
static void ReleaseDecoder(BDecoder* decoder);
static status_t GetDecoderInfo(BDecoder* decoder,
media_codec_info* info);
static status_t InstantiateWriter(BWriter** writer,
const media_file_format& mff,
@ -50,6 +47,32 @@ public:
BUrl url, BDataIO** source);
static void ReleaseStreamer(BStreamer* streamer);
static status_t GetDecoderInfo(BDecoder* decoder,
media_codec_info* info);
// The following API is from MediaFormats. The idea is to put
// there only the APIs really used in the BeOS/Haiku ecosystem
// so that we can discard unuseful code, thus reducing complexity.
// To choose the API I did a search among the Haiku codebase and
// programs for which we have the source available.
// TODO: At some point move all implementations here
static status_t MakeFormatFor(
const media_format_description* descriptions,
int32 descriptionCount,
media_format& format, uint32 flags,
void* _reserved);
// TODO: media_format_family: really?
static status_t GetCodecInfo(media_codec_info* _codecInfo,
media_format_family* _formatFamily,
media_format* _inputFormat,
media_format* _outputFormat, int32 cookie);
//! Use this function to iterate through available file format writers.
static status_t GetNextFileFormat(int32* cookie, media_file_format* mff);
/*! \brief Use this to iterate through the available encoders for a given file
format.
\param cookie A pointer to a preallocated cookie, which you need

View File

@ -7,10 +7,9 @@
#include <MediaIO.h>
#include <MediaPlugin.h>
#include <Url.h>
#include "MediaPlugin.h"
namespace BCodecKit {

View File

@ -7,6 +7,8 @@
#include <MediaFormats.h>
#include "AddOnManager.h"
#include "FormatManager.h"
#include "PluginManager.h"
@ -136,4 +138,41 @@ BCodecRoster::GetNextEncoder(int32* cookie, media_codec_info* _codecInfo)
}
status_t
BCodecRoster::GetNextFileFormat(int32* cookie, media_file_format* mff)
{
if (cookie == NULL || mff == NULL)
return B_BAD_VALUE;
status_t ret = BPrivate::AddOnManager::GetInstance()->GetFileFormat(mff,
*cookie);
if (ret != B_OK)
return ret;
*cookie = *cookie + 1;
return B_OK;
}
status_t
BCodecRoster::GetCodecInfo(media_codec_info* codecInfo,
media_format_family* formatFamily, media_format* inputFormat,
media_format* outputFormat, int32 cookie)
{
return BPrivate::AddOnManager::GetInstance()->GetCodecInfo(codecInfo,
formatFamily, inputFormat, outputFormat, cookie);
}
status_t
BCodecRoster::MakeFormatFor(const media_format_description* descriptions,
int32 descriptionCount, media_format& format, uint32 flags,
void* _reserved)
{
return FormatManager::GetInstance()->MakeFormatFor(descriptions,
descriptionCount, format, flags, _reserved);
}
} // namespace BCodecKit

View File

@ -21,12 +21,14 @@
#include "MediaDebug.h"
// Need to stay outside namespace
BCodecKit::BPrivate::PluginManager gPluginManager;
namespace BCodecKit {
namespace BPrivate {
PluginManager gPluginManager;
#define BLOCK_SIZE 4096
#define MAX_STREAMERS 40