Use rtp properties instead of adding a callback
authorTerry Wilson <twilson@digium.com>
Wed, 30 Sep 2009 18:21:03 +0000 (18:21 +0000)
committerTerry Wilson <twilson@digium.com>
Wed, 30 Sep 2009 18:21:03 +0000 (18:21 +0000)
Thanks, Josh.

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

channels/chan_sip.c
include/asterisk/rtp_engine.h
main/rtp_engine.c
res/res_rtp_asterisk.c

index 9c00765..908bc80 100644 (file)
@@ -5191,11 +5191,9 @@ static int create_addr_from_peer(struct sip_pvt *dialog, struct sip_peer *peer)
        if (dialog->rtp) { /* Audio */
                ast_rtp_instance_set_prop(dialog->rtp, AST_RTP_PROPERTY_DTMF, ast_test_flag(&dialog->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833);
                ast_rtp_instance_set_prop(dialog->rtp, AST_RTP_PROPERTY_DTMF_COMPENSATE, ast_test_flag(&dialog->flags[1], SIP_PAGE2_RFC2833_COMPENSATE));
+               ast_rtp_instance_set_prop(dialog->rtp, AST_RTP_PROPERTY_CONSTANT_SSRC, ast_test_flag(&dialog->flags[1], SIP_PAGE2_CONSTANT_SSRC));
                ast_rtp_instance_set_timeout(dialog->rtp, peer->rtptimeout);
                ast_rtp_instance_set_hold_timeout(dialog->rtp, peer->rtpholdtimeout);
-               if (ast_test_flag(&dialog->flags[1], SIP_PAGE2_CONSTANT_SSRC)) {
-                       ast_rtp_instance_set_constantssrc(dialog->rtp);
-               }
                /* Set Frame packetization */
                ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(dialog->rtp), dialog->rtp, &dialog->prefs);
                dialog->autoframing = peer->autoframing;
@@ -5203,9 +5201,7 @@ static int create_addr_from_peer(struct sip_pvt *dialog, struct sip_peer *peer)
        if (dialog->vrtp) { /* Video */
                ast_rtp_instance_set_timeout(dialog->vrtp, peer->rtptimeout);
                ast_rtp_instance_set_hold_timeout(dialog->vrtp, peer->rtpholdtimeout);
-               if (ast_test_flag(&dialog->flags[1], SIP_PAGE2_CONSTANT_SSRC)) {
-                       ast_rtp_instance_set_constantssrc(dialog->vrtp);
-               }
+               ast_rtp_instance_set_prop(dialog->vrtp, AST_RTP_PROPERTY_CONSTANT_SSRC, ast_test_flag(&dialog->flags[1], SIP_PAGE2_CONSTANT_SSRC));
        }
        if (dialog->trtp) { /* Realtime text */
                ast_rtp_instance_set_timeout(dialog->trtp, peer->rtptimeout);
@@ -20495,13 +20491,11 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
                                ast_debug(1, "No compatible codecs for this SIP call.\n");
                                return -1;
                        }
-                       if (ast_test_flag(&p->flags[1], SIP_PAGE2_CONSTANT_SSRC)) {
-                               if (p->rtp) {
-                                       ast_rtp_instance_set_constantssrc(p->rtp);
-                               }
-                               if (p->vrtp) {
-                                       ast_rtp_instance_set_constantssrc(p->vrtp);
-                               }
+                       if (p->rtp) {
+                               ast_rtp_instance_set_prop(p->rtp, AST_RTP_PROPERTY_CONSTANT_SSRC, ast_test_flag(&p->flags[1], SIP_PAGE2_CONSTANT_SSRC));
+                       }
+                       if (p->vrtp) {
+                               ast_rtp_instance_set_prop(p->vrtp, AST_RTP_PROPERTY_CONSTANT_SSRC, ast_test_flag(&p->flags[1], SIP_PAGE2_CONSTANT_SSRC));
                        }
                } else {        /* No SDP in invite, call control session */
                        p->jointcapability = p->capability;
index 29070d0..8f4292a 100644 (file)
@@ -94,6 +94,8 @@ enum ast_rtp_property {
        AST_RTP_PROPERTY_RTCP,
        /*! Maximum number of RTP properties supported */
        AST_RTP_PROPERTY_MAX,
+       /*! Don't force a new SSRC on new source */
+       AST_RTP_PROPERTY_CONSTANT_SSRC,
 };
 
 /*! Additional RTP options */
@@ -1185,23 +1187,6 @@ int ast_rtp_instance_dtmf_mode_set(struct ast_rtp_instance *instance, enum ast_r
 enum ast_rtp_dtmf_mode ast_rtp_instance_dtmf_mode_get(struct ast_rtp_instance *instance);
 
 /*!
- * \brief Mark an RTP instance not to update SSRC on a new source
- *
- * \param instance Instance to update
- *
- * Example usage:
- *
- * \code
- * ast_rtp_instance_set_constantssrc(instance);
- * \endcode
- *
- * This sets the indicated instance to not update the RTP SSRC when new_source
- * is called.
- *
- * \since 1.6.3
- */
-void ast_rtp_instance_set_constantssrc(struct ast_rtp_instance *instance);
-/*!
  * \brief Indicate a new source of audio has dropped in
  *
  * \param instance Instance that the new media source is feeding into
index 53ed892..cf6d2c6 100644 (file)
@@ -726,13 +726,6 @@ enum ast_rtp_dtmf_mode ast_rtp_instance_dtmf_mode_get(struct ast_rtp_instance *i
        return instance->dtmf_mode;
 }
 
-void ast_rtp_instance_set_constantssrc(struct ast_rtp_instance *instance)
-{
-       if (instance->engine->constant_ssrc_set) {
-               instance->engine->constant_ssrc_set(instance);
-       }
-}
-
 void ast_rtp_instance_new_source(struct ast_rtp_instance *instance)
 {
        if (instance->engine->new_source) {
index 42cce37..f4f3cb8 100644 (file)
@@ -103,7 +103,6 @@ enum strict_rtp_state {
 #define FLAG_NAT_INACTIVE_NOWARN        (1 << 1)
 #define FLAG_NEED_MARKER_BIT            (1 << 3)
 #define FLAG_DTMF_COMPENSATE            (1 << 4)
-#define FLAG_CONSTANT_SSRC              (1 << 5)
 
 /*! \brief RTP session description */
 struct ast_rtp {
@@ -254,7 +253,6 @@ static int ast_rtp_destroy(struct ast_rtp_instance *instance);
 static int ast_rtp_dtmf_begin(struct ast_rtp_instance *instance, char digit);
 static int ast_rtp_dtmf_end(struct ast_rtp_instance *instance, char digit);
 static void ast_rtp_new_source(struct ast_rtp_instance *instance);
-static void ast_rtp_set_constantssrc(struct ast_rtp_instance *instance);
 static int ast_rtp_write(struct ast_rtp_instance *instance, struct ast_frame *frame);
 static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtcp);
 static void ast_rtp_prop_set(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value);
@@ -277,7 +275,6 @@ static struct ast_rtp_engine asterisk_rtp_engine = {
        .dtmf_begin = ast_rtp_dtmf_begin,
        .dtmf_end = ast_rtp_dtmf_end,
        .new_source = ast_rtp_new_source,
-       .constant_ssrc_set = ast_rtp_set_constantssrc,
        .write = ast_rtp_write,
        .read = ast_rtp_read,
        .prop_set = ast_rtp_prop_set,
@@ -656,13 +653,6 @@ static int ast_rtp_dtmf_end(struct ast_rtp_instance *instance, char digit)
        return 0;
 }
 
-void ast_rtp_set_constantssrc(struct ast_rtp_instance *instance)
-{
-       struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
-
-       ast_set_flag(rtp, FLAG_CONSTANT_SSRC);
-}
-
 static void ast_rtp_new_source(struct ast_rtp_instance *instance)
 {
        struct ast_rtp *rtp = ast_rtp_instance_get_data(instance);
@@ -670,7 +660,8 @@ static void ast_rtp_new_source(struct ast_rtp_instance *instance)
        /* We simply set this bit so that the next packet sent will have the marker bit turned on */
        ast_set_flag(rtp, FLAG_NEED_MARKER_BIT);
 
-       if (!ast_test_flag(rtp, FLAG_CONSTANT_SSRC)) {
+       if (!ast_rtp_instance_get_prop(instance, AST_RTP_PROPERTY_CONSTANT_SSRC)) {
+               ast_log(LOG_ERROR, "Changing ssrc\n");
                rtp->ssrc = ast_random();
        }