[FFmpeg-cvslog] rtmp: Set correct message stream id when writing as server

Jonathan Murray git at videolan.org
Wed Feb 26 16:18:42 EET 2025


ffmpeg | branch: master | Jonathan Murray <jonathanmurray at spotify.com> | Thu Mar 31 16:23:17 2022 +0200| [98d97bb33b2a54265b3d41838b2fb64310360e22] | committer: Tomas Härdin

rtmp: Set correct message stream id when writing as server

rtmp_write is used both for writing outputs as a server. The
rt->listen flag determines which mode we're running in.

Previously, when running as a server, the message stream id would
always be set to 0 for media/metadata messages. This is surprising
given that we have both responded to "createStream()" with a value
of 1 and sent a "Stream Begin 1" to the client. Furthermore, some
client libraries (Red5) seem to trip up on receiving
"@setDataFrame" on stream 0 (and may be correct to assume that
this message would be sent on stream 1).

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

 libavformat/rtmpproto.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 4095ae9421..846376e668 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -3049,7 +3049,12 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, int size)
                                              pkttype, ts, pktsize)) < 0)
                 return ret;
 
-            rt->out_pkt.extra = rt->stream_id;
+            // If rt->listen, then we're running as a a server and should
+            // use the ID that we've sent in Stream Begin and in the
+            // _result to createStream.
+            // Otherwise, we're running as a client and should use the ID
+            // that we've received in the createStream from the server.
+            rt->out_pkt.extra = (rt->listen) ? rt->nb_streamid : rt->stream_id;
             rt->flv_data = rt->out_pkt.data;
         }
 



More information about the ffmpeg-cvslog mailing list