rtp: Fix ff_rtp_get_payload_type

Message ID 1318872590-78125-1-git-send-email-martin@martin.st
State Committed
Commit 2e69dd66b6e47ba33f9bb6696e9c587d3057034c
Headers show

Commit Message

Martin Storsjö Oct. 17, 2011, 5:29 p.m.
It was broken in 3b3ea34655db02d9cd9ea1a4122e920a7fdec602
"Remove all uses of deprecated AVOptions API", where any
presence of a payload_type AVOption caused its value to
be returned, even if it wasn't set (and thus had the default
-1 value).

This caused the RTP muxer to be broken.
---
 libavformat/rtp.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Comments

Ronald Bultje Oct. 17, 2011, 5:37 p.m. | #1
Hi,

On Mon, Oct 17, 2011 at 10:29 AM, Martin Storsjö <martin@martin.st> wrote:
> It was broken in 3b3ea34655db02d9cd9ea1a4122e920a7fdec602
> "Remove all uses of deprecated AVOptions API", where any
> presence of a payload_type AVOption caused its value to
> be returned, even if it wasn't set (and thus had the default
> -1 value).
>
> This caused the RTP muxer to be broken.
> ---
>  libavformat/rtp.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/libavformat/rtp.c b/libavformat/rtp.c
> index 4be845a..b6b4b72 100644
> --- a/libavformat/rtp.c
> +++ b/libavformat/rtp.c
> @@ -98,7 +98,8 @@ int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *codec)
>     /* Was the payload type already specified for the RTP muxer? */
>     if (ofmt && ofmt->priv_class) {
>         int64_t payload_type;
> -        if (av_opt_get_int(fmt->priv_data, "payload_type", 0, &payload_type) >= 0)
> +        if (av_opt_get_int(fmt->priv_data, "payload_type", 0, &payload_type) >= 0 &&
> +            payload_type >= 0)
>             return (int)payload_type;
>     }

OK.

Ronald

Patch

diff --git a/libavformat/rtp.c b/libavformat/rtp.c
index 4be845a..b6b4b72 100644
--- a/libavformat/rtp.c
+++ b/libavformat/rtp.c
@@ -98,7 +98,8 @@  int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *codec)
     /* Was the payload type already specified for the RTP muxer? */
     if (ofmt && ofmt->priv_class) {
         int64_t payload_type;
-        if (av_opt_get_int(fmt->priv_data, "payload_type", 0, &payload_type) >= 0)
+        if (av_opt_get_int(fmt->priv_data, "payload_type", 0, &payload_type) >= 0 &&
+            payload_type >= 0)
             return (int)payload_type;
     }