summaryrefslogtreecommitdiffstats
path: root/libavformat/rtpenc_vp9.c
blob: 172ab21f1eb4ddb0ab8a180829e22a8289ded4db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 * RTP packetizer for VP9 payload format (draft version 02) - experimental
 * Copyright (c) 2016 Thomas Volkert <thomas@netzeal.de>
 *
 * 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;
    }
}
OpenPOWER on IntegriCloud