MT#55283 move __ensure_codec_handler call

It makes more sense to set up the codec handler from the init function
rather than from the function reading the media packet.

Change-Id: I0bea3d0fc0669a54f93b2598251df69274950365
pull/1592/head
Richard Fuchs 3 years ago
parent 2cf74b6d7a
commit f642a9e603

@ -338,7 +338,6 @@ static int __ensure_codec_handler(struct media_player *mp, AVStream *avs) {
// synthesise rtp payload type
struct rtp_payload_type src_pt = { .payload_type = -1 };
// src_pt.codec_def = codec_find_by_av(avs->codec->codec_id); `codec` is deprecated
src_pt.codec_def = codec_find_by_av(avs->CODECPAR->codec_id);
if (!src_pt.codec_def) {
ilog(LOG_ERR, "Attempting to play media from an unsupported file format/codec");
@ -452,9 +451,6 @@ static void media_player_read_packet(struct media_player *mp) {
goto out;
}
if (__ensure_codec_handler(mp, avs))
goto out;
// scale pts and duration according to sample rate
long long duration_scaled = mp->pkt->duration * avs->CODECPAR->sample_rate
@ -523,6 +519,14 @@ static void media_player_play_start(struct media_player *mp, long long repeat, l
// needed to have usable duration for some formats. ignore errors.
avformat_find_stream_info(mp->fmtctx, NULL);
AVStream *avs = mp->fmtctx->streams[0];
if (!avs) {
ilog(LOG_ERR, "No AVStream present in format context");
return;
}
if (__ensure_codec_handler(mp, avs))
return;
mp->next_run = rtpe_now;
// give ourselves a bit of a head start with decoding
timeval_add_usec(&mp->next_run, -50000);

Loading…
Cancel
Save