[FFmpeg-cvslog] avformat/rtmpproto: send proper status for response to play command

Marton Balint git at videolan.org
Fri Apr 22 23:11:31 EEST 2022


ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Thu Apr 14 22:40:28 2022 +0200| [58454749a7e6b854d0120a2f58dff40a3ee7bf40] | committer: Marton Balint

avformat/rtmpproto: send proper status for response to play command

This fixes referencing the uninitialized filename variable.

Fixes ticket #9711.

Signed-off-by: Marton Balint <cus at passwd.hu>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=58454749a7e6b854d0120a2f58dff40a3ee7bf40
---

 libavformat/rtmpproto.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index f97e3c3b8e..f0ef223f05 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -1857,11 +1857,10 @@ static int write_begin(URLContext *s)
 }
 
 static int write_status(URLContext *s, RTMPPacket *pkt,
-                        const char *status, const char *filename)
+                        const char *status, const char *description, const char *details)
 {
     RTMPContext *rt = s->priv_data;
     RTMPPacket spkt = { 0 };
-    char statusmsg[128];
     uint8_t *pp;
     int ret;
 
@@ -1884,11 +1883,11 @@ static int write_status(URLContext *s, RTMPPacket *pkt,
     ff_amf_write_field_name(&pp, "code");
     ff_amf_write_string(&pp, status);
     ff_amf_write_field_name(&pp, "description");
-    snprintf(statusmsg, sizeof(statusmsg),
-             "%s is now published", filename);
-    ff_amf_write_string(&pp, statusmsg);
-    ff_amf_write_field_name(&pp, "details");
-    ff_amf_write_string(&pp, filename);
+    ff_amf_write_string(&pp, description);
+    if (details) {
+        ff_amf_write_field_name(&pp, "details");
+        ff_amf_write_string(&pp, details);
+    }
     ff_amf_write_object_end(&pp);
 
     spkt.size = pp - spkt.data;
@@ -1964,20 +1963,22 @@ static int send_invoke_response(URLContext *s, RTMPPacket *pkt)
         pp = spkt.data;
         ff_amf_write_string(&pp, "onFCPublish");
     } else if (!strcmp(command, "publish")) {
+        char statusmsg[128];
+        snprintf(statusmsg, sizeof(statusmsg), "%s is now published", filename);
         ret = write_begin(s);
         if (ret < 0)
             return ret;
 
         // Send onStatus(NetStream.Publish.Start)
         return write_status(s, pkt, "NetStream.Publish.Start",
-                           filename);
+                            statusmsg, filename);
     } else if (!strcmp(command, "play")) {
         ret = write_begin(s);
         if (ret < 0)
             return ret;
         rt->state = STATE_SENDING;
         return write_status(s, pkt, "NetStream.Play.Start",
-                            filename);
+                            "playing stream", NULL);
     } else {
         if ((ret = ff_rtmp_packet_create(&spkt, RTMP_SYSTEM_CHANNEL,
                                          RTMP_PT_INVOKE, 0,



More information about the ffmpeg-cvslog mailing list