[rtmpdump] [PATCH] Make rtmpgw handle full RTMP URLs with "-i"
Bastien Nocera
hadess at hadess.net
Thu Jul 19 18:22:03 CEST 2012
or --url. Just as rtmpdump and librtmp already can.
---
rtmpgw.c | 36 +++++++++++++++++++++++++++---------
1 file changed, 27 insertions(+), 9 deletions(-)
diff --git a/rtmpgw.c b/rtmpgw.c
index 0cf56bb..ab255d4 100644
--- a/rtmpgw.c
+++ b/rtmpgw.c
@@ -85,6 +85,7 @@ typedef struct
uint32_t bufferTime;
char *rtmpurl;
+ AVal fullUrl;
AVal playpath;
AVal swfUrl;
AVal tcUrl;
@@ -469,14 +470,14 @@ void processTCPrequest(STREAMING_SERVER * server, // server socket and state (ou
}
// do necessary checks right here to make sure the combined request of default values and GET parameters is correct
- if (!req.hostname.av_len)
+ if (!req.hostname.av_len && !req.fullUrl.av_len)
{
RTMP_Log(RTMP_LOGERROR,
"You must specify a hostname (--host) or url (-r \"rtmp://host[:port]/playpath\") containing a hostname");
status = "400 Missing Hostname";
goto filenotfound;
}
- if (req.playpath.av_len == 0)
+ if (req.playpath.av_len == 0 && !req.fullUrl.av_len)
{
RTMP_Log(RTMP_LOGERROR,
"You must specify a playpath (--playpath) or url (-r \"rtmp://host[:port]/playpath\") containing a playpath");
@@ -484,19 +485,19 @@ void processTCPrequest(STREAMING_SERVER * server, // server socket and state (ou
goto filenotfound;;
}
- if (req.protocol == RTMP_PROTOCOL_UNDEFINED)
+ if (req.protocol == RTMP_PROTOCOL_UNDEFINED && !req.fullUrl.av_len)
{
RTMP_Log(RTMP_LOGWARNING,
"You haven't specified a protocol (--protocol) or rtmp url (-r), using default protocol RTMP");
req.protocol = RTMP_PROTOCOL_RTMP;
}
- if (req.rtmpport == -1)
+ if (req.rtmpport == -1 && !req.fullUrl.av_len)
{
RTMP_Log(RTMP_LOGWARNING,
"You haven't specified a port (--port) or rtmp url (-r), using default port");
req.rtmpport = 0;
}
- if (req.rtmpport == 0)
+ if (req.rtmpport == 0 && !req.fullUrl.av_len)
{
if (req.protocol & RTMP_FEATURE_SSL)
req.rtmpport = 443;
@@ -552,9 +553,20 @@ void processTCPrequest(STREAMING_SERVER * server, // server socket and state (ou
RTMP_Log(RTMP_LOGDEBUG, "Setting buffer time to: %dms", req.bufferTime);
RTMP_Init(&rtmp);
RTMP_SetBufferMS(&rtmp, req.bufferTime);
- RTMP_SetupStream(&rtmp, req.protocol, &req.hostname, req.rtmpport, &req.sockshost,
- &req.playpath, &req.tcUrl, &req.swfUrl, &req.pageUrl, &req.app, &req.auth, &req.swfHash, req.swfSize, &req.flashVer, &req.subscribepath, &req.usherToken, dSeek, req.dStopOffset,
- req.bLiveStream, req.timeout);
+ if (!req.fullUrl.av_len)
+ {
+ RTMP_SetupStream(&rtmp, req.protocol, &req.hostname, req.rtmpport, &req.sockshost,
+ &req.playpath, &req.tcUrl, &req.swfUrl, &req.pageUrl, &req.app, &req.auth, &req.swfHash, req.swfSize, &req.flashVer, &req.subscribepath, &req.usherToken, dSeek, req.dStopOffset,
+ req.bLiveStream, req.timeout);
+ }
+ else
+ {
+ if (RTMP_SetupURL(&rtmp, req.fullUrl.av_val) == FALSE)
+ {
+ RTMP_Log(RTMP_LOGERROR, "Couldn't parse URL: %s", req.fullUrl.av_val);
+ return;
+ }
+ }
/* backward compatibility, we always sent this as true before */
if (req.auth.av_len)
rtmp.Link.lFlags |= RTMP_LF_AUTH;
@@ -908,6 +920,9 @@ ParseOption(char opt, char *arg, RTMP_REQUEST * req)
}
break;
}
+ case 'i':
+ STR2AVAL(req->fullUrl, optarg);
+ break;
case 's':
STR2AVAL(req->swfUrl, arg);
break;
@@ -993,6 +1008,7 @@ main(int argc, char **argv)
int opt;
struct option longopts[] = {
{"help", 0, NULL, 'h'},
+ {"url", 1, NULL, 'i'},
{"host", 1, NULL, 'n'},
{"port", 1, NULL, 'c'},
{"socks", 1, NULL, 'S'},
@@ -1040,7 +1056,7 @@ main(int argc, char **argv)
while ((opt =
getopt_long(argc, argv,
- "hvqVzr:s:t:p:a:f:u:n:c:l:y:m:d:D:A:B:T:g:w:x:W:X:S:j:", longopts,
+ "hvqVzr:s:t:i:p:a:f:u:n:c:l:y:m:d:D:A:B:T:g:w:x:W:X:S:j:", longopts,
NULL)) != -1)
{
switch (opt)
@@ -1050,6 +1066,8 @@ main(int argc, char **argv)
("\nThis program serves media content streamed from RTMP onto HTTP.\n\n");
RTMP_LogPrintf("--help|-h Prints this help screen.\n");
RTMP_LogPrintf
+ ("--url|-i url URL with options included (e.g. rtmp://host[:port]/path swfUrl=url tcUrl=url)\n");
+ RTMP_LogPrintf
("--rtmp|-r url URL (e.g. rtmp://host[:port]/path)\n");
RTMP_LogPrintf
("--host|-n hostname Overrides the hostname in the rtmp url\n");
--
1.7.10.2
More information about the rtmpdump
mailing list