FFmpeg
Data Structures | Macros | Functions | Variables
smoothstreamingenc.c File Reference
#include "config.h"
#include <float.h>
#include "avformat.h"
#include "avio_internal.h"
#include "internal.h"
#include "os_support.h"
#include "avc.h"
#include "url.h"
#include "isom.h"
#include "libavutil/opt.h"
#include "libavutil/avstring.h"
#include "libavutil/file.h"
#include "libavutil/mathematics.h"
#include "libavutil/intreadwrite.h"

Go to the source code of this file.

Data Structures

struct  Fragment
 
struct  OutputStream
 
struct  SmoothStreamingContext
 

Macros

#define OFFSET(x)   offsetof(SmoothStreamingContext, x)
 
#define E   AV_OPT_FLAG_ENCODING_PARAM
 

Functions

static int ism_write (void *opaque, uint8_t *buf, int buf_size)
 
static int64_t ism_seek (void *opaque, int64_t offset, int whence)
 
static void get_private_data (OutputStream *os)
 
static void ism_free (AVFormatContext *s)
 
static void output_chunk_list (OutputStream *os, AVIOContext *out, int final, int skip, int window_size)
 
static int write_manifest (AVFormatContext *s, int final)
 
static int ism_write_header (AVFormatContext *s)
 
static int parse_fragment (AVFormatContext *s, const char *filename, int64_t *start_ts, int64_t *duration, int64_t *moof_size, int64_t size)
 
static int add_fragment (OutputStream *os, const char *file, const char *infofile, int64_t start_time, int64_t duration, int64_t start_pos, int64_t size)
 
static int copy_moof (AVFormatContext *s, const char *infile, const char *outfile, int64_t size)
 
static int ism_flush (AVFormatContext *s, int final)
 
static int ism_write_packet (AVFormatContext *s, AVPacket *pkt)
 
static int ism_write_trailer (AVFormatContext *s)
 

Variables

static const AVOption options []
 
static const AVClass ism_class
 
const AVOutputFormat ff_smoothstreaming_muxer
 

Macro Definition Documentation

◆ OFFSET

#define OFFSET (   x)    offsetof(SmoothStreamingContext, x)

Definition at line 622 of file smoothstreamingenc.c.

◆ E

Definition at line 623 of file smoothstreamingenc.c.

Function Documentation

◆ ism_write()

static int ism_write ( void *  opaque,
uint8_t *  buf,
int  buf_size 
)
static

Definition at line 81 of file smoothstreamingenc.c.

Referenced by ism_write_header().

◆ ism_seek()

static int64_t ism_seek ( void *  opaque,
int64_t  offset,
int  whence 
)
static

Definition at line 94 of file smoothstreamingenc.c.

Referenced by ism_write_header().

◆ get_private_data()

static void get_private_data ( OutputStream os)
static

Definition at line 141 of file smoothstreamingenc.c.

Referenced by ism_write_header().

◆ ism_free()

static void ism_free ( AVFormatContext s)
static

Definition at line 164 of file smoothstreamingenc.c.

◆ output_chunk_list()

static void output_chunk_list ( OutputStream os,
AVIOContext out,
int  final,
int  skip,
int  window_size 
)
static

Definition at line 186 of file smoothstreamingenc.c.

Referenced by write_manifest().

◆ write_manifest()

static int write_manifest ( AVFormatContext s,
int  final 
)
static

Definition at line 206 of file smoothstreamingenc.c.

Referenced by ism_flush(), and ism_write_header().

◆ ism_write_header()

static int ism_write_header ( AVFormatContext s)
static

Definition at line 282 of file smoothstreamingenc.c.

◆ parse_fragment()

static int parse_fragment ( AVFormatContext s,
const char *  filename,
int64_t *  start_ts,
int64_t *  duration,
int64_t *  moof_size,
int64_t  size 
)
static

Definition at line 392 of file smoothstreamingenc.c.

Referenced by ism_flush().

◆ add_fragment()

static int add_fragment ( OutputStream os,
const char *  file,
const char *  infofile,
int64_t  start_time,
int64_t  duration,
int64_t  start_pos,
int64_t  size 
)
static

