[rtmpdump] r521 - in trunk/librtmp: rtmp.c rtmp.h
hyc
subversion at mplayerhq.hu
Tue Jun 29 03:31:18 CEST 2010
Author: hyc
Date: Tue Jun 29 03:31:17 2010
New Revision: 521
Log:
Fix tcUrl generation, free it on close if needed
Modified:
trunk/librtmp/rtmp.c
trunk/librtmp/rtmp.h
Modified: trunk/librtmp/rtmp.c
==============================================================================
--- trunk/librtmp/rtmp.c Tue Jun 29 03:09:21 2010 (r520)
+++ trunk/librtmp/rtmp.c Tue Jun 29 03:31:17 2010 (r521)
@@ -654,12 +654,13 @@ int RTMP_SetupURL(RTMP *r, char *url)
{
AVal opt, arg;
char *p1, *p2, *ptr = strchr(url, ' ');
- int ret;
+ int ret, len;
unsigned int port = 0;
if (ptr)
*ptr = '\0';
+ len = strlen(url);
ret = RTMP_ParseURL(url, &r->Link.protocol, &r->Link.hostname,
&port, &r->Link.playpath0, &r->Link.app);
if (!ret)
@@ -714,10 +715,28 @@ int RTMP_SetupURL(RTMP *r, char *url)
if (!r->Link.tcUrl.av_len)
{
r->Link.tcUrl.av_val = url;
- if (r->Link.app.av_len)
- r->Link.tcUrl.av_len = r->Link.app.av_len + (r->Link.app.av_val - url);
- else
+ if (r->Link.app.av_len) {
+ if (r->Link.app.av_val < url + len)
+ {
+ /* if app is part of original url, just use it */
+ r->Link.tcUrl.av_len = r->Link.app.av_len + (r->Link.app.av_val - url);
+ }
+ else
+ {
+ len = r->Link.hostname.av_len + r->Link.app.av_len +
+ sizeof("rtmpte://65535/");
+ r->Link.tcUrl.av_val = malloc(len);
+ r->Link.tcUrl.av_len = snprintf(r->Link.tcUrl.av_val, len,
+ "%s://%.*s:%d/%.*s",
+ RTMPProtocolStringsLower[r->Link.protocol],
+ r->Link.hostname.av_len, r->Link.hostname.av_val,
+ r->Link.port,
+ r->Link.app.av_len, r->Link.app.av_val);
+ r->Link.lFlags |= RTMP_LF_FTCU;
+ }
+ } else {
r->Link.tcUrl.av_len = strlen(url);
+ }
}
#ifdef CRYPTO
@@ -3428,6 +3447,13 @@ RTMP_Close(RTMP *r)
free(r->Link.playpath0.av_val);
r->Link.playpath0.av_val = NULL;
+ if (r->Link.lFlags & RTMP_LF_FTCU)
+ {
+ free(r->Link.tcUrl.av_val);
+ r->Link.tcUrl.av_val = NULL;
+ r->Link.lFlags ^= RTMP_LF_FTCU;
+ }
+
#ifdef CRYPTO
if (r->Link.dh)
{
Modified: trunk/librtmp/rtmp.h
==============================================================================
--- trunk/librtmp/rtmp.h Tue Jun 29 03:09:21 2010 (r520)
+++ trunk/librtmp/rtmp.h Tue Jun 29 03:31:17 2010 (r521)
@@ -147,6 +147,7 @@ extern "C"
#define RTMP_LF_SWFV 0x0004 /* do SWF verification */
#define RTMP_LF_PLST 0x0008 /* send playlist before play */
#define RTMP_LF_BUFX 0x0010 /* toggle stream on BufferEmpty msg */
+#define RTMP_LF_FTCU 0x0020 /* free tcUrl on close */
int lFlags;
int swfAge;
More information about the rtmpdump
mailing list