Asterisk - The Open Source Telephony Project GIT-master-f36a736
conf_chan_record.c
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2013 Digium, Inc.
5 *
6 * Richard Mudgett <rmudgett@digium.com>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19/*!
20 * \file
21 * \brief ConfBridge recorder channel driver
22 *
23 * \author Richard Mudgett <rmudgett@digium.com>
24 *
25 * See Also:
26 * \arg \ref AstCREDITS
27 */
28
29
30#include "asterisk.h"
31
32#include "asterisk/channel.h"
33#include "asterisk/bridge.h"
35#include "include/confbridge.h"
36
37/* ------------------------------------------------------------------- */
38
39static unsigned int name_sequence = 0;
40
41static int rec_call(struct ast_channel *chan, const char *addr, int timeout)
42{
43 /* Make sure anyone calling ast_call() for this channel driver is going to fail. */
44 return -1;
45}
46
47static struct ast_frame *rec_read(struct ast_channel *ast)
48{
49 return &ast_null_frame;
50}
51
52static int rec_write(struct ast_channel *ast, struct ast_frame *f)
53{
54 return 0;
55}
56
57static 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)
58{
59 struct ast_channel *chan;
60 const char *conf_name = data;
61 RAII_VAR(struct ast_format_cap *, capabilities, NULL, ao2_cleanup);
62 int generated_seqno = ast_atomic_fetchadd_int((int *) &name_sequence, +1);
63
65 if (!capabilities) {
66 return NULL;
67 }
69
71 "CBRec/%s-%08x",
72 conf_name, (unsigned) generated_seqno);
73 if (!chan) {
74 return NULL;
75 }
76 if (ast_channel_add_bridge_role(chan, "recorder")) {
79 return NULL;
80 }
81
83 ast_channel_nativeformats_set(chan, capabilities);
89 return chan;
90}
91
93 .type = "CBRec",
94 .description = "Conference Bridge Recording Channel",
95 .requester = rec_request,
96 .call = rec_call,
97 .read = rec_read,
98 .write = rec_write,
99 .properties = AST_CHAN_TP_INTERNAL,
100};
101
103{
104 return &record_tech;
105}
Asterisk main include file. File version handling, generic pbx functions.
#define ao2_cleanup(obj)
Definition: astobj2.h:1934
Bridging API.
int ast_channel_add_bridge_role(struct ast_channel *chan, const char *role_name)
Adds a bridge role to a channel.
Definition: bridge_roles.c:313
static const char type[]
Definition: chan_ooh323.c:109
General Asterisk PBX channel definitions.
@ AST_CHAN_TP_INTERNAL
Channels with this particular technology are an implementation detail of Asterisk and should generall...
Definition: channel.h:991
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
Definition: channel.h:1299
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
struct ast_channel * ast_channel_release(struct ast_channel *chan)
Unlink and release reference to a channel.
Definition: channel.c:1603
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
#define ast_channel_unlock(chan)
Definition: channel.h:2969
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
@ AST_STATE_UP
Definition: channelstate.h:42
@ AST_MEDIA_TYPE_AUDIO
Definition: codec.h:32
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)
static int rec_write(struct ast_channel *ast, struct ast_frame *f)
static struct ast_channel_tech record_tech
static struct ast_frame * rec_read(struct ast_channel *ast)
struct ast_channel_tech * conf_record_get_tech(void)
Get ConfBridge record channel technology struct.
static unsigned int name_sequence
static int rec_call(struct ast_channel *chan, const char *addr, int timeout)
Media Format Cache API.
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41
int ast_format_cap_append_by_type(struct ast_format_cap *cap, enum ast_media_type type)
Add all codecs Asterisk knows about for a specific type to the capabilities structure.
Definition: format_cap.c:216
@ AST_FORMAT_CAP_FLAG_DEFAULT
Definition: format_cap.h:38
#define ast_format_cap_alloc(flags)
Allocate a new ast_format_cap structure.
Definition: format_cap.h:49
struct ast_frame ast_null_frame
Definition: main/frame.c:79
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
Definition: lock.h:757
#define NULL
Definition: resample.c:96
Structure to pass both assignedid values to channel drivers.
Definition: channel.h:606
Structure to describe a channel "technology", ie a channel driver See for examples:
Definition: channel.h:648
const char *const type
Definition: channel.h:649
Main Channel structure associated with a channel.
const char * data
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54
Data structure associated with a single frame of data.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:941