avcpp  2.0
Wrapper for the FFmpeg that simplify usage from C++ projects.
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
av Namespace Reference

Namespaces

 codec_context
 
 frame
 
 internal
 
 v1
 The AvDeleter struct Unified delete functor for variois FFMPEG/libavformat/libavcodec and so on resource allocators.
 
 v2
 

Classes

class  AudioCodecContext
 
class  AudioDecoderContext
 
class  AudioEncoderContext
 
class  AudioResampler
 
class  AudioSamples
 
class  AvcppCategory
 The AvcppCategory class Describes internal AvCpp errors. More...
 
class  BufferSinkFilterContext
 
class  BufferSrcFilterContext
 
class  Codec
 
class  CodecContext2
 
class  CodecContextBase
 
class  CodecParameters
 
class  CodecParametersView
 The CodecParametersView class. More...
 
struct  CustomIO
 
struct  DefaultNextElement
 This functor uses simple notation to take next element from linked list. More...
 
struct  DefaultResetPtr
 This functor used by default to set new pointer that will be wrapped by W wrapper. More...
 
struct  DefaultWrapperCast
 This functor used by default to take access to raw pointer that wrapped by W wrapper. More...
 
class  Dictionary
 Implements interface to access to the AVDictionary entity. More...
 
class  DictionaryArray
 Array of Dictinaries wrapper. More...
 
struct  EmptyDeleter
 
struct  EqualComparator
 
class  Exception
 The AvException class Default exception that thows from function that does not accept error code storage. More...
 
class  FfmpegCategory
 The FfmpegCategory class Describers FFmpeg internal errors. More...
 
class  Filter
 
class  FilterContext
 
class  FilterGraph
 
class  FilterPadList
 
struct  Format
 
class  FormatContext
 
class  Frame
 
class  GenericCodecContext
 The GenericCodecContext class to copy contexts from input streams to output one. More...
 
struct  IncrementNextElement
 This functor uses increment operation to take next element in list/array. More...
 
class  InputFormat
 
class  LinkedListWrapper
 Universal wrapper for one directional linked list elements. More...
 
class  noncopyable
 
struct  NullDeleter
 This deleter does nothing. More...
 
class  OptionalErrorCode
 
class  OutputFormat
 
class  Packet
 
class  PixelFormat
 The PixelFormat class is a simple wrapper for AVPixelFormat that allow to acces it it properties. More...
 
struct  PtrDeleter
 This deleter simple call 'delete' operator. More...
 
class  Rational
 
class  Rect
 
class  SampleFormat
 The SampleFormat class is a simple proxy class for AVSampleFormat. More...
 
class  ScopedValue
 Functor to take next element in list/array. More...
 
class  ScopeOutAction
 The ScopeOutAction class - guard-type class that allows points callback that will be called at the scope out. More...
 
struct  SmartDeleter
 
class  Stream
 
class  Timestamp
 The Timestamp class represents timestamp value and it timebase. More...
 
class  VideoCodecContext
 
class  VideoDecoderContext
 
class  VideoEncoderContext
 
class  VideoFrame
 
class  VideoRescaler
 

Typedefs

template<typename T >
using avcpp_format_const = typename std::conditional< std::is_const< typename std::remove_pointer< decltype(AVFormatContext::iformat) >::type >::value, const T, T >::type
 
using FmtCodec = class Codec
 
using AvioInterruptCb = std::function< int()>
 

Enumerations

