| | 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 | |
| | 25 | static 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 | |
| | 36 | static 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 | |
| | 47 | static 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 | |
| | 58 | static 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 | |
| | 69 | RTPDynamicProtocolHandler 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 | |
| | 76 | RTPDynamicProtocolHandler 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 | |
| | 83 | RTPDynamicProtocolHandler 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 | |
| | 90 | RTPDynamicProtocolHandler 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 | }; |