From patchwork Fri May 1 18:52:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: abalam X-Patchwork-Id: 19421 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 6E9F844BC7E for ; Fri, 1 May 2020 21:53:03 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4489B68C691; Fri, 1 May 2020 21:53:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from apsu.aewd.net (vps-c0f041f5.vps.ovh.net [51.83.98.39]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7B7D168B5E8 for ; Fri, 1 May 2020 21:52:56 +0300 (EEST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPA id 618F7817DE for ; Fri, 1 May 2020 20:52:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aewd.net; s=dkim; t=1588359175; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=r3CaWcqLwjYjM1lMSU3kYsLK1MB2AKtYZLHEdELlP5s=; b=jUvUXBAQi5vmDQwHf08ezq8xTjCur/pBdOzFmUkzXd5isv74qOQd8QumdSArast75QGHiR TP6nqN6XQBR7VICppL9KTNp9n3eK+XS7SqVryz0K1/y37GBWzp9aiavjlTqVoQ2c/+NB+q FVy91tuJL9w3uanX39K3d0V1bbIbbVmnH5nItGmhWcWJbEFinEqAvN5TF3jGYzThS5tRTu a/O+81WWw9Bvb7rP6jvYMpbjCBixxbQl/ATavl2S7piTE5AprfapiEM5COFt6WFiTppsaG +jRvB/COs0OcZebERH8D5d+buu3cLiZevwtaJe8MR0zLvxrKP4ZWTyEqteqI5Q== From: "abalam" To: ffmpeg-devel@ffmpeg.org User-Agent: SOGoMail 4.3.0 MIME-Version: 1.0 Date: Fri, 01 May 2020 20:52:55 +0200 Message-ID: <4d-5eac7000-7-385e7000@156260547> X-Last-TLS-Session-Version: None X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] =?utf-8?q?fix=3A=3F=3D=3D=3Futf-8=3Fq=3F_rtsp/transp?= =?utf-8?q?ort_parser_should_accept_comma_for_parameters?= X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" I needed this fix to make [Shinobi](https://github.com/ShinobiCCTV/Shinobi) works with recent chinese cameras. We can read that FFmpeg is perfectly following the [RTSP specs](https://tools.ietf.org/html/rfc2326#page-58) :  `Transports are comma separated, listed in order of preference. Parameters may be added to each transport, separated by a semicolon.` But considering: - VLC is working smart with not perfect cameras ; - RTSP module in FFmpeg is not programmed to handle more than one transport ;  => this fix could be useful to anyone I also think this fix might be improved by a better scan of parameters if ffmpeg wants to handle more than one transport. Details:  I'm using [Shinobi](https://github.com/ShinobiCCTV/Shinobi) to record cameras rtsp streams For several cameras, cheap chinese ones, VLC is working to get stream but FFmpeg always crashes after it receives the RTSP transports parameters available. `Transport: RTP/AVP;unicast;mode=PLAY;source=192.168.66.164;client_port=11658-11659;server_port=40000-40001,ssrc=FFFFCCCC` After debugging the source code, it appears that FFmpeg is not considering that a comma `,` before `ssrc` is a correct separator and think it's a second transport. Then it crashes because RTSP don't want to accept more than one transport. ( This was closed PR https://github.com/FFmpeg/FFmpeg/pull/336 ) Thank you for having read, Keep good work and have a nice day! ---  libavformat/rtsp.c | 4 +---  1 file changed, 1 insertion(+), 3 deletions(-) -- 2.21.1 (Apple Git-122.3) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index b2b3f32011..f77de10119 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -1001,11 +1001,9 @@ static void rtsp_parse_transport(AVFormatContext *s,              while (*p != ';' && *p != '\0' && *p != ',')                  p++; -            if (*p == ';') +            if (*p == ';' || *p == ',')                  p++;          } -        if (*p == ',') -            p++;          reply->nb_transports++;          if (reply->nb_transports >= RTSP_MAX_TRANSPORTS)