37#include <librtmp/rtmp.h>
38#include <librtmp/log.h>
113 RTMP_LogSetLevel(
level);
128 char *sep, *p =
ctx->conn;
134 sep = strchr(p,
' ');
151 if (
ctx->client_buffer_time)
153 if (
ctx->swfurl ||
ctx->swfverify) {
167 if (!RTMP_SetupURL(
r,
ctx->filename.str)) {
175 if (!RTMP_Connect(
r,
NULL) || !RTMP_ConnectStream(
r, 0)) {
182 int tmp =
ctx->buffer_size;
183 if (setsockopt(
r->m_sb.sb_socket, SOL_SOCKET, SO_SNDBUF, &
tmp,
sizeof(
tmp))) {
204 RTMP *
r = &
ctx->rtmp;
206 int ret = RTMP_Write(
r, buf,
size);
215 RTMP *
r = &
ctx->rtmp;
217 int ret = RTMP_Read(
r, buf,
size);
227 RTMP *
r = &
ctx->rtmp;
229 if (!RTMP_Pause(
r, pause))
239 RTMP *
r = &
ctx->rtmp;
245 if (stream_index < 0)
249 if (!RTMP_SendSeek(
r, timestamp))
257 RTMP *
r = &
ctx->rtmp;
259 return RTMP_Socket(
r);
262#define OFFSET(x) offsetof(LibRTMPContext, x)
263#define DEC AV_OPT_FLAG_DECODING_PARAM
264#define ENC AV_OPT_FLAG_ENCODING_PARAM
267 {
"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},
270 {
"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"},
273 {
"recorded",
"recorded stream", 0,
AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0,
DEC, .unit =
"rtmp_live"},
274 {
"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},
276 {
"rtmp_subscribe",
"Name of live stream to subscribe to. Defaults to rtmp_playpath.",
OFFSET(subscribe),
AV_OPT_TYPE_STRING, {.str =
NULL }, 0, 0,
DEC},
278 {
"rtmp_swfverify",
"URL to player swf file, compute hash/size automatically. (unimplemented)",
OFFSET(swfverify),
AV_OPT_TYPE_STRING, {.str =
NULL }, 0, 0,
DEC},
286#define RTMP_CLASS(flavor)\
287static const AVClass lib ## flavor ## _class = {\
288 .class_name = "lib" #flavor " protocol",\
289 .item_name = av_default_item_name,\
291 .version = LIBAVUTIL_VERSION_INT,\
305 .priv_data_class = &librtmp_class,
320 .priv_data_class = &librtmpt_class,
335 .priv_data_class = &librtmpe_class,
350 .priv_data_class = &librtmpte_class,
365 .priv_data_class = &librtmps_class,
#define AVIO_FLAG_WRITE
write-only
void av_bprintf(AVBPrint *buf, const char *fmt,...)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
#define AV_BPRINT_SIZE_UNLIMITED
#define flags(name, subs,...)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ 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...
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AVERROR_EOF
End of file.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_vlog(void *avcl, int level, const char *fmt, va_list vl)
Send the specified message to the log if the level is less than or equal to the current av_log_level.
int av_log_get_level(void)
Get the current log level.
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
@ AV_ROUND_DOWN
Round toward -infinity.
@ AV_ROUND_UP
Round toward +infinity.
#define AV_TIME_BASE
Internal time base represented as integer.
static int rtmp_read(URLContext *s, uint8_t *buf, int size)
static int rtmp_get_file_handle(URLContext *s)
static int rtmp_open(URLContext *s, const char *uri, int flags)
Open RTMP connection and verify that the stream can be played.
static int rtmp_close(URLContext *s)
static int rtmp_read_pause(void *opaque, int pause)
const URLProtocol ff_librtmpe_protocol
static void rtmp_log(int level, const char *fmt, va_list args)
const URLProtocol ff_librtmpt_protocol
const URLProtocol ff_librtmpte_protocol
const URLProtocol ff_librtmps_protocol
const URLProtocol ff_librtmp_protocol
#define RTMP_CLASS(flavor)
static int64_t rtmp_read_seek(void *opaque, int stream_index, int64_t timestamp, int flags)
static int rtmp_write(URLContext *s, const uint8_t *buf, int size)
Describe the class of an AVClass context structure.
char * client_buffer_time
static AVFormatContext * ctx
unbuffered private I/O API
#define URL_PROTOCOL_FLAG_NETWORK