FFmpegfs Fuse Multi Media Filesystem 2.19
Loading...
Searching...
No Matches
ffmpeg_formatcontext.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017-2026 by Norbert Schlia (nschlia@oblivion-software.de)
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 3 of the License, or
7 * (at your option) any later version.
8 */
9
17#ifndef FFMPEG_FORMATCONTEXT_H
18#define FFMPEG_FORMATCONTEXT_H
19
20#pragma once
21
22#include "ffmpeg_utils.h"
23
33{
34public:
38 enum class TYPE
39 {
40 INPUT,
41 OUTPUT
42 };
43
48 explicit FFmpeg_FormatContext(TYPE type = TYPE::INPUT);
49
54
56 FFmpeg_FormatContext& operator=(const FFmpeg_FormatContext&) = delete;
57
63
69 FFmpeg_FormatContext& operator=(FFmpeg_FormatContext&& context) noexcept;
70
76
83 int alloc_output_context(const char *format_name, const char *filename = nullptr);
84
89 void set_type(TYPE type);
90
95 void set_custom_io(bool custom_io = true);
96
101 bool reset();
102
107 bool empty() const;
108
113 AVFormatContext* get();
114
119 const AVFormatContext* get() const;
120
129 AVFormatContext** address();
130
135 AVFormatContext* release();
136
140 operator AVFormatContext*();
141
145 operator const AVFormatContext*() const;
146
151 AVFormatContext* operator->();
152
157 const AVFormatContext* operator->() const;
158
159private:
163 void free_custom_io();
164
165private:
166 AVFormatContext * m_context;
169};
170
171#endif // FFMPEG_FORMATCONTEXT_H
RAII wrapper for AVFormatContext.
~FFmpeg_FormatContext()
Release the owned format context, if any.
void set_type(TYPE type)
Set the context direction used for later cleanup.
AVFormatContext * m_context
Pointer to underlying AVFormatContext.
bool m_custom_io
true if pb was allocated with avio_alloc_context().
TYPE m_type
Input or output context.
TYPE
Managed AVFormatContext direction.
@ OUTPUT
Output context freed with avformat_free_context().
@ INPUT
Input context closed with avformat_close_input().
int alloc_input_context()
Allocate a new input format context.
bool reset()
Free the owned format context and reset the wrapper to empty.
AVFormatContext * get()
Get the owned FFmpeg format context pointer.
AVFormatContext ** address()
Get a writable pointer-to-pointer for FFmpeg APIs.
AVFormatContext * operator->()
Access members of the underlying mutable format context.
AVFormatContext * release()
Release ownership without freeing the format context.
void set_custom_io(bool custom_io=true)
Mark whether the context owns a custom AVIOContext.
void free_custom_io()
Free the custom AVIOContext attached to the format context.
int alloc_output_context(const char *format_name, const char *filename=nullptr)
Allocate a new output format context.
bool empty() const
Check whether the wrapper currently owns a format context.
Various FFmpegfs utility functions.