enum  Errors {
  Errors::NoError = 0, Errors::Generic, Errors::Unallocated, Errors::InvalidArgument,
  Errors::OutOfRange, Errors::CantAllocateFrame, Errors::CodecStreamInvalid, Errors::CodecInvalidDirection,
  Errors::CodecAlreadyOpened, Errors::CodecIsNotOpened, Errors::CodecInvalid, Errors::CodecNotOpened,
  Errors::CodecInvalidDecodeProc, Errors::CodecInvalidEncodeProc, Errors::CodecDecodingOffsetToLarge, Errors::CodecInvalidForEncode,
  Errors::CodecInvalidForDecoce, Errors::CodecInvalidMediaType, Errors::FrameInvalid, Errors::DictOutOfRage,
  Errors::DictNoKey, Errors::FormatCantAddStream, Errors::FormatAlreadyOpened, Errors::FormatNullOutputFormat,
  Errors::FormatWrongCountOfStreamOptions, Errors::FormatNoStreams, Errors::FormatInvalidStreamIndex, Errors::FormatNotOpened,
  Errors::FormatInvalidDirection, Errors::FormatHeaderNotWriten, Errors::FormatCodecUnsupported, Errors::ResamplerInvalidParameters,
  Errors::ResamplerNotInited, Errors::ResamplerInputChanges, Errors::ResamplerOutputChanges, Errors::RescalerInvalidParameters,
  Errors::RescalerInternalSwsError, Errors::FilterNotInFilterGraph, Errors::FilterGraphDescriptionEmpty, Errors::IncorrectBufferSrcFilter,
  Errors::IncorrectBufferSrcMediaType, Errors::IncorrectBufferSinkFilter, Errors::IncorrectBufferSinkMediaType, Errors::MixBufferSinkAccess
}
 
enum  FilterMediaType { FilterMediaType::Unknown, FilterMediaType::Video, FilterMediaType::Audio }
 
enum  { RationalMaxPrecision = 5 }
 
enum  Direction { Direction::Invalid = -1, Direction::Encoding, Direction::Decoding }
 
enum  SwsFlags {
  SwsFlagAuto = 0, SwsFlagFastBilinear = SWS_FAST_BILINEAR, SwsFlagBilinear = SWS_BILINEAR, SwsFlagBicubic = SWS_BICUBIC,
  SwsFlagExprerimental = SWS_X, SwsFlagNeighbor = SWS_POINT, SwsFlagArea = SWS_AREA, SwsFlagBicublin = SWS_BICUBLIN,
  SwsFlagGauss = SWS_GAUSS, SwsFlagSinc = SWS_SINC, SwsFlagLanczos = SWS_LANCZOS, SwsFlagSpline = SWS_SPLINE,
  SwsFlagPrintInfo = SWS_PRINT_INFO, SwsFlagAccurateRnd = SWS_ACCURATE_RND, SwsFlagFullChromaInt = SWS_FULL_CHR_H_INT, SwsFlagFullChromaInp = SWS_FULL_CHR_H_INP,
  SwsFlagBitexact = SWS_BITEXACT, SwsFlagErrorDiffusion = SWS_ERROR_DIFFUSION
}
 

Functions

void init ()
 Init all subsustems needed by avcpp. More...
 
const AvcppCategoryavcpp_category ()
 
FfmpegCategoryffmpeg_category ()
 
std::error_condition make_error_condition (av::Errors errc) noexcept
 
std::error_code make_error_code (av::Errors errc) noexcept
 
std::error_code make_avcpp_error (Errors code)
 
std::error_condition make_avcpp_condition (Errors code)
 
std::error_code make_ffmpeg_error (int code)
 
std::error_condition make_ffmpeg_condition (int code)
 
template<typename Exception = av::Exception>
void throw_error_code (const std::error_code &ec)
 
template<typename Exception = av::Exception>
void throw_error_code (Errors errc)
 
OptionalErrorCode throws ()
 Helper to construct null OptionalErrorCode object. More...
 
template<typename Category , typename Exception = av::Exception>
void throws_if (OptionalErrorCode ec, int errcode, const Category &cat)
 Throws exception if ec is av::throws() or fill error code. More...
 
template<typename T , typename Exception = av::Exception>
void throws_if (OptionalErrorCode ec, T errcode)
 
void clear_if (OptionalErrorCode ec)
 clear_if - clear error code if it is not av::throws() More...
 
bool is_error (OptionalErrorCode ec)
 
int64_t gettime ()
 Get the current time in microseconds. More...
 
int usleep (unsigned usec)
 Sleep for a period of time. More...
 
void set_logging_level (int32_t level)
 This method can be used to turn up or down FFmpeg's logging level. More...
 
void set_logging_level (const string &level)
 
