aboutsummaryrefslogtreecommitdiffstats
path: root/main/rtp.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/rtp.c')
-rw-r--r--main/rtp.c52
1 files changed, 38 insertions, 14 deletions
diff --git a/main/rtp.c b/main/rtp.c
index d463873f7..c8e89d9a0 100644
--- a/main/rtp.c
+++ b/main/rtp.c
@@ -1578,6 +1578,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
struct rtpPayloadType rtpPT;
struct ast_rtp *bridged = NULL;
int prev_seqno;
+ AST_LIST_HEAD_NOLOCK(, ast_frame) frames;
/* If time is up, kill it */
if (rtp->sending_digit)
@@ -1679,10 +1680,22 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
timestamp = ntohl(rtpheader[1]);
ssrc = ntohl(rtpheader[2]);
- if (!mark && rtp->rxssrc && rtp->rxssrc != ssrc) {
- if (option_debug || rtpdebug)
- ast_debug(0, "Forcing Marker bit, because SSRC has changed\n");
- mark = 1;
+ AST_LIST_HEAD_INIT_NOLOCK(&frames);
+ /* Force a marker bit and change SSRC if the SSRC changes */
+ if (rtp->rxssrc && rtp->rxssrc != ssrc) {
+ struct ast_frame *f, srcupdate = {
+ AST_FRAME_CONTROL,
+ .subclass = AST_CONTROL_SRCCHANGE,
+ };
+
+ if (!mark) {
+ if (option_debug || rtpdebug) {
+ ast_debug(0, "Forcing Marker bit, because SSRC has changed\n");
+ }
+ mark = 1;
+ }
+ f = ast_frisolate(&srcupdate);
+ AST_LIST_INSERT_TAIL(&frames, f, frame_list);
}
rtp->rxssrc = ssrc;
@@ -1713,7 +1726,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
if (res < hdrlen) {
ast_log(LOG_WARNING, "RTP Read too short (%d, expecting %d)\n", res, hdrlen);
- return &ast_null_frame;
+ return AST_LIST_FIRST(&frames) ? AST_LIST_FIRST(&frames) : &ast_null_frame;
}
rtp->rxcount++; /* Only count reasonably valid packets, this'll make the rtcp stats more accurate */
@@ -1777,7 +1790,11 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
} else {
ast_log(LOG_NOTICE, "Unknown RTP codec %d received from '%s'\n", payloadtype, ast_inet_ntoa(rtp->them.sin_addr));
}
- return f ? f : &ast_null_frame;
+ if (f) {
+ AST_LIST_INSERT_TAIL(&frames, f, frame_list);
+ return AST_LIST_FIRST(&frames);
+ }
+ return &ast_null_frame;
}
rtp->lastrxformat = rtp->f.subclass = rtpPT.code;
rtp->f.frametype = (rtp->f.subclass & AST_FORMAT_AUDIO_MASK) ? AST_FRAME_VOICE : (rtp->f.subclass & AST_FORMAT_VIDEO_MASK) ? AST_FRAME_VIDEO : AST_FRAME_TEXT;
@@ -1793,7 +1810,8 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
f->len = ast_tvdiff_ms(ast_samp2tv(rtp->dtmf_duration, rtp_get_rate(f->subclass)), ast_tv(0, 0));
rtp->resp = 0;
rtp->dtmf_timeout = rtp->dtmf_duration = 0;
- return f;
+ AST_LIST_INSERT_TAIL(&frames, f, frame_list);
+ return AST_LIST_FIRST(&frames);
}
}
@@ -1897,7 +1915,9 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
rtp->f.delivery.tv_usec = 0;
}
rtp->f.src = "RTP";
- return &rtp->f;
+
+ AST_LIST_INSERT_TAIL(&frames, &rtp->f, frame_list);
+ return AST_LIST_FIRST(&frames);
}
/* The following array defines the MIME Media type (and subtype) for each
@@ -2638,18 +2658,22 @@ int ast_rtp_setqos(struct ast_rtp *rtp, int type_of_service, int class_of_servic
return ast_netsock_set_qos(rtp->s, type_of_service, class_of_service, desc);
}
-void ast_rtp_set_constantssrc(struct ast_rtp *rtp)
+void ast_rtp_update_source(struct ast_rtp *rtp)
{
- rtp->constantssrc = 1;
+ if (rtp) {
+ rtp->set_marker_bit = 1;
+ ast_debug(3, "Setting the marker bit due to a source update\n");
+ }
}
-void ast_rtp_new_source(struct ast_rtp *rtp)
+void ast_rtp_change_source(struct ast_rtp *rtp)
{
if (rtp) {
+ unsigned int ssrc = ast_random();
+
rtp->set_marker_bit = 1;
- if (!rtp->constantssrc) {
- rtp->ssrc = ast_random();
- }
+ ast_debug(3, "Changing ssrc from %u to %u due to a source change\n", rtp->ssrc, ssrc);
+ rtp->ssrc = ssrc;
}
}