FS-8748 FS-8751 check current play_status

This commit is contained in:
Seven Du 2016-02-17 23:42:35 +08:00
parent 8b7f0766f1
commit 648ec5db84
3 changed files with 40 additions and 0 deletions

View File

@ -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", "<file_path> [async|<member_id> [nomux]]"},
{"pause_play", (void_fn_t) & conference_api_sub_pause_play, CONF_API_SUB_ARGS_SPLIT, "pause", "[<member_id>]"},
{"play_status", (void_fn_t) & conference_api_sub_play_status, CONF_API_SUB_ARGS_SPLIT, "play_status", "[<member_id>]"},
{"file_seek", (void_fn_t) & conference_api_sub_file_seek, CONF_API_SUB_ARGS_SPLIT, "file_seek", "[+-]<val> [<member_id>]"},
{"say", (void_fn_t) & conference_api_sub_say, CONF_API_SUB_ARGS_AS_ONE, "say", "<text>"},
{"saymember", (void_fn_t) & conference_api_sub_saymember, CONF_API_SUB_ARGS_AS_ONE, "saymember", "<member_id> <text>"},
@ -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)
{

View File

@ -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)
{

View File

@ -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);