MythTV  master
mythaverror.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) David Hampton 2020
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef MYTHAVERROR_H
20 #define MYTHAVERROR_H
21 
22 #include <string>
23 #include "mythexp.h"
24 
25 extern "C" {
26 #include "libavcodec/avcodec.h"
27 #include "libavutil/error.h"
28 }
29 
30 // MythAVFrame moved from mythavutil, original copyright
31 // Created by Jean-Yves Avenard on 7/06/2014.
32 // Copyright (c) 2014 Bubblestuff Pty Ltd. All rights reserved.
33 //
34 
53 {
54  public:
56  {
57  m_frame = av_frame_alloc();
58  }
60  {
61  av_frame_free(&m_frame);
62  }
63  bool operator !() const
64  {
65  return m_frame == nullptr;
66  }
68  {
69  return m_frame;
70  }
71  AVFrame& operator*() const
72  {
73  return *m_frame;
74  }
75  operator AVFrame*() const
76  {
77  return m_frame;
78  }
79  operator const AVFrame*() const
80  {
81  return m_frame;
82  }
83 
84  private:
85  AVFrame *m_frame {nullptr};
86 };
87 
88 MPUBLIC int av_strerror_stdstring (int errnum, std::string &errbuf);
89 MPUBLIC char *av_make_error_stdstring(std::string &errbuf, int errnum);
90 
91 #endif // MYTHAVERROR_H
MPUBLIC
#define MPUBLIC
Definition: mythexp.h:10
MythAVFrame::operator*
AVFrame & operator*() const
Definition: mythaverror.h:71
mythexp.h
MythAVFrame
MythAVFrame little utility class that act as a safe way to allocate an AVFrame which can then be allo...
Definition: mythaverror.h:52
MythAVFrame::operator->
AVFrame * operator->() const
Definition: mythaverror.h:67
av_make_error_stdstring
MPUBLIC char * av_make_error_stdstring(std::string &errbuf, int errnum)
Definition: mythaverror.cpp:41
AVFrame
struct AVFrame AVFrame
Definition: BorderDetector.h:15
av_strerror_stdstring
MPUBLIC int av_strerror_stdstring(int errnum, std::string &errbuf)
Definition: mythaverror.cpp:27
MythAVFrame::~MythAVFrame
~MythAVFrame(void)
Definition: mythaverror.h:59
MythAVFrame::MythAVFrame
MythAVFrame(void)
Definition: mythaverror.h:55