Ticket #611: 0001-libavformat-add-G726-audio-decoder-in-RTP.patch

File 0001-libavformat-add-G726-audio-decoder-in-RTP.patch, 5.9 KB (added by Miroslav Slugeň, 15 years ago)

Updated signed patch

  • libavformat/Makefile

    From 150b10e2a0ca3f21cc848067402649396d5d2a1f Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Miroslav=20Sluge=C5=88?= <thunder.m@seznam.cz>
    Date: Mon, 7 Nov 2011 12:48:23 +0100
    Subject: [PATCH] libavformat: add support for G726 audio decoder in RTP and RTSP streams
    
    Fixes Ticket611
    ---
     libavformat/Makefile         |    1 +
     libavformat/rtpdec.c         |    5 ++
     libavformat/rtpdec_formats.h |    4 ++
     libavformat/rtpdec_g726.c    |   95 ++++++++++++++++++++++++++++++++++++++++++
     4 files changed, 105 insertions(+), 0 deletions(-)
     create mode 100644 libavformat/rtpdec_g726.c
    
    diff --git a/libavformat/Makefile b/libavformat/Makefile
    index 264ab92..420143d 100644
    a b OBJS-$(CONFIG_RTPDEC) += rdt.o \  
    261261                                            rtpdec.o      \
    262262                                            rtpdec_amr.o  \
    263263                                            rtpdec_asf.o  \
     264                                            rtpdec_g726.o \
    264265                                            rtpdec_h263.o \
    265266                                            rtpdec_h264.o \
    266267                                            rtpdec_latm.o \
  • libavformat/rtpdec.c

    diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
    index 01902a7..20e5bd7 100644
    a b void av_register_rtp_dynamic_payload_handlers(void)  
    8383    ff_register_dynamic_payload_handler(&ff_qt_rtp_vid_handler);
    8484    ff_register_dynamic_payload_handler(&ff_quicktime_rtp_aud_handler);
    8585    ff_register_dynamic_payload_handler(&ff_quicktime_rtp_vid_handler);
     86
     87    ff_register_dynamic_payload_handler(&ff_g726_16_dynamic_handler);
     88    ff_register_dynamic_payload_handler(&ff_g726_24_dynamic_handler);
     89    ff_register_dynamic_payload_handler(&ff_g726_32_dynamic_handler);
     90    ff_register_dynamic_payload_handler(&ff_g726_40_dynamic_handler);
    8691}
    8792
    8893RTPDynamicProtocolHandler *ff_rtp_handler_find_by_name(const char *name,
  • libavformat/rtpdec_formats.h

    diff --git a/libavformat/rtpdec_formats.h b/libavformat/rtpdec_formats.h
    index 16f5a9d..afd047b 100644
    a b int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p);  
    3333
    3434extern RTPDynamicProtocolHandler ff_amr_nb_dynamic_handler;
    3535extern RTPDynamicProtocolHandler ff_amr_wb_dynamic_handler;
     36extern RTPDynamicProtocolHandler ff_g726_16_dynamic_handler;
     37extern RTPDynamicProtocolHandler ff_g726_24_dynamic_handler;
     38extern RTPDynamicProtocolHandler ff_g726_32_dynamic_handler;
     39extern RTPDynamicProtocolHandler ff_g726_40_dynamic_handler;
    3640extern RTPDynamicProtocolHandler ff_h263_1998_dynamic_handler;
    3741extern RTPDynamicProtocolHandler ff_h263_2000_dynamic_handler;
    3842extern RTPDynamicProtocolHandler ff_h264_dynamic_handler;
  • new file libavformat/rtpdec_g726.c

    diff --git a/libavformat/rtpdec_g726.c b/libavformat/rtpdec_g726.c
    new file mode 100644
    index 0000000..b69c2f5
    - +  
     1/*
     2 * RTP G.726 ADPCM support
     3 * Copyright (c) 2011 Miroslav Slugen
     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 "avformat.h"
     23#include "rtpdec_formats.h"
     24
     25static int g726_16_parse_sdp_line(AVFormatContext *s, int st_index,
     26                              PayloadContext *data, const char *line)
     27{
     28    AVStream *stream = s->streams[st_index];
     29    AVCodecContext *codec = stream->codec;
     30
     31    codec->bit_rate = 16000;
     32
     33    return 0;
     34}
     35
     36static int g726_24_parse_sdp_line(AVFormatContext *s, int st_index,
     37                              PayloadContext *data, const char *line)
     38{
     39    AVStream *stream = s->streams[st_index];
     40    AVCodecContext *codec = stream->codec;
     41
     42    codec->bit_rate = 24000;
     43
     44    return 0;
     45}
     46
     47static int g726_32_parse_sdp_line(AVFormatContext *s, int st_index,
     48                              PayloadContext *data, const char *line)
     49{
     50    AVStream *stream = s->streams[st_index];
     51    AVCodecContext *codec = stream->codec;
     52
     53    codec->bit_rate = 32000;
     54
     55    return 0;
     56}
     57
     58static int g726_40_parse_sdp_line(AVFormatContext *s, int st_index,
     59                              PayloadContext *data, const char *line)
     60{
     61    AVStream *stream = s->streams[st_index];
     62    AVCodecContext *codec = stream->codec;
     63
     64    codec->bit_rate = 40000;
     65
     66    return 0;
     67}
     68
     69RTPDynamicProtocolHandler ff_g726_16_dynamic_handler = {
     70    .enc_name         = "G726-16",
     71    .codec_type       = AVMEDIA_TYPE_AUDIO,
     72    .codec_id         = CODEC_ID_ADPCM_G726,
     73    .parse_sdp_a_line = g726_16_parse_sdp_line,
     74};
     75
     76RTPDynamicProtocolHandler ff_g726_24_dynamic_handler = {
     77    .enc_name         = "G726-24",
     78    .codec_type       = AVMEDIA_TYPE_AUDIO,
     79    .codec_id         = CODEC_ID_ADPCM_G726,
     80    .parse_sdp_a_line = g726_24_parse_sdp_line,
     81};
     82
     83RTPDynamicProtocolHandler ff_g726_32_dynamic_handler = {
     84    .enc_name         = "G726-32",
     85    .codec_type       = AVMEDIA_TYPE_AUDIO,
     86    .codec_id         = CODEC_ID_ADPCM_G726,
     87    .parse_sdp_a_line = g726_32_parse_sdp_line,
     88};
     89
     90RTPDynamicProtocolHandler ff_g726_40_dynamic_handler = {
     91    .enc_name         = "G726-40",
     92    .codec_type       = AVMEDIA_TYPE_AUDIO,
     93    .codec_id         = CODEC_ID_ADPCM_G726,
     94    .parse_sdp_a_line = g726_40_parse_sdp_line,
     95};