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

          Line data    Source code
       1             : /*
       2             :  * Common code for the RTP depacketization of MPEG-1/2 formats.
       3             :  * Copyright (c) 2002 Fabrice Bellard
       4             :  *
       5             :  * This file is part of FFmpeg.
       6             :  *
       7             :  * FFmpeg is free software; you can redistribute it and/or
       8             :  * modify it under the terms of the GNU Lesser General Public
       9             :  * License as published by the Free Software Foundation; either
      10             :  * version 2.1 of the License, or (at your option) any later version.
      11             :  *
      12             :  * FFmpeg is distributed in the hope that it will be useful,
      13             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15             :  * Lesser General Public License for more details.
      16             :  *
      17             :  * You should have received a copy of the GNU Lesser General Public
      18             :  * License along with FFmpeg; if not, write to the Free Software
      19             :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
      20             :  */
      21             : 
      22             : #include "libavutil/attributes.h"
      23             : #include "libavutil/intreadwrite.h"
      24             : #include "rtpdec_formats.h"
      25             : 
      26           0 : static int mpeg_parse_packet(AVFormatContext *ctx, PayloadContext *data,
      27             :                              AVStream *st, AVPacket *pkt, uint32_t *timestamp,
      28             :                              const uint8_t *buf, int len, uint16_t seq,
      29             :                              int flags)
      30             : {
      31             :     unsigned int h;
      32           0 :     if (len <= 4)
      33           0 :         return AVERROR_INVALIDDATA;
      34           0 :     h    = AV_RB32(buf);
      35           0 :     buf += 4;
      36           0 :     len -= 4;
      37           0 :     if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && h & (1 << 26)) {
      38             :         /* MPEG-2 */
      39           0 :         if (len <= 4)
      40           0 :             return AVERROR_INVALIDDATA;
      41           0 :         buf += 4;
      42           0 :         len -= 4;
      43             :     }
      44           0 :     if (av_new_packet(pkt, len) < 0)
      45           0 :         return AVERROR(ENOMEM);
      46           0 :     memcpy(pkt->data, buf, len);
      47           0 :     pkt->stream_index = st->index;
      48           0 :     return 0;
      49             : }
      50             : 
      51             : RTPDynamicProtocolHandler ff_mpeg_audio_dynamic_handler = {
      52             :     .codec_type        = AVMEDIA_TYPE_AUDIO,
      53             :     .codec_id          = AV_CODEC_ID_MP3,
      54             :     .need_parsing      = AVSTREAM_PARSE_FULL,
      55             :     .parse_packet      = mpeg_parse_packet,
      56             :     .static_payload_id = 14,
      57             : };
      58             : 
      59             : RTPDynamicProtocolHandler ff_mpeg_video_dynamic_handler = {
      60             :     .codec_type        = AVMEDIA_TYPE_VIDEO,
      61             :     .codec_id          = AV_CODEC_ID_MPEG2VIDEO,
      62             :     .need_parsing      = AVSTREAM_PARSE_FULL,
      63             :     .parse_packet      = mpeg_parse_packet,
      64             :     .static_payload_id = 32,
      65             : };

Generated by: LCOV version 1.13