From 831946a8d417586eb47cdc75a4a88591908a86f9 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Mon, 4 Mar 2019 14:57:09 -0500 Subject: [PATCH] TT#50652 fix compilation for with_transcode=no Change-Id: Ie65827be7e27a6f77019a983a1ce131c11b694d3 --- daemon/call_interfaces.c | 4 ++++ daemon/codec.c | 2 +- daemon/main.c | 2 ++ daemon/media_player.c | 31 +++++++++++++++++++++++++++++-- include/media_player.h | 28 ++++++++++++++++++++-------- 5 files changed, 56 insertions(+), 11 deletions(-) diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 70f301551..42bf24984 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -1733,6 +1733,7 @@ out: const char *call_play_media_ng(bencode_item_t *input, bencode_item_t *output) { +#ifdef WITH_TRANSCODING str callid, fromtag, file; struct call *call; struct call_monologue *monologue; @@ -1777,6 +1778,9 @@ out: rwlock_unlock_w(&call->master_lock); obj_put(call); return err; +#else + return "unsupported"; +#endif } diff --git a/daemon/codec.c b/daemon/codec.c index 20982eb47..b5e4fc939 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -871,9 +871,9 @@ struct rtp_payload_type *codec_make_payload_type(const str *codec_str, struct ca } void codec_init_payload_type(struct rtp_payload_type *ret, struct call_media *media) { +#ifdef WITH_TRANSCODING const codec_def_t *def = ret->codec_def; -#ifdef WITH_TRANSCODING if (def) { if (!ret->clock_rate) ret->clock_rate = def->default_clockrate; diff --git a/daemon/main.c b/daemon/main.c index a944eac88..664963ac0 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -787,7 +787,9 @@ int main(int argc, char **argv) { if (rtpe_config.media_num_threads < 0) rtpe_config.media_num_threads = rtpe_config.num_threads; for (idx = 0; idx < rtpe_config.media_num_threads; ++idx) { +#ifdef WITH_TRANSCODING thread_create_detach_prio(media_player_loop, NULL, rtpe_config.scheduling, rtpe_config.priority); +#endif thread_create_detach_prio(send_timer_loop, NULL, rtpe_config.scheduling, rtpe_config.priority); } diff --git a/daemon/media_player.c b/daemon/media_player.c index 5beba21fe..ad0f30cce 100644 --- a/daemon/media_player.c +++ b/daemon/media_player.c @@ -1,7 +1,5 @@ #include "media_player.h" #include -#include -#include #include "obj.h" #include "log.h" #include "timerthread.h" @@ -19,11 +17,14 @@ +#ifdef WITH_TRANSCODING static struct timerthread media_player_thread; +#endif static struct timerthread send_timer_thread; +#ifdef WITH_TRANSCODING // appropriate lock must be held static void media_player_shutdown(struct media_player *mp) { ilog(LOG_DEBUG, "shutting down media_player"); @@ -46,13 +47,17 @@ static void media_player_shutdown(struct media_player *mp) { mp->blob = NULL; mp->read_pos = STR_NULL; } +#endif void media_player_stop(struct media_player *mp) { +#ifdef WITH_TRANSCODING media_player_shutdown(mp); +#endif } +#ifdef WITH_TRANSCODING static void __media_player_free(void *p) { struct media_player *mp = p; @@ -62,10 +67,12 @@ static void __media_player_free(void *p) { mutex_destroy(&mp->lock); obj_put(mp->call); } +#endif // call->master_lock held in W struct media_player *media_player_new(struct call_monologue *ml) { +#ifdef WITH_TRANSCODING ilog(LOG_DEBUG, "creating media_player"); struct media_player *mp = obj_alloc0("media_player", sizeof(*mp), __media_player_free); @@ -81,6 +88,9 @@ struct media_player *media_player_new(struct call_monologue *ml) { mp->pkt.size = 0; return mp; +#else + return NULL; +#endif } @@ -163,6 +173,7 @@ void send_timer_push(struct send_timer *st, struct codec_packet *cp) { } +#ifdef WITH_TRANSCODING static int __ensure_codec_handler(struct media_player *mp, AVStream *avs) { if (mp->handler) return 0; @@ -322,10 +333,12 @@ static void media_player_play_start(struct media_player *mp) { timeval_add_usec(&mp->next_run, -50000); media_player_read_packet(mp); } +#endif // call->master_lock held in W int media_player_play_file(struct media_player *mp, const str *file) { +#ifdef WITH_TRANSCODING if (media_player_play_init(mp)) return -1; @@ -339,9 +352,13 @@ int media_player_play_file(struct media_player *mp, const str *file) { media_player_play_start(mp); return 0; +#else + return -1; +#endif } +#ifdef WITH_TRANSCODING static int __mp_avio_read_wrap(void *opaque, uint8_t *buf, int buf_size) { struct media_player *mp = opaque; if (buf_size < 0) @@ -384,9 +401,12 @@ static int64_t __mp_avio_seek(void *opaque, int64_t offset, int whence) { return __mp_avio_seek_set(mp, ((int64_t) mp->blob->len) + offset); return AVERROR(EINVAL); } +#endif + // call->master_lock held in W int media_player_play_blob(struct media_player *mp, const str *blob) { +#ifdef WITH_TRANSCODING const char *err; if (media_player_play_init(mp)) @@ -427,10 +447,12 @@ int media_player_play_blob(struct media_player *mp, const str *blob) { err: ilog(LOG_ERR, "Failed to start media playback from memory: %s", err); +#endif return -1; } +#ifdef WITH_TRANSCODING static void media_player_run(void *ptr) { struct media_player *mp = ptr; struct call *call = mp->call; @@ -449,6 +471,7 @@ static void media_player_run(void *ptr) { log_info_clear(); } +#endif static void send_timer_run(void *ptr) { @@ -487,15 +510,19 @@ static void send_timer_run(void *ptr) { void media_player_init(void) { +#ifdef WITH_TRANSCODING timerthread_init(&media_player_thread, media_player_run); +#endif timerthread_init(&send_timer_thread, send_timer_run); } +#ifdef WITH_TRANSCODING void media_player_loop(void *p) { ilog(LOG_DEBUG, "media_player_loop"); timerthread_run(&media_player_thread); } +#endif void send_timer_loop(void *p) { ilog(LOG_DEBUG, "send_timer_loop"); timerthread_run(&send_timer_thread); diff --git a/include/media_player.h b/include/media_player.h index 6fc77388c..862f0d9f3 100644 --- a/include/media_player.h +++ b/include/media_player.h @@ -2,8 +2,6 @@ #define _MEDIA_PLAYER_H_ -#include -#include #include "auxlib.h" #include "timerthread.h" #include "str.h" @@ -16,8 +14,14 @@ struct codec_handler; struct ssrc_ctx; struct packet_stream; struct codec_packet; +struct media_player; +#ifdef WITH_TRANSCODING + +#include +#include + struct media_player { struct timerthread_obj tt_obj; mutex_t lock; @@ -39,6 +43,20 @@ struct media_player { str read_pos; }; +INLINE void media_player_put(struct media_player **mp) { + if (!*mp) + return; + obj_put(&(*mp)->tt_obj); + *mp = NULL; +} + +#else + +INLINE void media_player_put(struct media_player **mp) { +} + +#endif + struct send_timer { struct timerthread_obj tt_obj; mutex_t lock; @@ -63,12 +81,6 @@ void send_timer_loop(void *p); -INLINE void media_player_put(struct media_player **mp) { - if (!*mp) - return; - obj_put(&(*mp)->tt_obj); - *mp = NULL; -} INLINE void send_timer_put(struct send_timer **st) { if (!*st) return;