MCPcopy Create free account
hub / github.com/MusicPlayerDaemon/MPD / FfmpegScanStream

Function FfmpegScanStream

src/decoder/plugins/FfmpegDecoderPlugin.cxx:604–649  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

602}
603
604static bool
605FfmpegScanStream(AVFormatContext &format_context, TagHandler &handler)
606{
607 const int find_result =
608 avformat_find_stream_info(&format_context, nullptr);
609 if (find_result < 0)
610 return false;
611
612 const int audio_stream = ffmpeg_find_audio_stream(format_context);
613 if (audio_stream < 0)
614 return false;
615
616 const AVStream &stream = *format_context.streams[audio_stream];
617 if (stream.duration != (int64_t)AV_NOPTS_VALUE)
618 handler.OnDuration(FromFfmpegTime(stream.duration,
619 stream.time_base));
620 else if (format_context.duration != (int64_t)AV_NOPTS_VALUE)
621 handler.OnDuration(FromFfmpegTime(format_context.duration,
622 AV_TIME_BASE_Q));
623
624 const auto &codec_params = *stream.codecpar;
625
626#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 25, 100)
627 const unsigned channels = codec_params.ch_layout.nb_channels;
628#else
629 const unsigned channels = codec_params.channels;
630#endif
631
632 try {
633 handler.OnAudioFormat(CheckAudioFormat(codec_params.sample_rate,
634 ffmpeg_sample_format(AVSampleFormat(codec_params.format)),
635 channels));
636 } catch (...) {
637 }
638
639 FfmpegScanMetadata(format_context, audio_stream, handler);
640
641 if (handler.WantPicture()) {
642 const auto *picture_stream = FindPictureStream(format_context);
643 if (picture_stream != nullptr)
644 handler.OnPicture(GetMimeType(*picture_stream),
645 ToSpan(picture_stream->attached_pic));
646 }
647
648 return true;
649}
650
651static bool
652ffmpeg_scan_stream(InputStream &is, TagHandler &handler)

Callers 1

ffmpeg_scan_streamFunction · 0.85

Calls 11

ffmpeg_find_audio_streamFunction · 0.85
ffmpeg_sample_formatFunction · 0.85
AVSampleFormatEnum · 0.85
FfmpegScanMetadataFunction · 0.85
FindPictureStreamFunction · 0.85
GetMimeTypeFunction · 0.85
ToSpanFunction · 0.85
CheckAudioFormatFunction · 0.70
OnDurationMethod · 0.45
OnAudioFormatMethod · 0.45
OnPictureMethod · 0.45

Tested by

no test coverage detected