summaryrefslogtreecommitdiff
path: root/channels/chan_multicast_rtp.c
diff options
context:
space:
mode:
authorDavid Vossel <dvossel@digium.com>2011-02-03 16:22:10 +0000
committerDavid Vossel <dvossel@digium.com>2011-02-03 16:22:10 +0000
commitc26c190711a1bbe3b5fff1a93facae333757c56e (patch)
tree00da0caa5a07b7b25729f089dbcafb08129fa9be /channels/chan_multicast_rtp.c
parent652fb64a01c7a8656697d07e606620ee0ced6929 (diff)
Asterisk media architecture conversion - no more format bitfields
This patch is the foundation of an entire new way of looking at media in Asterisk. The code present in this patch is everything required to complete phase1 of my Media Architecture proposal. For more information about this project visit the link below. https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal The primary function of this patch is to convert all the usages of format bitfields in Asterisk to use the new format and format_cap APIs. Functionally no change in behavior should be present in this patch. Thanks to twilson and russell for all the time they spent reviewing these changes. Review: https://reviewboard.asterisk.org/r/1083/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@306010 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_multicast_rtp.c')
-rw-r--r--channels/chan_multicast_rtp.c27
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;
}