FFmpeg
Loading...
Searching...
No Matches
webvttdec.c File Reference

WebVTT subtitle demuxer. More...

#include "avformat.h"
#include "demux.h"
#include "internal.h"
#include "subtitles.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"

Go to the source code of this file.

Data Structures

struct  WebVTTContext
 

Macros

#define SET_SIDE_DATA(name, type)
 
#define OFFSET(x)
 
#define KIND_FLAGS   AV_OPT_FLAG_SUBTITLE_PARAM|AV_OPT_FLAG_DECODING_PARAM
 

Functions

static int webvtt_probe (const AVProbeData *p)
 
static int64_t read_ts (const char *s)
 
static void parse_timestamp_map (AVFormatContext *s, const char *p, AVRational time_base, int64_t *offset)
 
static int webvtt_read_header (AVFormatContext *s)
 
static int webvtt_read_packet (AVFormatContext *s, AVPacket *pkt)
 
static int webvtt_read_seek (AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
 
static int webvtt_read_close (AVFormatContext *s)
 

Variables

static const AVOption options []
 
static const AVClass webvtt_demuxer_class
 
const FFInputFormat ff_webvtt_demuxer
 

Detailed Description

WebVTT subtitle demuxer.

See also
https://www.w3.org/TR/webvtt1/

Definition in file webvttdec.c.

Macro Definition Documentation

◆ SET_SIDE_DATA

#define SET_SIDE_DATA ( name,
type )
Value:
do { \
if (name##_len) { \
uint8_t *buf = av_packet_new_side_data(sub, type, name##_len); \
if (!buf) { \
res = AVERROR(ENOMEM); \
goto end; \
} \
memcpy(buf, name, name##_len); \
} \
} while (0)
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
Allocate new information of a packet.
Definition packet.c:231
#define AVERROR(e)
Definition error.h:45
enum MPFType type
Definition jpegmpfenc.c:55
const char * name
Definition qsvenc.c:142

Referenced by webvtt_read_header().

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 246 of file webvttdec.c.

◆ KIND_FLAGS

Definition at line 247 of file webvttdec.c.

Function Documentation

◆ webvtt_probe()

static int webvtt_probe ( const AVProbeData * p)
static

Definition at line 43 of file webvttdec.c.

◆ read_ts()

static int64_t read_ts ( const char * s)
static

Definition at line 55 of file webvttdec.c.

Referenced by parse_timestamp_map(), and webvtt_read_header().

◆ parse_timestamp_map()

static void parse_timestamp_map ( AVFormatContext * s,
const char * p,
AVRational time_base,
int64_t * offset )
static

Definition at line 65 of file webvttdec.c.

Referenced by webvtt_read_header().

◆ webvtt_read_header()

static int webvtt_read_header ( AVFormatContext * s)
static

Definition at line 101 of file webvttdec.c.

◆ webvtt_read_packet()

static int webvtt_read_packet ( AVFormatContext * s,
AVPacket * pkt )
static

Definition at line 225 of file webvttdec.c.

◆ webvtt_read_seek()

static int webvtt_read_seek ( AVFormatContext * s,
int stream_index,
int64_t min_ts,
int64_t ts,
int64_t max_ts,
int flags )
static

Definition at line 231 of file webvttdec.c.

◆ webvtt_read_close()

static int webvtt_read_close ( AVFormatContext * s)
static

Definition at line 239 of file webvttdec.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "kind", "Set kind of WebVTT track", OFFSET(kind), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, KIND_FLAGS, .unit = "webvtt_kind" },
{ "subtitles", "WebVTT subtitles kind", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, KIND_FLAGS, .unit = "webvtt_kind" },
{ "captions", "WebVTT captions kind", 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CAPTIONS }, INT_MIN, INT_MAX, KIND_FLAGS, .unit = "webvtt_kind" },
{ "descriptions", "WebVTT descriptions kind", 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DESCRIPTIONS }, INT_MIN, INT_MAX, KIND_FLAGS, .unit = "webvtt_kind" },
{ "metadata", "WebVTT metadata kind", 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_METADATA }, INT_MIN, INT_MAX, KIND_FLAGS, .unit = "webvtt_kind" },
{ "timestamp_map", "Apply the X-TIMESTAMP-MAP header to the cue timestamps, in the 90 kHz MPEG-TS time base", OFFSET(timestamp_map), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, KIND_FLAGS },
{ NULL }
}
#define AV_DISPOSITION_CAPTIONS
The subtitle stream contains captions, providing a transcription and possibly a translation of audio.
Definition avformat.h:712
#define AV_DISPOSITION_METADATA
The subtitle stream contains time-aligned metadata that is not intended to be directly presented to t...
Definition avformat.h:723
#define AV_DISPOSITION_DESCRIPTIONS
The subtitle stream contains a textual description of the video content.
Definition avformat.h:718
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
#define KIND_FLAGS
Definition webvttdec.c:247

Definition at line 249 of file webvttdec.c.

◆ webvtt_demuxer_class

const AVClass webvtt_demuxer_class
static
Initial value:
= {
.class_name = "WebVTT demuxer",
.item_name = av_default_item_name,
.option = options,
}
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:247
#define LIBAVUTIL_VERSION_INT
Definition version.h:85

Definition at line 259 of file webvttdec.c.

◆ ff_webvtt_demuxer

const FFInputFormat ff_webvtt_demuxer
Initial value:
= {
.p.name = "webvtt",
.p.long_name = NULL_IF_CONFIG_SMALL("WebVTT subtitle"),
.p.mime_type = "text/vtt",
.p.extensions = "vtt,webvtt",
.p.priv_class = &webvtt_demuxer_class,
.priv_data_size = sizeof(WebVTTContext),
.flags_internal = FF_INFMT_FLAG_INIT_CLEANUP,
.read_seek2 = webvtt_read_seek,
}
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
static int read_probe(const AVProbeData *p)
Definition cdg.c:30
#define FF_INFMT_FLAG_INIT_CLEANUP
For an FFInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
Definition demux.h:35
static int read_header(FFV1Context *f, RangeCoder *c)
Definition ffv1dec.c:580
static int webvtt_read_seek(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
Definition webvttdec.c:231
static int webvtt_probe(const AVProbeData *p)
Definition webvttdec.c:43
static const AVClass webvtt_demuxer_class
Definition webvttdec.c:259
static int webvtt_read_header(AVFormatContext *s)
Definition webvttdec.c:101
static int webvtt_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition webvttdec.c:225
static int webvtt_read_close(AVFormatContext *s)
Definition webvttdec.c:239
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:97
static av_cold int read_close(AVFormatContext *ctx)
Definition libcdio.c:143

Definition at line 266 of file webvttdec.c.