diff mbox series

[FFmpeg-devel,1/3] lavf/sdp: add const qualifiers where appropriate

Message ID 20211204173300.5742-1-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,1/3] lavf/sdp: add const qualifiers where appropriate | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Anton Khirnov Dec. 4, 2021, 5:32 p.m. UTC
Declares that these structs are read-only for this code.
---
 libavformat/internal.h |  2 +-
 libavformat/rtp.c      |  4 ++--
 libavformat/rtp.h      |  4 ++--
 libavformat/sdp.c      | 21 +++++++++++----------
 4 files changed, 16 insertions(+), 15 deletions(-)

Comments

Martin Storsjö Dec. 7, 2021, 9 a.m. UTC | #1
On Sat, 4 Dec 2021, Anton Khirnov wrote:

> Declares that these structs are read-only for this code.
> ---
> libavformat/internal.h |  2 +-
> libavformat/rtp.c      |  4 ++--
> libavformat/rtp.h      |  4 ++--
> libavformat/sdp.c      | 21 +++++++++++----------
> 4 files changed, 16 insertions(+), 15 deletions(-)

LGTM

// Martin
diff mbox series

Patch

diff --git a/libavformat/internal.h b/libavformat/internal.h
index 20e93d9267..528ff7e017 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -546,7 +546,7 @@  uint64_t ff_parse_ntp_time(uint64_t ntp_ts);
  * @param fmt the AVFormatContext, which might contain options modifying
  *            the generated SDP
  */
-void ff_sdp_write_media(char *buff, int size, AVStream *st, int idx,
+void ff_sdp_write_media(char *buff, int size, const AVStream *st, int idx,
                         const char *dest_addr, const char *dest_type,
                         int port, int ttl, AVFormatContext *fmt);
 
diff --git a/libavformat/rtp.c b/libavformat/rtp.c
index 38e234391b..c536a6f082 100644
--- a/libavformat/rtp.c
+++ b/libavformat/rtp.c
@@ -87,8 +87,8 @@  int ff_rtp_get_codec_info(AVCodecParameters *par, int payload_type)
     return -1;
 }
 
-int ff_rtp_get_payload_type(AVFormatContext *fmt,
-                            AVCodecParameters *par, int idx)
+int ff_rtp_get_payload_type(const AVFormatContext *fmt,
+                            const AVCodecParameters *par, int idx)
 {
     int i;
     const AVOutputFormat *ofmt = fmt ? fmt->oformat : NULL;
diff --git a/libavformat/rtp.h b/libavformat/rtp.h
index 389b824223..0c0e6089d7 100644
--- a/libavformat/rtp.h
+++ b/libavformat/rtp.h
@@ -38,8 +38,8 @@ 
  * @param idx   The stream index
  * @return The payload type (the 'PT' field in the RTP header).
  */
-int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecParameters *par,
-                            int idx);
+int ff_rtp_get_payload_type(const AVFormatContext *fmt,
+                            const AVCodecParameters *par, int idx);
 
 /**
  * Initialize a codec context based on the payload type.
diff --git a/libavformat/sdp.c b/libavformat/sdp.c
index a41c2cf655..ec5f7b763d 100644
--- a/libavformat/sdp.c
+++ b/libavformat/sdp.c
@@ -151,7 +151,7 @@  static int sdp_get_address(char *dest_addr, int size, int *ttl, const char *url)
 }
 
 #define MAX_PSET_SIZE 1024
-static char *extradata2psets(AVFormatContext *s, AVCodecParameters *par)
+static char *extradata2psets(AVFormatContext *s, const AVCodecParameters *par)
 {
     char *psets, *p;
     const uint8_t *r;
@@ -223,7 +223,7 @@  static char *extradata2psets(AVFormatContext *s, AVCodecParameters *par)
     return psets;
 }
 
-static char *extradata2psets_hevc(AVCodecParameters *par)
+static char *extradata2psets_hevc(const AVCodecParameters *par)
 {
     char *psets;
     uint8_t *extradata = par->extradata;
@@ -324,7 +324,7 @@  err:
     return NULL;
 }
 
-static char *extradata2config(AVFormatContext *s, AVCodecParameters *par)
+static char *extradata2config(AVFormatContext *s, const AVCodecParameters *par)
 {
     char *config;
 
@@ -345,7 +345,7 @@  static char *extradata2config(AVFormatContext *s, AVCodecParameters *par)
     return config;
 }
 
-static char *xiph_extradata2config(AVFormatContext *s, AVCodecParameters *par)
+static char *xiph_extradata2config(AVFormatContext *s, const AVCodecParameters *par)
 {
     uint8_t *config;
     char *encoded_config;
@@ -415,7 +415,7 @@  xiph_fail:
     return NULL;
 }
 
-static int latm_context2profilelevel(AVCodecParameters *par)
+static int latm_context2profilelevel(const AVCodecParameters *par)
 {
     /* MP4A-LATM
      * The RTP payload format specification is described in RFC 3016
@@ -444,7 +444,7 @@  static int latm_context2profilelevel(AVCodecParameters *par)
     return profile_level;
 }
 
-static char *latm_context2config(AVFormatContext *s, AVCodecParameters *par)
+static char *latm_context2config(AVFormatContext *s, const AVCodecParameters *par)
 {
     /* MP4A-LATM
      * The RTP payload format specification is described in RFC 3016
@@ -480,10 +480,11 @@  static char *latm_context2config(AVFormatContext *s, AVCodecParameters *par)
     return config;
 }
 
-static char *sdp_write_media_attributes(char *buff, int size, AVStream *st, int payload_type, AVFormatContext *fmt)
+static char *sdp_write_media_attributes(char *buff, int size, const AVStream *st,
+                                        int payload_type, AVFormatContext *fmt)
 {
     char *config = NULL;
-    AVCodecParameters *p = st->codecpar;
+    const AVCodecParameters *p = st->codecpar;
 
     switch (p->codec_id) {
         case AV_CODEC_ID_DIRAC:
@@ -765,11 +766,11 @@  static char *sdp_write_media_attributes(char *buff, int size, AVStream *st, int
     return buff;
 }
 
-void ff_sdp_write_media(char *buff, int size, AVStream *st, int idx,
+void ff_sdp_write_media(char *buff, int size, const AVStream *st, int idx,
                         const char *dest_addr, const char *dest_type,
                         int port, int ttl, AVFormatContext *fmt)
 {
-    AVCodecParameters *p = st->codecpar;
+    const AVCodecParameters *p = st->codecpar;
     const char *type;
     int payload_type;