CHANNEL(callid): Give dialplan access to the callid.
[asterisk/asterisk.git] / main / rtp_engine.c
index 3ef2d87..931f89d 100644 (file)
@@ -1493,7 +1493,8 @@ int ast_rtp_codecs_find_payload_code(struct ast_rtp_codecs *codecs, int payload)
        return res;
 }
 
-const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, struct ast_format *format, int code, enum ast_rtp_options options)
+const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format,
+       const struct ast_format *format, int code, enum ast_rtp_options options)
 {
        int i;
        const char *res = "";
@@ -1522,7 +1523,8 @@ const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, struct ast_f
        return res;
 }
 
-unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, struct ast_format *format, int code)
+unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format,
+       const struct ast_format *format, int code)
 {
        unsigned int i;
        unsigned int res = 0;
@@ -1899,16 +1901,16 @@ void ast_rtp_instance_set_stats_vars(struct ast_channel *chan, struct ast_rtp_in
 {
        char quality_buf[AST_MAX_USER_FIELD];
        char *quality;
-       struct ast_channel *bridge = ast_channel_bridge_peer(chan);
+       struct ast_channel *bridge;
 
-       ast_channel_lock(chan);
-       ast_channel_stage_snapshot(chan);
-       ast_channel_unlock(chan);
+       bridge = ast_channel_bridge_peer(chan);
        if (bridge) {
-               ast_channel_lock(bridge);
+               ast_channel_lock_both(chan, bridge);
                ast_channel_stage_snapshot(bridge);
-               ast_channel_unlock(bridge);
+       } else {
+               ast_channel_lock(chan);
        }
+       ast_channel_stage_snapshot(chan);
 
        quality = ast_rtp_instance_get_quality(instance, AST_RTP_INSTANCE_STAT_FIELD_QUALITY,
                quality_buf, sizeof(quality_buf));
@@ -1946,11 +1948,9 @@ void ast_rtp_instance_set_stats_vars(struct ast_channel *chan, struct ast_rtp_in
                }
        }
 
-       ast_channel_lock(chan);
        ast_channel_stage_snapshot_done(chan);
        ast_channel_unlock(chan);
        if (bridge) {
-               ast_channel_lock(bridge);
                ast_channel_stage_snapshot_done(bridge);
                ast_channel_unlock(bridge);
                ast_channel_unref(bridge);