FFmpeg
Data Structures | Macros | Functions | Variables
librtmp.c File Reference
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "avformat.h"
#include "url.h"
#include <librtmp/rtmp.h>
#include <librtmp/log.h>

Go to the source code of this file.

Data Structures

struct  LibRTMPContext
 

Macros

#define OFFSET(x)   offsetof(LibRTMPContext, x)
 
#define DEC   AV_OPT_FLAG_DECODING_PARAM
 
#define ENC   AV_OPT_FLAG_ENCODING_PARAM
 
#define RTMP_CLASS(flavor)
 

Functions

static void rtmp_log (int level, const char *fmt, va_list args)
 
static int rtmp_close (URLContext *s)
 
static int rtmp_open (URLContext *s, const char *uri, int flags)
 Open RTMP connection and verify that the stream can be played. More...
 
static int rtmp_write (URLContext *s, const uint8_t *buf, int size)
 
static int rtmp_read (URLContext *s, uint8_t *buf, int size)
 
static int rtmp_read_pause (void *opaque, int pause)
 
static int64_t rtmp_read_seek (void *opaque, int stream_index, int64_t timestamp, int flags)
 
static int rtmp_get_file_handle (URLContext *s)
 

Variables

static const AVOption options []
 
const URLProtocol ff_librtmp_protocol
 
const URLProtocol ff_librtmpt_protocol
 
const URLProtocol ff_librtmpe_protocol
 
const URLProtocol ff_librtmpte_protocol
 
const URLProtocol ff_librtmps_protocol
 

Detailed Description

RTMP protocol based on http://rtmpdump.mplayerhq.hu/ librtmp

Definition in file librtmp.c.

Macro Definition Documentation

◆ OFFSET

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

Definition at line 262 of file librtmp.c.

◆ DEC

#define DEC   AV_OPT_FLAG_DECODING_PARAM

Definition at line 263 of file librtmp.c.

◆ ENC

#define ENC   AV_OPT_FLAG_ENCODING_PARAM

Definition at line 264 of file librtmp.c.

◆ RTMP_CLASS

#define RTMP_CLASS (   flavor)
Value:
static const AVClass lib ## flavor ## _class = {\
.class_name = "lib" #flavor " protocol",\
.item_name = av_default_item_name,\
.option = options,\
.version = LIBAVUTIL_VERSION_INT,\
};

Definition at line 286 of file librtmp.c.

Function Documentation

◆ rtmp_log()

static void rtmp_log ( int  level,
const char *  fmt,
va_list  args 
)
static

Definition at line 58 of file librtmp.c.

Referenced by rtmp_open().

◆ rtmp_close()

static int rtmp_close ( URLContext s)
static

Definition at line 74 of file librtmp.c.

◆ rtmp_open()

static int rtmp_open ( URLContext s,
const char *  uri,
int  flags 
)
static

Open RTMP connection and verify that the stream can be played.

URL syntax: rtmp://server[:port][/app][/playpath][ keyword=value]... where 'app' is first one or two directories in the path (e.g. /ondemand/, /flash/live/, etc.) and 'playpath' is a file name (the rest of the path, may be prefixed with "mp4:")

Additional RTMP library options may be appended as space-separated key-value pairs.

Definition at line 96 of file librtmp.c.

◆ rtmp_write()

static int rtmp_write ( URLContext s,
const uint8_t *  buf,
int  size 
)
static

Definition at line 201 of file librtmp.c.

◆ rtmp_read()

static int rtmp_read ( URLContext s,
uint8_t *  buf,
int  size 
)
static

Definition at line 212 of file librtmp.c.

◆ rtmp_read_pause()

static int rtmp_read_pause ( void *  opaque,
int  pause 
)
static

Definition at line 223 of file librtmp.c.

◆ rtmp_read_seek()

static int64_t rtmp_read_seek ( void *  opaque,
int  stream_index,
int64_t  timestamp,
int  flags 
)
static

Definition at line 234 of file librtmp.c.

◆ rtmp_get_file_handle()

static int rtmp_get_file_handle ( URLContext s)
static