void dumpBinaryBuffer (uint8_t *buffer, int buffer_size, int width=16)
 dump_binary_buffer Dump binary buffer to std out in HEX view More...
 
static int avcpp_lockmgr_cb (void **ctx, enum AVLockOp op)
 
string error2string (int error)
 C++ verstion of the av_err2str() More...
 
template<typename R , typename T >
lexical_cast (const T &v)
 
void set_logging_level (const std::string &level)
 Like. More...
 
template<typename T >
std::unique_ptr< T, void(*)(void *)> malloc (size_t size)
 
template<typename T >
std::unique_ptr< T, void(*)(void *)> mallocz (size_t size)
 
template<typename T >
std::unique_ptr< T, void(*)(void *)> memdup (const void *p, size_t size)
 
template<typename T , typename L , typename C >
guessValue (const T &value, const L *list, C endListComparator)
 Select more approptiate value from given value list. More...
 
template<typename T , typename Container >
void array_to_container (const T *array, std::size_t nelements, Container &container)
 
template<typename T , typename Container , typename Callable >
void array_to_container (const T *array, std::size_t nelements, Container &container, Callable convert)
 
template<typename T , typename Container , typename Compare >
void array_to_container (const T *array, Container &container, Compare isEnd)
 
template<typename T , typename Container , typename Compare , typename Callable >
void array_to_container (const T *array, Container &container, Compare isEnd, Callable convert)
 
Codec findEncodingCodec (AVCodecID id)
 
Codec findEncodingCodec (const string &name)
 
Codec findDecodingCodec (AVCodecID id)
 
Codec findDecodingCodec (const string &name)
 
Codec guessEncodingCodec (OutputFormat format, const char *name, const char *url, const char *mime, AVMediaType mediaType)
 
Codec findEncodingCodec (const OutputFormat &format, bool isVideo)
 
Codec findEncodingCodec (const std::string &name)
 
Codec findDecodingCodec (const std::string &name)
 
bool operator== (const Dictionary::Entry &lhs, const Dictionary::Entry &rhs)
 
bool operator!= (const Dictionary::Entry &lhs, const Dictionary::Entry &rhs)
 
static size_t get_pad_count (const AVFilter *filter, bool output)
 
OutputFormat guessOutputFormat (const std::string &name, const std::string &url, const std::string &mime)
 
static void dummy_buffer_free (void *, uint8_t *)
 
template<typename T >
auto operator/ (T num, Rational value) -> std::enable_if_t< std::is_floating_point_v< T >||std::is_integral_v< T >, Rational >
 
template<typename T >
auto operator/ (Rational value, T num) -> std::enable_if_t< std::is_floating_point_v< T >||std::is_integral_v< T >, Rational >
 
std::ostream & operator<< (std::ostream &stream, const Rational &value)
 
std::istream & operator>> (std::istream &stream, Rational &value)
 
Timestamp operator+ (const Timestamp &left, const Timestamp &right) noexcept
 
Timestamp operator- (const Timestamp &left, const Timestamp &right) noexcept
 
Timestamp operator* (const Timestamp &left, const Timestamp &right) noexcept
 
Timestamp operator/ (const Timestamp &left, const Timestamp &right) noexcept
 
bool operator> (const Timestamp &left, const Timestamp &right) noexcept
 
bool operator< (const Timestamp &left, const Timestamp &right) noexcept
 
bool operator== (const Timestamp &left, const Timestamp &right) noexcept
 
bool operator!= (const Timestamp &left, const Timestamp &right) noexcept
 
bool operator>= (const Timestamp &left, const Timestamp &right) noexcept
 
bool operator<= (const Timestamp &left, const Timestamp &right) noexcept
 
std::ostream & operator<< (std::ostream &ost, const Timestamp &ts)
 

Variables

constexpr auto NoPts = static_cast<int64_t>(AV_NOPTS_VALUE)
 
constexpr auto TimeBase = static_cast<int>(AV_TIME_BASE)
 
constexpr auto TimeBaseQ = AVRational{1, AV_TIME_BASE}
 

Typedef Documentation

◆ avcpp_format_const

