Debian Codegraph @

xbmc/cores/FFmpeg.h

raw ◀ ▶
Source reconstructed at patch state 1 of 2 — not the installed (fully patched) source.
2 Debian patches touch this file
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9 #pragma once
10
11 #include "ServiceBroker.h"
12 #include "utils/StringUtils.h"
13
14 extern "C"
15 {
16 #include <libavcodec/avcodec.h>
17 #include <libavfilter/avfilter.h>
18 #include <libavformat/avformat.h>
19 #include <libavutil/avutil.h>
20 #include <libavutil/ffversion.h>
21 #include <libavutil/log.h>
22 }
23
24 #include <tuple>
25
26 namespace FFMPEG_HELP_TOOLS
27 {
28
29 struct FFMpegException : public std::exception
30 {
31 std::string s;
32 template<typename... Args>
33 FFMpegException(const std::string& fmt, Args&&... args)
34 : s(StringUtils::Format(fmt, std::forward<Args>(args)...))
35 {
36 }
37 const char* what() const noexcept override { return s.c_str(); }
38 };
39
40 std::string FFMpegErrorToString(int err);
41
42 } // namespace FFMPEG_HELP_TOOLS
43
44 // callback used for logging
45 void ff_avutil_log(void* ptr, int level, const char* format, va_list va);
46 void ff_flush_avutil_log_buffers(void);
47
48 class CFFmpegLog
49 {
50 public:
51 static void SetLogLevel(int level);
52 static int GetLogLevel();
53 static void ClearLogLevel();
54 int level;
55 };
56
57 class FFmpegExtraData
58 {
59 public:
60 FFmpegExtraData() = default;
61 explicit FFmpegExtraData(size_t size);
62 FFmpegExtraData(const uint8_t* data, size_t size);
63 FFmpegExtraData(const FFmpegExtraData& other);
64 FFmpegExtraData(FFmpegExtraData&& other) noexcept;
65
66 ~FFmpegExtraData();
67
68 FFmpegExtraData& operator=(const FFmpegExtraData& other);
69 FFmpegExtraData& operator=(FFmpegExtraData&& other) noexcept;
70
71 bool operator==(const FFmpegExtraData& other) const;
72 bool operator!=(const FFmpegExtraData& other) const;
73
74 operator bool() const { return m_data != nullptr && m_size != 0; }
75 uint8_t* GetData() { return m_data; }
76 const uint8_t* GetData() const { return m_data; }
77 size_t GetSize() const { return m_size; }
78 /*!
79 * \brief Take ownership over the extra data buffer
80 *
81 * It's in the responsibility of the caller to free the buffer with av_free. After the call
82 * FFmpegExtraData is empty.
83 *
84 * \return The extra data buffer or nullptr if FFmpegExtraData is empty.
85 */
86 uint8_t* TakeData();
87
88 private:
89 uint8_t* m_data{nullptr};
90 size_t m_size{};
91 };
92
93 FFmpegExtraData GetPacketExtradata(const AVPacket* pkt, const AVCodecParameters* codecPar);