Audacity 3.2.0
FFmpegAPIResolver.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 FFmpegAPIResolver.h
6
7 Dmitry Vedenko
8
9**********************************************************************/
10#pragma once
11
12#include <memory>
13#include <vector>
14#include <map>
15
16#include "FFmpegTypes.h"
17#include "AVCodecID.h"
18
19struct FFmpegFunctions;
20class FFmpegLog;
21
23class AVCodecWrapper;
24class AVPacketWrapper;
26
28{
31};
32
33struct AVCodecFactories final
34{
35 std::unique_ptr<AVCodecContextWrapper> (*CreateAVCodecContextWrapper)(const FFmpegFunctions&, AVCodecContext*) = nullptr;
36 std::unique_ptr<AVCodecContextWrapper> (*CreateAVCodecContextWrapperFromCodec)(const FFmpegFunctions&, std::unique_ptr<AVCodecWrapper>) = nullptr;
37 std::unique_ptr<AVCodecWrapper> (*CreateAVCodecWrapper) (const AVCodec*) = nullptr;
38
40 std::unique_ptr<AVPacketWrapper> (*CreateAVPacketWrapper) (const FFmpegFunctions&) = nullptr;
41};
42
47class AVStreamWrapper;
48
50{
51 std::unique_ptr<AVFormatContextWrapper> (*CreateAVFormatContextWrapper) (const FFmpegFunctions&) = nullptr;
52 std::unique_ptr<AVInputFormatWrapper> (*CreateAVInputFormatWrapper) (AVInputFormat*) = nullptr;
53 std::unique_ptr<AVIOContextWrapper> (*CreateAVIOContextWrapper) (const FFmpegFunctions&) = nullptr;
54 std::unique_ptr<AVOutputFormatWrapper> (*CreateAVOutputFormatWrapper) (const AVOutputFormat*) = nullptr;
55 std::unique_ptr<AVStreamWrapper> (*CreateAVStreamWrapper) (const FFmpegFunctions&, AVStream*, bool) = nullptr;
56};
57
58class AVFrameWrapper;
59
60struct AVUtilFactories final
61{
63 std::unique_ptr<AVFrameWrapper> (*CreateAVFrameWrapper)(const FFmpegFunctions&) = nullptr;
64 std::unique_ptr<FFmpegLog> (*CreateLogCallbackSetter)(const FFmpegFunctions&) = nullptr;
65
66 std::unique_ptr<AVChannelLayoutWrapper> (*CreateDefaultChannelLayout)(const FFmpegFunctions&, int channelsCount) = nullptr;
67 std::unique_ptr<AVChannelLayoutWrapper> (*CreateLegacyChannelLayout)(const FFmpegFunctions&, uint64_t layout, int channelsCount) = nullptr;
68 std::unique_ptr<AVChannelLayoutWrapper> (*CreateAVChannelLayout)(const FFmpegFunctions&, const AVChannelLayout* layout) = nullptr;
69};
70
72{
73 FFmpegAPIResolver() = default;
74
75public:
76 static FFmpegAPIResolver& Get();
77
78 bool GetAVCodecIDResolver(int avCodecVersion, AVCodecIDResolver& resolver) const;
79 bool GetAVCodecFactories(int avCodecVersion, AVCodecFactories& factories) const;
80 bool GetAVFormatFactories(int avFormatVersion, AVFormatFactories& factories) const;
81 bool GetAVUtilFactories(int avUtilVersion, AVUtilFactories& factories) const;
82
83 void AddAVCodecIDResolver(int avCodecVersion, const AVCodecIDResolver& resolver);
84 void AddAVCodecFactories(int avCodecVersion, const AVCodecFactories& factories);
85 void AddAVFormatFactories(int avFormatVersion, const AVFormatFactories& factories);
86 void AddAVUtilFactories(int avUtilVersion, const AVUtilFactories& factories);
87
90 std::vector<int> GetSuportedAVFormatVersions() const;
91
92private:
93 std::map<int, AVCodecIDResolver> mAVCodecIDResolvers;
94 std::map<int, AVCodecFactories> mAVCodecFactories;
95 std::map<int, AVFormatFactories> mAVFormatFactories;
96 std::map<int, AVUtilFactories> mAVUtilFactories;
97};
int AVCodecIDFwd
Definition: AVCodecID.h:407
void AddAVCodecIDResolver(int avCodecVersion, const AVCodecIDResolver &resolver)
void AddAVFormatFactories(int avFormatVersion, const AVFormatFactories &factories)
bool GetAVCodecFactories(int avCodecVersion, AVCodecFactories &factories) const
bool GetAVFormatFactories(int avFormatVersion, AVFormatFactories &factories) const
bool GetAVUtilFactories(int avUtilVersion, AVUtilFactories &factories) const
std::vector< int > GetSuportedAVFormatVersions() const
std::map< int, AVUtilFactories > mAVUtilFactories
std::map< int, AVCodecFactories > mAVCodecFactories
FFmpegAPIResolver()=default
void AddAVCodecFactories(int avCodecVersion, const AVCodecFactories &factories)
bool GetAVCodecIDResolver(int avCodecVersion, AVCodecIDResolver &resolver) const
void AddAVUtilFactories(int avUtilVersion, const AVUtilFactories &factories)
static FFmpegAPIResolver & Get()
std::map< int, AVFormatFactories > mAVFormatFactories
std::map< int, AVCodecIDResolver > mAVCodecIDResolvers
std::unique_ptr< AVCodecWrapper >(* CreateAVCodecWrapper)(const AVCodec *)
std::unique_ptr< AVPacketWrapper >(* CreateAVPacketWrapper)(const FFmpegFunctions &)
std::unique_ptr< AVCodecContextWrapper >(* CreateAVCodecContextWrapper)(const FFmpegFunctions &, AVCodecContext *)
std::unique_ptr< AVCodecContextWrapper >(* CreateAVCodecContextWrapperFromCodec)(const FFmpegFunctions &, std::unique_ptr< AVCodecWrapper >)
AudacityAVCodecID(* GetAudacityCodecID)(AVCodecIDFwd)
AVCodecIDFwd(* GetAVCodecID)(AudacityAVCodecID)
std::unique_ptr< AVFormatContextWrapper >(* CreateAVFormatContextWrapper)(const FFmpegFunctions &)
std::unique_ptr< AVIOContextWrapper >(* CreateAVIOContextWrapper)(const FFmpegFunctions &)
std::unique_ptr< AVInputFormatWrapper >(* CreateAVInputFormatWrapper)(AVInputFormat *)
std::unique_ptr< AVStreamWrapper >(* CreateAVStreamWrapper)(const FFmpegFunctions &, AVStream *, bool)
std::unique_ptr< AVOutputFormatWrapper >(* CreateAVOutputFormatWrapper)(const AVOutputFormat *)
std::unique_ptr< AVFrameWrapper >(* CreateAVFrameWrapper)(const FFmpegFunctions &)
std::unique_ptr< AVChannelLayoutWrapper >(* CreateLegacyChannelLayout)(const FFmpegFunctions &, uint64_t layout, int channelsCount)
std::unique_ptr< AVChannelLayoutWrapper >(* CreateAVChannelLayout)(const FFmpegFunctions &, const AVChannelLayout *layout)
std::unique_ptr< AVChannelLayoutWrapper >(* CreateDefaultChannelLayout)(const FFmpegFunctions &, int channelsCount)
std::unique_ptr< FFmpegLog >(* CreateLogCallbackSetter)(const FFmpegFunctions &)