template<typename T >
using av::avcpp_format_const = typedef typename std::conditional< std::is_const< typename std::remove_pointer< decltype(AVFormatContext::iformat) >::type >::value, const T, T>::type

◆ AvioInterruptCb

using av::AvioInterruptCb = typedef std::function<int()>

◆ FmtCodec

using av::FmtCodec = typedef class Codec

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
RationalMaxPrecision 

◆ Direction

enum av::Direction
strong
Enumerator
Invalid 
Encoding 
Decoding 

◆ Errors

enum av::Errors
strong
Enumerator
NoError 
Generic 
Unallocated 
InvalidArgument 
OutOfRange 
CantAllocateFrame 
CodecStreamInvalid 
CodecInvalidDirection 
CodecAlreadyOpened 
CodecIsNotOpened 
CodecInvalid 
CodecNotOpened 
CodecInvalidDecodeProc 
CodecInvalidEncodeProc 
CodecDecodingOffsetToLarge 
CodecInvalidForEncode 
CodecInvalidForDecoce 
CodecInvalidMediaType 
FrameInvalid 
DictOutOfRage 
DictNoKey 
FormatCantAddStream 
FormatAlreadyOpened 
FormatNullOutputFormat 
FormatWrongCountOfStreamOptions 
FormatNoStreams 
FormatInvalidStreamIndex 
FormatNotOpened 
FormatInvalidDirection 
FormatHeaderNotWriten 
FormatCodecUnsupported 
ResamplerInvalidParameters 
ResamplerNotInited 
ResamplerInputChanges 
ResamplerOutputChanges 
RescalerInvalidParameters 
RescalerInternalSwsError 
FilterNotInFilterGraph 
FilterGraphDescriptionEmpty 
IncorrectBufferSrcFilter 
IncorrectBufferSrcMediaType 
IncorrectBufferSinkFilter 
IncorrectBufferSinkMediaType 
MixBufferSinkAccess 

◆ FilterMediaType

enum av::FilterMediaType
strong
Enumerator
Unknown 
Video 
Audio 

◆ SwsFlags

Enumerator
SwsFlagAuto 
SwsFlagFastBilinear 
SwsFlagBilinear 
SwsFlagBicubic 
SwsFlagExprerimental 
SwsFlagNeighbor 
SwsFlagArea 
SwsFlagBicublin 
SwsFlagGauss 
SwsFlagSinc 
SwsFlagLanczos 
SwsFlagSpline 
SwsFlagPrintInfo 
SwsFlagAccurateRnd 
SwsFlagFullChromaInt 
SwsFlagFullChromaInp 
SwsFlagBitexact 
SwsFlagErrorDiffusion 

Function Documentation

◆ array_to_container() [1/4]

template<typename T , typename Container , typename Compare >
void av::array_to_container ( const T *  array,
Container &  container,
Compare  isEnd 
)

◆ array_to_container() [2/4]

template<typename T , typename Container , typename Compare , typename Callable >
void av::array_to_container ( const T *  array,
Container &  container,
Compare  isEnd,
Callable  convert 
)

◆ array_to_container() [3/4]

template<typename T , typename Container >
void av::array_to_container ( const T *  array,
std::size_t  nelements,
Container &  container 
)

◆ array_to_container() [4/4]

template<typename T , typename Container , typename Callable >
void av::array_to_container ( const T *  array,
std::size_t  nelements,
Container &  container,
Callable  convert 
)

◆ avcpp_category()

const AvcppCategory& av::avcpp_category ( )
inline

◆ avcpp_lockmgr_cb()

static int av::avcpp_lockmgr_cb ( void **  ctx,
enum AVLockOp  op 
)
static

◆ clear_if()

void av::clear_if ( OptionalErrorCode  ec)
inline

clear_if - clear error code if it is not av::throws()

Parameters
ecerror code to clear

◆ dummy_buffer_free()

static void av::dummy_buffer_free ( void *  ,
uint8_t *   
)
static

◆ dumpBinaryBuffer()

void av::dumpBinaryBuffer ( uint8_t *  buffer,
int  buffer_size,
int  width = 16 
)

