Module: libav
Branch: master
Commit: b3b175120151b9d39f05a7e24e322a70ab835138

Author:    Samuel Pitoiset <samuel.pitoi...@gmail.com>
Committer: Martin Storsjö <mar...@martin.st>
Date:      Sun Apr 15 21:50:50 2012 +0200

rtmp: Support 'rtmp_playpath', an option which overrides the stream identifier

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. -rtmp_playpath).

Signed-off-by: Martin Storsjö <mar...@martin.st>

---

 libavformat/rtmpproto.c |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 1d27c6f..9cdb639 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, PLAYPATH_MAX_LENGTH - 5);
     }
-    strncat(rt->playpath, fname, sizeof(rt->playpath) - 5);
 
     rt->client_report_size = 1048576;
     rt->bytes_read = 0;
@@ -1041,6 +1050,7 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, 
int size)
 
 static const AVOption rtmp_options[] = {
     {"rtmp_app", "Name of application to connect to on the RTMP server", 
OFFSET(app), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
+    {"rtmp_playpath", "Stream identifier to play or to publish", 
OFFSET(playpath), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
     { NULL },
 };
 

_______________________________________________
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits

Reply via email to