mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-14 08:15:02 -05:00
Simplify streams handling
Keep pointers to the streams instead of the stream number.
This commit is contained in:
parent
6677b3435d
commit
c545e52374
@ -225,8 +225,8 @@ scan_metadata_ffmpeg(char *file, struct media_file_info *mfi)
|
|||||||
enum CodecID codec_id;
|
enum CodecID codec_id;
|
||||||
enum CodecID video_codec_id;
|
enum CodecID video_codec_id;
|
||||||
enum CodecID audio_codec_id;
|
enum CodecID audio_codec_id;
|
||||||
int video_stream;
|
AVStream *video_stream;
|
||||||
int audio_stream;
|
AVStream *audio_stream;
|
||||||
int mdcount;
|
int mdcount;
|
||||||
int i;
|
int i;
|
||||||
int ret;
|
int ret;
|
||||||
@ -257,31 +257,31 @@ scan_metadata_ffmpeg(char *file, struct media_file_info *mfi)
|
|||||||
|
|
||||||
/* Extract codec IDs, check for video */
|
/* Extract codec IDs, check for video */
|
||||||
video_codec_id = CODEC_ID_NONE;
|
video_codec_id = CODEC_ID_NONE;
|
||||||
video_stream = -1;
|
video_stream = NULL;
|
||||||
|
|
||||||
audio_codec_id = CODEC_ID_NONE;
|
audio_codec_id = CODEC_ID_NONE;
|
||||||
audio_stream = -1;
|
audio_stream = NULL;
|
||||||
|
|
||||||
for (i = 0; i < ctx->nb_streams; i++)
|
for (i = 0; i < ctx->nb_streams; i++)
|
||||||
{
|
{
|
||||||
switch (ctx->streams[i]->codec->codec_type)
|
switch (ctx->streams[i]->codec->codec_type)
|
||||||
{
|
{
|
||||||
case CODEC_TYPE_VIDEO:
|
case CODEC_TYPE_VIDEO:
|
||||||
if (video_stream == -1)
|
if (!video_stream)
|
||||||
{
|
{
|
||||||
DPRINTF(E_DBG, L_SCAN, "File has video (stream %d)\n", i);
|
DPRINTF(E_DBG, L_SCAN, "File has video (stream %d)\n", i);
|
||||||
|
|
||||||
mfi->has_video = 1;
|
mfi->has_video = 1;
|
||||||
video_codec_id = ctx->streams[i]->codec->codec_id;
|
video_stream = ctx->streams[i];
|
||||||
video_stream = i;
|
video_codec_id = video_stream->codec->codec_id;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CODEC_TYPE_AUDIO:
|
case CODEC_TYPE_AUDIO:
|
||||||
if (audio_stream == -1)
|
if (!audio_stream)
|
||||||
{
|
{
|
||||||
audio_codec_id = ctx->streams[i]->codec->codec_id;
|
audio_stream = ctx->streams[i];
|
||||||
audio_stream = i;
|
audio_codec_id = audio_stream->codec->codec_id;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -310,13 +310,13 @@ scan_metadata_ffmpeg(char *file, struct media_file_info *mfi)
|
|||||||
DPRINTF(E_DBG, L_SCAN, "Duration %d ms, bitrate %d kbps\n", mfi->song_length, mfi->bitrate);
|
DPRINTF(E_DBG, L_SCAN, "Duration %d ms, bitrate %d kbps\n", mfi->song_length, mfi->bitrate);
|
||||||
|
|
||||||
/* Get some more information on the audio stream */
|
/* Get some more information on the audio stream */
|
||||||
if (audio_stream != -1)
|
if (audio_stream)
|
||||||
{
|
{
|
||||||
if (ctx->streams[audio_stream]->codec->sample_rate != 0)
|
if (audio_stream->codec->sample_rate != 0)
|
||||||
mfi->samplerate = ctx->streams[audio_stream]->codec->sample_rate;
|
mfi->samplerate = audio_stream->codec->sample_rate;
|
||||||
|
|
||||||
/* Try sample format first */
|
/* Try sample format first */
|
||||||
mfi->bits_per_sample = av_get_bits_per_sample_format(ctx->streams[audio_stream]->codec->sample_fmt);
|
mfi->bits_per_sample = av_get_bits_per_sample_format(audio_stream->codec->sample_fmt);
|
||||||
if (mfi->bits_per_sample == 0)
|
if (mfi->bits_per_sample == 0)
|
||||||
{
|
{
|
||||||
/* Try codec */
|
/* Try codec */
|
||||||
@ -444,8 +444,8 @@ scan_metadata_ffmpeg(char *file, struct media_file_info *mfi)
|
|||||||
|
|
||||||
mdcount = 0;
|
mdcount = 0;
|
||||||
|
|
||||||
if ((!ctx->metadata) && (!ctx->streams[audio_stream]->metadata)
|
if ((!ctx->metadata) && (!audio_stream->metadata)
|
||||||
&& ((video_stream != -1) && (!ctx->streams[video_stream]->metadata)))
|
&& (video_stream && !video_stream->metadata))
|
||||||
{
|
{
|
||||||
DPRINTF(E_WARN, L_SCAN, "ffmpeg reports no metadata\n");
|
DPRINTF(E_WARN, L_SCAN, "ffmpeg reports no metadata\n");
|
||||||
|
|
||||||
@ -463,18 +463,18 @@ scan_metadata_ffmpeg(char *file, struct media_file_info *mfi)
|
|||||||
mdcount += ret;
|
mdcount += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->streams[audio_stream]->metadata)
|
if (audio_stream->metadata)
|
||||||
{
|
{
|
||||||
ret = extract_metadata(mfi, ctx->streams[audio_stream]->metadata, extra_md_map);
|
ret = extract_metadata(mfi, audio_stream->metadata, extra_md_map);
|
||||||
|
|
||||||
DPRINTF(E_DBG, L_SCAN, "Picked up %d tags from audio stream metadata\n", ret);
|
DPRINTF(E_DBG, L_SCAN, "Picked up %d tags from audio stream metadata\n", ret);
|
||||||
|
|
||||||
mdcount += ret;
|
mdcount += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((video_stream != -1) && (ctx->streams[video_stream]->metadata))
|
if (video_stream && video_stream->metadata)
|
||||||
{
|
{
|
||||||
ret = extract_metadata(mfi, ctx->streams[video_stream]->metadata, extra_md_map);
|
ret = extract_metadata(mfi, video_stream->metadata, extra_md_map);
|
||||||
|
|
||||||
DPRINTF(E_DBG, L_SCAN, "Picked up %d tags from video stream metadata\n", ret);
|
DPRINTF(E_DBG, L_SCAN, "Picked up %d tags from video stream metadata\n", ret);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user