dump_binary_buffer Dump binary buffer to std out in HEX view

Parameters
bufferpointer to buffer start
buffer_sizebuffer size
widthoutput width in hex values (real text screen with is: sw = width * 3 - 1)

◆ error2string()

std::string av::error2string ( int  error)

C++ verstion of the av_err2str()

Parameters
error- error code to convert to string
Returns
string representation of error code

◆ ffmpeg_category()

FfmpegCategory& av::ffmpeg_category ( )
inline

◆ findDecodingCodec() [1/3]

Codec av::findDecodingCodec ( AVCodecID  id)

◆ findDecodingCodec() [2/3]

Codec av::findDecodingCodec ( const std::string &  name)

◆ findDecodingCodec() [3/3]

Codec av::findDecodingCodec ( const string &  name)

◆ findEncodingCodec() [1/4]

Codec av::findEncodingCodec ( AVCodecID  id)

◆ findEncodingCodec() [2/4]

Codec av::findEncodingCodec ( const OutputFormat format,
bool  isVideo 
)

◆ findEncodingCodec() [3/4]

Codec av::findEncodingCodec ( const std::string &  name)

◆ findEncodingCodec() [4/4]

Codec av::findEncodingCodec ( const string &  name)

◆ get_pad_count()

static size_t av::get_pad_count ( const AVFilter *  filter,
bool  output 
)
static

◆ gettime()

int64_t av::gettime ( )

Get the current time in microseconds.

◆ guessEncodingCodec()

Codec av::guessEncodingCodec ( OutputFormat  format,
const char *  name,
const char *  url,
const char *  mime,
AVMediaType  mediaType 
)

◆ guessOutputFormat()

OutputFormat av::guessOutputFormat ( const std::string &  name,
const std::string &  url,
const std::string &  mime 
)

◆ guessValue()

template<typename T , typename L , typename C >
T av::guessValue ( const T &  value,
const L *  list,
endListComparator 
)

Select more approptiate value from given value list.

Useful for AVCodec::supported_framerates, AVCodec::pix_fmts and so on.

T - type of value and (by default) list elements L - type of list elements C - end list comparator

If T and L different types, T must be have ctor from L.

Parameters
valuevalue to set
listlist of allowed values
endOfListValueend of list value, like
Returns
value if list null or if it present in list, or more appropriate value from list

◆ init()

void av::init ( )

Init all subsustems needed by avcpp.

Must be call before any other functionality

◆ is_error()

bool av::is_error ( OptionalErrorCode  ec)
inline

◆ lexical_cast()

template<typename R , typename T >
R av::lexical_cast ( const T &  v)

◆ make_avcpp_condition()

std::error_condition av::make_avcpp_condition ( Errors  code)
inline

◆ make_avcpp_error()

std::error_code av::make_avcpp_error ( Errors  code)
inline

◆ make_error_code()

std::error_code av::make_error_code ( av::Errors  errc)
inlinenoexcept

◆ make_error_condition()

std::error_condition av::make_error_condition ( av::Errors  errc)
inlinenoexcept

◆ make_ffmpeg_condition()

std::error_condition av::make_ffmpeg_condition ( int  code)
inline

◆ make_ffmpeg_error()

std::error_code av::make_ffmpeg_error ( int  code)
inline

◆ malloc()

template<typename T >
std::unique_ptr<T, void(*)(void*)> av::malloc ( size_t  size)

◆ mallocz()

template<typename T >
std::unique_ptr<T, void(*)(void*)> av::mallocz ( size_t  size)

◆ memdup()

template<typename T >
std::unique_ptr<T, void(*)(void*)> av::memdup ( const void *  p,
size_t  size 
)

◆ operator!=() [1/2]

bool av::operator!= ( const Dictionary::Entry lhs,
const Dictionary::Entry rhs 
)

◆ operator!=() [2/2]

bool av::operator!= ( const Timestamp left,
const Timestamp right 
)
inlinenoexcept

◆ operator*()

Timestamp av::operator* ( const Timestamp left,
const Timestamp right 
)
noexcept

◆ operator+()

