Browse code

libavformat: add support for G726 audio decoder in RTP and RTSP streams Fixes Ticket611

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Miroslav Slugeň authored on 2011/11/07 20:13:55
Showing 4 changed files
... ...
@@ -261,6 +261,7 @@ OBJS-$(CONFIG_RTPDEC)                    += rdt.o         \
261 261
                                             rtpdec.o      \
262 262
                                             rtpdec_amr.o  \
263 263
                                             rtpdec_asf.o  \
264
+                                            rtpdec_g726.o \
264 265
                                             rtpdec_h263.o \
265 266
                                             rtpdec_h264.o \
266 267
                                             rtpdec_latm.o \
... ...
@@ -83,6 +83,11 @@ void av_register_rtp_dynamic_payload_handlers(void)
83 83
     ff_register_dynamic_payload_handler(&ff_qt_rtp_vid_handler);
84 84
     ff_register_dynamic_payload_handler(&ff_quicktime_rtp_aud_handler);
85 85
     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);
86 91
 }
87 92
 
88 93
 RTPDynamicProtocolHandler *ff_rtp_handler_find_by_name(const char *name,
... ...
@@ -33,6 +33,10 @@ int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p);
33 33
 
34 34
 extern RTPDynamicProtocolHandler ff_amr_nb_dynamic_handler;
35 35
 extern RTPDynamicProtocolHandler ff_amr_wb_dynamic_handler;
36
+extern RTPDynamicProtocolHandler ff_g726_16_dynamic_handler;
37
+extern RTPDynamicProtocolHandler ff_g726_24_dynamic_handler;
38
+extern RTPDynamicProtocolHandler ff_g726_32_dynamic_handler;
39
+extern RTPDynamicProtocolHandler ff_g726_40_dynamic_handler;
36 40
 extern RTPDynamicProtocolHandler ff_h263_1998_dynamic_handler;
37 41
 extern RTPDynamicProtocolHandler ff_h263_2000_dynamic_handler;
38 42
 extern RTPDynamicProtocolHandler ff_h264_dynamic_handler;
39 43
new file mode 100644
... ...
@@ -0,0 +1,94 @@
0
+/*
1
+ * Copyright (c) 2011 Miroslav Slugeň <Thunder.m@seznam.cz>
2
+ *
3
+ * This file is part of FFmpeg.
4
+ *
5
+ * FFmpeg is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * FFmpeg is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with FFmpeg; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ */
19
+
20
+#include "avformat.h"
21
+#include "rtpdec_formats.h"
22
+
23
+static int g726_16_parse_sdp_line(AVFormatContext *s, int st_index,
24
+                              PayloadContext *data, const char *line)
25
+{
26
+    AVStream *stream = s->streams[st_index];
27
+    AVCodecContext *codec = stream->codec;
28
+
29
+    codec->bit_rate = 16000;
30
+
31
+    return 0;
32
+}
33
+
34
+static int g726_24_parse_sdp_line(AVFormatContext *s, int st_index,
35
+                              PayloadContext *data, const char *line)
36
+{
37
+    AVStream *stream = s->streams[st_index];
38
+    AVCodecContext *codec = stream->codec;
39
+
40
+    codec->bit_rate = 24000;
41
+
42
+    return 0;
43
+}
44
+
45
+static int g726_32_parse_sdp_line(AVFormatContext *s, int st_index,
46
+                              PayloadContext *data, const char *line)
47
+{
48
+    AVStream *stream = s->streams[st_index];
49
+    AVCodecContext *codec = stream->codec;
50
+
51
+    codec->bit_rate = 32000;
52
+
53
+    return 0;
54
+}
55
+
56
+static int g726_40_parse_sdp_line(AVFormatContext *s, int st_index,
57
+                              PayloadContext *data, const char *line)
58
+{
59
+    AVStream *stream = s->streams[st_index];
60
+    AVCodecContext *codec = stream->codec;
61
+
62
+    codec->bit_rate = 40000;
63
+
64
+    return 0;
65
+}
66
+
67
+RTPDynamicProtocolHandler ff_g726_16_dynamic_handler = {
68
+    .enc_name         = "G726-16",
69
+    .codec_type       = AVMEDIA_TYPE_AUDIO,
70
+    .codec_id         = CODEC_ID_ADPCM_G726,
71
+    .parse_sdp_a_line = g726_16_parse_sdp_line,
72
+};
73
+
74
+RTPDynamicProtocolHandler ff_g726_24_dynamic_handler = {
75
+    .enc_name         = "G726-24",
76
+    .codec_type       = AVMEDIA_TYPE_AUDIO,
77
+    .codec_id         = CODEC_ID_ADPCM_G726,
78
+    .parse_sdp_a_line = g726_24_parse_sdp_line,
79
+};
80
+
81
+RTPDynamicProtocolHandler ff_g726_32_dynamic_handler = {
82
+    .enc_name         = "G726-32",
83
+    .codec_type       = AVMEDIA_TYPE_AUDIO,
84
+    .codec_id         = CODEC_ID_ADPCM_G726,
85
+    .parse_sdp_a_line = g726_32_parse_sdp_line,
86
+};
87
+
88
+RTPDynamicProtocolHandler ff_g726_40_dynamic_handler = {
89
+    .enc_name         = "G726-40",
90
+    .codec_type       = AVMEDIA_TYPE_AUDIO,
91
+    .codec_id         = CODEC_ID_ADPCM_G726,
92
+    .parse_sdp_a_line = g726_40_parse_sdp_line,
93
+};