diff options
Diffstat (limited to 'channels/chan_multicast_rtp.c')
-rw-r--r-- | channels/chan_multicast_rtp.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/channels/chan_multicast_rtp.c b/channels/chan_multicast_rtp.c index 55b757567..b398abb21 100644 --- a/channels/chan_multicast_rtp.c +++ b/channels/chan_multicast_rtp.c @@ -52,17 +52,16 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") static const char tdesc[] = "Multicast RTP Paging Channel Driver"; /* Forward declarations */ -static struct ast_channel *multicast_rtp_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause); +static struct ast_channel *multicast_rtp_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, void *data, int *cause); static int multicast_rtp_call(struct ast_channel *ast, char *dest, int timeout); static int multicast_rtp_hangup(struct ast_channel *ast); static struct ast_frame *multicast_rtp_read(struct ast_channel *ast); static int multicast_rtp_write(struct ast_channel *ast, struct ast_frame *f); /* Channel driver declaration */ -static const struct ast_channel_tech multicast_rtp_tech = { +static struct ast_channel_tech multicast_rtp_tech = { .type = "MulticastRTP", .description = tdesc, - .capabilities = -1, .requester = multicast_rtp_request, .call = multicast_rtp_call, .hangup = multicast_rtp_hangup, @@ -107,14 +106,15 @@ static int multicast_rtp_hangup(struct ast_channel *ast) } /*! \brief Function called when we should prepare to call the destination */ -static struct ast_channel *multicast_rtp_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause) +static struct ast_channel *multicast_rtp_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, void *data, int *cause) { char *tmp = ast_strdupa(data), *multicast_type = tmp, *destination, *control; struct ast_rtp_instance *instance; struct ast_sockaddr control_address; struct ast_sockaddr destination_address; struct ast_channel *chan; - format_t fmt = ast_best_codec(format); + struct ast_format fmt; + ast_best_codec(cap, &fmt); ast_sockaddr_setnull(&control_address); @@ -153,11 +153,13 @@ static struct ast_channel *multicast_rtp_request(const char *type, format_t form ast_rtp_instance_set_remote_address(instance, &destination_address); chan->tech = &multicast_rtp_tech; - chan->nativeformats = fmt; - chan->writeformat = fmt; - chan->readformat = fmt; - chan->rawwriteformat = fmt; - chan->rawreadformat = fmt; + + ast_format_cap_add(chan->nativeformats, &fmt); + ast_format_copy(&chan->writeformat, &fmt); + ast_format_copy(&chan->rawwriteformat, &fmt); + ast_format_copy(&chan->readformat, &fmt); + ast_format_copy(&chan->rawreadformat, &fmt); + chan->tech_pvt = instance; return chan; @@ -170,6 +172,10 @@ failure: /*! \brief Function called when our module is loaded */ static int load_module(void) { + if (!(multicast_rtp_tech.capabilities = ast_format_cap_alloc())) { + return AST_MODULE_LOAD_DECLINE; + } + ast_format_cap_add_all(multicast_rtp_tech.capabilities); if (ast_channel_register(&multicast_rtp_tech)) { ast_log(LOG_ERROR, "Unable to register channel class 'MulticastRTP'\n"); return AST_MODULE_LOAD_DECLINE; @@ -182,6 +188,7 @@ static int load_module(void) static int unload_module(void) { ast_channel_unregister(&multicast_rtp_tech); + multicast_rtp_tech.capabilities = ast_format_cap_destroy(multicast_rtp_tech.capabilities); return 0; } |