Timestamp av::operator+ ( const Timestamp left,
const Timestamp right 
)
noexcept

◆ operator-()

Timestamp av::operator- ( const Timestamp left,
const Timestamp right 
)
noexcept

◆ operator/() [1/3]

Timestamp av::operator/ ( const Timestamp left,
const Timestamp right 
)
noexcept

◆ operator/() [2/3]

template<typename T >
auto av::operator/ ( Rational  value,
num 
) -> std::enable_if_t<std::is_floating_point_v<T> || std::is_integral_v<T>, Rational>

◆ operator/() [3/3]

template<typename T >
auto av::operator/ ( num,
Rational  value 
) -> std::enable_if_t<std::is_floating_point_v<T> || std::is_integral_v<T>, Rational>

◆ operator<()

bool av::operator< ( const Timestamp left,
const Timestamp right 
)
inlinenoexcept

◆ operator<<() [1/2]

std::ostream& av::operator<< ( std::ostream &  ost,
const Timestamp ts 
)
inline

◆ operator<<() [2/2]

std::ostream& av::operator<< ( std::ostream &  stream,
const Rational value 
)
inline

◆ operator<=()

bool av::operator<= ( const Timestamp left,
const Timestamp right 
)
inlinenoexcept

◆ operator==() [1/2]

bool av::operator== ( const Dictionary::Entry lhs,
const Dictionary::Entry rhs 
)

◆ operator==() [2/2]

bool av::operator== ( const Timestamp left,
const Timestamp right 
)
inlinenoexcept

◆ operator>()

bool av::operator> ( const Timestamp left,
const Timestamp right 
)
inlinenoexcept

◆ operator>=()

bool av::operator>= ( const Timestamp left,
const Timestamp right 
)
inlinenoexcept

◆ operator>>()

std::istream& av::operator>> ( std::istream &  stream,
Rational value 
)
inline

◆ set_logging_level() [1/3]

void av::set_logging_level ( const std::string &  level)

Like.

See also
set_logging_level, but can assept logging level as string.
Parameters
level- string representation of loggin level: 'quiet', 'panic', 'fatal', 'error', 'warning', 'info', 'verbose' or 'debug', it also can be numeric (but in string representation), it it case boost::lexical_cast will be used and set_logging_level(int32_t) will be called.

◆ set_logging_level() [2/3]

void av::set_logging_level ( const string &  level)

◆ set_logging_level() [3/3]

void av::set_logging_level ( int32_t  level)

This method can be used to turn up or down FFmpeg's logging level.

Parameters
levelAn integer value for level. Lower numbers mean less logging. A negative number tells FFmpeg to shut up.

◆ throw_error_code() [1/2]

template<typename Exception = av::Exception>
void av::throw_error_code ( const std::error_code &  ec)

◆ throw_error_code() [2/2]

template<typename Exception = av::Exception>
void av::throw_error_code ( Errors  errc)

◆ throws()

OptionalErrorCode av::throws ( )
inline

Helper to construct null OptionalErrorCode object.

Returns
null OptionalErrorCode object

◆ throws_if() [1/2]

template<typename Category , typename Exception = av::Exception>
void av::throws_if ( OptionalErrorCode  ec,
int  errcode,
const Category &  cat 
)

Throws exception if ec is av::throws() or fill error code.

◆ throws_if() [2/2]

template<typename T , typename Exception = av::Exception>
void av::throws_if ( OptionalErrorCode  ec,
errcode 
)

◆ usleep()

int av::usleep ( unsigned  usec)

Sleep for a period of time.

Although the duration is expressed in microseconds, the actual delay may be rounded to the precision of the system timer.

Parameters
usecNumber of microseconds to sleep.
Returns
zero on success or (negative) error code.

Variable Documentation

◆ NoPts

constexpr auto av::NoPts = static_cast<int64_t>(AV_NOPTS_VALUE)
constexpr

◆ TimeBase

constexpr auto av::TimeBase = static_cast<int>(AV_TIME_BASE)
constexpr

◆ TimeBaseQ

constexpr auto av::TimeBaseQ = AVRational{1, AV_TIME_BASE}
constexpr