Пример #1
0
static int mute_channel(struct ast_channel *chan, const char *direction, int mute)
{
	unsigned int mute_direction = 0;
	enum ast_frame_type frametype = AST_FRAME_VOICE;
	int ret = 0;

	if (!strcmp(direction, "in")) {
		mute_direction = AST_MUTE_DIRECTION_READ;
	} else if (!strcmp(direction, "out")) {
		mute_direction = AST_MUTE_DIRECTION_WRITE;
	} else if (!strcmp(direction, "all")) {
		mute_direction = AST_MUTE_DIRECTION_READ | AST_MUTE_DIRECTION_WRITE;
	} else {
		return -1;
	}

	ast_channel_lock(chan);

	if (mute) {
		ret = ast_channel_suppress(chan, mute_direction, frametype);
	} else {
		ret = ast_channel_unsuppress(chan, mute_direction, frametype);
	}

	ast_channel_unlock(chan);

	return ret;
}
Пример #2
0
static int app_control_mute(struct stasis_app_control *control,
                            struct ast_channel *chan, void *data)
{
    RAII_VAR(struct stasis_app_control_mute_data *, mute_data, data, ast_free);
    SCOPED_CHANNELLOCK(lockvar, chan);

    ast_channel_suppress(control->channel, mute_data->direction, mute_data->frametype);

    return 0;
}