summaryrefslogtreecommitdiff
path: root/modules/vp8/encode.c
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-07-29 15:13:00 +0200
committerGitHub <noreply@github.com>2017-07-29 15:13:00 +0200
commit6c56980cbeecaaeac0367ad9aa48eaa84fd8314b (patch)
tree062e0fa2e0ecf1a3072386972a87886fa38fe3ec /modules/vp8/encode.c
parent5d297b1594765b681466b13257af0a59bf765ff8 (diff)
Video timestamp (#286)
* add timestamp to video encoder/decoder * update vp8 vp9 * random offset * revert decoder timestamp * cleanup * gst_video1: add timestamp * change timestamp to RTP-timestamp * update modules * timestamp things * save rtp timestamp * packet_handler: align params same as RTP header * align parameters same way like RTP-header * avcodec: calc ts for old FFmpeg versions * cleanup * fix gst avcodec: use correct AVPacket * minor cleanup
Diffstat (limited to 'modules/vp8/encode.c')
-rw-r--r--modules/vp8/encode.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/modules/vp8/encode.c b/modules/vp8/encode.c
index 99560de..83f136b 100644
--- a/modules/vp8/encode.c
+++ b/modules/vp8/encode.c
@@ -157,7 +157,8 @@ static inline void hdr_encode(uint8_t hdr[HDR_SIZE], bool noref, bool start,
static inline int packetize(bool marker, const uint8_t *buf, size_t len,
size_t maxlen, bool noref, uint8_t partid,
- uint16_t picid, videnc_packet_h *pkth, void *arg)
+ uint16_t picid, uint32_t rtp_ts,
+ videnc_packet_h *pkth, void *arg)
{
uint8_t hdr[HDR_SIZE];
bool start = true;
@@ -169,7 +170,8 @@ static inline int packetize(bool marker, const uint8_t *buf, size_t len,
hdr_encode(hdr, noref, start, partid, picid);
- err |= pkth(false, hdr, sizeof(hdr), buf, maxlen, arg);
+ err |= pkth(false, rtp_ts, hdr, sizeof(hdr), buf, maxlen,
+ arg);
buf += maxlen;
len -= maxlen;
@@ -178,7 +180,7 @@ static inline int packetize(bool marker, const uint8_t *buf, size_t len,
hdr_encode(hdr, noref, start, partid, picid);
- err |= pkth(marker, hdr, sizeof(hdr), buf, len, arg);
+ err |= pkth(marker, rtp_ts, hdr, sizeof(hdr), buf, len, arg);
return err;
}
@@ -234,6 +236,7 @@ int vp8_encode(struct videnc_state *ves, bool update,
bool keyframe = false, marker = true;
const vpx_codec_cx_pkt_t *pkt;
uint8_t partid = 0;
+ uint32_t ts;
pkt = vpx_codec_get_cx_data(&ves->ctx, &iter);
if (!pkt)
@@ -253,10 +256,13 @@ int vp8_encode(struct videnc_state *ves, bool update,
partid = pkt->data.frame.partition_id;
#endif
+ ts = video_calc_rtp_timestamp(pkt->data.frame.pts, ves->fps);
+
err = packetize(marker,
pkt->data.frame.buf,
pkt->data.frame.sz,
ves->pktsize, !keyframe, partid, ves->picid,
+ ts,
ves->pkth, ves->arg);
if (err)
return err;