conf_chan_record.c

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 2013 Digium, Inc.
00005  *
00006  * Richard Mudgett <rmudgett@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*!
00020  * \file
00021  * \brief ConfBridge recorder channel driver
00022  *
00023  * \author Richard Mudgett <rmudgett@digium.com>
00024  *
00025  * See Also:
00026  * \arg \ref AstCREDITS
00027  */
00028 
00029 
00030 #include "asterisk.h"
00031 
00032 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 431055 $")
00033 
00034 #include "asterisk/channel.h"
00035 #include "asterisk/bridge.h"
00036 #include "asterisk/format_cache.h"
00037 #include "include/confbridge.h"
00038 
00039 /* ------------------------------------------------------------------- */
00040 
00041 static unsigned int name_sequence = 0;
00042 
00043 static int rec_call(struct ast_channel *chan, const char *addr, int timeout)
00044 {
00045    /* Make sure anyone calling ast_call() for this channel driver is going to fail. */
00046    return -1;
00047 }
00048 
00049 static struct ast_frame *rec_read(struct ast_channel *ast)
00050 {
00051    return &ast_null_frame;
00052 }
00053 
00054 static int rec_write(struct ast_channel *ast, struct ast_frame *f)
00055 {
00056    return 0;
00057 }
00058 
00059 static struct ast_channel *rec_request(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause)
00060 {
00061    struct ast_channel *chan;
00062    const char *conf_name = data;
00063    RAII_VAR(struct ast_format_cap *, capabilities, NULL, ao2_cleanup);
00064    int generated_seqno = ast_atomic_fetchadd_int((int *) &name_sequence, +1);
00065 
00066    capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
00067    if (!capabilities) {
00068       return NULL;
00069    }
00070    ast_format_cap_append_by_type(capabilities, AST_MEDIA_TYPE_UNKNOWN);
00071 
00072    chan = ast_channel_alloc(1, AST_STATE_UP, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0,
00073       "CBRec/%s-%08x",
00074       conf_name, (unsigned) generated_seqno);
00075    if (!chan) {
00076       return NULL;
00077    }
00078    if (ast_channel_add_bridge_role(chan, "recorder")) {
00079       ast_channel_unlock(chan);
00080       ast_channel_release(chan);
00081       return NULL;
00082    }
00083 
00084    ast_channel_tech_set(chan, conf_record_get_tech());
00085    ast_channel_nativeformats_set(chan, capabilities);
00086    ast_channel_set_writeformat(chan, ast_format_slin);
00087    ast_channel_set_rawwriteformat(chan, ast_format_slin);
00088    ast_channel_set_readformat(chan, ast_format_slin);
00089    ast_channel_set_rawreadformat(chan, ast_format_slin);
00090    ast_channel_unlock(chan);
00091    return chan;
00092 }
00093 
00094 static struct ast_channel_tech record_tech = {
00095    .type = "CBRec",
00096    .description = "Conference Bridge Recording Channel",
00097    .requester = rec_request,
00098    .call = rec_call,
00099    .read = rec_read,
00100    .write = rec_write,
00101    .properties = AST_CHAN_TP_INTERNAL,
00102 };
00103 
00104 struct ast_channel_tech *conf_record_get_tech(void)
00105 {
00106    return &record_tech;
00107 }

Generated on Thu Apr 16 06:27:31 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6