mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 07:51:19 +02:00
driver/audiodec/ffmpegdec.cpp: parse metadata only for AVMEDIA_TYPE_AUDIO streams;
fix type_info and possible crash (thanks Jacek)
This commit is contained in:
@@ -111,6 +111,8 @@ bool CFfmpegDec::Init(void *_in, const CFile::FileType ft)
|
|||||||
bitrate = 0;
|
bitrate = 0;
|
||||||
total_time = 0;
|
total_time = 0;
|
||||||
|
|
||||||
|
av_log_set_level(AV_LOG_DEBUG);
|
||||||
|
|
||||||
AVIOContext *avioc = NULL;
|
AVIOContext *avioc = NULL;
|
||||||
in = _in;
|
in = _in;
|
||||||
is_stream = fseek((FILE *)in, 0, SEEK_SET);
|
is_stream = fseek((FILE *)in, 0, SEEK_SET);
|
||||||
@@ -394,9 +396,11 @@ bool CFfmpegDec::SetMetaData(FILE *_in, CFile::FileType ft, CAudioMetaData* m)
|
|||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
if (!is_stream) {
|
if (!is_stream) {
|
||||||
GetMeta(avc->metadata);
|
GetMeta(avc->metadata);
|
||||||
for(unsigned int i = 0; i < avc->nb_streams; i++)
|
for(unsigned int i = 0; i < avc->nb_streams; i++) {
|
||||||
|
if (avc->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
|
||||||
GetMeta(avc->streams[i]->metadata);
|
GetMeta(avc->streams[i]->metadata);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//fseek((FILE *) in, 0, SEEK_SET);
|
//fseek((FILE *) in, 0, SEEK_SET);
|
||||||
av_dump_format(avc, 0, "", 0);
|
av_dump_format(avc, 0, "", 0);
|
||||||
@@ -413,11 +417,17 @@ bool CFfmpegDec::SetMetaData(FILE *_in, CFile::FileType ft, CAudioMetaData* m)
|
|||||||
codec = avcodec_find_decoder(avc->streams[best_stream]->codec->codec_id);
|
codec = avcodec_find_decoder(avc->streams[best_stream]->codec->codec_id);
|
||||||
samplerate = avc->streams[best_stream]->codec->sample_rate;
|
samplerate = avc->streams[best_stream]->codec->sample_rate;
|
||||||
mChannels = av_get_channel_layout_nb_channels(avc->streams[best_stream]->codec->channel_layout);
|
mChannels = av_get_channel_layout_nb_channels(avc->streams[best_stream]->codec->channel_layout);
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss.str("unknown");
|
|
||||||
if (codec)
|
if (codec && codec->long_name != NULL)
|
||||||
ss << std::string(codec->long_name) + " / " << mChannels << " channel" << ( mChannels > 1 ? "s" : "");
|
type_info = codec->long_name;
|
||||||
type_info = ss.str();
|
else if(codec && codec->name != NULL)
|
||||||
|
type_info = codec->name;
|
||||||
|
else
|
||||||
|
type_info = "unknown";
|
||||||
|
ss << " / " << mChannels << " channel" << ( mChannels > 1 ? "s" : "");
|
||||||
|
type_info += ss.str();
|
||||||
|
|
||||||
bitrate = 0;
|
bitrate = 0;
|
||||||
total_time = 0;
|
total_time = 0;
|
||||||
|
Reference in New Issue
Block a user