Audacity 3.2.0
AVDictionaryWrapper.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 AVDictionaryWrapper.cpp
6
7 Dmitry Vedenko
8
9**********************************************************************/
10
11#include "AVDictionaryWrapper.h"
12
13#include "FFmpegFunctions.h"
14#include "FFmpegTypes.h"
15
16#include <utility>
17
19 const FFmpegFunctions& ffmpeg) noexcept
20 : mFFmpeg(ffmpeg)
21{
22}
23
25 const FFmpegFunctions& ffmpeg, AVDictionary* rhs) noexcept
26 : mFFmpeg(ffmpeg)
27{
28 if (rhs != nullptr)
29 mFFmpeg.av_dict_copy(&mAVDictionary, rhs, 0);
30}
31
33 const AVDictionaryWrapper& rhs) noexcept
34 : AVDictionaryWrapper(rhs.mFFmpeg, rhs.mAVDictionary)
35{
36}
37
39 AVDictionaryWrapper&& rhs) noexcept
40 : mFFmpeg(rhs.mFFmpeg)
41{
42 *this = std::move(rhs);
43}
44
47{
48 assert(&mFFmpeg == &rhs.mFFmpeg);
49
50 if (rhs.mAVDictionary != nullptr)
51 mFFmpeg.av_dict_copy(&mAVDictionary, rhs.mAVDictionary, 0);
52
53 return *this;
54}
55
58{
59 assert(&mFFmpeg == &rhs.mFFmpeg);
60
61 std::swap(mAVDictionary, rhs.mAVDictionary);
62
63 return *this;
64}
65
67{
68 return mAVDictionary;
69}
70
72{
73 return mAVDictionary;
74}
75
77{
79}
80
82 const std::string_view& key, const std::string& value,
83 int flags) noexcept
84{
85 mFFmpeg.av_dict_set(&mAVDictionary, key.data(), value.data(), flags);
86}
87
89 const std::string_view& key, const wxString& value, int flags) noexcept
90{
91 mFFmpeg.av_dict_set(&mAVDictionary, key.data(), value.ToUTF8().data(), flags);
92}
93
95 const std::string_view& key, const char* value, int flags) noexcept
96{
97 mFFmpeg.av_dict_set(
98 &mAVDictionary, key.data(), value, flags);
99}
100
102 const std::string_view& key, const std::string_view& defaultValue,
103 int flags) const
104{
105 if (mAVDictionary == nullptr)
106 return defaultValue;
107
109 mFFmpeg.av_dict_get(mAVDictionary, key.data(), nullptr, flags);
110
111 if (entry != nullptr)
112 return entry->value;
113
114 return defaultValue;
115}
116
118 const std::string_view& key, int flags) const noexcept
119{
120 if (mAVDictionary == nullptr)
121 return false;
122
124 mFFmpeg.av_dict_get(mAVDictionary, key.data(), nullptr, flags);
125
126 return entry != nullptr;
127}
128
130{
131 auto temp = mAVDictionary;
132 mAVDictionary = nullptr;
133
134 return temp;
135}
struct AVDictionary AVDictionary
Definition: FFmpegTypes.h:117
static ProjectFileIORegistry::AttributeWriterEntry entry
static const AudacityProject::AttachedObjects::RegisteredFactory key
const FFmpegFunctions & mFFmpeg
AVDictionaryWrapper & operator=(const AVDictionaryWrapper &rhs) noexcept
bool HasValue(const std::string_view &key, int flags=0) const noexcept
AVDictionaryWrapper(const AVDictionaryWrapper &rhs) noexcept
Unlike the other FFmpeg wrapper classes, this one is copyable.
std::string_view Get(const std::string_view &key, const std::string_view &defaultValue, int flags=0) const
AVDictionary * mAVDictionary
void Set(const std::string_view &key, const std::string &value, int flags=0) noexcept
AVDictionary * Release() noexcept
AVDictionary * GetWrappedValue() noexcept
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:628
void(* av_dict_free)(AVDictionary **m)
AudacityAVDictionaryEntry *(* av_dict_get)(const AVDictionary *m, const char *key, const AudacityAVDictionaryEntry *prev, int flags)
Simply an overlay of AVDictionaryEntry, but we avoid including that type.
Definition: FFmpegTypes.h:143