MT#59038 shortcut media_player_new()

Change-Id: I25fa42eb98684ea087b3e48d4fcdb6c94baeda27
pull/1808/head
Richard Fuchs 2 years ago
parent 1ff089114c
commit 24ce8de2bb

@ -107,8 +107,10 @@ bool audio_player_setup(struct call_media *m, const rtp_payload_type *dst_pt,
if (mp)
media_player_stop(mp);
else
mp = ap->mp = media_player_new(m->monologue);
else {
media_player_new(&mp, m->monologue);
ap->mp = mp;
}
if (!mp)
goto error;

@ -3364,8 +3364,7 @@ const char *call_play_media_ng(bencode_item_t *input, bencode_item_t *output) {
// media_player_new() now knows that audio player is in use
// TODO: player options can have changed if already exists
if (!monologue->player)
monologue->player = media_player_new(monologue);
media_player_new(&monologue->player, monologue);
if (flags.repeat_times <= 0)
flags.repeat_times = 1;

@ -157,8 +157,11 @@ static void __media_player_free(void *p) {
// call->master_lock held in W
struct media_player *media_player_new(struct call_monologue *ml) {
void media_player_new(struct media_player **mpp, struct call_monologue *ml) {
#ifdef WITH_TRANSCODING
if (*mpp)
return;
//ilog(LOG_DEBUG, "creating media_player");
uint32_t ssrc = 0;
@ -167,7 +170,7 @@ struct media_player *media_player_new(struct call_monologue *ml) {
struct ssrc_ctx *ssrc_ctx = get_ssrc_ctx(ssrc, ml->ssrc_hash, SSRC_DIR_OUTPUT, ml);
ssrc_ctx->next_rtcp = rtpe_now;
struct media_player *mp = obj_alloc0("media_player", sizeof(*mp), __media_player_free);
struct media_player *mp = *mpp = obj_alloc0("media_player", sizeof(*mp), __media_player_free);
mp->tt_obj.tt = &media_player_thread;
mutex_init(&mp->lock);
@ -182,10 +185,8 @@ struct media_player *media_player_new(struct call_monologue *ml) {
mp->coder.pkt = av_packet_alloc();
mp->coder.pkt->data = NULL;
mp->coder.pkt->size = 0;
return mp;
#else
return NULL;
return;
#endif
}

@ -407,9 +407,7 @@ 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;
err = "Failed to create media player";
if (!(tg->pcm_player = media_player_new(pcm_media->monologue)))
goto err;
media_player_new(&tg->pcm_player, pcm_media->monologue);
// 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

@ -103,7 +103,7 @@ struct send_timer {
};
struct media_player *media_player_new(struct call_monologue *);
void media_player_new(struct media_player **, struct call_monologue *);
int media_player_play_file(struct media_player *, const str *, long long, long long);
int media_player_play_blob(struct media_player *, const str *, long long, long long);
int media_player_play_db(struct media_player *, long long, long long, long long);

Loading…
Cancel
Save