[FFmpeg-devel] [PATCH 2/2] mmst: don't look for a hr field in ping messages

Francesco Cosoleto cosoleto
Sat Feb 12 11:17:21 CET 2011


This fixes premature closure of connection with mmst streams, as a
ping message from server get ignored.

According to MMS specification, in case of a SC_PKT_KEEPALIVE server
message, bytes after the packet id don't contain a 'hr' field, should
be set to 0, and must be ignored by the client.

In the wild, even servers that initially send ping messages with the
specified data set to 0, can change the behaviour after some minutes,
transmitting some arbitrary values[1]. When this occurs, it makes the
previous code to interpret the data as an error code and returns
without managing the ping.

[1] mmst://wm.bbc.co.uk/wms/bbc7coyopa/bbc7_-_friday_0430.wma

Signed-off-by: Francesco Cosoleto <cosoleto at gmail.com>
---
 libavformat/mmst.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavformat/mmst.c b/libavformat/mmst.c
index ad87bbf..10d30ff 100644
--- a/libavformat/mmst.c
+++ b/libavformat/mmst.c
@@ -290,6 +290,10 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
                 return read_result < 0 ? read_result : AVERROR_IO;
             }
             packet_type= AV_RL16(mms->in_buffer+36);
+            if(packet_type == SC_PKT_KEEPALIVE) {
+                send_keepalive_packet(mmst);
+                continue;
+            }
             hr = AV_RL32(mms->in_buffer + 40);
             if (hr) {
                 av_log(NULL, AV_LOG_ERROR,
@@ -356,10 +360,7 @@ static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
         }
 
         // preprocess some packet type
-        if(packet_type == SC_PKT_KEEPALIVE) {
-            send_keepalive_packet(mmst);
-            continue;
-        } else if(packet_type == SC_PKT_STREAM_CHANGING) {
+        if(packet_type == SC_PKT_STREAM_CHANGING) {
             handle_packet_stream_changing_type(mmst);
         } else if(packet_type == SC_PKT_ASF_MEDIA) {
             pad_media_packet(mms);
-- 
1.7.1




More information about the ffmpeg-devel mailing list