annotate ffmpeg/libavformat/rtpenc_vp8.c @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents f445c3017523
children
rev   line source
yading@11 1 /*
yading@11 2 * RTP VP8 Packetizer
yading@11 3 * Copyright (c) 2010 Josh Allmann
yading@11 4 *
yading@11 5 * This file is part of FFmpeg.
yading@11 6 *
yading@11 7 * FFmpeg is free software; you can redistribute it and/or
yading@11 8 * modify it under the terms of the GNU Lesser General Public
yading@11 9 * License as published by the Free Software Foundation; either
yading@11 10 * version 2.1 of the License, or (at your option) any later version.
yading@11 11 *
yading@11 12 * FFmpeg is distributed in the hope that it will be useful,
yading@11 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@11 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@11 15 * Lesser General Public License for more details.
yading@11 16 *
yading@11 17 * You should have received a copy of the GNU Lesser General Public
yading@11 18 * License along with FFmpeg; if not, write to the Free Software
yading@11 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@11 20 */
yading@11 21
yading@11 22 #include "rtpenc.h"
yading@11 23
yading@11 24 /* Based on a draft spec for VP8 RTP.
yading@11 25 * ( http://tools.ietf.org/html/draft-ietf-payload-vp8-05 ) */
yading@11 26 void ff_rtp_send_vp8(AVFormatContext *s1, const uint8_t *buf, int size)
yading@11 27 {
yading@11 28 RTPMuxContext *s = s1->priv_data;
yading@11 29 int len, max_packet_size, header_size;
yading@11 30
yading@11 31 s->buf_ptr = s->buf;
yading@11 32 s->timestamp = s->cur_timestamp;
yading@11 33
yading@11 34 // extended control bit set, reference frame, start of partition,
yading@11 35 // partition id 0
yading@11 36 *s->buf_ptr++ = 0x90;
yading@11 37 *s->buf_ptr++ = 0x80; // Picture id present
yading@11 38 *s->buf_ptr++ = s->frame_count++ & 0x7f;
yading@11 39 // Calculate the number of remaining bytes
yading@11 40 header_size = s->buf_ptr - s->buf;
yading@11 41 max_packet_size = s->max_payload_size - header_size;
yading@11 42
yading@11 43 while (size > 0) {
yading@11 44 len = FFMIN(size, max_packet_size);
yading@11 45
yading@11 46 memcpy(s->buf_ptr, buf, len);
yading@11 47 // marker bit is last packet in frame
yading@11 48 ff_rtp_send_data(s1, s->buf, len + header_size, size == len);
yading@11 49
yading@11 50 size -= len;
yading@11 51 buf += len;
yading@11 52 // Clear the partition start bit, keep the rest of the header untouched
yading@11 53 s->buf[0] &= ~0x10;
yading@11 54 }
yading@11 55 }