yading@11: /* yading@11: * RTP VP8 Packetizer yading@11: * Copyright (c) 2010 Josh Allmann yading@11: * yading@11: * This file is part of FFmpeg. yading@11: * yading@11: * FFmpeg is free software; you can redistribute it and/or yading@11: * modify it under the terms of the GNU Lesser General Public yading@11: * License as published by the Free Software Foundation; either yading@11: * version 2.1 of the License, or (at your option) any later version. yading@11: * yading@11: * FFmpeg is distributed in the hope that it will be useful, yading@11: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@11: * Lesser General Public License for more details. yading@11: * yading@11: * You should have received a copy of the GNU Lesser General Public yading@11: * License along with FFmpeg; if not, write to the Free Software yading@11: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@11: */ yading@11: yading@11: #include "rtpenc.h" yading@11: yading@11: /* Based on a draft spec for VP8 RTP. yading@11: * ( http://tools.ietf.org/html/draft-ietf-payload-vp8-05 ) */ yading@11: void ff_rtp_send_vp8(AVFormatContext *s1, const uint8_t *buf, int size) yading@11: { yading@11: RTPMuxContext *s = s1->priv_data; yading@11: int len, max_packet_size, header_size; yading@11: yading@11: s->buf_ptr = s->buf; yading@11: s->timestamp = s->cur_timestamp; yading@11: yading@11: // extended control bit set, reference frame, start of partition, yading@11: // partition id 0 yading@11: *s->buf_ptr++ = 0x90; yading@11: *s->buf_ptr++ = 0x80; // Picture id present yading@11: *s->buf_ptr++ = s->frame_count++ & 0x7f; yading@11: // Calculate the number of remaining bytes yading@11: header_size = s->buf_ptr - s->buf; yading@11: max_packet_size = s->max_payload_size - header_size; yading@11: yading@11: while (size > 0) { yading@11: len = FFMIN(size, max_packet_size); yading@11: yading@11: memcpy(s->buf_ptr, buf, len); yading@11: // marker bit is last packet in frame yading@11: ff_rtp_send_data(s1, s->buf, len + header_size, size == len); yading@11: yading@11: size -= len; yading@11: buf += len; yading@11: // Clear the partition start bit, keep the rest of the header untouched yading@11: s->buf[0] &= ~0x10; yading@11: } yading@11: }