• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

libavformat/rtpenc_latm.c

Go to the documentation of this file.
00001 /*
00002  * RTP Packetization of MPEG-4 Audio (RFC 3016)
00003  * Copyright (c) 2011 Juan Carlos Rodriguez <ing.juancarlosrodriguez@hotmail.com>
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 "avformat.h"
00023 #include "rtpenc.h"
00024 
00025 void ff_rtp_send_latm(AVFormatContext *s1, const uint8_t *buff, int size)
00026 {
00027     /* MP4A-LATM
00028      * The RTP payload format specification is described in RFC 3016
00029      * The encoding specifications are provided in ISO/IEC 14496-3 */
00030 
00031     RTPMuxContext *s = s1->priv_data;
00032     int header_size;
00033     int offset = 0;
00034     int len    = 0;
00035 
00036     /* skip ADTS header, if present */
00037     if ((s1->streams[0]->codec->extradata_size) == 0) {
00038         size -= 7;
00039         buff += 7;
00040     }
00041 
00042     /* PayloadLengthInfo() */
00043     header_size = size/0xFF + 1;
00044     memset(s->buf, 0xFF, header_size - 1);
00045     s->buf[header_size - 1] = size % 0xFF;
00046 
00047     s->timestamp = s->cur_timestamp;
00048 
00049     /* PayloadMux() */
00050     while (size > 0) {
00051         len   = FFMIN(size, s->max_payload_size - (!offset ? header_size : 0));
00052         size -= len;
00053         if (!offset) {
00054             memcpy(s->buf + header_size, buff, len);
00055             ff_rtp_send_data(s1, s->buf, header_size + len, !size);
00056         } else {
00057             ff_rtp_send_data(s1, buff + offset, len, !size);
00058         }
00059         offset += len;
00060     }
00061 }
Generated on Sun Apr 22 2012 21:54:08 for Libav by doxygen 1.7.1