From 668fb1cb6a4ebdbf367881ca0f1b4dfd1fdafce8 Mon Sep 17 00:00:00 2001 From: Thomas Volkert Date: Mon, 30 May 2016 16:31:52 +0200 Subject: rtpenc: packetizer for VP9 RTP payload format (draft v2) --- libavformat/rtpenc_vp9.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 libavformat/rtpenc_vp9.c (limited to 'libavformat/rtpenc_vp9.c') diff --git a/libavformat/rtpenc_vp9.c b/libavformat/rtpenc_vp9.c new file mode 100644 index 0000000000..172ab21f1e --- /dev/null +++ b/libavformat/rtpenc_vp9.c @@ -0,0 +1,54 @@ +/* + * RTP packetizer for VP9 payload format (draft version 02) - experimental + * Copyright (c) 2016 Thomas Volkert + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "rtpenc.h" + +#define RTP_VP9_DESC_REQUIRED_SIZE 1 + +void ff_rtp_send_vp9(AVFormatContext *ctx, const uint8_t *buf, int size) +{ + RTPMuxContext *rtp_ctx = ctx->priv_data; + int len; + + rtp_ctx->timestamp = rtp_ctx->cur_timestamp; + rtp_ctx->buf_ptr = rtp_ctx->buf; + + /* mark the first fragment */ + *rtp_ctx->buf_ptr++ = 0x08; + + while (size > 0) { + len = FFMIN(size, rtp_ctx->max_payload_size - RTP_VP9_DESC_REQUIRED_SIZE); + + if (len == size) { + /* mark the last fragment */ + rtp_ctx->buf[0] |= 0x04; + } + + memcpy(rtp_ctx->buf_ptr, buf, len); + ff_rtp_send_data(ctx, rtp_ctx->buf, len + RTP_VP9_DESC_REQUIRED_SIZE, size == len); + + size -= len; + buf += len; + + /* clear the end bit */ + rtp_ctx->buf[0] &= ~0x08; + } +} -- cgit v1.2.3