1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
/**********************************************************************
Audacity: A Digital Audio Editor
AVDictionaryWrapper.h
Dmitry Vedenko
**********************************************************************/
#pragma once
#include <string_view>
#include <string>
#include <wx/string.h>
struct FFmpegFunctions;
typedef struct AVDictionary AVDictionary;
#define DICT_MATCH_CASE 1
#define DICT_IGNORE_SUFFIX 2
class FFMPEG_SUPPORT_API AVDictionaryWrapper
{
public:
//! Unlike the other FFmpeg wrapper classes, this one is copyable.
AVDictionaryWrapper(const AVDictionaryWrapper& rhs) noexcept;
AVDictionaryWrapper(AVDictionaryWrapper&& rhs) noexcept;
// We expect that &mFFmpeg == rhs.mFFmpeg
AVDictionaryWrapper& operator=(const AVDictionaryWrapper& rhs) noexcept;
AVDictionaryWrapper& operator=(AVDictionaryWrapper&& rhs) noexcept;
explicit AVDictionaryWrapper(const FFmpegFunctions& ffmpeg) noexcept;
explicit AVDictionaryWrapper(const FFmpegFunctions& ffmpeg, AVDictionary* rhs) noexcept;
AVDictionary* GetWrappedValue() noexcept;
const AVDictionary* GetWrappedValue() const noexcept;
virtual ~AVDictionaryWrapper();
void Set(const std::string_view& key, const std::string& value, int flags = 0) noexcept;
void Set(const std::string_view& key, const wxString& value, int flags = 0) noexcept;
void Set(const std::string_view& key, const char* value, int flags = 0) noexcept;
template<typename T>
void Set(const std::string_view& key, const T& value, int flags = 0) noexcept
{
Set(key, std::to_string(value), flags);
}
std::string_view Get(const std::string_view& key, const std::string_view& defaultValue, int flags = 0) const;
bool HasValue(const std::string_view& key, int flags = 0) const noexcept;
AVDictionary* Release() noexcept;
protected:
const FFmpegFunctions& mFFmpeg;
AVDictionary* mAVDictionary { nullptr };
};
|