Definition at line 442 of file smoothstreamingenc.c.

Referenced by ism_flush().

◆ copy_moof()

static int copy_moof ( AVFormatContext s,
const char *  infile,
const char *  outfile,
int64_t  size 
)
static

Definition at line 470 of file smoothstreamingenc.c.

Referenced by ism_flush().

◆ ism_flush()

static int ism_flush ( AVFormatContext s,
int  final 
)
static

Definition at line 497 of file smoothstreamingenc.c.

Referenced by ism_write_packet(), and ism_write_trailer().

◆ ism_write_packet()

static int ism_write_packet ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 581 of file smoothstreamingenc.c.

◆ ism_write_trailer()

static int ism_write_trailer ( AVFormatContext s)
static

Definition at line 607 of file smoothstreamingenc.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "window_size", "number of fragments kept in the manifest", OFFSET(window_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, E },
{ "extra_window_size", "number of fragments kept outside of the manifest before removing from disk", OFFSET(extra_window_size), AV_OPT_TYPE_INT, { .i64 = 5 }, 0, INT_MAX, E },
{ "lookahead_count", "number of lookahead fragments", OFFSET(lookahead_count), AV_OPT_TYPE_INT, { .i64 = 2 }, 0, INT_MAX, E },
{ "min_frag_duration", "minimum fragment duration (in microseconds)", OFFSET(min_frag_duration), AV_OPT_TYPE_INT64, { .i64 = 5000000 }, 0, INT_MAX, E },
{ "remove_at_exit", "remove all fragments when finished", OFFSET(remove_at_exit), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
{ NULL },
}

Definition at line 624 of file smoothstreamingenc.c.

◆ ism_class

const AVClass ism_class
static
Initial value:
= {
.class_name = "smooth streaming muxer",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 633 of file smoothstreamingenc.c.

◆ ff_smoothstreaming_muxer

const AVOutputFormat ff_smoothstreaming_muxer
Initial value:
= {
.name = "smoothstreaming",
.long_name = NULL_IF_CONFIG_SMALL("Smooth Streaming Muxer"),
.priv_data_size = sizeof(SmoothStreamingContext),
.audio_codec = AV_CODEC_ID_AAC,
.video_codec = AV_CODEC_ID_H264,
.priv_class = &ism_class,
}

Definition at line 641 of file smoothstreamingenc.c.

deinit
static void deinit(AVFormatContext *s)
Definition: chromaprint.c:50
SmoothStreamingContext
Definition: smoothstreamingenc.c:69
OFFSET
#define OFFSET(x)
Definition: smoothstreamingenc.c:622
AV_OPT_TYPE_INT64
@ AV_OPT_TYPE_INT64
Definition: opt.h:225
ism_write_trailer
static int ism_write_trailer(AVFormatContext *s)
Definition: smoothstreamingenc.c:607
AV_CODEC_ID_H264
@ AV_CODEC_ID_H264
Definition: codec_id.h:77
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
write_trailer
static int write_trailer(AVFormatContext *s1)
Definition: v4l2enc.c:98
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
ism_free
static void ism_free(AVFormatContext *s)
Definition: smoothstreamingenc.c:164
AV_CODEC_ID_AAC
@ AV_CODEC_ID_AAC
Definition: codec_id.h:425
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
AVFMT_NOFILE
#define AVFMT_NOFILE
Demuxer will use avio_open, no opened file should be provided by the caller.
Definition: avformat.h:464
write_packet
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
Definition: ffmpeg.c:727
AVFMT_GLOBALHEADER
#define AVFMT_GLOBALHEADER
Format wants global header.
Definition: avformat.h:474
ism_write_packet
static int ism_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: smoothstreamingenc.c:581
ism_class
static const AVClass ism_class
Definition: smoothstreamingenc.c:633
options
static const AVOption options[]
Definition: smoothstreamingenc.c:624
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
ism_write_header
static int ism_write_header(AVFormatContext *s)
Definition: smoothstreamingenc.c:282
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:241
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
write_header
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:347
E
#define E
Definition: smoothstreamingenc.c:623