void ast_ari_bridges_set_video_source(struct ast_variable *headers,
	struct ast_ari_bridges_set_video_source_args *args, struct ast_ari_response *response)
{
	struct ast_bridge *bridge;
	struct stasis_app_control *control;

	bridge = find_bridge(response, args->bridge_id);
	if (!bridge) {
		return;
	}

	control = find_channel_control(response, args->channel_id);
	if (!control) {
		ao2_ref(bridge, -1);
		return;
	}

	if (stasis_app_get_bridge(control) != bridge) {
		ast_ari_response_error(response, 422,
			"Unprocessable Entity",
			"Channel not in this bridge");
		ao2_ref(bridge, -1);
		ao2_ref(control, -1);
		return;
	}

	stasis_app_send_command(control, bridge_set_video_source_cb,
		ao2_bump(bridge), __ao2_cleanup);

	ao2_ref(bridge, -1);
	ao2_ref(control, -1);

	ast_ari_response_no_content(response);
}
Exemple #2
0
static struct control_list *control_list_create(struct ast_ari_response *response, size_t count, const char **channels) {
	RAII_VAR(struct control_list *, list, NULL, ao2_cleanup);
	size_t i;

	if (count == 0 || !channels) {
		ast_ari_response_error(response, 400, "Bad Request", "Missing parameter channel");
		return NULL;
	}

	list = ao2_alloc(sizeof(*list) + count * sizeof(list->controls[0]), control_list_dtor);
	if (!list) {
		ast_ari_response_alloc_failed(response);
		return NULL;
	}

	for (i = 0; i < count; ++i) {
		if (ast_strlen_zero(channels[i])) {
			continue;
		}
		list->controls[list->count] =
			find_channel_control(response, channels[i]);
		if (!list->controls[list->count]) {
			/* response filled in by find_channel_control() */
			return NULL;
		}
		++list->count;
	}

	if (list->count == 0) {
		ast_ari_response_error(response, 400, "Bad Request", "Missing parameter channel");
		return NULL;
	}

	ao2_ref(list, +1);
	return list;
}