[asterisk-commits] mmichelson: branch mmichelson/features_config r390351 - in /team/mmichelson/f...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jun 3 10:48:22 CDT 2013
Author: mmichelson
Date: Mon Jun 3 10:48:18 2013
New Revision: 390351
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390351
Log:
Resolve conflict and reset automerge.
Modified:
team/mmichelson/features_config/ (props changed)
team/mmichelson/features_config/apps/app_userevent.c
team/mmichelson/features_config/bridges/bridge_builtin_features.c
team/mmichelson/features_config/include/asterisk/bridging.h
team/mmichelson/features_config/include/asterisk/channel.h
team/mmichelson/features_config/include/asterisk/stasis_channels.h
team/mmichelson/features_config/main/bridging.c
team/mmichelson/features_config/main/channel.c
team/mmichelson/features_config/main/channel_internal_api.c
team/mmichelson/features_config/main/pbx.c
team/mmichelson/features_config/main/stasis_channels.c
Propchange: team/mmichelson/features_config/
------------------------------------------------------------------------------
automerge = *
Propchange: team/mmichelson/features_config/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jun 3 10:48:18 2013
@@ -1,1 +1,1 @@
-/trunk:1-390275
+/trunk:1-390350
Modified: team/mmichelson/features_config/apps/app_userevent.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/features_config/apps/app_userevent.c?view=diff&rev=390351&r1=390350&r2=390351
==============================================================================
--- team/mmichelson/features_config/apps/app_userevent.c (original)
+++ team/mmichelson/features_config/apps/app_userevent.c Mon Jun 3 10:48:18 2013
@@ -76,7 +76,6 @@
AST_APP_ARG(extra)[100];
);
RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
- RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "UserEvent requires an argument (eventname,optional event body)\n");
@@ -115,14 +114,7 @@
}
}
- msg = ast_channel_blob_create(
- chan, ast_channel_user_event_type(), blob);
- if (!msg) {
- return -1;
- }
-
- stasis_publish(ast_channel_topic(chan), msg);
-
+ ast_channel_publish_blob(chan, ast_channel_user_event_type(), blob);
return 0;
}
Modified: team/mmichelson/features_config/bridges/bridge_builtin_features.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/features_config/bridges/bridge_builtin_features.c?view=diff&rev=390351&r1=390350&r2=390351
==============================================================================
--- team/mmichelson/features_config/bridges/bridge_builtin_features.c (original)
+++ team/mmichelson/features_config/bridges/bridge_builtin_features.c Mon Jun 3 10:48:18 2013
@@ -189,7 +189,8 @@
const char *context;
char *goto_on_blindxfr;
-/* BUGBUG the peer needs to be put on hold for the transfer. */
+ ast_bridge_channel_write_hold(bridge_channel, NULL);
+
ast_channel_lock(bridge_channel->chan);
context = ast_strdupa(get_transfer_context(bridge_channel->chan,
blind_transfer ? blind_transfer->context : NULL));
@@ -199,6 +200,7 @@
/* Grab the extension to transfer to */
if (grab_transfer(bridge_channel->chan, exten, sizeof(exten), context)) {
+ ast_bridge_channel_write_unhold(bridge_channel);
return 0;
}
@@ -276,9 +278,10 @@
const char *fail_sound;
RAII_VAR(struct ast_features_xfer_config *, xfer_cfg, NULL, ao2_cleanup);
+ ast_bridge_channel_write_hold(bridge_channel, NULL);
+
bridge = ast_bridge_channel_merge_inhibit(bridge_channel, +1);
-/* BUGBUG the peer needs to be put on hold for the transfer. */
ast_channel_lock(bridge_channel->chan);
context = ast_strdupa(get_transfer_context(bridge_channel->chan,
attended_transfer ? attended_transfer->context : NULL));
@@ -293,6 +296,7 @@
if (grab_transfer(bridge_channel->chan, exten, sizeof(exten), context)) {
ast_bridge_merge_inhibit(bridge, -1);
ao2_ref(bridge, -1);
+ ast_bridge_channel_write_unhold(bridge_channel);
return 0;
}
@@ -302,6 +306,7 @@
ast_bridge_merge_inhibit(bridge, -1);
ao2_ref(bridge, -1);
ast_stream_and_wait(bridge_channel->chan, fail_sound, AST_DIGIT_NONE);
+ ast_bridge_channel_write_unhold(bridge_channel);
return 0;
}
@@ -321,6 +326,7 @@
ast_bridge_merge_inhibit(bridge, -1);
ao2_ref(bridge, -1);
ast_stream_and_wait(bridge_channel->chan, fail_sound, AST_DIGIT_NONE);
+ ast_bridge_channel_write_unhold(bridge_channel);
return 0;
}
@@ -333,6 +339,7 @@
ast_bridge_merge_inhibit(bridge, -1);
ao2_ref(bridge, -1);
ast_stream_and_wait(bridge_channel->chan, fail_sound, AST_DIGIT_NONE);
+ ast_bridge_channel_write_unhold(bridge_channel);
return 0;
}
ast_bridge_merge_inhibit(attended_bridge, +1);
@@ -346,6 +353,7 @@
ast_bridge_merge_inhibit(bridge, -1);
ao2_ref(bridge, -1);
ast_stream_and_wait(bridge_channel->chan, fail_sound, AST_DIGIT_NONE);
+ ast_bridge_channel_write_unhold(bridge_channel);
return 0;
}
@@ -390,6 +398,7 @@
break;
case ATXFER_COMPLETE:
/* The peer takes our place in the bridge. */
+ ast_bridge_channel_write_unhold(bridge_channel);
ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
xfer_failed = ast_bridge_impart(bridge_channel->bridge, peer, bridge_channel->chan, NULL, 1);
break;
@@ -400,6 +409,7 @@
* Just impart the peer onto the bridge and have us return to it
* as normal.
*/
+ ast_bridge_channel_write_unhold(bridge_channel);
xfer_failed = ast_bridge_impart(bridge_channel->bridge, peer, NULL, NULL, 1);
break;
case ATXFER_ABORT:
@@ -413,6 +423,7 @@
if (!ast_check_hangup_locked(bridge_channel->chan)) {
ast_stream_and_wait(bridge_channel->chan, fail_sound, AST_DIGIT_NONE);
}
+ ast_bridge_channel_write_unhold(bridge_channel);
}
return 0;
Modified: team/mmichelson/features_config/include/asterisk/bridging.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/features_config/include/asterisk/bridging.h?view=diff&rev=390351&r1=390350&r2=390351
==============================================================================
--- team/mmichelson/features_config/include/asterisk/bridging.h (original)
+++ team/mmichelson/features_config/include/asterisk/bridging.h Mon Jun 3 10:48:18 2013
@@ -1110,6 +1110,27 @@
void ast_bridge_channel_write_control_data(struct ast_bridge_channel *bridge_channel, enum ast_control_frame_type control, const void *data, size_t datalen);
/*!
+ * \brief Write a hold frame into the bridge.
+ * \since 12.0.0
+ *
+ * \param bridge_channel Which channel is putting the hold into the bridge.
+ * \param moh_class The suggested music class for the other end to use.
+ *
+ * \return Nothing
+ */
+void ast_bridge_channel_write_hold(struct ast_bridge_channel *bridge_channel, const char *moh_class);
+
+/*!
+ * \brief Write an unhold frame into the bridge.
+ * \since 12.0.0
+ *
+ * \param bridge_channel Which channel is putting the hold into the bridge.
+ *
+ * \return Nothing
+ */
+void ast_bridge_channel_write_unhold(struct ast_bridge_channel *bridge_channel);
+
+/*!
* \brief Run an application on the bridge channel.
* \since 12.0.0
*
Modified: team/mmichelson/features_config/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/features_config/include/asterisk/channel.h?view=diff&rev=390351&r1=390350&r2=390351
==============================================================================
--- team/mmichelson/features_config/include/asterisk/channel.h (original)
+++ team/mmichelson/features_config/include/asterisk/channel.h Mon Jun 3 10:48:18 2013
@@ -872,8 +872,6 @@
AST_FLAG_MOH = (1 << 6),
/*! This channel is spying on another channel */
AST_FLAG_SPYING = (1 << 7),
- /*! This channel is in a native bridge */
- AST_FLAG_NBRIDGE = (1 << 8),
/*! the channel is in an auto-incrementing dialplan processor,
* so when ->priority is set, it will get incremented before
* finding the next priority to run */
@@ -927,7 +925,6 @@
AST_FEATURE_AUTOMON = (1 << 4),
AST_FEATURE_PARKCALL = (1 << 5),
AST_FEATURE_AUTOMIXMON = (1 << 6),
- AST_FEATURE_WARNING_ACTIVE = (1 << 8),
};
#define AST_FEATURE_DTMF_MASK AST_FEATURE_REDIRECT | AST_FEATURE_DISCONNECT |\
@@ -2006,21 +2003,6 @@
* \return Returns 0 on success and -1 if it could not be done
*/
int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1);
-
-/*!
- * \brief Bridge two channels together
- * \param c0 first channel to bridge
- * \param c1 second channel to bridge
- * \param config config for the channels
- * \param fo destination frame(?)
- * \param rc destination channel(?)
- * \details
- * Bridge two channels (c0 and c1) together. If an important frame occurs, we return that frame in
- * *rf (remember, it could be NULL) and which channel (0 or 1) in rc
- */
-/* int ast_channel_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc); */
-int ast_channel_bridge(struct ast_channel *c0,struct ast_channel *c1,
- struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc);
/*!
* \brief Weird function made for call transfers
Modified: team/mmichelson/features_config/include/asterisk/stasis_channels.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/features_config/include/asterisk/stasis_channels.h?view=diff&rev=390351&r1=390350&r2=390351
==============================================================================
--- team/mmichelson/features_config/include/asterisk/stasis_channels.h (original)
+++ team/mmichelson/features_config/include/asterisk/stasis_channels.h Mon Jun 3 10:48:18 2013
@@ -273,6 +273,19 @@
const char *role, struct ast_channel_snapshot *snapshot);
/*!
+ * \brief Publish a channel blob message.
+ * \since 12.0.0
+ *
+ * \param chan Channel publishing the blob.
+ * \param type Type of stasis message.
+ * \param blob The blob being published. (NULL if no blob)
+ *
+ * \return Nothing
+ */
+void ast_channel_publish_blob(struct ast_channel *chan, struct stasis_message_type *type,
+ struct ast_json *blob);
+
+/*!
* \since 12
* \brief Publish a \ref ast_channel_snapshot for a channel.
*
Modified: team/mmichelson/features_config/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/features_config/main/bridging.c?view=diff&rev=390351&r1=390350&r2=390351
==============================================================================
--- team/mmichelson/features_config/main/bridging.c (original)
+++ team/mmichelson/features_config/main/bridging.c Mon Jun 3 10:48:18 2013
@@ -43,6 +43,7 @@
#include "asterisk/bridging_basic.h"
#include "asterisk/bridging_technology.h"
#include "asterisk/stasis_bridging.h"
+#include "asterisk/stasis_channels.h"
#include "asterisk/app.h"
#include "asterisk/file.h"
#include "asterisk/module.h"
@@ -715,6 +716,32 @@
bridge_channel_write_frame(bridge_channel, &frame);
}
+void ast_bridge_channel_write_hold(struct ast_bridge_channel *bridge_channel, const char *moh_class)
+{
+ RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
+ size_t datalen;
+
+ if (!ast_strlen_zero(moh_class)) {
+ datalen = strlen(moh_class) + 1;
+
+ blob = ast_json_pack("{s: s}",
+ "musicclass", moh_class);
+ } else {
+ moh_class = NULL;
+ datalen = 0;
+ }
+
+ ast_channel_publish_blob(bridge_channel->chan, ast_channel_hold_type(), blob);
+ ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_HOLD, moh_class,
+ datalen);
+}
+
+void ast_bridge_channel_write_unhold(struct ast_bridge_channel *bridge_channel)
+{
+ ast_channel_publish_blob(bridge_channel->chan, ast_channel_unhold_type(), NULL);
+ ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_UNHOLD, NULL, 0);
+}
+
static int run_app_helper(struct ast_channel *chan, const char *app_name, const char *app_args)
{
int res = 0;
@@ -739,21 +766,14 @@
void ast_bridge_channel_run_app(struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class)
{
if (moh_class) {
- if (ast_strlen_zero(moh_class)) {
- ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_HOLD,
- NULL, 0);
- } else {
- ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_HOLD,
- moh_class, strlen(moh_class) + 1);
- }
+ ast_bridge_channel_write_hold(bridge_channel, moh_class);
}
if (run_app_helper(bridge_channel->chan, app_name, S_OR(app_args, ""))) {
/* Break the bridge if the app returns non-zero. */
bridge_handle_hangup(bridge_channel);
}
if (moh_class) {
- ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_UNHOLD,
- NULL, 0);
+ ast_bridge_channel_write_unhold(bridge_channel);
}
}
@@ -822,13 +842,7 @@
void ast_bridge_channel_playfile(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class)
{
if (moh_class) {
- if (ast_strlen_zero(moh_class)) {
- ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_HOLD,
- NULL, 0);
- } else {
- ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_HOLD,
- moh_class, strlen(moh_class) + 1);
- }
+ ast_bridge_channel_write_hold(bridge_channel, moh_class);
}
if (custom_play) {
custom_play(bridge_channel, playfile);
@@ -836,8 +850,7 @@
ast_stream_and_wait(bridge_channel->chan, playfile, AST_DIGIT_NONE);
}
if (moh_class) {
- ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_UNHOLD,
- NULL, 0);
+ ast_bridge_channel_write_unhold(bridge_channel);
}
/*
@@ -5436,24 +5449,48 @@
ao2_iterator_destroy(&iter);
}
+static struct ast_bridge *acquire_bridge(struct ast_channel *chan)
+{
+ struct ast_bridge *bridge;
+
+ ast_channel_lock(chan);
+ bridge = ast_channel_get_bridge(chan);
+ ast_channel_unlock(chan);
+
+ if (bridge
+ && ast_test_flag(&bridge->feature_flags, AST_BRIDGE_FLAG_MASQUERADE_ONLY)) {
+ ao2_ref(bridge, -1);
+ bridge = NULL;
+ }
+
+ return bridge;
+}
+
enum ast_transfer_result ast_bridge_transfer_blind(struct ast_channel *transferer,
const char *exten, const char *context,
transfer_channel_cb new_channel_cb, void *user_data)
{
RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_bridge_channel *, bridge_channel, NULL, ao2_cleanup);
RAII_VAR(struct ao2_container *, channels, NULL, ao2_cleanup);
RAII_VAR(struct ast_channel *, transferee, NULL, ao2_cleanup);
int do_bridge_transfer;
int transfer_prohibited;
enum try_parking_result parking_result;
- ast_channel_lock(transferer);
- bridge = ast_channel_get_bridge(transferer);
- ast_channel_unlock(transferer);
-
+ bridge = acquire_bridge(transferer);
if (!bridge) {
return AST_BRIDGE_TRANSFER_INVALID;
}
+ ast_channel_lock(transferer);
+ bridge_channel = ast_channel_get_bridge_channel(transferer);
+ ast_channel_unlock(transferer);
+ if (!bridge_channel) {
+ return AST_BRIDGE_TRANSFER_INVALID;
+ }
+
+ /* Take off hold if they are on hold. */
+ ast_bridge_channel_write_unhold(bridge_channel);
parking_result = try_parking(bridge, transferer, exten, context);
switch (parking_result) {
@@ -5507,26 +5544,6 @@
ast_bridge_remove(bridge, transferer);
return AST_BRIDGE_TRANSFER_SUCCESS;
-}
-
-static struct ast_bridge *acquire_bridge(struct ast_channel *chan)
-{
- struct ast_bridge *bridge;
-
- ast_channel_lock(chan);
- bridge = ast_channel_get_bridge(chan);
- ast_channel_unlock(chan);
-
- if (!bridge) {
- return NULL;
- }
-
- if (ast_test_flag(&bridge->feature_flags, AST_BRIDGE_FLAG_MASQUERADE_ONLY)) {
- ao2_ref(bridge, -1);
- bridge = NULL;
- }
-
- return bridge;
}
/*!
@@ -5621,6 +5638,8 @@
{
RAII_VAR(struct ast_bridge *, to_transferee_bridge, NULL, ao2_cleanup);
RAII_VAR(struct ast_bridge *, to_target_bridge, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_bridge_channel *, to_transferee_bridge_channel, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_bridge_channel *, to_target_bridge_channel, NULL, ao2_cleanup);
RAII_VAR(struct ao2_container *, channels, NULL, ao2_cleanup);
RAII_VAR(struct ast_channel *, transferee, NULL, ao2_cleanup);
struct ast_bridge *the_bridge;
@@ -5637,19 +5656,31 @@
return AST_BRIDGE_TRANSFER_INVALID;
}
+ ast_channel_lock(to_transferee);
+ to_transferee_bridge_channel = ast_channel_get_bridge_channel(to_transferee);
+ ast_channel_unlock(to_transferee);
+
+ ast_channel_lock(to_transfer_target);
+ to_target_bridge_channel = ast_channel_get_bridge_channel(to_transfer_target);
+ ast_channel_unlock(to_transfer_target);
+
+ if (to_transferee_bridge_channel) {
+ /* Take off hold if they are on hold. */
+ ast_bridge_channel_write_unhold(to_transferee_bridge_channel);
+ }
+
+ if (to_target_bridge_channel) {
+ /* Take off hold if they are on hold. */
+ ast_bridge_channel_write_unhold(to_target_bridge_channel);
+ }
+
/* Let's get the easy one out of the way first */
if (to_transferee_bridge && to_target_bridge) {
- RAII_VAR(struct ast_bridge_channel *, to_transferee_bridge_channel, NULL, ao2_cleanup);
- RAII_VAR(struct ast_bridge_channel *, to_target_bridge_channel, NULL, ao2_cleanup);
enum ast_transfer_result res;
- ast_channel_lock(to_transferee);
- to_transferee_bridge_channel = ast_channel_get_bridge_channel(to_transferee);
- ast_channel_unlock(to_transferee);
-
- ast_channel_lock(to_transfer_target);
- to_target_bridge_channel = ast_channel_get_bridge_channel(to_transfer_target);
- ast_channel_unlock(to_transfer_target);
+ if (!to_transferee_bridge_channel || !to_target_bridge_channel) {
+ return AST_BRIDGE_TRANSFER_INVALID;
+ }
ast_bridge_lock_both(to_transferee_bridge, to_target_bridge);
res = two_bridge_attended_transfer(to_transferee, to_transferee_bridge_channel,
Modified: team/mmichelson/features_config/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/features_config/main/channel.c?view=diff&rev=390351&r1=390350&r2=390351
==============================================================================
--- team/mmichelson/features_config/main/channel.c (original)
+++ team/mmichelson/features_config/main/channel.c Mon Jun 3 10:48:18 2013
@@ -1348,21 +1348,6 @@
return __ast_queue_frame(chan, fin, 1, NULL);
}
-/*! \internal \brief Publish a channel blob message */
-static void publish_channel_blob(struct ast_channel *chan,
- struct stasis_message_type *type, struct ast_json *blob)
-{
- RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
- if (!blob) {
- blob = ast_json_null();
- }
-
- message = ast_channel_blob_create(chan, type, blob);
- if (message) {
- stasis_publish(ast_channel_topic(chan), message);
- }
-}
-
/*! \brief Queue a hangup frame for channel */
int ast_queue_hangup(struct ast_channel *chan)
{
@@ -1372,7 +1357,7 @@
/* Yeah, let's not change a lock-critical value without locking */
ast_channel_lock(chan);
ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_DEV);
- publish_channel_blob(chan, ast_channel_hangup_request_type(), NULL);
+ ast_channel_publish_blob(chan, ast_channel_hangup_request_type(), NULL);
res = ast_queue_frame(chan, &f);
ast_channel_unlock(chan);
@@ -1398,7 +1383,7 @@
}
blob = ast_json_pack("{s: i}",
"cause", cause);
- publish_channel_blob(chan, ast_channel_hangup_request_type(), blob);
+ ast_channel_publish_blob(chan, ast_channel_hangup_request_type(), blob);
res = ast_queue_frame(chan, &f);
ast_channel_unlock(chan);
@@ -1419,7 +1404,7 @@
"musicclass", musicclass);
}
- publish_channel_blob(chan, ast_channel_hold_type(), blob);
+ ast_channel_publish_blob(chan, ast_channel_hold_type(), blob);
res = ast_queue_frame(chan, &f);
return res;
@@ -1430,7 +1415,7 @@
struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_UNHOLD };
int res;
- publish_channel_blob(chan, ast_channel_unhold_type(), NULL);
+ ast_channel_publish_blob(chan, ast_channel_unhold_type(), NULL);
res = ast_queue_frame(chan, &f);
return res;
@@ -2741,7 +2726,7 @@
blob = ast_json_pack("{s: i, s: b}",
"cause", cause,
"soft", 1);
- publish_channel_blob(chan, ast_channel_hangup_request_type(), blob);
+ ast_channel_publish_blob(chan, ast_channel_hangup_request_type(), blob);
ast_channel_unlock(chan);
return res;
@@ -3755,7 +3740,7 @@
return;
}
- publish_channel_blob(chan, ast_channel_dtmf_begin_type(), blob);
+ ast_channel_publish_blob(chan, ast_channel_dtmf_begin_type(), blob);
}
static void send_dtmf_end_event(struct ast_channel *chan,
@@ -3772,7 +3757,7 @@
return;
}
- publish_channel_blob(chan, ast_channel_dtmf_end_type(), blob);
+ ast_channel_publish_blob(chan, ast_channel_dtmf_end_type(), blob);
}
static void ast_read_generator_actions(struct ast_channel *chan, struct ast_frame *f)
@@ -6670,6 +6655,7 @@
}
}
+#if 0 //BUGBUG setting up peeraccount needs to be removed.
/* copy accountcode and peeraccount across during a link */
static void ast_set_owners_and_peers(struct ast_channel *chan1,
struct ast_channel *chan2)
@@ -6705,6 +6691,7 @@
ast_channel_peeraccount_set(chan1, ast_channel_accountcode(chan2));
}
}
+#endif //BUGBUG
/*!
* \internal
@@ -7337,251 +7324,6 @@
return NULL;
}
-static void bridge_playfile(struct ast_channel *chan, struct ast_channel *peer, const char *sound, int remain)
-{
- int check;
-
- check = ast_autoservice_start(peer);
- if (check) {
- return;
- }
-
- if (!strcmp(sound, "timeleft")) { /* Queue support */
- int min = 0;
- int sec = 0;
-
- if (remain > 0) {
- if (remain / 60 > 1) {
- min = remain / 60;
- sec = remain % 60;
- } else {
- sec = remain;
- }
- }
-
- ast_stream_and_wait(chan, "vm-youhave", "");
- if (min) {
- ast_say_number(chan, min, AST_DIGIT_ANY, ast_channel_language(chan), NULL);
- ast_stream_and_wait(chan, "queue-minutes", "");
- }
- if (sec) {
- ast_say_number(chan, sec, AST_DIGIT_ANY, ast_channel_language(chan), NULL);
- ast_stream_and_wait(chan, "queue-seconds", "");
- }
- } else {
- ast_stream_and_wait(chan, sound, "");
- }
-
- ast_autoservice_stop(peer);
-}
-
-static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct ast_channel *c1,
- struct ast_bridge_config *config, struct ast_frame **fo,
- struct ast_channel **rc)
-{
- /* Copy voice back and forth between the two channels. */
- struct ast_channel *cs[3];
- struct ast_frame *f;
- enum ast_bridge_result res = AST_BRIDGE_COMPLETE;
- struct ast_format_cap *o0nativeformats;
- struct ast_format_cap *o1nativeformats;
- int watch_c0_dtmf;
- int watch_c1_dtmf;
- void *pvt0, *pvt1;
- /* Indicates whether a frame was queued into a jitterbuffer */
- int frame_put_in_jb = 0;
- int jb_in_use;
- int to;
-
- o0nativeformats = ast_format_cap_dup(ast_channel_nativeformats(c0));
- o1nativeformats = ast_format_cap_dup(ast_channel_nativeformats(c1));
-
- if (!o0nativeformats || !o1nativeformats) {
- ast_format_cap_destroy(o0nativeformats); /* NULL safe */
- ast_format_cap_destroy(o1nativeformats); /* NULL safe */
- return AST_BRIDGE_FAILED;
- }
-
- cs[0] = c0;
- cs[1] = c1;
- pvt0 = ast_channel_tech_pvt(c0);
- pvt1 = ast_channel_tech_pvt(c1);
- watch_c0_dtmf = config->flags & AST_BRIDGE_DTMF_CHANNEL_0;
- watch_c1_dtmf = config->flags & AST_BRIDGE_DTMF_CHANNEL_1;
-
- /* Check the need of a jitterbuffer for each channel */
- jb_in_use = ast_jb_do_usecheck(c0, c1);
- if (jb_in_use)
- ast_jb_empty_and_reset(c0, c1);
-
- ast_poll_channel_add(c0, c1);
-
- if (config->feature_timer > 0 && ast_tvzero(config->nexteventts)) {
- /* nexteventts is not set when the bridge is not scheduled to
- * break, so calculate when the bridge should possibly break
- * if a partial feature match timed out */
- config->nexteventts = ast_tvadd(ast_tvnow(), ast_samp2tv(config->feature_timer, 1000));
- }
-
- for (;;) {
- struct ast_channel *who, *other;
-
- if ((ast_channel_tech_pvt(c0) != pvt0) || (ast_channel_tech_pvt(c1) != pvt1) ||
- (!ast_format_cap_identical(o0nativeformats, ast_channel_nativeformats(c0))) ||
- (!ast_format_cap_identical(o1nativeformats, ast_channel_nativeformats(c1)))) {
- /* Check for Masquerade, codec changes, etc */
- res = AST_BRIDGE_RETRY;
- break;
- }
- if (!ast_tvzero(config->nexteventts)) {
- to = ast_tvdiff_ms(config->nexteventts, ast_tvnow());
- if (to <= 0) {
- if (config->feature_timer) {
- /* feature timer expired - make sure we do not play warning */
- ast_clear_flag(config, AST_FEATURE_WARNING_ACTIVE);
- /* Indicate a feature timeout. */
- res = AST_BRIDGE_RETRY;
- } else if (config->timelimit
- && !ast_test_flag(config, AST_FEATURE_WARNING_ACTIVE)) {
- /* generic bridge ending to play warning */
- ast_set_flag(config, AST_FEATURE_WARNING_ACTIVE);
- res = AST_BRIDGE_RETRY;
- } else {
- res = AST_BRIDGE_COMPLETE;
- }
- break;
- }
- } else {
- to = -1;
- }
- /* Calculate the appropriate max sleep interval - in general, this is the time,
- left to the closest jb delivery moment */
- if (jb_in_use)
- to = ast_jb_get_when_to_wakeup(c0, c1, to);
- who = ast_waitfor_n(cs, 2, &to);
- if (!who) {
- /* No frame received within the specified timeout - check if we have to deliver now */
- if (jb_in_use)
- ast_jb_get_and_deliver(c0, c1);
- if ((ast_channel_softhangup_internal_flag(c0) | ast_channel_softhangup_internal_flag(c1)) & AST_SOFTHANGUP_UNBRIDGE) {/* Bit operators are intentional. */
- if (ast_channel_softhangup_internal_flag(c0) & AST_SOFTHANGUP_UNBRIDGE) {
- ast_channel_clear_softhangup(c0, AST_SOFTHANGUP_UNBRIDGE);
- }
- if (ast_channel_softhangup_internal_flag(c1) & AST_SOFTHANGUP_UNBRIDGE) {
- ast_channel_clear_softhangup(c1, AST_SOFTHANGUP_UNBRIDGE);
- }
- ast_channel_lock_both(c0, c1);
- ast_channel_internal_bridged_channel_set(c0, c1);
- ast_channel_internal_bridged_channel_set(c1, c0);
- ast_channel_unlock(c0);
- ast_channel_unlock(c1);
- }
- continue;
- }
- f = ast_read(who);
- if (!f) {
- *fo = NULL;
- *rc = who;
- ast_debug(1, "Didn't get a frame from channel: %s\n", ast_channel_name(who));
- break;
- }
-
- other = (who == c0) ? c1 : c0; /* the 'other' channel */
- /* Try add the frame info the who's bridged channel jitterbuff */
- if (jb_in_use)
- frame_put_in_jb = !ast_jb_put(other, f);
-
- if ((f->frametype == AST_FRAME_CONTROL) && !(config->flags & AST_BRIDGE_IGNORE_SIGS)) {
- int bridge_exit = 0;
-
- switch (f->subclass.integer) {
- case AST_CONTROL_PVT_CAUSE_CODE:
- case AST_CONTROL_AOC:
- case AST_CONTROL_MCID:
- ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
- break;
- case AST_CONTROL_REDIRECTING:
- if (ast_channel_redirecting_sub(who, other, f, 1) &&
- ast_channel_redirecting_macro(who, other, f, other == c0, 1)) {
- ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
- }
- break;
- case AST_CONTROL_CONNECTED_LINE:
- if (ast_channel_connected_line_sub(who, other, f, 1) &&
- ast_channel_connected_line_macro(who, other, f, other == c0, 1)) {
- ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
- }
- break;
- case AST_CONTROL_HOLD:
- case AST_CONTROL_UNHOLD:
- case AST_CONTROL_VIDUPDATE:
- case AST_CONTROL_SRCUPDATE:
- case AST_CONTROL_SRCCHANGE:
- case AST_CONTROL_T38_PARAMETERS:
- ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen);
- if (jb_in_use) {
- ast_jb_empty_and_reset(c0, c1);
- }
- break;
- default:
- *fo = f;
- *rc = who;
- bridge_exit = 1;
- ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass.integer, ast_channel_name(who));
- break;
- }
- if (bridge_exit)
- break;
- }
- if ((f->frametype == AST_FRAME_VOICE) ||
- (f->frametype == AST_FRAME_DTMF_BEGIN) ||
- (f->frametype == AST_FRAME_DTMF) ||
- (f->frametype == AST_FRAME_VIDEO) ||
- (f->frametype == AST_FRAME_IMAGE) ||
- (f->frametype == AST_FRAME_HTML) ||
- (f->frametype == AST_FRAME_MODEM) ||
- (f->frametype == AST_FRAME_TEXT)) {
- /* monitored dtmf causes exit from bridge */
- int monitored_source = (who == c0) ? watch_c0_dtmf : watch_c1_dtmf;
-
- if (monitored_source &&
- (f->frametype == AST_FRAME_DTMF_END ||
- f->frametype == AST_FRAME_DTMF_BEGIN)) {
- *fo = f;
- *rc = who;
- ast_debug(1, "Got DTMF %s on channel (%s)\n",
- f->frametype == AST_FRAME_DTMF_END ? "end" : "begin",
- ast_channel_name(who));
-
- break;
- }
- /* Write immediately frames, not passed through jb */
- if (!frame_put_in_jb)
- ast_write(other, f);
-
- /* Check if we have to deliver now */
- if (jb_in_use)
- ast_jb_get_and_deliver(c0, c1);
- }
- /* XXX do we want to pass on also frames not matched above ? */
- ast_frfree(f);
-
-#ifndef HAVE_EPOLL
- /* Swap who gets priority */
- cs[2] = cs[0];
- cs[0] = cs[1];
- cs[1] = cs[2];
-#endif
- }
-
- ast_poll_channel_del(c0, c1);
-
- ast_format_cap_destroy(o0nativeformats);
- ast_format_cap_destroy(o1nativeformats);
-
- return res;
-}
-
/*! \brief Bridge two channels together (early) */
int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1)
{
@@ -7590,382 +7332,6 @@
return -1;
return ast_channel_tech(c0)->early_bridge(c0, c1);
-}
-
-/*! \brief Send manager event for bridge link and unlink events.
- * \param onoff Link/Unlinked
- * \param type 1 for core, 2 for native
- * \param c0 first channel in bridge
- * \param c1 second channel in bridge
-*/
-static void manager_bridge_event(int onoff, int type, struct ast_channel *c0, struct ast_channel *c1)
-{
- struct ast_channel *chans[2] = { c0, c1 };
- /*** DOCUMENTATION
- <managerEventInstance>
- <synopsis>Raised when a bridge changes between two channels.</synopsis>
- <syntax>
- <parameter name="Bridgestate">
- <enumlist>
- <enum name="Link"/>
- <enum name="Unlink"/>
- </enumlist>
- </parameter>
- <parameter name="Bridgetype">
- <enumlist>
- <enum name="core"/>
- <enum name="native"/>
- </enumlist>
- </parameter>
- </syntax>
- </managerEventInstance>
- ***/
- ast_manager_event_multichan(EVENT_FLAG_CALL, "Bridge", 2, chans,
- "Bridgestate: %s\r\n"
- "Bridgetype: %s\r\n"
- "Channel1: %s\r\n"
- "Channel2: %s\r\n"
- "Uniqueid1: %s\r\n"
- "Uniqueid2: %s\r\n"
- "CallerID1: %s\r\n"
- "CallerID2: %s\r\n",
- onoff ? "Link" : "Unlink",
- type == 1 ? "core" : "native",
- ast_channel_name(c0), ast_channel_name(c1),
- ast_channel_uniqueid(c0), ast_channel_uniqueid(c1),
- S_COR(ast_channel_caller(c0)->id.number.valid, ast_channel_caller(c0)->id.number.str, ""),
- S_COR(ast_channel_caller(c1)->id.number.valid, ast_channel_caller(c1)->id.number.str, ""));
-}
-
-static void update_bridge_vars_set(struct ast_channel *chan, const char *name, const char *pvtid)
-{
- if (!ast_strlen_zero(pbx_builtin_getvar_helper(chan, "BRIDGEPEER"))) {
- pbx_builtin_setvar_helper(chan, "BRIDGEPEER", name);
- }
- if (pvtid) {
- pbx_builtin_setvar_helper(chan, "BRIDGEPVTCALLID", pvtid);
- }
-}
-
-static void update_bridge_vars(struct ast_channel *c0, struct ast_channel *c1)
-{
- const char *c0_name;
- const char *c1_name;
- const char *c0_pvtid = NULL;
- const char *c1_pvtid = NULL;
-#define UPDATE_BRIDGE_VARS_GET(chan, name, pvtid) \
- do { \
- name = ast_strdupa(ast_channel_name(chan)); \
- if (ast_channel_tech(chan)->get_pvt_uniqueid) { \
- pvtid = ast_strdupa(ast_channel_tech(chan)->get_pvt_uniqueid(chan)); \
- } \
- } while (0)
-
- ast_channel_lock(c1);
- UPDATE_BRIDGE_VARS_GET(c1, c1_name, c1_pvtid);
- ast_channel_unlock(c1);
-
- ast_channel_lock(c0);
- update_bridge_vars_set(c0, c1_name, c1_pvtid);
- UPDATE_BRIDGE_VARS_GET(c0, c0_name, c0_pvtid);
- ast_channel_unlock(c0);
-
- ast_channel_lock(c1);
- update_bridge_vars_set(c1, c0_name, c0_pvtid);
- ast_channel_unlock(c1);
-}
-
-static void bridge_play_sounds(struct ast_channel *c0, struct ast_channel *c1)
-{
- const char *s, *sound;
-
- /* See if we need to play an audio file to any side of the bridge */
-
- ast_channel_lock(c0);
- if ((s = pbx_builtin_getvar_helper(c0, "BRIDGE_PLAY_SOUND"))) {
- sound = ast_strdupa(s);
- ast_channel_unlock(c0);
- bridge_playfile(c0, c1, sound, 0);
- pbx_builtin_setvar_helper(c0, "BRIDGE_PLAY_SOUND", NULL);
- } else {
- ast_channel_unlock(c0);
- }
-
- ast_channel_lock(c1);
- if ((s = pbx_builtin_getvar_helper(c1, "BRIDGE_PLAY_SOUND"))) {
- sound = ast_strdupa(s);
- ast_channel_unlock(c1);
- bridge_playfile(c1, c0, sound, 0);
- pbx_builtin_setvar_helper(c1, "BRIDGE_PLAY_SOUND", NULL);
- } else {
- ast_channel_unlock(c1);
- }
-}
-
-/* BUGBUG ast_channel_bridge() and anything that only it calls will be removed. */
-/*! \brief Bridge two channels together */
-enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_channel *c1,
- struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc)
-{
- enum ast_bridge_result res;
- struct ast_format_cap *o0nativeformats;
- struct ast_format_cap *o1nativeformats;
- long time_left_ms=0;
- char caller_warning = 0;
- char callee_warning = 0;
-
- *fo = NULL;
-
- if (ast_channel_internal_bridged_channel(c0)) {
- ast_log(LOG_WARNING, "%s is already in a bridge with %s\n",
- ast_channel_name(c0), ast_channel_name(ast_channel_internal_bridged_channel(c0)));
- return AST_BRIDGE_FAILED;
- }
- if (ast_channel_internal_bridged_channel(c1)) {
- ast_log(LOG_WARNING, "%s is already in a bridge with %s\n",
- ast_channel_name(c1), ast_channel_name(ast_channel_internal_bridged_channel(c1)));
- return AST_BRIDGE_FAILED;
- }
-
- /* Stop if we're a zombie or need a soft hangup */
- if (ast_test_flag(ast_channel_flags(c0), AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) ||
- ast_test_flag(ast_channel_flags(c1), AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1))
- return AST_BRIDGE_FAILED;
-
- o0nativeformats = ast_format_cap_dup(ast_channel_nativeformats(c0));
- o1nativeformats = ast_format_cap_dup(ast_channel_nativeformats(c1));
- if (!o0nativeformats || !o1nativeformats) {
- ast_format_cap_destroy(o0nativeformats);
- ast_format_cap_destroy(o1nativeformats);
- ast_log(LOG_WARNING, "failed to copy native formats\n");
- return AST_BRIDGE_FAILED;
- }
-
- caller_warning = ast_test_flag(&config->features_caller, AST_FEATURE_PLAY_WARNING);
- callee_warning = ast_test_flag(&config->features_callee, AST_FEATURE_PLAY_WARNING);
-
- if (ast_tvzero(config->start_time)) {
- config->start_time = ast_tvnow();
- if (config->start_sound) {
- if (caller_warning) {
- bridge_playfile(c0, c1, config->start_sound, config->timelimit / 1000);
- }
- if (callee_warning) {
- bridge_playfile(c1, c0, config->start_sound, config->timelimit / 1000);
- }
- }
- }
-
- /* Keep track of bridge */
- ast_channel_lock_both(c0, c1);
- ast_channel_internal_bridged_channel_set(c0, c1);
- ast_channel_internal_bridged_channel_set(c1, c0);
- ast_channel_unlock(c0);
- ast_channel_unlock(c1);
-
- ast_set_owners_and_peers(c0, c1);
-
- if (config->feature_timer && !ast_tvzero(config->nexteventts)) {
- config->nexteventts = ast_tvadd(config->feature_start_time, ast_samp2tv(config->feature_timer, 1000));
- } else if (config->timelimit) {
- time_left_ms = config->timelimit - ast_tvdiff_ms(ast_tvnow(), config->start_time);
- config->nexteventts = ast_tvadd(config->start_time, ast_samp2tv(config->timelimit, 1000));
- if ((caller_warning || callee_warning) && config->play_warning) {
- long next_warn = config->play_warning;
- if (time_left_ms < config->play_warning && config->warning_freq > 0) {
- /* At least one warning was played, which means we are returning after feature */
- long warns_passed = (config->play_warning - time_left_ms) / config->warning_freq;
- /* It is 'warns_passed * warning_freq' NOT '(warns_passed + 1) * warning_freq',
- because nexteventts will be updated once again in the 'if (!to)' block */
- next_warn = config->play_warning - warns_passed * config->warning_freq;
- }
- config->nexteventts = ast_tvsub(config->nexteventts, ast_samp2tv(next_warn, 1000));
- }
- } else {
- config->nexteventts = ast_tv(0, 0);
- }
-
- if (!ast_channel_tech(c0)->send_digit_begin)
- ast_set_flag(ast_channel_flags(c1), AST_FLAG_END_DTMF_ONLY);
- if (!ast_channel_tech(c1)->send_digit_begin)
- ast_set_flag(ast_channel_flags(c0), AST_FLAG_END_DTMF_ONLY);
- manager_bridge_event(1, 1, c0, c1);
-
- /* Before we enter in and bridge these two together tell them both the source of audio has changed */
- ast_indicate(c0, AST_CONTROL_SRCUPDATE);
- ast_indicate(c1, AST_CONTROL_SRCUPDATE);
-
- for (/* ever */;;) {
- struct timeval now = { 0, };
- int to;
-
- if (!ast_tvzero(config->nexteventts)) {
- now = ast_tvnow();
- to = ast_tvdiff_ms(config->nexteventts, now);
- if (to <= 0) {
- if (!config->timelimit) {
- res = AST_BRIDGE_COMPLETE;
- break;
- }
- to = 0;
- }
- } else {
- to = -1;
- }
-
- if (config->timelimit) {
- time_left_ms = config->timelimit - ast_tvdiff_ms(now, config->start_time);
- if (time_left_ms < to)
- to = time_left_ms;
-
- if (time_left_ms <= 0) {
- if (caller_warning && config->end_sound)
- bridge_playfile(c0, c1, config->end_sound, 0);
- if (callee_warning && config->end_sound)
- bridge_playfile(c1, c0, config->end_sound, 0);
- *fo = NULL;
- res = AST_BRIDGE_COMPLETE;
- ast_test_suite_event_notify("BRIDGE_TIMELIMIT",
- "Channel1: %s\r\n"
- "Channel2: %s",
- ast_channel_name(c0), ast_channel_name(c1));
- break;
- }
-
- if (!to) {
- if (time_left_ms >= 5000 && config->warning_sound && config->play_warning && ast_test_flag(config, AST_FEATURE_WARNING_ACTIVE)) {
- int t = (time_left_ms + 500) / 1000; /* round to nearest second */
- if (caller_warning)
- bridge_playfile(c0, c1, config->warning_sound, t);
- if (callee_warning)
- bridge_playfile(c1, c0, config->warning_sound, t);
- }
-
- if (config->warning_freq && (time_left_ms > (config->warning_freq + 5000))) {
- config->nexteventts = ast_tvadd(config->nexteventts, ast_samp2tv(config->warning_freq, 1000));
- } else {
- config->nexteventts = ast_tvadd(config->start_time, ast_samp2tv(config->timelimit, 1000));
- }
- }
- ast_clear_flag(config, AST_FEATURE_WARNING_ACTIVE);
- }
-
- if ((ast_channel_softhangup_internal_flag(c0) | ast_channel_softhangup_internal_flag(c1)) & AST_SOFTHANGUP_UNBRIDGE) {/* Bit operators are intentional. */
- if (ast_channel_softhangup_internal_flag(c0) & AST_SOFTHANGUP_UNBRIDGE) {
- ast_channel_clear_softhangup(c0, AST_SOFTHANGUP_UNBRIDGE);
- }
- if (ast_channel_softhangup_internal_flag(c1) & AST_SOFTHANGUP_UNBRIDGE) {
- ast_channel_clear_softhangup(c1, AST_SOFTHANGUP_UNBRIDGE);
- }
- ast_channel_lock_both(c0, c1);
- ast_channel_internal_bridged_channel_set(c0, c1);
- ast_channel_internal_bridged_channel_set(c1, c0);
- ast_channel_unlock(c0);
- ast_channel_unlock(c1);
- }
-
- /* Stop if we're a zombie or need a soft hangup */
- if (ast_test_flag(ast_channel_flags(c0), AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) ||
- ast_test_flag(ast_channel_flags(c1), AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1)) {
- *fo = NULL;
- res = AST_BRIDGE_COMPLETE;
- ast_debug(1, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n",
- ast_channel_name(c0), ast_channel_name(c1),
- ast_test_flag(ast_channel_flags(c0), AST_FLAG_ZOMBIE) ? "Yes" : "No",
- ast_check_hangup(c0) ? "Yes" : "No",
- ast_test_flag(ast_channel_flags(c1), AST_FLAG_ZOMBIE) ? "Yes" : "No",
- ast_check_hangup(c1) ? "Yes" : "No");
- break;
- }
-
- update_bridge_vars(c0, c1);
[... 184 lines stripped ...]
More information about the asterisk-commits
mailing list