Libav 0.7.1
libavformat/rtpenc_vp8.c
Go to the documentation of this file.
00001 /*
00002  * RTP VP8 Packetizer
00003  * Copyright (c) 2010 Josh Allmann
00004  *
00005  * This file is part of Libav.
00006  *
00007  * Libav is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * Libav is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with Libav; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00020  */
00021 
00022 #include "rtpenc.h"
00023 
00024 /* Based on a draft spec for VP8 RTP.
00025  * ( http://www.webmproject.org/code/specs/rtp/ ) */
00026 void ff_rtp_send_vp8(AVFormatContext *s1, const uint8_t *buf, int size)
00027 {
00028     RTPMuxContext *s = s1->priv_data;
00029     int len, max_packet_size;
00030 
00031     s->buf_ptr      = s->buf;
00032     s->timestamp    = s->cur_timestamp;
00033     max_packet_size = s->max_payload_size - 1; // minus one for header byte
00034 
00035     *s->buf_ptr++ = 1; // 0b1 indicates start of frame
00036     while (size > 0) {
00037         len = FFMIN(size, max_packet_size);
00038 
00039         memcpy(s->buf_ptr, buf, len);
00040         ff_rtp_send_data(s1, s->buf, len+1, size == len); // marker bit is last packet in frame
00041 
00042         size         -= len;
00043         buf          += len;
00044         s->buf_ptr    = s->buf;
00045         *s->buf_ptr++ = 0; // payload descriptor
00046     }
00047 }