This option is the stream identifier to play or to publish. Sometimes
the URL parser cannot determine the correct playpath automatically,
so it must be given explicitly using this option (ie. -playpath).
---
 libavformat/rtmpproto.c |   26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 946eaea..2fc16ed 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -43,6 +43,7 @@
 //#define DEBUG
 
 #define APP_MAX_LENGTH 128
+#define PLAYPATH_MAX_LENGTH 256
 
 /** RTMP protocol handler state */
 typedef enum {
@@ -64,7 +65,7 @@ typedef struct RTMPContext {
     RTMPPacket    prev_pkt[2][RTMP_CHANNELS]; ///< packet history used when 
reading and sending packets
     int           chunk_size;                 ///< size of the chunks RTMP 
packets are divided into
     int           is_input;                   ///< input/output flag
-    char          playpath[256];              ///< path to filename to play 
(with possible "mp4:" prefix)
+    char          *playpath;                  ///< stream identifier to play 
(with possible "mp4:" prefix)
     char          *app;                       ///< name of application
     ClientState   state;                      ///< current state
     int           main_channel_id;            ///< an additional channel ID 
which is used for some invocations
@@ -890,14 +891,22 @@ static int rtmp_open(URLContext *s, const char *uri, int 
flags)
         rt->app = old_app;
     }
 
-    if (!strchr(fname, ':') &&
-        (!strcmp(fname + strlen(fname) - 4, ".f4v") ||
-         !strcmp(fname + strlen(fname) - 4, ".mp4"))) {
-        memcpy(rt->playpath, "mp4:", 5);
-    } else {
-        rt->playpath[0] = 0;
+    if (!rt->playpath) {
+        rt->playpath = av_malloc(PLAYPATH_MAX_LENGTH);
+        if (!rt->playpath) {
+            rtmp_close(s);
+            return AVERROR(ENOMEM);
+        }
+
+        if (!strchr(fname, ':') &&
+            (!strcmp(fname + strlen(fname) - 4, ".f4v") ||
+             !strcmp(fname + strlen(fname) - 4, ".mp4"))) {
+            memcpy(rt->playpath, "mp4:", 5);
+        } else {
+            rt->playpath[0] = 0;
+        }
+        strncat(rt->playpath, fname, strlen(rt->playpath) - 5);
     }
-    strncat(rt->playpath, fname, sizeof(rt->playpath) - 5);
 
     rt->client_report_size = 1048576;
     rt->bytes_read = 0;
@@ -1040,6 +1049,7 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, 
int size)
 
 static const AVOption rtmp_options[] = {
     {"application", "Name of application to connect to on the RTMP server", 
OFFSET(app), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC},
+    {"playpath", "Stream identifier to play or to publish", OFFSET(playpath), 
AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC},
     { NULL },
 };
 
-- 
1.7.10

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

Reply via email to