FFmpeg
Loading...
Searching...
No Matches
muxer.h
Go to the documentation of this file.
1/*
2 * Ogg muxer
3 * Copyright (c) 2007 Baptiste Coudurier <baptiste dot coudurier at free dot fr>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#ifndef AVFORMAT_OGG_MUXER_H
23#define AVFORMAT_OGG_MUXER_H
24
25#include <stdint.h>
26
27#include "libavutil/dict.h"
29
30#define MAX_PAGE_SIZE 65025
31
32typedef struct OGGPage {
36 uint8_t flags;
38 uint8_t segments[255];
40 uint16_t size;
41} OGGPage;
42
43typedef struct OGGMuxerMapping OGGMuxerMapping;
44
45typedef struct OGGStreamContext {
46 unsigned page_counter;
47 uint8_t *header[3];
48 int header_len[3];
50 void *priv_data; ///< state of the mapping
51 /**
52 * Granule layout, set by the mapping. The timestamp of a granule is its
53 * high part, above granule_shift bits, plus its granule_delta_mask bits.
54 */
55 unsigned granule_shift;
57 int64_t granule_key_mask; ///< bits all clear on keyframes, 0 when no granule marks one
58 int packet_granule_offset; ///< added to the end timestamp of a packet without packet_granule
59 int eos;
60 unsigned page_count; ///< number of page buffered
61 OGGPage page; ///< current page
62 unsigned serial_num; ///< serial number
63 int64_t last_granule; ///< last packet granule
64 int packet_seen; ///< true when packets have been submitted
66
67/**
68 * Codec mapping of the muxer: the parts of the Ogg encapsulation that depend
69 * on the codec.
70 */
73 size_t priv_data_size; ///< size of OGGStreamContext.priv_data
74 int optional_extradata; ///< the headers can be built without extradata
75 int new_links; ///< a new link can replace the current one
76 /**
77 * Build the header packets in OGGStreamContext.header, adjusting the
78 * stream time base when the codec sets its own.
79 */
81 /**
82 * @return why a new link cannot start with this packet, NULL if it can.
83 * When the callback is NULL, the codec imposes no additional
84 * packet restriction.
85 */
86 const char *(*new_link_refused)(const AVStream *st, const AVPacket *pkt,
87 const uint8_t *new_extradata, size_t size);
88 /**
89 * @return the granule of a packet. When NULL, the granule is the
90 * packet's end timestamp plus OGGStreamContext.packet_granule_offset.
91 */
93};
94
95/**
96 * Allocate a comment header packet holding a VorbisComment. The metadata is
97 * converted to VorbisComment field names in place.
98 *
99 * @param offset the number of zeroed bytes before the VorbisComment, left
100 * for the codec's packet type
101 * @param header_len set to the packet size
102 * @param framing_bit whether the packet ends with a framing bit
103 * @return the packet, to free with av_free(), or NULL on error
104 */
105uint8_t *ff_ogg_write_vorbiscomment(int64_t offset, int bitexact,
106 int *header_len, AVDictionary **m, int framing_bit,
107 AVChapter **chapters, unsigned int nb_chapters);
108
109/**
110 * Build the headers of a codec using the Xiph header layout: identification,
111 * comment and setup packets laced in the extradata.
112 *
113 * @param first_header_size the size of the identification header
114 * @param comment_type the packet type of the comment header
115 * @param name the codec name in the comment header
116 * @param framing_bit whether the comment header ends with a framing bit
117 */
119 int first_header_size, int comment_type,
120 const char *name, int framing_bit);
121
128
129#endif /* AVFORMAT_OGG_MUXER_H */
Main libavformat public API header.
#define s(width, name)
Definition cbs_vp9.c:198
long long int64_t
Definition coverity.c:34
static AVPacket * pkt
Public dictionary API.
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition codec_id.h:47
unsigned offset
Definition libaomenc.c:812
const OGGMuxerMapping ff_ogg_speex_muxer_mapping
Definition speex.c:66
const OGGMuxerMapping ff_ogg_theora_muxer_mapping
Definition theora.c:110
#define MAX_PAGE_SIZE
Definition muxer.h:30
const OGGMuxerMapping ff_ogg_vp8_muxer_mapping
Definition vp8.c:110
const OGGMuxerMapping ff_ogg_flac_muxer_mapping
Definition flac.c:73
int ff_ogg_build_xiph_headers(AVFormatContext *s, AVStream *st, int first_header_size, int comment_type, const char *name, int framing_bit)
Build the headers of a codec using the Xiph header layout: identification, comment and setup packets ...
Definition muxer.c:287
uint8_t * ff_ogg_write_vorbiscomment(int64_t offset, int bitexact, int *header_len, AVDictionary **m, int framing_bit, AVChapter **chapters, unsigned int nb_chapters)
Allocate a comment header packet holding a VorbisComment.
Definition muxer.c:257
const OGGMuxerMapping ff_ogg_vorbis_muxer_mapping
Definition vorbis.c:29
const OGGMuxerMapping ff_ogg_opus_muxer_mapping
Definition opus.c:78
const char * name
Definition qsvenc.c:142
Format I/O context.
Definition avformat.h:1401
This structure stores compressed data.
Definition packet.h:587
Stream structure.
Definition avformat.h:768
Codec mapping of the muxer: the parts of the Ogg encapsulation that depend on the codec.
Definition muxer.h:71
int new_links
a new link can replace the current one
Definition muxer.h:75
int(* init)(AVFormatContext *s, AVStream *st)
Build the header packets in OGGStreamContext.header, adjusting the stream time base when the codec se...
Definition muxer.h:80
size_t priv_data_size
size of OGGStreamContext.priv_data
Definition muxer.h:73
enum AVCodecID codec_id
Definition muxer.h:72
int optional_extradata
the headers can be built without extradata
Definition muxer.h:74
int64_t(* packet_granule)(AVStream *st, const AVPacket *pkt)
Definition muxer.h:92
uint8_t data[MAX_PAGE_SIZE]
Definition muxer.h:39
uint16_t size
Definition muxer.h:40
int stream_index
Definition muxer.h:35
uint8_t segments_count
Definition muxer.h:37
uint8_t segments[255]
Definition muxer.h:38
uint8_t flags
Definition muxer.h:36
int64_t start_granule
Definition muxer.h:33
int64_t granule
Definition muxer.h:34
unsigned granule_shift
Granule layout, set by the mapping.
Definition muxer.h:55
unsigned serial_num
serial number
Definition muxer.h:62
unsigned page_count
number of page buffered
Definition muxer.h:60
const OGGMuxerMapping * mapping
Definition muxer.h:49
uint8_t * header[3]
Definition muxer.h:47
unsigned page_counter
Definition muxer.h:46
void * priv_data
state of the mapping
Definition muxer.h:50
int packet_granule_offset
added to the end timestamp of a packet without packet_granule
Definition muxer.h:58
int64_t granule_delta_mask
Definition muxer.h:56
int64_t granule_key_mask
bits all clear on keyframes, 0 when no granule marks one
Definition muxer.h:57
int packet_seen
true when packets have been submitted
Definition muxer.h:64
OGGPage page
current page
Definition muxer.h:61
int64_t last_granule
last packet granule
Definition muxer.h:63
int header_len[3]
Definition muxer.h:48
int size