|
FFmpegfs Fuse Multi Media Filesystem 2.19
|
RAII wrapper for AVFormatContext. More...
#include <ffmpeg_formatcontext.h>
Public Types | |
| enum class | TYPE { INPUT , OUTPUT } |
| Managed AVFormatContext direction. More... | |
Public Member Functions | |
| FFmpeg_FormatContext (TYPE type=TYPE::INPUT) | |
| Construct an empty format-context wrapper. | |
| ~FFmpeg_FormatContext () | |
| Release the owned format context, if any. | |
| FFmpeg_FormatContext (const FFmpeg_FormatContext &)=delete | |
| FFmpeg_FormatContext & | operator= (const FFmpeg_FormatContext &)=delete |
| FFmpeg_FormatContext (FFmpeg_FormatContext &&context) noexcept | |
| Move-construct a format-context wrapper. | |
| FFmpeg_FormatContext & | operator= (FFmpeg_FormatContext &&context) noexcept |
| Move-assign a format-context wrapper. | |
| int | alloc_input_context () |
| Allocate a new input format context. | |
| int | alloc_output_context (const char *format_name, const char *filename=nullptr) |
| Allocate a new output format context. | |
| void | set_type (TYPE type) |
| Set the context direction used for later cleanup. | |
| void | set_custom_io (bool custom_io=true) |
| Mark whether the context owns a custom AVIOContext. | |
| bool | reset () |
| Free the owned format context and reset the wrapper to empty. | |
| bool | empty () const |
| Check whether the wrapper currently owns a format context. | |
| AVFormatContext * | get () |
| Get the owned FFmpeg format context pointer. | |
| const AVFormatContext * | get () const |
| Get the owned FFmpeg format context pointer. | |
| AVFormatContext ** | address () |
| Get a writable pointer-to-pointer for FFmpeg APIs. | |
| AVFormatContext * | release () |
| Release ownership without freeing the format context. | |
| operator AVFormatContext * () | |
| Convert to the underlying mutable format context pointer. | |
| operator const AVFormatContext * () const | |
| Convert to the underlying const format context pointer. | |
| AVFormatContext * | operator-> () |
| Access members of the underlying mutable format context. | |
| const AVFormatContext * | operator-> () const |
| Access members of the underlying const format context. | |
Private Member Functions | |
| void | free_custom_io () |
| Free the custom AVIOContext attached to the format context. | |
Private Attributes | |
| AVFormatContext * | m_context |
| Pointer to underlying AVFormatContext. | |
| TYPE | m_type |
| Input or output context. | |
| bool | m_custom_io |
| true if pb was allocated with avio_alloc_context(). | |
RAII wrapper for AVFormatContext.
Owns the AVFormatContext and releases it with the correct FFmpeg function. Input contexts are closed with avformat_close_input(), output contexts are released with avformat_free_context(). Custom AVIO contexts allocated with avio_alloc_context() are freed before the format context is released.
Definition at line 32 of file ffmpeg_formatcontext.h.
|
strong |
Managed AVFormatContext direction.
| Enumerator | |
|---|---|
| INPUT | Input context closed with avformat_close_input(). |
| OUTPUT | Output context freed with avformat_free_context(). |
Definition at line 38 of file ffmpeg_formatcontext.h.
|
explicit |
Construct an empty format-context wrapper.
| [in] | type | Initial context direction used when resetting/freeing. |
Definition at line 33 of file ffmpeg_formatcontext.cc.
| FFmpeg_FormatContext::~FFmpeg_FormatContext | ( | ) |
Release the owned format context, if any.
Definition at line 40 of file ffmpeg_formatcontext.cc.
References reset().
|
noexcept |
Move-construct a format-context wrapper.
| [in,out] | context | Source wrapper whose context ownership is transferred. |
Definition at line 45 of file ffmpeg_formatcontext.cc.
| AVFormatContext ** FFmpeg_FormatContext::address | ( | ) |
Get a writable pointer-to-pointer for FFmpeg APIs.
Any currently owned context is released first so that FFmpeg can write a fresh context pointer without leaking the previous one.
Definition at line 145 of file ffmpeg_formatcontext.cc.
References m_context.
Referenced by FFmpeg_Transcoder::open_input_file().
| int FFmpeg_FormatContext::alloc_input_context | ( | ) |
Allocate a new input format context.
Definition at line 71 of file ffmpeg_formatcontext.cc.
References INPUT, m_context, m_type, and reset().
Referenced by FFmpeg_Transcoder::open_input_file().
| int FFmpeg_FormatContext::alloc_output_context | ( | const char * | format_name, |
| const char * | filename = nullptr |
||
| ) |
Allocate a new output format context.
| [in] | format_name | Output container format name, or nullptr for automatic selection. |
| [in] | filename | Optional output file name used by FFmpeg for format probing. |
Definition at line 81 of file ffmpeg_formatcontext.cc.
References m_context, m_type, OUTPUT, and reset().
Referenced by FFmpeg_Transcoder::open_output_filestreams().
| bool FFmpeg_FormatContext::empty | ( | ) | const |
Check whether the wrapper currently owns a format context.
Definition at line 130 of file ffmpeg_formatcontext.cc.
References m_context.
|
private |
Free the custom AVIOContext attached to the format context.
Definition at line 180 of file ffmpeg_formatcontext.cc.
References m_context, and m_custom_io.
Referenced by reset().
| AVFormatContext * FFmpeg_FormatContext::get | ( | ) |
Get the owned FFmpeg format context pointer.
Definition at line 135 of file ffmpeg_formatcontext.cc.
References m_context.
| const AVFormatContext * FFmpeg_FormatContext::get | ( | ) | const |
Get the owned FFmpeg format context pointer.
Definition at line 140 of file ffmpeg_formatcontext.cc.
References m_context.
| FFmpeg_FormatContext::operator AVFormatContext * | ( | ) |
Convert to the underlying mutable format context pointer.
Definition at line 160 of file ffmpeg_formatcontext.cc.
| FFmpeg_FormatContext::operator const AVFormatContext * | ( | ) | const |
Convert to the underlying const format context pointer.
Definition at line 165 of file ffmpeg_formatcontext.cc.
| AVFormatContext * FFmpeg_FormatContext::operator-> | ( | ) |
Access members of the underlying mutable format context.
Definition at line 170 of file ffmpeg_formatcontext.cc.
References m_context.
| const AVFormatContext * FFmpeg_FormatContext::operator-> | ( | ) | const |
Access members of the underlying const format context.
Definition at line 175 of file ffmpeg_formatcontext.cc.
References m_context.
|
noexcept |
Move-assign a format-context wrapper.
| [in,out] | context | Source wrapper whose context ownership is transferred. |
Definition at line 54 of file ffmpeg_formatcontext.cc.
| AVFormatContext * FFmpeg_FormatContext::release | ( | ) |
Release ownership without freeing the format context.
Definition at line 150 of file ffmpeg_formatcontext.cc.
References m_context, and m_custom_io.
| bool FFmpeg_FormatContext::reset | ( | ) |
Free the owned format context and reset the wrapper to empty.
Definition at line 106 of file ffmpeg_formatcontext.cc.
References free_custom_io(), m_context, m_custom_io, m_type, and OUTPUT.
Referenced by alloc_input_context(), alloc_output_context(), FFmpeg_Transcoder::close_input_file(), FFmpeg_Transcoder::close_output_file(), FFmpeg_Transcoder::open_input_file(), and ~FFmpeg_FormatContext().
| void FFmpeg_FormatContext::set_custom_io | ( | bool | custom_io = true | ) |
Mark whether the context owns a custom AVIOContext.
| [in] | custom_io | true if pb was allocated with avio_alloc_context(). |
Definition at line 101 of file ffmpeg_formatcontext.cc.
References m_custom_io.
Referenced by FFmpeg_Transcoder::open_input_file(), and FFmpeg_Transcoder::open_output_filestreams().
| void FFmpeg_FormatContext::set_type | ( | TYPE | type | ) |
Set the context direction used for later cleanup.
| [in] | type | Input or output context direction. |
Definition at line 96 of file ffmpeg_formatcontext.cc.
References m_type.
|
private |
Pointer to underlying AVFormatContext.
Definition at line 166 of file ffmpeg_formatcontext.h.
Referenced by address(), alloc_input_context(), alloc_output_context(), empty(), free_custom_io(), get(), get(), operator->(), operator->(), release(), and reset().
|
private |
true if pb was allocated with avio_alloc_context().
Definition at line 168 of file ffmpeg_formatcontext.h.
Referenced by free_custom_io(), release(), reset(), and set_custom_io().
|
private |
Input or output context.
Definition at line 167 of file ffmpeg_formatcontext.h.
Referenced by alloc_input_context(), alloc_output_context(), reset(), and set_type().