Definition at line 254 of file librtmp.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{"rtmp_app", "Name of application to connect to on the RTMP server", OFFSET(app), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
{"rtmp_buffer", "Set buffer time in milliseconds. The default is 3000.", OFFSET(client_buffer_time), AV_OPT_TYPE_STRING, {.str = "3000"}, 0, 0, DEC|ENC},
{"rtmp_conn", "Append arbitrary AMF data to the Connect message", OFFSET(conn), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
{"rtmp_flashver", "Version of the Flash plugin used to run the SWF player.", OFFSET(flashver), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
{"rtmp_live", "Specify that the media is a live stream.", OFFSET(live), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC, .unit = "rtmp_live"},
{"any", "both", 0, AV_OPT_TYPE_CONST, {.i64 = -2}, 0, 0, DEC, .unit = "rtmp_live"},
{"live", "live stream", 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, DEC, .unit = "rtmp_live"},
{"recorded", "recorded stream", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, DEC, .unit = "rtmp_live"},
{"rtmp_pageurl", "URL of the web page in which the media was embedded. By default no value will be sent.", OFFSET(pageurl), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC},
{"rtmp_playpath", "Stream identifier to play or to publish", OFFSET(playpath), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
{"rtmp_subscribe", "Name of live stream to subscribe to. Defaults to rtmp_playpath.", OFFSET(subscribe), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC},
{"rtmp_swfurl", "URL of the SWF player. By default no value will be sent", OFFSET(swfurl), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
{"rtmp_swfverify", "URL to player swf file, compute hash/size automatically. (unimplemented)", OFFSET(swfverify), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC},
{"rtmp_tcurl", "URL of the target stream. Defaults to proto://host[:port]/app.", OFFSET(tcurl), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
{ NULL },
}

Definition at line 265 of file librtmp.c.

◆ ff_librtmp_protocol

const URLProtocol ff_librtmp_protocol
Initial value:
= {
.name = "rtmp",
.url_open = rtmp_open,
.url_read = rtmp_read,
.url_write = rtmp_write,
.url_close = rtmp_close,
.url_read_pause = rtmp_read_pause,
.url_read_seek = rtmp_read_seek,
.url_get_file_handle = rtmp_get_file_handle,
.priv_data_size = sizeof(LibRTMPContext),
.priv_data_class = &librtmp_class,
}

Definition at line 295 of file librtmp.c.

◆ ff_librtmpt_protocol

const URLProtocol ff_librtmpt_protocol
Initial value:
= {
.name = "rtmpt",
.url_open = rtmp_open,
.url_read = rtmp_read,
.url_write = rtmp_write,
.url_close = rtmp_close,
.url_read_pause = rtmp_read_pause,
.url_read_seek = rtmp_read_seek,
.url_get_file_handle = rtmp_get_file_handle,
.priv_data_size = sizeof(LibRTMPContext),
.priv_data_class = &librtmpt_class,
}

Definition at line 310 of file librtmp.c.

◆ ff_librtmpe_protocol

const URLProtocol ff_librtmpe_protocol
Initial value:
= {
.name = "rtmpe",
.url_open = rtmp_open,
.url_read = rtmp_read,
.url_write = rtmp_write,
.url_close = rtmp_close,
.url_read_pause = rtmp_read_pause,
.url_read_seek = rtmp_read_seek,
.url_get_file_handle = rtmp_get_file_handle,
.priv_data_size = sizeof(LibRTMPContext),
.priv_data_class = &librtmpe_class,
}

Definition at line 325 of file librtmp.c.

◆ ff_librtmpte_protocol

const URLProtocol ff_librtmpte_protocol
Initial value:
= {
.name = "rtmpte",
.url_open = rtmp_open,
.url_read = rtmp_read,
.url_write = rtmp_write,
.url_close = rtmp_close,
.url_read_pause = rtmp_read_pause,
.url_read_seek = rtmp_read_seek,
.url_get_file_handle = rtmp_get_file_handle,
.priv_data_size = sizeof(LibRTMPContext),
.priv_data_class = &librtmpte_class,
}

Definition at line 340 of file librtmp.c.

◆ ff_librtmps_protocol

const URLProtocol ff_librtmps_protocol
Initial value:
= {
.name = "rtmps",
.url_open = rtmp_open,
.url_read = rtmp_read,
.url_write = rtmp_write,
.url_close = rtmp_close,
.url_read_pause = rtmp_read_pause,
.url_read_seek = rtmp_read_seek,
.url_get_file_handle = rtmp_get_file_handle,
.priv_data_size = sizeof(LibRTMPContext),
.priv_data_class = &librtmps_class,
}

Definition at line 355 of file librtmp.c.

URL_PROTOCOL_FLAG_NETWORK
#define URL_PROTOCOL_FLAG_NETWORK
Definition: url.h:33
ENC
#define ENC
Definition: librtmp.c:264
rtmp_read_pause
static int rtmp_read_pause(void *opaque, int pause)
Definition: librtmp.c:223
rtmp_close
static int rtmp_close(URLContext *s)
Definition: librtmp.c:74
rtmp_open
static int rtmp_open(URLContext *s, const char *uri, int flags)
Open RTMP connection and verify that the stream can be played.
Definition: librtmp.c:96
DEC
#define DEC
Definition: librtmp.c:263
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:75
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
LibRTMPContext
Definition: librtmp.c:40
options
static const AVOption options[]
Definition: librtmp.c:265
rtmp_read
static int rtmp_read(URLContext *s, uint8_t *buf, int size)
Definition: librtmp.c:212
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:80
OFFSET
#define OFFSET(x)
Definition: librtmp.c:262
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
rtmp_write
static int rtmp_write(URLContext *s, const uint8_t *buf, int size)
Definition: librtmp.c:201
rtmp_get_file_handle
static int rtmp_get_file_handle(URLContext *s)
Definition: librtmp.c:254
rtmp_read_seek
static int64_t rtmp_read_seek(void *opaque, int stream_index, int64_t timestamp, int flags)
Definition: librtmp.c:234
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition: opt.h:276
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299