Skip to content

Commit

Permalink
Merge pull request wang-bin#1391 from mwochal/master
Browse files Browse the repository at this point in the history
Fix crash when unable to decode subtitles
  • Loading branch information
wang-bin authored Nov 12, 2021
2 parents 2372b77 241b1cd commit b156991
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/AVPlayerPrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 472,11 @@ QVariantList AVPlayer::Private::getTracksInfo(AVDemuxer *demuxer, AVDemuxer::Str
AVStream *stream = demuxer->formatContext()->streams[s];
AVCodecContext *ctx = stream->codec;
if (ctx) {
t[QStringLiteral("codec")] = QByteArray(avcodec_descriptor_get(ctx->codec_id)->name);
const AVCodecDescriptor* codec_desc = avcodec_descriptor_get(ctx->codec_id);
if (codec_desc)
t[QStringLiteral("codec")] = QByteArray(codec_desc->name);
else
continue;
if (ctx->extradata)
t[QStringLiteral("extra")] = QByteArray((const char*)ctx->extradata, ctx->extradata_size);
}
Expand Down Expand Up @@ -503,6 507,8 @@ bool AVPlayer::Private::applySubtitleStream(int n, AVPlayer *player)
return false;
// FIXME: AVCodecDescriptor.name and AVCodec.name are different!
const AVCodecDescriptor *codec_desc = avcodec_descriptor_get(ctx->codec_id);
if (!codec_desc)
return false;
QByteArray codec(codec_desc->name);
if (ctx->extradata)
Q_EMIT player->internalSubtitleHeaderRead(codec, QByteArray((const char*)ctx->extradata, ctx->extradata_size));
Expand Down

0 comments on commit b156991

Please sign in to comment.