Merged revisions 106235 via svnmerge from
authorJoshua Colp <jcolp@digium.com>
Wed, 5 Mar 2008 22:43:22 +0000 (22:43 +0000)
committerJoshua Colp <jcolp@digium.com>
Wed, 5 Mar 2008 22:43:22 +0000 (22:43 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r106235 | file | 2008-03-05 18:32:10 -0400 (Wed, 05 Mar 2008) | 4 lines

Add a control frame to indicate the source of media has changed. Depending on the underlying technology it may need to change some things.
(closes issue #12148)
Reported by: jcomellas

........

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@106239 65c4cc65-6c06-0410-ace0-fbb531ad65f3

17 files changed:
apps/app_dial.c
apps/app_followme.c
channels/chan_alsa.c
channels/chan_console.c
channels/chan_h323.c
channels/chan_mgcp.c
channels/chan_oss.c
channels/chan_phone.c
channels/chan_sip.c
channels/chan_skinny.c
channels/chan_unistim.c
channels/chan_zap.c
include/asterisk/frame.h
main/channel.c
main/dial.c
main/file.c
main/rtp.c

index 5698c19..b52a97b 100644 (file)
@@ -717,6 +717,10 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
                                        ast_verb(3, "%s requested a video update, passing it to %s\n", c->name, in->name);
                                        ast_indicate(in, AST_CONTROL_VIDUPDATE);
                                        break;
+                               case AST_CONTROL_SRCUPDATE:
+                                       ast_verb(3, "%s requested a source update, passing it to %s\n", c->name, in->name);
+                                       ast_indicate(in, AST_CONTROL_SRCUPDATE);
+                                       break;
                                case AST_CONTROL_PROCEEDING:
                                        ast_verb(3, "%s is proceeding passing it to %s\n", c->name, in->name);
                                        if (single && CAN_EARLY_BRIDGE(peerflags))
@@ -820,7 +824,8 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
                        if (single && (f->frametype == AST_FRAME_CONTROL) &&
                                ((f->subclass == AST_CONTROL_HOLD) ||
                                (f->subclass == AST_CONTROL_UNHOLD) ||
-                               (f->subclass == AST_CONTROL_VIDUPDATE))) {
+                               (f->subclass == AST_CONTROL_VIDUPDATE) ||
+                                (f->subclass == AST_CONTROL_SRCUPDATE))) {
                                ast_verb(3, "%s requested special control %d, passing it to %s\n", in->name, f->subclass, outgoing->chan->name);
                                ast_indicate_data(outgoing->chan, f->subclass, f->data, f->datalen);
                        }
index 9dd130b..4e83c81 100644 (file)
@@ -656,6 +656,9 @@ static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_us
                                        case AST_CONTROL_VIDUPDATE:
                                                ast_verb(3, "%s requested a video update, passing it to %s\n", winner->name, caller->name);
                                                break;
+                                       case AST_CONTROL_SRCUPDATE:
+                                               ast_verb(3, "%s requested a source update, passing it to %s\n", winner->name, caller->name);
+                                               break;
                                        case AST_CONTROL_PROCEEDING:
                                                ast_verb(3, "%s is proceeding passing it to %s\n", winner->name,caller->name);
                                                break;
index ec11076..3e9199f 100644 (file)
@@ -510,6 +510,7 @@ static int alsa_indicate(struct ast_channel *chan, int cond, const void *data, s
        case AST_CONTROL_PROGRESS:
        case AST_CONTROL_PROCEEDING:
        case AST_CONTROL_VIDUPDATE:
+       case AST_CONTROL_SRCUPDATE:
                break;
        case AST_CONTROL_HOLD:
                ast_verbose(" << Console Has Been Placed on Hold >> \n");
index c558f5b..7d62e62 100644 (file)
@@ -610,6 +610,7 @@ static int console_indicate(struct ast_channel *chan, int cond, const void *data
        case AST_CONTROL_PROGRESS:
        case AST_CONTROL_PROCEEDING:
        case AST_CONTROL_VIDUPDATE:
+       case AST_CONTROL_SRCUPDATE:
                break;
        case AST_CONTROL_HOLD:
                ast_verb(1, V_BEGIN "Console Has Been Placed on Hold" V_END);
index e61fa10..2b1ef51 100644 (file)
@@ -914,6 +914,10 @@ static int oh323_indicate(struct ast_channel *c, int condition, const void *data
                ast_moh_stop(c);
                res = 0;
                break;
+       case AST_CONTROL_SRCUPDATE:
+               ast_rtp_new_source(pvt->rtp);
+               res = 0;
+               break;
        case AST_CONTROL_PROCEEDING:
        case -1:
                break;
index f4ce2ce..9f33429 100644 (file)
@@ -1479,6 +1479,9 @@ static int mgcp_indicate(struct ast_channel *ast, int ind, const void *data, siz
        case AST_CONTROL_UNHOLD:
                ast_moh_stop(ast);
                break;
+       case AST_CONTROL_SRCUPDATE:
+               ast_rtp_new_source(sub->rtp);
+               break;
        case -1:
                transmit_notify_request(sub, "");
                break;
index 4f40085..6269512 100644 (file)
@@ -764,6 +764,7 @@ static int oss_indicate(struct ast_channel *c, int cond, const void *data, size_
        case AST_CONTROL_PROGRESS:
        case AST_CONTROL_PROCEEDING:
        case AST_CONTROL_VIDUPDATE:
+       case AST_CONTROL_SRCUPDATE:
                break;
        case AST_CONTROL_HOLD:
                ast_verbose(" << Console Has Been Placed on Hold >> \n");
index 233e5e8..48b26c1 100644 (file)
@@ -206,21 +206,24 @@ static int phone_indicate(struct ast_channel *chan, int condition, const void *d
        int res=-1;
        ast_debug(1, "Requested indication %d on channel %s\n", condition, chan->name);
        switch(condition) {
-               case AST_CONTROL_FLASH:
-                       ioctl(p->fd, IXJCTL_PSTN_SET_STATE, PSTN_ON_HOOK);
-                       usleep(320000);
-                       ioctl(p->fd, IXJCTL_PSTN_SET_STATE, PSTN_OFF_HOOK);
+       case AST_CONTROL_FLASH:
+               ioctl(p->fd, IXJCTL_PSTN_SET_STATE, PSTN_ON_HOOK);
+               usleep(320000);
+               ioctl(p->fd, IXJCTL_PSTN_SET_STATE, PSTN_OFF_HOOK);
                        p->lastformat = -1;
                        res = 0;
                        break;
-               case AST_CONTROL_HOLD:
-                       ast_moh_start(chan, data, NULL);
-                       break;
-               case AST_CONTROL_UNHOLD:
-                       ast_moh_stop(chan);
-                       break;
-               default:
-                       ast_log(LOG_WARNING, "Condition %d is not supported on channel %s\n", condition, chan->name);
+       case AST_CONTROL_HOLD:
+               ast_moh_start(chan, data, NULL);
+               break;
+       case AST_CONTROL_UNHOLD:
+               ast_moh_stop(chan);
+               break;
+       case AST_CONTROL_SRCUPDATE:
+               res = 0;
+               break;
+       default:
+               ast_log(LOG_WARNING, "Condition %d is not supported on channel %s\n", condition, chan->name);
        }
        return res;
 }
index 4343583..fa9052d 100644 (file)
@@ -5140,6 +5140,9 @@ static int sip_indicate(struct ast_channel *ast, int condition, const void *data
                        }
                }
                break;
+       case AST_CONTROL_SRCUPDATE:
+               ast_rtp_new_source(p->rtp);
+               break;
        case -1:
                res = -1;
                break;
index 90a611b..44d88ae 100644 (file)
@@ -3650,6 +3650,9 @@ static int skinny_indicate(struct ast_channel *ast, int ind, const void *data, s
                break;
        case AST_CONTROL_PROCEEDING:
                break;
+       case AST_CONTROL_SRCUPDATE:
+               ast_rtp_new_source(sub->rtp);
+               break;
        default:
                ast_log(LOG_WARNING, "Don't know how to indicate condition %d\n", ind);
                return -1;
index 923d5d4..8adb349 100644 (file)
@@ -4117,6 +4117,7 @@ static int unistim_indicate(struct ast_channel *ast, int ind, const void *data,
                ast_moh_stop(ast);
                break;
        case AST_CONTROL_PROGRESS:
+       case AST_CONTROL_SRCUPDATE:
                break;
        case -1:
                ast_playtones_stop(ast);
index 9e73eef..ea19e9f 100644 (file)
@@ -5813,6 +5813,9 @@ static int zt_indicate(struct ast_channel *chan, int condition, const void *data
                        } else
                                res = 0;
                        break;
+               case AST_CONTROL_SRCUPDATE:
+                       res = 0;
+                       break;
                case -1:
                        res = tone_zone_play_tone(p->subs[index].zfd, -1);
                        break;
index 3206f86..ad4b829 100644 (file)
@@ -83,6 +83,7 @@ struct ast_codec_pref {
        \arg \b HOLD    Call is placed on hold
        \arg \b UNHOLD  Call is back from hold
        \arg \b VIDUPDATE       Video update requested
+       \arg \b SRCUPDATE       The source of media has changed
 
 */
 
@@ -292,7 +293,8 @@ enum ast_control_frame_type {
        AST_CONTROL_HOLD = 16,          /*!< Indicate call is placed on hold */
        AST_CONTROL_UNHOLD = 17,        /*!< Indicate call is left from hold */
        AST_CONTROL_VIDUPDATE = 18,     /*!< Indicate video frame update */
-       AST_CONTROL_T38 = 19            /*!< T38 state change request/notification */
+       AST_CONTROL_T38 = 19,           /*!< T38 state change request/notification */
+       AST_CONTROL_SRCUPDATE = 20,     /*!< Indicate source of media has changed */
 };
 
 enum ast_control_t38 {
index ecb12ac..3c68a71 100644 (file)
@@ -2745,6 +2745,8 @@ int ast_indicate_data(struct ast_channel *chan, int condition, const void *data,
                                /* Do nothing.... */
                        } else if (condition == AST_CONTROL_VIDUPDATE) {
                                /* Do nothing.... */
+                       } else if (condition == AST_CONTROL_SRCUPDATE) {
+                               /* Do nothing... */
                        } else {
                                /* not handled */
                                ast_log(LOG_WARNING, "Unable to handle indication %d for '%s'\n", condition, chan->name);
@@ -3272,6 +3274,7 @@ struct ast_channel *__ast_request_and_dial(const char *type, int format, void *d
                                case AST_CONTROL_HOLD:
                                case AST_CONTROL_UNHOLD:
                                case AST_CONTROL_VIDUPDATE:
+                               case AST_CONTROL_SRCUPDATE:
                                case -1:                        /* Ignore -- just stopping indications */
                                        break;
 
@@ -4156,6 +4159,7 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
                        case AST_CONTROL_HOLD:
                        case AST_CONTROL_UNHOLD:
                        case AST_CONTROL_VIDUPDATE:
+                       case AST_CONTROL_SRCUPDATE:
                                ast_indicate_data(other, f->subclass, f->data, f->datalen);
                                break;
                        default:
@@ -4318,6 +4322,10 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
                ast_set_flag(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;
@@ -4470,6 +4478,10 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
        ast_clear_flag(c0, AST_FLAG_END_DTMF_ONLY);
        ast_clear_flag(c1, AST_FLAG_END_DTMF_ONLY);
 
+       /* Now that we have broken the bridge the source will change yet again */
+       ast_indicate(c0, AST_CONTROL_SRCUPDATE);
+       ast_indicate(c1, AST_CONTROL_SRCUPDATE);
+
        c0->_bridge = NULL;
        c1->_bridge = NULL;
 
index 22472a8..688382f 100644 (file)
@@ -422,6 +422,10 @@ static void handle_frame(struct ast_dial *dial, struct ast_dial_channel *channel
                        ast_verb(3, "%s requested a video update, passing it to %s\n", channel->owner->name, chan->name);
                        ast_indicate(chan, AST_CONTROL_VIDUPDATE);
                        break;
+               case AST_CONTROL_SRCUPDATE:
+                       if (option_verbose > 2)
+                               ast_verbose (VERBOSE_PREFIX_3 "%s requested a source update, passing it to %s\n", channel->owner->name, chan->name);
+                       ast_indicate(chan, AST_CONTROL_SRCUPDATE);
                case AST_CONTROL_PROCEEDING:
                        ast_verb(3, "%s is proceeding, passing it to %s\n", channel->owner->name, chan->name);
                        ast_indicate(chan, AST_CONTROL_PROCEEDING);
index c16f251..16fe39e 100644 (file)
@@ -1136,6 +1136,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
                                case AST_CONTROL_RINGING:
                                case AST_CONTROL_ANSWER:
                                case AST_CONTROL_VIDUPDATE:
+                               case AST_CONTROL_SRCUPDATE:
                                case AST_CONTROL_HOLD:
                                case AST_CONTROL_UNHOLD:
                                        /* Unimportant */
index 5be0586..433fa2c 100644 (file)
@@ -3376,7 +3376,8 @@ static enum ast_bridge_result bridge_native_loop(struct ast_channel *c0, struct
                        if ((fr->subclass == AST_CONTROL_HOLD) ||
                            (fr->subclass == AST_CONTROL_UNHOLD) ||
                            (fr->subclass == AST_CONTROL_VIDUPDATE) ||
-                           (fr->subclass == AST_CONTROL_T38)) {
+                           (fr->subclass == AST_CONTROL_T38) ||
+                           (fr->subclass == AST_CONTROL_SRCUPDATE)) {
                                if (fr->subclass == AST_CONTROL_HOLD) {
                                        /* If we someone went on hold we want the other side to reinvite back to us */
                                        if (who == c0)
@@ -3615,7 +3616,8 @@ static enum ast_bridge_result bridge_p2p_loop(struct ast_channel *c0, struct ast
                        if ((fr->subclass == AST_CONTROL_HOLD) ||
                            (fr->subclass == AST_CONTROL_UNHOLD) ||
                            (fr->subclass == AST_CONTROL_VIDUPDATE) ||
-                           (fr->subclass == AST_CONTROL_T38)) {
+                           (fr->subclass == AST_CONTROL_T38) ||
+                           (fr->subclass == AST_CONTROL_SRCUPDATE)) {
                                /* If we are going on hold, then break callback mode and P2P bridging */
                                if (fr->subclass == AST_CONTROL_HOLD) {
                                        if (p0_callback)