Sometimes the URL parser cannot determine the app name automatically,
so it must be given explicitly using this option.
---
 libavformat/rtmpproto.c |   23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index a6917ce..e6b2dd2 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -805,7 +805,7 @@ static int rtmp_close(URLContext *h)
 static int rtmp_open(URLContext *s, const char *uri, int flags)
 {
     RTMPContext *rt = s->priv_data;
-    char proto[8], hostname[256], path[1024], *fname;
+    char proto[8], hostname[256], path[2048], *fname, *params, *param;
     uint8_t buf[2048];
     int port;
     int ret;
@@ -831,6 +831,16 @@ static int rtmp_open(URLContext *s, const char *uri, int 
flags)
 
     rt->chunk_size = 128;
     rt->state = STATE_HANDSHAKED;
+
+    // Extract parameters from path.
+    params = strchr(path, ' ');
+    if (params) {
+        while (*params == ' ') {
+            *params = 0;
+            ++params;
+        }
+    }
+
     //extract "app" part from path
     if (!strncmp(path, "/ondemand/", 10)) {
         fname = path + 10;
@@ -861,6 +871,17 @@ static int rtmp_open(URLContext *s, const char *uri, int 
flags)
     }
     strncat(rt->playpath, fname, sizeof(rt->playpath) - 5);
 
+    // Parse parameters.
+    param = strtok(params, " ");
+    while (param != NULL) {
+        if (!strncmp(param, "app=", 4)) {
+            // Override the name of application.
+            param += 4;
+            av_strlcpy(rt->app, param, strlen(param) + 1);
+        }
+        param = strtok(NULL, " ");
+    }
+
     rt->client_report_size = 1048576;
     rt->bytes_read = 0;
     rt->last_bytes_read = 0;
-- 
1.7.9.4

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to