@@ -619,7 +619,7 @@ void ff_parse_key_value(const char *str, ff_parse_key_val_cb callback_get_buf,
* Find stream index based on format-specific stream ID
* @return stream index, or < 0 on error
*/
-int ff_find_stream_index(AVFormatContext *s, int id);
+int ff_find_stream_index(const AVFormatContext *s, int id);
/**
* Internal version of av_index_search_timestamp
@@ -1263,7 +1263,7 @@ void ff_parse_key_value(const char *str, ff_parse_key_val_cb callback_get_buf,
}
}
-int ff_find_stream_index(AVFormatContext *s, int id)
+int ff_find_stream_index(const AVFormatContext *s, int id)
{
for (unsigned i = 0; i < s->nb_streams; i++)
if (s->streams[i]->id == id)
@@ -1406,8 +1406,9 @@ AVRational av_guess_frame_rate(AVFormatContext *format, AVStream *st, AVFrame *f
* 0 if st is NOT a matching stream
* >0 if st is a matching stream
*/
-static int match_stream_specifier(AVFormatContext *s, AVStream *st,
- const char *spec, const char **indexptr, AVProgram **p)
+static int match_stream_specifier(const AVFormatContext *s, const AVStream *st,
+ const char *spec, const char **indexptr,
+ const AVProgram **p)
{
int match = 1; /* Stores if the specifier matches so far. */
while (*spec) {
@@ -1474,7 +1475,7 @@ static int match_stream_specifier(AVFormatContext *s, AVStream *st,
return AVERROR(EINVAL);
return match && (stream_id == st->id);
} else if (*spec == 'm' && *(spec + 1) == ':') {
- AVDictionaryEntry *tag;
+ const AVDictionaryEntry *tag;
char *key, *val;
int ret;
@@ -1499,7 +1500,7 @@ static int match_stream_specifier(AVFormatContext *s, AVStream *st,
}
return match && ret;
} else if (*spec == 'u' && *(spec + 1) == '\0') {
- AVCodecParameters *par = st->codecpar;
+ const AVCodecParameters *par = st->codecpar;
int val;
switch (par->codec_type) {
case AVMEDIA_TYPE_AUDIO:
@@ -1535,7 +1536,7 @@ int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st,
int ret, index;
char *endptr;
const char *indexptr = NULL;
- AVProgram *p = NULL;
+ const AVProgram *p = NULL;
int nb_streams;
ret = match_stream_specifier(s, st, spec, &indexptr, &p);
@@ -1558,7 +1559,7 @@ int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st,
/* If we requested a matching stream index, we have to ensure st is that. */
nb_streams = p ? p->nb_stream_indexes : s->nb_streams;
for (int i = 0; i < nb_streams && index >= 0; i++) {
- AVStream *candidate = p ? s->streams[p->stream_index[i]] : s->streams[i];
+ const AVStream *candidate = s->streams[p ? p->stream_index[i] : i];
ret = match_stream_specifier(s, candidate, spec, NULL, NULL);
if (ret < 0)
goto error;
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavformat/internal.h | 2 +- libavformat/utils.c | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-)