| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
#include "asterisk.h" |
| 31 |
|
| 32 |
#include "asterisk/channel.h" |
| 33 |
#include "asterisk/bridge.h" |
| 34 |
#include "asterisk/format_cache.h" |
| 35 |
#include "include/confbridge.h" |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
static unsigned int name_sequence = 0; |
| 40 |
|
| 41 |
static int rec_call(struct ast_channel *chan, const char *addr, int timeout) |
| 42 |
{ |
| 43 |
|
| 44 |
return -1; |
| 45 |
} |
| 46 |
|
| 47 |
static struct ast_frame *rec_read(struct ast_channel *ast) |
| 48 |
{ |
| 49 |
return &ast_null_frame; |
| 50 |
} |
| 51 |
|
| 52 |
static int rec_write(struct ast_channel *ast, struct ast_frame *f) |
| 53 |
{ |
| 54 |
return 0; |
| 55 |
} |
| 56 |
|
| 57 |
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) |
| 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 |
|
| 64 |
capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT); |
| 65 |
if (!capabilities) { |
| 66 |
return NULL; |
| 67 |
} |
| 68 |
ast_format_cap_append_by_type(capabilities, AST_MEDIA_TYPE_AUDIO); |
| 69 |
|
| 70 |
chan = ast_channel_alloc(1, AST_STATE_UP, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, |
| 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")) { |
| 77 |
ast_channel_unlock(chan); |
| 78 |
ast_channel_release(chan); |
| 79 |
return NULL; |
| 80 |
} |
| 81 |
|
| 82 |
ast_channel_tech_set(chan, conf_record_get_tech()); |
| 83 |
ast_channel_nativeformats_set(chan, capabilities); |
| 84 |
ast_channel_set_writeformat(chan, ast_format_slin); |
| 85 |
ast_channel_set_rawwriteformat(chan, ast_format_slin); |
| 86 |
ast_channel_set_readformat(chan, ast_format_slin); |
| 87 |
ast_channel_set_rawreadformat(chan, ast_format_slin); |
| 88 |
ast_channel_unlock(chan); |
| 89 |
return chan; |
| 90 |
} |
| 91 |
|
| 92 |
static struct ast_channel_tech record_tech = { |
| 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 |
|
| 102 |
struct ast_channel_tech *conf_record_get_tech(void) |
| 103 |
{ |
| 104 |
return &record_tech; |
| 105 |
} |