diff --git a/daemon/audio_player.c b/daemon/audio_player.c index 99d3bad48..52c1cc50f 100644 --- a/daemon/audio_player.c +++ b/daemon/audio_player.c @@ -108,7 +108,7 @@ bool audio_player_setup(struct call_media *m, const rtp_payload_type *dst_pt, if (mp) media_player_stop(mp); else { - media_player_new(&mp, m->monologue); + media_player_new(&mp, m->monologue, NULL); ap->mp = mp; } if (!mp) diff --git a/daemon/call.c b/daemon/call.c index c1bd3f4d4..f3f4a01f9 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -2766,7 +2766,7 @@ static void __call_monologue_init_from_flags(struct call_monologue *ml, struct c #ifdef WITH_TRANSCODING if (flags->recording_announcement) { - media_player_new(&ml->rec_player, ml); + media_player_new(&ml->rec_player, ml, NULL); media_player_opts_t opts = MPO( .repeat = flags->repeat_times, .duration_spent = flags->repeat_duration, diff --git a/daemon/media_player.c b/daemon/media_player.c index c778a5d04..ac3a3c38e 100644 --- a/daemon/media_player.c +++ b/daemon/media_player.c @@ -234,7 +234,7 @@ static void __media_player_free(struct media_player *mp) { // call->master_lock held in W -void media_player_new(struct media_player **mpp, struct call_monologue *ml) { +void media_player_new(struct media_player **mpp, struct call_monologue *ml, struct ssrc_ctx *prev_ssrc) { #ifdef WITH_TRANSCODING struct media_player *mp; @@ -256,7 +256,10 @@ void media_player_new(struct media_player **mpp, struct call_monologue *ml) { mp->run_func = media_player_read_packet; // default mp->call = obj_get(ml->call); mp->ml = ml; - mp->seq = ssl_random(); + if (prev_ssrc) + mp->seq = atomic_get_na(&prev_ssrc->stats->ext_seq) + 1; + else + mp->seq = ssl_random(); mp->buffer_ts = ssl_random(); mp->ssrc_out = ssrc_ctx; } @@ -1606,7 +1609,7 @@ const char * call_play_media_for_ml(struct call_monologue *ml, update_init_subscribers(ml, OP_PLAY_MEDIA); /* media_player_new() now knows that audio player is in use * TODO: player options can have changed if already exists */ - media_player_new(&ml->player, ml); + media_player_new(&ml->player, ml, NULL); if (opts.file.len) { if (!media_player_play_file(ml->player, opts)) diff --git a/daemon/t38.c b/daemon/t38.c index 6b6e6d2bc..01f3d67c3 100644 --- a/daemon/t38.c +++ b/daemon/t38.c @@ -406,7 +406,8 @@ int t38_gateway_pair(struct call_media *t38_media, struct call_media *pcm_media, if (!(tg->gw = t38_gateway_init(NULL, t38_gateway_handler, tg))) goto err; - media_player_new(&tg->pcm_player, pcm_media->monologue); + media_player_new(&tg->pcm_player, pcm_media->monologue, + pcm_media->streams.length ? pcm_media->streams.head->data->ssrc_out[0] : NULL); // even though we call media_player_set_media() here, we need to call it again in // t38_gateway_start because our sink might not have any streams added here yet, // leaving the media_player setup incomplete diff --git a/include/media_player.h b/include/media_player.h index 8bf97e2a5..1269fbd1c 100644 --- a/include/media_player.h +++ b/include/media_player.h @@ -121,7 +121,7 @@ struct send_timer { #define MPO(...) (media_player_opts_t){__VA_ARGS__} -void media_player_new(struct media_player **, struct call_monologue *); +void media_player_new(struct media_player **, struct call_monologue *, struct ssrc_ctx *prev_ssrc); bool media_player_add(struct media_player *mp, media_player_opts_t opts); bool media_player_start(struct media_player *); long long media_player_stop(struct media_player *);