Browse Source

MT#56471 tie in play_media with audio_player

Engage or disengage the audio_player as requested.

Change-Id: Ibbc3d122e908c013ad2285c2253f13ae9790a852
pull/1627/head
Richard Fuchs 3 years ago
parent
commit
dd75c761cc
3 changed files with 25 additions and 1 deletions
  1. +15
    -0
      daemon/call_interfaces.c
  2. +9
    -1
      daemon/codec.c
  3. +1
    -0
      include/call.h

+ 15
- 0
daemon/call_interfaces.c View File

@ -3139,13 +3139,23 @@ const char *call_play_media_ng(bencode_item_t *input, bencode_item_t *output) {
if (err)
return err;
flags.opmode = OP_PLAY_MEDIA;
for (GList *l = monologues.head; l; l = l->next) {
struct call_monologue *monologue = l->data;
// if mixing is enabled, codec handlers of all sources must be updated
codec_update_all_source_handlers(monologue, &flags);
// this starts the audio player if needed
update_init_subscribers(monologue, OP_PLAY_MEDIA);
// 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);
if (flags.repeat_times <= 0)
flags.repeat_times = 1;
if (flags.file.len) {
if (media_player_play_file(monologue->player, &flags.file, flags.repeat_times, flags.start_pos))
return "Failed to start media playback from file";
@ -3163,6 +3173,7 @@ const char *call_play_media_ng(bencode_item_t *input, bencode_item_t *output) {
if (l == monologues.head && monologue->player->coder.duration)
bencode_dictionary_add_integer(output, "duration", monologue->player->coder.duration);
}
return NULL;
@ -3190,6 +3201,10 @@ const char *call_stop_media_ng(bencode_item_t *input, bencode_item_t *output) {
return "Not currently playing media";
last_frame_pos = media_player_stop(monologue->player);
// restore to non-mixing if needed
codec_update_all_source_handlers(monologue, NULL);
update_init_subscribers(monologue, OP_OTHER);
}
bencode_dictionary_add_integer(output, "last-frame-pos", last_frame_pos);


+ 9
- 1
daemon/codec.c View File

@ -1063,6 +1063,7 @@ bool codec_handlers_update(struct call_media *receiver, struct call_media *sink,
// default choice of audio player usage is based on whether it was in use previously,
// overridden by signalling flags, overridden by global option
bool use_audio_player = !!MEDIA_ISSET(sink, AUDIO_PLAYER);
bool implicit_audio_player = false;
if (flags && flags->audio_player == AP_FORCE)
use_audio_player = true;
@ -1070,6 +1071,13 @@ bool codec_handlers_update(struct call_media *receiver, struct call_media *sink,
use_audio_player = false;
else if (rtpe_config.use_audio_player == UAP_ALWAYS)
use_audio_player = true;
else if (rtpe_config.use_audio_player == UAP_PLAY_MEDIA) {
// check for implicitly enabled player
if ((flags && flags->opmode == OP_PLAY_MEDIA) || (media_player_is_active(sink->monologue))) {
use_audio_player = true;
implicit_audio_player = true;
}
}
// first gather info about what we can send
AUTO_CLEANUP_NULL(GHashTable *supplemental_sinks, __g_hash_table_destroy);
@ -1377,7 +1385,7 @@ next:
MEDIA_CLEAR(sink, AUDIO_PLAYER);
audio_player_stop(sink);
}
else
else if (!implicit_audio_player)
MEDIA_SET(sink, AUDIO_PLAYER);
if (is_transcoding) {


+ 1
- 0
include/call.h View File

@ -60,6 +60,7 @@ enum call_opmode {
OP_REQUEST,
OP_REQ_ANSWER,
OP_PUBLISH,
OP_PLAY_MEDIA,
OP_OTHER,
};


Loading…
Cancel
Save