[rtmpdump] [PATCH] Make rtmpdump handle full RTMP URLs with "-i"
Bastien Nocera
hadess at hadess.net
Wed Jul 18 23:52:07 CEST 2012
or --url. The library already can handle those, so it makes debugging
easier for users of the library.
---
rtmpdump.c | 36 +++++++++++++++++++++++++++---------
1 file changed, 27 insertions(+), 9 deletions(-)
diff --git a/rtmpdump.c b/rtmpdump.c
index 34bfdba..7827eae 100644
--- a/rtmpdump.c
+++ b/rtmpdump.c
@@ -638,6 +638,8 @@ void usage(char *prog)
("\n%s: This program dumps the media content streamed over RTMP.\n\n", prog);
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");
@@ -755,6 +757,7 @@ main(int argc, char **argv)
uint32_t dStopOffset = 0;
RTMP rtmp = { 0 };
+ AVal fullUrl = { 0, 0 };
AVal swfUrl = { 0, 0 };
AVal tcUrl = { 0, 0 };
AVal pageUrl = { 0, 0 };
@@ -817,6 +820,7 @@ main(int argc, char **argv)
{"protocol", 1, NULL, 'l'},
{"playpath", 1, NULL, 'y'},
{"playlist", 0, NULL, 'Y'},
+ {"url", 1, NULL, 'i'},
{"rtmp", 1, NULL, 'r'},
{"swfUrl", 1, NULL, 's'},
{"tcUrl", 1, NULL, 't'},
@@ -851,7 +855,7 @@ main(int argc, char **argv)
while ((opt =
getopt_long(argc, argv,
- "hVveqzr:s:t:p:a:b:f:o:u:C:n:c:l:y:Ym:k:d:A:B:T:w:x:W:X:S:#j:",
+ "hVveqzr:s:t:i:p:a:b:f:o:u:C:n:c:l:y:Ym:k:d:A:B:T:w:x:W:X:S:#j:",
longopts, NULL)) != -1)
{
switch (opt)
@@ -991,6 +995,9 @@ main(int argc, char **argv)
}
break;
}
+ case 'i':
+ STR2AVAL(fullUrl, optarg);
+ break;
case 's':
STR2AVAL(swfUrl, optarg);
break;
@@ -1069,32 +1076,32 @@ main(int argc, char **argv)
}
}
- if (!hostname.av_len)
+ if (!hostname.av_len && !fullUrl.av_len)
{
RTMP_Log(RTMP_LOGERROR,
"You must specify a hostname (--host) or url (-r \"rtmp://host[:port]/playpath\") containing a hostname");
return RD_FAILED;
}
- if (playpath.av_len == 0)
+ if (playpath.av_len == 0 && !fullUrl.av_len)
{
RTMP_Log(RTMP_LOGERROR,
"You must specify a playpath (--playpath) or url (-r \"rtmp://host[:port]/playpath\") containing a playpath");
return RD_FAILED;
}
- if (protocol == RTMP_PROTOCOL_UNDEFINED)
+ if (protocol == RTMP_PROTOCOL_UNDEFINED && !fullUrl.av_len)
{
RTMP_Log(RTMP_LOGWARNING,
"You haven't specified a protocol (--protocol) or rtmp url (-r), using default protocol RTMP");
protocol = RTMP_PROTOCOL_RTMP;
}
- if (port == -1)
+ if (port == -1 && !fullUrl.av_len)
{
RTMP_Log(RTMP_LOGWARNING,
"You haven't specified a port (--port) or rtmp url (-r), using default port 1935");
port = 0;
}
- if (port == 0)
+ if (port == 0 && !fullUrl.av_len)
{
if (protocol & RTMP_FEATURE_SSL)
port = 443;
@@ -1176,9 +1183,20 @@ main(int argc, char **argv)
}
}
- RTMP_SetupStream(&rtmp, protocol, &hostname, port, &sockshost, &playpath,
- &tcUrl, &swfUrl, &pageUrl, &app, &auth, &swfHash, swfSize,
- &flashVer, &subscribepath, &usherToken, dSeek, dStopOffset, bLiveStream, timeout);
+ if (!fullUrl.av_len)
+ {
+ RTMP_SetupStream(&rtmp, protocol, &hostname, port, &sockshost, &playpath,
+ &tcUrl, &swfUrl, &pageUrl, &app, &auth, &swfHash, swfSize,
+ &flashVer, &subscribepath, &usherToken, dSeek, dStopOffset, bLiveStream, timeout);
+ }
+ else
+ {
+ if (RTMP_SetupURL(&rtmp, fullUrl.av_val) == FALSE)
+ {
+ RTMP_Log(RTMP_LOGERROR, "Couldn't parse URL: %s", fullUrl.av_val);
+ return RD_FAILED;
+ }
+ }
/* Try to keep the stream moving if it pauses on us */
if (!bLiveStream && !(protocol & RTMP_FEATURE_HTTP))
--
1.7.10.2
More information about the rtmpdump
mailing list