MT#61856 media_player: check if frame seek failed

Before to start the media player, check if the
seek process for the start frame failed, because
otherwise it starts from the unexpected position,
and there is no awareness about it.

Just add log for this case.

Change-Id: I36a912a9ef044825b050f8b7a6ad5562571b7d34
mr26.1
Donat Zenichev 1 week ago
parent 5d67968575
commit e7b9897ddd

@ -1255,6 +1255,8 @@ static const rtp_payload_type *media_player_play_init(struct media_player *mp) {
static bool media_player_play_start(struct media_player *mp, const rtp_payload_type *dst_pt,
str_case_value_ht codec_set)
{
int ret = 0;
// needed to have usable duration for some formats. ignore errors.
if (!mp->coder.fmtctx->streams || !mp->coder.fmtctx->streams[0])
avformat_find_stream_info(mp->coder.fmtctx, NULL);
@ -1280,10 +1282,14 @@ static bool media_player_play_start(struct media_player *mp, const rtp_payload_t
// if start_pos is positive, try to seek to that position
if (mp->opts.start_pos > 0) {
ilog(LOG_DEBUG, "Seeking to position %lli", mp->opts.start_pos);
av_seek_frame(mp->coder.fmtctx, 0, mp->opts.start_pos, AVSEEK_FLAG_ANY | AVSEEK_FLAG_BACKWARD);
ret = av_seek_frame(mp->coder.fmtctx, 0, mp->opts.start_pos, AVSEEK_FLAG_ANY | AVSEEK_FLAG_BACKWARD);
}
else // in case this is a repeated start
av_seek_frame(mp->coder.fmtctx, 0, 0, AVSEEK_FLAG_ANY | AVSEEK_FLAG_BACKWARD);
ret = av_seek_frame(mp->coder.fmtctx, 0, 0, AVSEEK_FLAG_ANY | AVSEEK_FLAG_BACKWARD);
if (ret < 0)
ilog(LOG_ERR, "Failed to seek to beginning of media file");
// should we return false at this point?
media_player_read_packet(mp);

Loading…
Cancel
Save