Makes the two protocols nearly seamless.
---
It isn't complete and some options might be mapped in better ways.
libavformat/librtmp.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 111 insertions(+), 3 deletions(-)
diff --git a/libavformat/librtmp.c b/libavformat/librtmp.c
index 7133bd6..1996ba9 100644
--- a/libavformat/librtmp.c
+++ b/libavformat/librtmp.c
@@ -37,7 +37,21 @@ typedef struct LibRTMPContext {
const AVClass *class;
RTMP rtmp;
char *app;
+ char *conn;
+ char *subscribe;
char *playpath;
+ char *tcurl; ///< url of the target stream
+ char *flashver; ///< version of the flash plugin
+ char *swfhash; ///< SHA256 hash of the decompressed SWF
file (32 bytes)
+ char *swfurl;
+ char *swfverify;
+ char *pageurl;
+ char *client_buffer_time;
+ int flush_interval;
+ int swfsize;
+ int live;
+ int listen;
+ int listen_timeout;
} LibRTMPContext;
static void rtmp_log(int level, const char *fmt, va_list args)
@@ -99,7 +113,40 @@ static int rtmp_open(URLContext *s, const char *uri, int
flags)
if (ctx->app || ctx->playpath) {
int len = strlen(s->filename) + 1;
if (ctx->app) len += strlen(ctx->app) + sizeof(" app=");
- if (ctx->playpath) len += strlen(ctx->playpath) + sizeof(" playpath=");
+ if (ctx->tcurl) len += strlen(ctx->tcurl) + sizeof(" tcUrl=");
+ if (ctx->pageurl) len += strlen(ctx->pageurl) + sizeof(" pageUrl=");
+ if (ctx->swfurl) len += strlen(ctx->swfurl) + sizeof(" swfUrl=");
+ if (ctx->flashver) len += strlen(ctx->flashver) + sizeof(" flashver=");
+
+ if (ctx->conn) {
+ char *sep, *p = ctx->conn;
+ int options = 0;
+
+ while (p) {
+ options++;
+ p += strspn(p, " ");
+ if (!*p)
+ break;
+ sep = strchr(p, ' ');
+ if (sep)
+ p = sep + 1;
+ else
+ break;
+ }
+ len += options * sizeof(" conn=");
+ len += strlen(ctx->conn);
+ }
+
+ if (ctx->playpath)
+ len += strlen(ctx->playpath) + sizeof(" playpath=");
+ if (ctx->live)
+ len += sizeof(" live=1");
+ if (ctx->subscribe)
+ len += strlen(ctx->subscribe) + sizeof(" subscribe=");
+
+ if (ctx->client_buffer_time)
+ len += strlen(ctx->client_buffer_time) + sizeof(" buffer=");
+
if (!(filename = av_malloc(len)))
return AVERROR(ENOMEM);
@@ -109,10 +156,53 @@ static int rtmp_open(URLContext *s, const char *uri, int
flags)
av_strlcat(filename, " app=", len);
av_strlcat(filename, ctx->app, len);
}
+ if (ctx->tcurl) {
+ av_strlcat(filename, " tcUrl=", len);
+ av_strlcat(filename, ctx->tcurl, len);
+ }
+ if (ctx->pageurl) {
+ av_strlcat(filename, " pageUrl=", len);
+ av_strlcat(filename, ctx->pageurl, len);
+ }
+ if (ctx->swfurl) {
+ av_strlcat(filename, " swfUrl=", len);
+ av_strlcat(filename, ctx->pageurl, len);
+ }
+ if (ctx->flashver) {
+ av_strlcat(filename, " flashVer=", len);
+ av_strlcat(filename, ctx->flashver, len);
+ }
+ if (ctx->conn) {
+ char *sep, *p = ctx->conn;
+ while (p) {
+ av_strlcat(filename, " conn=", len);
+ p += strspn(p, " ");
+ if (!*p)
+ break;
+ sep = strchr(p, ' ');
+ if (sep)
+ *sep = '\0';
+ av_strlcat(filename, p, len);
+
+ if (sep)
+ p = sep + 1;
+ }
+ }
+
if (ctx->playpath) {
av_strlcat(filename, " playpath=", len);
av_strlcat(filename, ctx->playpath, len);
}
+ if (ctx->live)
+ av_strlcat(filename, " live=1", len);
+ if (ctx->subscribe) {
+ av_strlcat(filename, " subscribe=", len);
+ av_strlcat(filename, ctx->subscribe, len);
+ }
+ if (ctx->client_buffer_time) {
+ av_strlcat(filename, " buffer=", len);
+ av_strlcat(filename, ctx->client_buffer_time, len);
+ }
}
RTMP_Init(r);
@@ -194,8 +284,26 @@ static int rtmp_get_file_handle(URLContext *s)
#define DEC AV_OPT_FLAG_DECODING_PARAM
#define ENC AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
- {"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_playpath", "Stream identifier to play or to publish",
OFFSET(playpath), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
+ {"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_flush_interval", "Number of packets flushed in the same request
(RTMPT only).", OFFSET(flush_interval), AV_OPT_TYPE_INT, {.i64 = 10}, 0,
INT_MAX, ENC},
+ {"rtmp_live", "Specify that the media is a live stream.", OFFSET(live),
AV_OPT_TYPE_INT, {.i64 = -2}, INT_MIN, INT_MAX, DEC, "rtmp_live"},
+ {"any", "both", 0, AV_OPT_TYPE_CONST, {.i64 = -2}, 0, 0, DEC, "rtmp_live"},
+ {"live", "live stream", 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, DEC,
"rtmp_live"},
+ {"recorded", "recorded stream", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0,
DEC, "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_swfhash", "SHA256 hash of the decompressed SWF file (32 bytes).
(unimplemented)", OFFSET(swfhash), AV_OPT_TYPE_BINARY, .flags = DEC},
+ {"rtmp_swfsize", "Size of the decompressed SWF file, required for
SWFVerification. (unimplemented)", OFFSET(swfsize), AV_OPT_TYPE_INT, {.i64 =
0}, 0, INT_MAX, 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},
+ {"rtmp_listen", "Listen for incoming rtmp connections (unimplemented)",
OFFSET(listen), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC,
"rtmp_listen" },
+ {"listen", "Listen for incoming rtmp connections (unimplemented)",
OFFSET(listen), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC,
"rtmp_listen" },
+ {"timeout", "Maximum timeout (in seconds) to wait for incoming
connections. (unimplemented)", OFFSET(listen_timeout), AV_OPT_TYPE_INT, {.i64
= -1}, INT_MIN, INT_MAX, DEC, "rtmp_listen" },
{ NULL },
};
--
1.8.5.2 (Apple Git-48)
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel