36 #include <librtmp/rtmp.h>
37 #include <librtmp/log.h>
112 RTMP_LogSetLevel(
level);
115 if (ctx->
app) len += strlen(ctx->
app) +
sizeof(
" app=");
116 if (ctx->
tcurl) len += strlen(ctx->
tcurl) +
sizeof(
" tcUrl=");
117 if (ctx->
pageurl) len += strlen(ctx->
pageurl) +
sizeof(
" pageUrl=");
121 char *sep, *p = ctx->
conn;
129 sep = strchr(p,
' ');
135 len += options *
sizeof(
" conn=");
136 len += strlen(ctx->
conn);
140 len += strlen(ctx->
playpath) +
sizeof(
" playpath=");
142 len +=
sizeof(
" live=1");
144 len += strlen(ctx->
subscribe) +
sizeof(
" subscribe=");
150 len +=
sizeof(
" swfUrl=");
153 len += strlen(ctx->
swfverify) +
sizeof(
" swfVfy=1");
155 len += strlen(ctx->
swfurl);
183 char *sep, *p = ctx->
conn;
189 sep = strchr(p,
' ');
224 if (!RTMP_SetupURL(r, filename)) {
232 if (!RTMP_Connect(r,
NULL) || !RTMP_ConnectStream(r, 0)) {
238 if (ctx->
buffer_size >= 0 && (flags & AVIO_FLAG_WRITE)) {
240 setsockopt(r->m_sb.sb_socket, SOL_SOCKET, SO_SNDBUF, &tmp,
sizeof(tmp));
257 RTMP *
r = &ctx->
rtmp;
259 return RTMP_Write(r, buf, size);
265 RTMP *
r = &ctx->
rtmp;
267 return RTMP_Read(r, buf, size);
273 RTMP *
r = &ctx->
rtmp;
275 if (!RTMP_Pause(r, pause))
281 int64_t timestamp,
int flags)
284 RTMP *
r = &ctx->
rtmp;
290 if (stream_index < 0)
294 if (!RTMP_SendSeek(r, timestamp))
302 RTMP *
r = &ctx->
rtmp;
304 return RTMP_Socket(r);
307 #define OFFSET(x) offsetof(LibRTMPContext, x)
308 #define DEC AV_OPT_FLAG_DECODING_PARAM
309 #define ENC AV_OPT_FLAG_ENCODING_PARAM
312 {
"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},
315 {
"rtmp_live",
"Specify that the media is a live stream.",
OFFSET(live),
AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX,
DEC,
"rtmp_live"},
319 {
"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},
321 {
"rtmp_subscribe",
"Name of live stream to subscribe to. Defaults to rtmp_playpath.",
OFFSET(subscribe),
AV_OPT_TYPE_STRING, {.str =
NULL }, 0, 0,
DEC},
323 {
"rtmp_swfverify",
"URL to player swf file, compute hash/size automatically. (unimplemented)",
OFFSET(swfverify),
AV_OPT_TYPE_STRING, {.str =
NULL }, 0, 0,
DEC},
331 #define RTMP_CLASS(flavor)\
332 static const AVClass lib ## flavor ## _class = {\
333 .class_name = "lib" #flavor " protocol",\
334 .item_name = av_default_item_name,\
336 .version = LIBAVUTIL_VERSION_INT,\
350 .priv_data_class = &librtmp_class,
365 .priv_data_class = &librtmpt_class,
380 .priv_data_class = &librtmpe_class,
395 .priv_data_class = &librtmpte_class,
410 .priv_data_class = &librtmps_class,