LCOV - code coverage report
Current view: top level - libavformat - rtpenc_aac.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 41 0.0 %
Date: 2017-12-16 01:21:47 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /*
       2             :  * copyright (c) 2007 Luca Abeni
       3             :  *
       4             :  * This file is part of FFmpeg.
       5             :  *
       6             :  * FFmpeg is free software; you can redistribute it and/or
       7             :  * modify it under the terms of the GNU Lesser General Public
       8             :  * License as published by the Free Software Foundation; either
       9             :  * version 2.1 of the License, or (at your option) any later version.
      10             :  *
      11             :  * FFmpeg is distributed in the hope that it will be useful,
      12             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      14             :  * Lesser General Public License for more details.
      15             :  *
      16             :  * You should have received a copy of the GNU Lesser General Public
      17             :  * License along with FFmpeg; if not, write to the Free Software
      18             :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
      19             :  */
      20             : 
      21             : #include "libavutil/intreadwrite.h"
      22             : 
      23             : #include "avformat.h"
      24             : #include "rtpenc.h"
      25             : 
      26             : 
      27           0 : void ff_rtp_send_aac(AVFormatContext *s1, const uint8_t *buff, int size)
      28             : {
      29           0 :     RTPMuxContext *s = s1->priv_data;
      30           0 :     AVStream *st = s1->streams[0];
      31           0 :     const int max_au_headers_size = 2 + 2 * s->max_frames_per_packet;
      32           0 :     int len, max_packet_size = s->max_payload_size - max_au_headers_size;
      33             :     uint8_t *p;
      34             : 
      35             :     /* skip ADTS header, if present */
      36           0 :     if ((s1->streams[0]->codecpar->extradata_size) == 0) {
      37           0 :         size -= 7;
      38           0 :         buff += 7;
      39             :     }
      40             : 
      41             :     /* test if the packet must be sent */
      42           0 :     len = (s->buf_ptr - s->buf);
      43           0 :     if (s->num_frames &&
      44           0 :         (s->num_frames == s->max_frames_per_packet ||
      45           0 :          (len + size) > s->max_payload_size ||
      46           0 :          av_compare_ts(s->cur_timestamp - s->timestamp, st->time_base,
      47           0 :                        s1->max_delay, AV_TIME_BASE_Q) >= 0)) {
      48           0 :         int au_size = s->num_frames * 2;
      49             : 
      50           0 :         p = s->buf + max_au_headers_size - au_size - 2;
      51           0 :         if (p != s->buf) {
      52           0 :             memmove(p + 2, s->buf + 2, au_size);
      53             :         }
      54             :         /* Write the AU header size */
      55           0 :         AV_WB16(p, au_size * 8);
      56             : 
      57           0 :         ff_rtp_send_data(s1, p, s->buf_ptr - p, 1);
      58             : 
      59           0 :         s->num_frames = 0;
      60             :     }
      61           0 :     if (s->num_frames == 0) {
      62           0 :         s->buf_ptr = s->buf + max_au_headers_size;
      63           0 :         s->timestamp = s->cur_timestamp;
      64             :     }
      65             : 
      66           0 :     if (size <= max_packet_size) {
      67           0 :         p = s->buf + s->num_frames++ * 2 + 2;
      68           0 :         AV_WB16(p, size * 8);
      69           0 :         memcpy(s->buf_ptr, buff, size);
      70           0 :         s->buf_ptr += size;
      71             :     } else {
      72           0 :         int au_size = size;
      73             : 
      74           0 :         max_packet_size = s->max_payload_size - 4;
      75           0 :         p = s->buf;
      76           0 :         AV_WB16(p, 2 * 8);
      77           0 :         while (size > 0) {
      78           0 :             len = FFMIN(size, max_packet_size);
      79           0 :             AV_WB16(&p[2], au_size * 8);
      80           0 :             memcpy(p + 4, buff, len);
      81           0 :             ff_rtp_send_data(s1, p, len + 4, len == size);
      82           0 :             size -= len;
      83           0 :             buff += len;
      84             :         }
      85             :     }
      86           0 : }

Generated by: LCOV version 1.13