From ed877868c194b56314a6d7557c7c4ca2f5e007b7 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 27 Feb 2024 11:15:54 -0500 Subject: [PATCH] MT#59038 separate player init/start functions Change-Id: Ic65879e49995f6e7d7fc695b6fa33b9ae937c068 --- daemon/media_player.c | 36 ++++++++++++++++++++++++++++++++++++ include/media_player.h | 4 ++++ 2 files changed, 40 insertions(+) diff --git a/daemon/media_player.c b/daemon/media_player.c index 3b3bde4b5..9a9a9e3f8 100644 --- a/daemon/media_player.c +++ b/daemon/media_player.c @@ -1009,6 +1009,12 @@ bool media_player_play_file(struct media_player *mp, const str *file, media_play #endif } +// call->master_lock held in W +bool media_player_init_file(struct media_player *mp, const str *file, media_player_opts_t opts) { + int ret = __media_player_init_file(mp, file, opts, NULL); + return ret == 0; +} + #ifdef WITH_TRANSCODING static int __mp_avio_read_wrap(void *opaque, uint8_t *buf, int buf_size) { @@ -1139,6 +1145,12 @@ bool media_player_play_blob(struct media_player *mp, const str *blob, media_play return true; } +// call->master_lock held in W +bool media_player_init_blob(struct media_player *mp, const str *blob, media_player_opts_t opts) { + int ret = __media_player_init_blob_id(mp, blob, opts, -1, NULL); + return ret == 0; +} + static int __connect_db(void) { if (mysql_conn) { @@ -1242,6 +1254,12 @@ bool media_player_play_db(struct media_player *mp, long long id, media_player_op return true; } +// call->master_lock held in W +bool media_player_init_db(struct media_player *mp, long long id, media_player_opts_t opts) { + int ret = __media_player_init_db(mp, id, opts, NULL); + return ret == 0; +} + static void media_player_run(void *ptr) { struct media_player *mp = ptr; @@ -1341,6 +1359,24 @@ static void media_player_cache_entry_free(void *p) { #endif +// call->master_lock held in W +bool media_player_start(struct media_player *mp) { +#ifdef WITH_TRANSCODING + if (!mp->coder.fmtctx) // initialised? + return false; + + const rtp_payload_type *dst_pt = media_player_play_setup(mp); + if (!dst_pt) + return false; + + media_player_play_start(mp, dst_pt); + + return true; +#else + return false; +#endif +} + void media_player_init(void) { #ifdef WITH_TRANSCODING if (rtpe_config.player_cache) { diff --git a/include/media_player.h b/include/media_player.h index 4e2b369fa..99ab31ae8 100644 --- a/include/media_player.h +++ b/include/media_player.h @@ -116,6 +116,10 @@ void media_player_new(struct media_player **, struct call_monologue *); bool media_player_play_file(struct media_player *, const str *, media_player_opts_t); bool media_player_play_blob(struct media_player *, const str *, media_player_opts_t); bool media_player_play_db(struct media_player *, long long, media_player_opts_t); +bool media_player_init_file(struct media_player *, const str *, media_player_opts_t); +bool media_player_init_blob(struct media_player *, const str *, media_player_opts_t); +bool media_player_init_db(struct media_player *, long long, media_player_opts_t); +bool media_player_start(struct media_player *); long long media_player_stop(struct media_player *); bool media_player_is_active(struct call_monologue *);