MythTV master
mythavbufferref.h
Go to the documentation of this file.
1#ifndef LIBMYTHTV_MYTHAVBUFFERREF_H
2#define LIBMYTHTV_MYTHAVBUFFERREF_H
3
4#include <utility>
5
6// FFmpeg
7extern "C" {
8#include "libavutil/buffer.h"
9}
10
19 public:
23 explicit MythAVBufferRef(const AVBufferRef* buf = nullptr) : m_buffer(ref(buf)) {}
25
26 // Copy constructor
28 // Move constructor
29 MythAVBufferRef(MythAVBufferRef&& other) noexcept : MythAVBufferRef() { swap(*this, other); }
30 // Copy assignment operator
32 {
33 swap(*this, other);
34 return *this;
35 }
36 // Move assignment operator
38 {
39 // release resources held by this, but prevent suicide on self-assignment
40 MythAVBufferRef tmp {std::move(other)};
41 swap(*this, tmp);
42 return *this;
43 }
44
45 friend void swap(MythAVBufferRef& a, MythAVBufferRef& b) noexcept
46 {
47 using std::swap;
48 swap(a.m_buffer, b.m_buffer);
49 }
50
51 bool has_buffer() { return m_buffer != nullptr; }
52
53 const uint8_t* data() { return m_buffer->data; }
54 size_t size() { return m_buffer->size; }
55 private:
56 static AVBufferRef* ref(const AVBufferRef* buf);
57 void unref() { av_buffer_unref(&m_buffer); }
58
59 AVBufferRef* m_buffer {nullptr};
60};
61
62#endif // LIBMYTHTV_MYTHAVBUFFERREF_H
C++ wrapper for AVBufferRef.
friend void swap(MythAVBufferRef &a, MythAVBufferRef &b) noexcept
static AVBufferRef * ref(const AVBufferRef *buf)
MythAVBufferRef(const AVBufferRef *buf=nullptr)
const uint8_t * data()
MythAVBufferRef & operator=(MythAVBufferRef other)
AVBufferRef * m_buffer
MythAVBufferRef(const MythAVBufferRef &other)
MythAVBufferRef(MythAVBufferRef &&other) noexcept
MythAVBufferRef & operator=(MythAVBufferRef &&other) noexcept
static guint32 * tmp
Definition: goom_core.cpp:26