[vlc-commits] [Git][videolan/vlc][master] 2 commits: rtp/pcm: add audio/G726-{16, 24, 32, 40} ADPCM formats
Hugo Beauzée-Luyssen (@chouquette)
gitlab at videolan.org
Mon Nov 29 15:19:22 UTC 2021
Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC
Commits:
10576415 by Rémi Denis-Courmont at 2021-11-29T15:05:58+00:00
rtp/pcm: add audio/G726-{16,24,32,40} ADPCM formats
- - - - -
7c4c14d3 by Rémi Denis-Courmont at 2021-11-29T15:05:58+00:00
rtp/pcm: add audio/G727 ADPCM format
- - - - -
1 changed file:
- modules/access/rtp/pcm.c
Changes:
=====================================
modules/access/rtp/pcm.c
=====================================
@@ -1,6 +1,8 @@
/**
* @file pcm.c
- * @brief Real-Time Protocol (RTP) linear and logarithmic audio
+ * @brief Real-Time Protocol (RTP) sample-based audio
+ * This files defines the same-based RTP payload formats (mostly from RFC3551)
+ * including linear, logarithmic and adaptive audio formats.
*/
/*****************************************************************************
* Copyright © 2021 Rémi Denis-Courmont
@@ -132,6 +134,47 @@ static const struct vlc_rtp_pt_operations rtp_pcm_ops = {
rtp_pcm_release, rtp_pcm_init, rtp_pcm_destroy, rtp_pcm_decode,
};
+
+static void *rtp_g722_init(struct vlc_rtp_pt *pt)
+{
+ struct rtp_pcm *sys = pt->opaque;
+ es_format_t fmt;
+
+ es_format_Init(&fmt, AUDIO_ES, VLC_CODEC_ADPCM_G722);
+ /* For historical reasons, the RTP clock rate is 8000 Hz
+ * but the sampling rate really is 16000 Hz. */
+ fmt.audio.i_rate = 16000;
+ fmt.audio.i_physical_channels = sys->channel_mask;
+ fmt.audio.i_channels = sys->channel_count;
+ aout_FormatPrepare(&fmt.audio);
+ return vlc_rtp_pt_request_es(pt, &fmt);
+}
+
+static const struct vlc_rtp_pt_operations rtp_g722_ops = {
+ rtp_pcm_release, rtp_g722_init, rtp_pcm_destroy, rtp_pcm_decode,
+};
+
+
+static void *rtp_g726_init(struct vlc_rtp_pt *pt)
+{
+ struct rtp_pcm *sys = pt->opaque;
+ es_format_t fmt;
+
+ es_format_Init(&fmt, AUDIO_ES, VLC_CODEC_ADPCM_G726);
+ fmt.audio.i_rate = 8000;
+ fmt.audio.i_physical_channels = sys->channel_mask;
+ fmt.audio.i_channels = sys->channel_count;
+ /* By VLC convention, the decoder knows the bit depth from the bit rate. */
+ fmt.i_bitrate = sys->sample_bits * sys->channel_count * 8000;
+ aout_FormatPrepare(&fmt.audio);
+ return vlc_rtp_pt_request_es(pt, &fmt);
+}
+
+static const struct vlc_rtp_pt_operations rtp_g726_ops = {
+ rtp_pcm_release, rtp_g726_init, rtp_pcm_destroy, rtp_pcm_decode,
+};
+
+
static const uint32_t channel_masks[] = {
/* By default, there is only one channel. */
AOUT_CHAN_CENTER,
@@ -164,6 +207,7 @@ static int rtp_pcm_open(vlc_object_t *obj, struct vlc_rtp_pt *pt,
{
vlc_fourcc_t fourcc;
unsigned bits;
+ const struct vlc_rtp_pt_operations *ops = &rtp_pcm_ops;
if (vlc_ascii_strcasecmp(desc->name, "L8") == 0) {
fourcc = VLC_CODEC_U8; /* RFC3551 §4.5.10 */
@@ -189,6 +233,20 @@ static int rtp_pcm_open(vlc_object_t *obj, struct vlc_rtp_pt *pt,
fourcc = VLC_CODEC_MULAW; /* RFC3551 §4.5.14 */
bits = 8;
+ } else if (vlc_ascii_strcasecmp(desc->name, "G722") == 0) {
+ fourcc = VLC_CODEC_ADPCM_G726; /* RFC33551 §4.5.2 */
+ bits = 8;
+ ops = &rtp_g722_ops;
+
+ } else if (sscanf(desc->name, "G726-%u", &bits) == 1
+ || sscanf(desc->name, "g726-%u", &bits) == 1) {
+ fourcc = VLC_CODEC_ADPCM_G726; /* RFC33551 §4.5.4 */
+ bits /= 8;
+ ops = &rtp_g726_ops;
+
+ if (unlikely(bits < 16 || bits % 8 || bits > 40))
+ return VLC_ENOTSUP;
+
} else if (vlc_ascii_strcasecmp(desc->name, "DAT12") == 0) {
fourcc = VLC_CODEC_DAT12; /* RFC3190 §3 */
bits = 12;
@@ -227,7 +285,7 @@ static int rtp_pcm_open(vlc_object_t *obj, struct vlc_rtp_pt *pt,
}
pt->opaque = sys;
- pt->ops = &rtp_pcm_ops;
+ pt->ops = ops;
return VLC_SUCCESS;
}
@@ -238,5 +296,8 @@ vlc_module_begin()
set_subcategory(SUBCAT_INPUT_DEMUX)
set_rtp_parser_callback(rtp_pcm_open)
add_shortcut("audio/L8", "audio/L16", "audio/L20", "audio/L24",
- "audio/DAT12", "audio/PCMA", "audio/PCMU")
+ "audio/DAT12", "audio/PCMA", "audio/PCMU", "audio/G722",
+ "audio/G726-16", "audio/G726-24", "audio/G726-32",
+ "audio/G726-40")
+ /* TODO? DVI4, VDVI */
vlc_module_end()
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/478e4dac8f9dc4d7db89d8e9f0b08f61d95e60a4...7c4c14d340a9a1273a3291d5efdf4ed40d5e555c
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/478e4dac8f9dc4d7db89d8e9f0b08f61d95e60a4...7c4c14d340a9a1273a3291d5efdf4ed40d5e555c
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list