Commit 7e84c73b authored by Max Kellermann's avatar Max Kellermann

ffmpeg: moved code to ffmpeg_find_audio_stream()

parent 5e486964
...@@ -130,6 +130,17 @@ static bool ffmpeg_init(void) ...@@ -130,6 +130,17 @@ static bool ffmpeg_init(void)
return true; return true;
} }
static int
ffmpeg_find_audio_stream(const AVFormatContext *format_context)
{
for (unsigned i = 0; i < format_context->nb_streams; ++i)
if (format_context->streams[i]->codec->codec_type ==
CODEC_TYPE_AUDIO)
return i;
return -1;
}
static bool static bool
ffmpeg_helper(struct input_stream *input, ffmpeg_helper(struct input_stream *input,
bool (*callback)(struct ffmpeg_context *ctx), bool (*callback)(struct ffmpeg_context *ctx),
...@@ -139,7 +150,6 @@ ffmpeg_helper(struct input_stream *input, ...@@ -139,7 +150,6 @@ ffmpeg_helper(struct input_stream *input,
AVCodecContext *codec_context; AVCodecContext *codec_context;
AVCodec *codec; AVCodec *codec;
int audio_stream; int audio_stream;
unsigned i;
struct ffmpeg_stream stream = { struct ffmpeg_stream stream = {
.url = "mpd://X", /* only the mpd:// prefix matters */ .url = "mpd://X", /* only the mpd:// prefix matters */
}; };
...@@ -163,14 +173,7 @@ ffmpeg_helper(struct input_stream *input, ...@@ -163,14 +173,7 @@ ffmpeg_helper(struct input_stream *input,
return false; return false;
} }
audio_stream = -1; audio_stream = ffmpeg_find_audio_stream(format_context);
for(i=0; i<format_context->nb_streams; i++) {
if (format_context->streams[i]->codec->codec_type==CODEC_TYPE_AUDIO &&
audio_stream < 0) {
audio_stream=i;
}
}
if (audio_stream == -1) { if (audio_stream == -1) {
ERROR("No audio stream inside!\n"); ERROR("No audio stream inside!\n");
return false; return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment