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

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index a6917ce..dda8223 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -806,6 +806,7 @@ 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 *params, *param, *saveptr;
     uint8_t buf[2048];
     int port;
     int ret;
@@ -831,6 +832,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 +872,19 @@ static int rtmp_open(URLContext *s, const char *uri, int 
flags)
     }
     strncat(rt->playpath, fname, sizeof(rt->playpath) - 5);
 
+    // Parse parameters.
+    if (params) {
+        param = strtok_r(params, " ", &saveptr);
+        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_r(NULL, " ", &saveptr);
+        }
+    }
+
     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