From 648ec5db84c9267aaef66e3b4dcd3539b6b9d5e4 Mon Sep 17 00:00:00 2001 From: Seven Du Date: Wed, 17 Feb 2016 23:42:35 +0800 Subject: [PATCH] FS-8748 FS-8751 check current play_status --- .../mod_conference/conference_api.c | 29 +++++++++++++++++++ .../mod_conference/mod_conference.c | 9 ++++++ .../mod_conference/mod_conference.h | 2 ++ 3 files changed, 40 insertions(+) diff --git a/src/mod/applications/mod_conference/conference_api.c b/src/mod/applications/mod_conference/conference_api.c index 0b685d3c3a..eb52a2ef7b 100644 --- a/src/mod/applications/mod_conference/conference_api.c +++ b/src/mod/applications/mod_conference/conference_api.c @@ -55,6 +55,7 @@ api_command_t conference_api_sub_commands[] = { {"auto-3d-position", (void_fn_t) & conference_api_sub_auto_position, CONF_API_SUB_ARGS_SPLIT, "auto-3d-position", "[on|off]"}, {"play", (void_fn_t) & conference_api_sub_play, CONF_API_SUB_ARGS_SPLIT, "play", " [async| [nomux]]"}, {"pause_play", (void_fn_t) & conference_api_sub_pause_play, CONF_API_SUB_ARGS_SPLIT, "pause", "[]"}, + {"play_status", (void_fn_t) & conference_api_sub_play_status, CONF_API_SUB_ARGS_SPLIT, "play_status", "[]"}, {"file_seek", (void_fn_t) & conference_api_sub_file_seek, CONF_API_SUB_ARGS_SPLIT, "file_seek", "[+-] []"}, {"say", (void_fn_t) & conference_api_sub_say, CONF_API_SUB_ARGS_AS_ONE, "say", ""}, {"saymember", (void_fn_t) & conference_api_sub_saymember, CONF_API_SUB_ARGS_AS_ONE, "saymember", " "}, @@ -135,6 +136,34 @@ switch_status_t conference_api_sub_pause_play(conference_obj_t *conference, swit return SWITCH_STATUS_GENERR; } +switch_status_t conference_api_sub_play_status(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv) +{ + if (argc == 2) { + switch_mutex_lock(conference->mutex); + conference_fnode_check_status(conference->fnode, stream); + switch_mutex_unlock(conference->mutex); + + return SWITCH_STATUS_SUCCESS; + } + + if (argc == 3) { + uint32_t id = atoi(argv[2]); + conference_member_t *member; + + if ((member = conference_member_get(conference, id))) { + switch_mutex_lock(member->fnode_mutex); + conference_fnode_check_status(member->fnode, stream); + switch_mutex_unlock(member->fnode_mutex); + switch_thread_rwlock_unlock(member->rwlock); + return SWITCH_STATUS_SUCCESS; + } else { + stream->write_function(stream, "Member: %u not found.\n", id); + } + } + + return SWITCH_STATUS_GENERR; +} + /* _In_opt_z_ const char *cmd, _In_opt_ switch_core_session_t *session, _In_ switch_stream_handle_t *stream */ switch_status_t conference_api_main_real(const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream) { diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 1e9902a048..8e29e3c0e6 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -1259,6 +1259,15 @@ void conference_fnode_toggle_pause(conference_file_node_t *fnode, switch_stream_ } } +void conference_fnode_check_status(conference_file_node_t *fnode, switch_stream_handle_t *stream) +{ + if (fnode) { + stream->write_function(stream, "+OK %"SWITCH_INT64_T_FMT "/%" SWITCH_INT64_T_FMT " %s\n", + fnode->fh.vpos, fnode->fh.duration, fnode->fh.file_path); + } else { + stream->write_function(stream, "-ERR Nothing is playing\n"); + } +} void conference_fnode_seek(conference_file_node_t *fnode, switch_stream_handle_t *stream, char *arg) { diff --git a/src/mod/applications/mod_conference/mod_conference.h b/src/mod/applications/mod_conference/mod_conference.h index a32510254a..6aecbeaa83 100644 --- a/src/mod/applications/mod_conference/mod_conference.h +++ b/src/mod/applications/mod_conference/mod_conference.h @@ -956,6 +956,7 @@ int conference_member_noise_gate_check(conference_member_t *member); void conference_member_check_channels(switch_frame_t *frame, conference_member_t *member, switch_bool_t in); void conference_fnode_toggle_pause(conference_file_node_t *fnode, switch_stream_handle_t *stream); +void conference_fnode_check_status(conference_file_node_t *fnode, switch_stream_handle_t *stream); // static conference_relationship_t *conference_member_get_relationship(conference_member_t *member, conference_member_t *other_member); // static void conference_list(conference_obj_t *conference, switch_stream_handle_t *stream, char *delim); @@ -1051,6 +1052,7 @@ switch_status_t conference_api_sub_position(conference_member_t *member, switch_ switch_status_t conference_api_sub_conference_video_vmute_snap(conference_member_t *member, switch_stream_handle_t *stream, void *data); switch_status_t conference_api_sub_dtmf(conference_member_t *member, switch_stream_handle_t *stream, void *data); switch_status_t conference_api_sub_pause_play(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv); +switch_status_t conference_api_sub_play_status(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv); switch_status_t conference_api_sub_play(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv); switch_status_t conference_api_sub_say(conference_obj_t *conference, switch_stream_handle_t *stream, const char *text); switch_status_t conference_api_sub_dial(conference_obj_t *conference, switch_stream_handle_t *stream, int argc, char **argv);