From fe9542fdb54c313ab7959f704897850c3d25de02 Mon Sep 17 00:00:00 2001 From: Barrett17 Date: Tue, 27 Nov 2018 11:33:11 +0100 Subject: [PATCH] BCodecRoster: Add useful functionality from MediaFormats --- headers/os/codec/CodecRoster.h | 29 +++++++++++++++++++++--- headers/os/codec/Streamer.h | 3 +-- src/kits/codec/CodecRoster.cpp | 39 ++++++++++++++++++++++++++++++++ src/kits/codec/PluginManager.cpp | 6 +++-- 4 files changed, 70 insertions(+), 7 deletions(-) diff --git a/headers/os/codec/CodecRoster.h b/headers/os/codec/CodecRoster.h index b7be6c4657..47ea7c175d 100644 --- a/headers/os/codec/CodecRoster.h +++ b/headers/os/codec/CodecRoster.h @@ -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 diff --git a/headers/os/codec/Streamer.h b/headers/os/codec/Streamer.h index 1391b6bf13..4344cd9517 100644 --- a/headers/os/codec/Streamer.h +++ b/headers/os/codec/Streamer.h @@ -7,10 +7,9 @@ #include +#include #include -#include "MediaPlugin.h" - namespace BCodecKit { diff --git a/src/kits/codec/CodecRoster.cpp b/src/kits/codec/CodecRoster.cpp index d56790e60b..db272e8dc0 100644 --- a/src/kits/codec/CodecRoster.cpp +++ b/src/kits/codec/CodecRoster.cpp @@ -7,6 +7,8 @@ #include +#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 diff --git a/src/kits/codec/PluginManager.cpp b/src/kits/codec/PluginManager.cpp index 0ab69d76e9..4414513c53 100644 --- a/src/kits/codec/PluginManager.cpp +++ b/src/kits/codec/PluginManager.cpp @@ -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