From 77eed91fab9b29426722f424fc39c109a8fa5b11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 5 Mar 2014 16:07:37 +0200 Subject: [PATCH] rtmppkt: Rename the ts_delta field to ts_field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on a suggestion by Martin Panter. This is more descriptive, since it's the actual timestamp field from the RTMP packet, which might or might not be a delta depending on context (in some packets it's a delta, in some packets it's an absolute timestamp, and in some packets it's 0xffffff to indicate that the actual delta or absolute timestamp is transmitted separately). Signed-off-by: Martin Storsjö --- libavformat/rtmppkt.c | 20 ++++++++++---------- libavformat/rtmppkt.h | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c index 241a521eb3..306a243941 100644 --- a/libavformat/rtmppkt.c +++ b/libavformat/rtmppkt.c @@ -196,7 +196,7 @@ static int rtmp_packet_read_one_chunk(URLContext *h, RTMPPacket *p, hdr >>= 6; // header size indicator if (hdr == RTMP_PS_ONEBYTE) { - ts_field = prev_pkt[channel_id].ts_delta; + ts_field = prev_pkt[channel_id].ts_field; } else { if (ffurl_read_complete(h, buf, 3) != 3) return AVERROR(EIO); @@ -235,7 +235,7 @@ static int rtmp_packet_read_one_chunk(URLContext *h, RTMPPacket *p, return ret; p->read = written; p->offset = 0; - prev_pkt[channel_id].ts_delta = ts_field; + prev_pkt[channel_id].ts_field = ts_field; prev_pkt[channel_id].timestamp = timestamp; } else { // previous packet in this channel hasn't completed reading @@ -244,7 +244,7 @@ static int rtmp_packet_read_one_chunk(URLContext *h, RTMPPacket *p, p->size = prev->size; p->channel_id = prev->channel_id; p->type = prev->type; - p->ts_delta = prev->ts_delta; + p->ts_field = prev->ts_field; p->extra = prev->extra; p->offset = prev->offset; p->read = prev->read + written; @@ -323,16 +323,16 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *pkt, timestamp -= prev_pkt[pkt->channel_id].timestamp; } if (timestamp >= 0xFFFFFF) { - pkt->ts_delta = 0xFFFFFF; + pkt->ts_field = 0xFFFFFF; } else { - pkt->ts_delta = timestamp; + pkt->ts_field = timestamp; } if (use_delta) { if (pkt->type == prev_pkt[pkt->channel_id].type && pkt->size == prev_pkt[pkt->channel_id].size) { mode = RTMP_PS_FOURBYTES; - if (pkt->ts_delta == prev_pkt[pkt->channel_id].ts_delta) + if (pkt->ts_field == prev_pkt[pkt->channel_id].ts_field) mode = RTMP_PS_ONEBYTE; } else { mode = RTMP_PS_EIGHTBYTES; @@ -349,7 +349,7 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *pkt, bytestream_put_le16(&p, pkt->channel_id - 64); } if (mode != RTMP_PS_ONEBYTE) { - bytestream_put_be24(&p, pkt->ts_delta); + bytestream_put_be24(&p, pkt->ts_field); if (mode != RTMP_PS_FOURBYTES) { bytestream_put_be24(&p, pkt->size); bytestream_put_byte(&p, pkt->type); @@ -357,14 +357,14 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *pkt, bytestream_put_le32(&p, pkt->extra); } } - if (pkt->ts_delta == 0xFFFFFF) + if (pkt->ts_field == 0xFFFFFF) bytestream_put_be32(&p, timestamp); // save history prev_pkt[pkt->channel_id].channel_id = pkt->channel_id; prev_pkt[pkt->channel_id].type = pkt->type; prev_pkt[pkt->channel_id].size = pkt->size; prev_pkt[pkt->channel_id].timestamp = pkt->timestamp; - prev_pkt[pkt->channel_id].ts_delta = pkt->ts_delta; + prev_pkt[pkt->channel_id].ts_field = pkt->ts_field; prev_pkt[pkt->channel_id].extra = pkt->extra; if ((ret = ffurl_write(h, pkt_hdr, p - pkt_hdr)) < 0) @@ -398,7 +398,7 @@ int ff_rtmp_packet_create(RTMPPacket *pkt, int channel_id, RTMPPacketType type, pkt->type = type; pkt->timestamp = timestamp; pkt->extra = 0; - pkt->ts_delta = 0; + pkt->ts_field = 0; return 0; } diff --git a/libavformat/rtmppkt.h b/libavformat/rtmppkt.h index 3ccc6b4110..e973684aa9 100644 --- a/libavformat/rtmppkt.h +++ b/libavformat/rtmppkt.h @@ -78,7 +78,7 @@ typedef struct RTMPPacket { int channel_id; ///< RTMP channel ID (nothing to do with audio/video channels though) RTMPPacketType type; ///< packet payload type uint32_t timestamp; ///< packet full timestamp - uint32_t ts_delta; ///< 24-bit timestamp or increment to the previous one, in milliseconds (latter only for media packets). Clipped to a maximum of 0xFFFFFF, indicating an extended timestamp field. + uint32_t ts_field; ///< 24-bit timestamp or increment to the previous one, in milliseconds (latter only for media packets). Clipped to a maximum of 0xFFFFFF, indicating an extended timestamp field. uint32_t extra; ///< probably an additional channel ID used during streaming data uint8_t *data; ///< packet payload int size; ///< packet payload size