Audacity 3.2.0
AVCodecContextWrapper.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 AVCodecContextWrapper.h
6
7 Dmitry Vedenko
8
9**********************************************************************/
10
11#pragma once
12
13#include <memory>
14#include <vector>
15#include <cstdint>
16
17#include "FFmpegTypes.h"
18
19#include "SampleFormat.h"
20
21struct FFmpegFunctions;
23
24class AVCodecWrapper;
26class AVFrameWrapper;
27class AVPacketWrapper;
29
30class FFMPEG_SUPPORT_API AVCodecContextWrapper
31{
32public:
35
38
39 AVCodecContextWrapper(const FFmpegFunctions& ffmpeg, std::unique_ptr<AVCodecWrapper> codec) noexcept;
40 AVCodecContextWrapper(const FFmpegFunctions& ffmpeg, AVCodecContext* wrapped) noexcept;
41
42 AVCodecContext* GetWrappedValue() noexcept;
43 const AVCodecContext* GetWrappedValue() const noexcept;
44
45 virtual ~AVCodecContextWrapper();
46
47 std::vector<uint8_t> DecodeAudioPacket(const AVPacketWrapper* packet);
48
49 virtual sampleFormat GetPreferredAudacitySampleFormat() const noexcept = 0;
50
51 virtual std::vector<int16_t> DecodeAudioPacketInt16(const AVPacketWrapper* packet) = 0;
52 virtual std::vector<float> DecodeAudioPacketFloat(const AVPacketWrapper* packet) = 0;
53
54 virtual int GetBitRate() const noexcept = 0;
55 virtual void SetBitRate(int value) noexcept = 0;
56
57 virtual const AVChannelLayoutWrapper* GetChannelLayout() const noexcept = 0;
58 virtual void SetChannelLayout(const AVChannelLayoutWrapper* value) noexcept = 0;
59
60 virtual int GetChannels() const noexcept = 0;
61
62 virtual const AVCodecWrapper* GetCodec() const noexcept = 0;
63
64 virtual AVCodecIDFwd GetCodecId() const noexcept = 0;
65
66 void SetCodecTagFourCC(const char* fourCC) noexcept;
67
68 virtual void SetCodecTag(unsigned int tag) noexcept = 0;
69 virtual unsigned int GetCodecTag() const noexcept = 0;
70
71 virtual AVMediaTypeFwd GetCodecType() const noexcept = 0;
72
73 virtual int GetCompressionLevel() const noexcept = 0;
74 virtual void SetCompressionLevel(int value) noexcept = 0;
75
76 virtual int GetCutoff() const noexcept = 0;
77 virtual void SetCutoff(int value) noexcept = 0;
78
79 virtual int GetFlags() const noexcept = 0;
80 virtual void SetFlags(int value) noexcept = 0;
81
82 virtual int GetFlags2() const noexcept = 0;
83 virtual void SetFlags2(int value) noexcept = 0;
84
85 virtual int GetFrameNumber() const noexcept = 0;
86
87 virtual int GetFrameSize() const noexcept = 0;
88 virtual void SetFrameSize(int value) noexcept = 0;
89
90 virtual int GetGlobalQuality() const noexcept = 0;
91 virtual void SetGlobalQuality(int value) noexcept = 0;
92
93 virtual int GetProfile() const noexcept = 0;
94 virtual void SetProfile(int value) noexcept = 0;
95
96 virtual AVSampleFormatFwd GetSampleFmt() const noexcept = 0;
97 virtual void SetSampleFmt(AVSampleFormatFwd value) noexcept = 0;
98
99 virtual int GetSampleRate() const noexcept = 0;
100 virtual void SetSampleRate(int value) noexcept = 0;
101
102 virtual int GetStrictStdCompliance() const noexcept = 0;
103 virtual void SetStrictStdCompliance(int value) noexcept = 0;
104
105 virtual struct AudacityAVRational GetTimeBase() const noexcept = 0;
106 virtual void SetTimeBase(struct AudacityAVRational value) noexcept = 0;
107
115 virtual int Open(
116 const AVCodecWrapper *codec, AVDictionaryWrapper *options = nullptr) = 0;
117
118private:
119 void ConsumeFrame(std::vector<uint8_t>& data, AVFrameWrapper& frame);
120
121protected:
122 const FFmpegFunctions& mFFmpeg;
123 AVCodecContext* mAVCodecContext { nullptr };
124 // May be created on demand to satisfy GetCodec():
125 mutable std::unique_ptr<AVCodecWrapper> mAVCodec;
126
127 bool mIsOwned { false };
128};
int AVCodecIDFwd
Definition: AVCodecID.h:407
int AVMediaTypeFwd
Definition: FFmpegTypes.h:130
int AVSampleFormatFwd
Definition: FFmpegTypes.h:132
sampleFormat
The ordering of these values with operator < agrees with the order of increasing bit width.
Definition: SampleFormat.h:30
std::unique_ptr< AVCodecWrapper > mAVCodec
AVCodecContextWrapper & operator=(AVCodecContextWrapper &&)=delete
AVCodecContextWrapper & operator=(AVCodecContextWrapper &)=delete
AVCodecContextWrapper(AVCodecContextWrapper &&)=delete
AVCodecContextWrapper(const AVCodecContextWrapper &)=delete
STL namespace.