]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
rtp: Preserve timestamps on video frames. 98/3898/2
authorJoshua Colp <jcolp@digium.com>
Wed, 14 Sep 2016 12:59:51 +0000 (08:59 -0400)
committerJoshua Colp <jcolp@digium.com>
Wed, 14 Sep 2016 17:58:04 +0000 (12:58 -0500)
Currently when receiving video over RTP we store only
a calculated samples on the frame. When starting the video
it can take some time for this calculation to actually yield
a value as it requires constant changing timestamps. As well
if a video frame passes over multiple RTP packets this calculation
will fail as the timestamp is the same as the previous RTP
packet and the number of samples calculated will be 0.

This change preserves the timestamp on the frame and allows
it to pass through the core. When sending the video this timestamp
is used instead of a new one being calculated.

ASTERISK-26367 #close

Change-Id: Iba8179fb5c14c9443aee4baf670d2185da3ecfbd

main/codec_builtin.c
res/res_rtp_asterisk.c

index 1d329bc3bcfaa74c96b6d7a53ef67f75ff2335e8..973423d55f47d9f9cb5145c3951f200ce80278d1 100644 (file)
@@ -728,36 +728,42 @@ static struct ast_codec h261 = {
        .name = "h261",
        .description = "H.261 video",
        .type = AST_MEDIA_TYPE_VIDEO,
+       .sample_rate = 1000,
 };
 
 static struct ast_codec h263 = {
        .name = "h263",
        .description = "H.263 video",
        .type = AST_MEDIA_TYPE_VIDEO,
+       .sample_rate = 1000,
 };
 
 static struct ast_codec h263p = {
        .name = "h263p",
        .description = "H.263+ video",
        .type = AST_MEDIA_TYPE_VIDEO,
+       .sample_rate = 1000,
 };
 
 static struct ast_codec h264 = {
        .name = "h264",
        .description = "H.264 video",
        .type = AST_MEDIA_TYPE_VIDEO,
+       .sample_rate = 1000,
 };
 
 static struct ast_codec mpeg4 = {
        .name = "mpeg4",
        .description = "MPEG4 video",
        .type = AST_MEDIA_TYPE_VIDEO,
+       .sample_rate = 1000,
 };
 
 static struct ast_codec vp8 = {
        .name = "vp8",
        .description = "VP8 video",
        .type = AST_MEDIA_TYPE_VIDEO,
+       .sample_rate = 1000,
 };
 
 static struct ast_codec t140red = {
index d05774fde01af631411d1f294e475dea3a4dfc1d..627f800a4ffb9a2a6b8bc33132d043f63afb2702 100644 (file)
@@ -4764,6 +4764,8 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc
                /* Video -- samples is # of samples vs. 90000 */
                if (!rtp->lastividtimestamp)
                        rtp->lastividtimestamp = timestamp;
+               ast_set_flag(&rtp->f, AST_FRFLAG_HAS_TIMING_INFO);
+               rtp->f.ts = timestamp / (rtp_get_rate(rtp->f.subclass.format) / 1000);
                rtp->f.samples = timestamp - rtp->lastividtimestamp;
                rtp->lastividtimestamp = timestamp;
                rtp->f.delivery.tv_sec = 0;