use Opus, not OPUS

For audio codecs, we respect its native capitalization of letters, eg.
AAC, speex. So do it also for Opus. This should not affect existing
applications since the Opus name is parsed case-insensitively.

Only exception is SDP (rtpmap) where is usually used lower-case (at
least in rfc7587).
This commit is contained in:
Martin Pulec
2023-04-26 09:05:00 +02:00
parent da699d007d
commit 48219758ea
6 changed files with 14 additions and 14 deletions

View File

@@ -3,7 +3,7 @@
* @author Martin Pulec <pulec@cesnet.cz>
*/
/*
* Copyright (c) 2013-2021 CESNET, z. s. p. o.
* Copyright (c) 2013-2023 CESNET, z. s. p. o.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -65,7 +65,7 @@ static const unordered_map<audio_codec_t, audio_codec_info_t, hash<int>> audio_c
{AC_ALAW, { "A-law", 0x0006 }},
{AC_MULAW, { "u-law", 0x0007 }},
{AC_SPEEX, { "speex", 0xA109 }},
{AC_OPUS, { "OPUS", 0x7375704F }}, // == Opus, the TwoCC isn't defined
{AC_OPUS, { "Opus", 0x7375704F }}, // == Opus, the TwoCC isn't defined
{AC_G722, { "G.722", 0x028F }},
{AC_MP3, { "MP3", 0x0055 }},
{AC_AAC, { "AAC", 0x00FF }},

View File

@@ -1,5 +1,5 @@
/**
* @file audio/codec/libavcodec.cpp
* @file audio/codec/libavcodec.c
* @author Martin Pulec <pulec@cesnet.cz>
*/
/*
@@ -335,7 +335,7 @@ static bool reinitialize_encoder(struct libavcodec_codec_state *s, struct audio_
if (strcmp(s->codec->name, "libopus") == 0) {
int ret = av_opt_set(s->codec_ctx->priv_data, "application", "lowdelay", 0);
if (ret != 0) {
print_libav_audio_error(LOG_LEVEL_WARNING, "Could not set OPUS low delay app type", ret);
print_libav_audio_error(LOG_LEVEL_WARNING, "Could not set Opus low delay app type", ret);
}
} else if (strcmp(s->codec->name, "opus") == 0) {
char warn[] = MOD_NAME "Native FFmpeg Opus encoder seems to be currently broken "
@@ -356,7 +356,7 @@ static bool reinitialize_encoder(struct libavcodec_codec_state *s, struct audio_
if (s->codec->id == AV_CODEC_ID_OPUS) {
int ret = av_opt_set_double(s->codec_ctx->priv_data, "frame_duration", frame_duration, 0);
if (ret != 0) {
print_libav_audio_error(LOG_LEVEL_ERROR, "Could not set OPUS frame duration", ret);
print_libav_audio_error(LOG_LEVEL_ERROR, "Could not set Opus frame duration", ret);
}
}
if (s->codec->id == AV_CODEC_ID_FLAC) {

View File

@@ -1130,7 +1130,7 @@ static int adjust_params(struct ug_options *opt) {
if (opt->audio.codec_cfg == nullptr) {
if (strcasecmp(opt->audio.proto, "rtsp") == 0 || strcasecmp(opt->audio.proto, "sdp") == 0) {
opt->audio.codec_cfg = "OPUS:sample_rate=48000";
opt->audio.codec_cfg = "Opus:sample_rate=48000";
} else {
opt->audio.codec_cfg = DEFAULT_AUDIO_CODEC;
}

View File

@@ -170,7 +170,7 @@ void BasicRTSPOnlySubsession::setSDPLines() {
//rtpmapLine, // a=rtpmap:... (if present)
rtp_port_audio + 1,
rtpPayloadType,
audio_codec == AC_MULAW ? "PCMU" : audio_codec == AC_ALAW ? "PCMA" : "OPUS",
audio_codec == AC_MULAW ? "PCMU" : audio_codec == AC_ALAW ? "PCMA" : "opus",
audio_sample_rate,
audio_channels,
trackId()); // a=control:<track-id>

View File

@@ -17,7 +17,7 @@
*
* Copyright (c) 2005-2010 Fundació i2CAT, Internet I Innovació Digital a Catalunya
* Copyright (c) 2001-2004 University of Southern California
* Copyright (c) 2005-2021 CESNET z.s.p.o.
* Copyright (c) 2005-2023 CESNET z.s.p.o.
*
* Redistribution and use in source and binary forms, with or without
* modification, is permitted provided that the following conditions
@@ -983,7 +983,7 @@ void audio_tx_send_standard(struct tx* tx, struct rtp *rtp_session,
if (buffer->get_codec() == AC_OPUS) { // OPUS needs to fit one package
if (payload_size < data_len) {
log_msg(LOG_LEVEL_ERROR, "Transmit: OPUS frame larger than packet! Discarding...\n");
log_msg(LOG_LEVEL_ERROR, "Transmit: Opus frame larger than packet! Discarding...\n");
return;
}
} else { // we may split the data into more packets, compute chunk size
@@ -997,8 +997,8 @@ void audio_tx_send_standard(struct tx* tx, struct rtp *rtp_session,
// interleave
if (buffer->get_codec() == AC_OPUS) {
if (buffer->get_channel_count() > 1) { // we cannot interleave OPUS here
LOG(LOG_LEVEL_ERROR) << "Transmit: Only OPUS with 1 channel is supported in RFC-compliant mode! Discarding...\n";
if (buffer->get_channel_count() > 1) { // we cannot interleave Opus here
LOG(LOG_LEVEL_ERROR) << "Transmit: Only Opus with 1 channel is supported in RFC-compliant mode! Discarding...\n";
return;
}
memcpy(tx->tmp_packet, buffer->get_data(0), pkt_len);

View File

@@ -183,11 +183,11 @@ int sdp_add_audio(struct sdp *sdp, int port, int sample_rate, int channels, audi
audio_codec = "PCMU";
break;
case AC_OPUS:
audio_codec = "OPUS";
ts_rate = 48000; // RFC 7587 specifies always 48 kHz for OPUS
audio_codec = "opus";
ts_rate = 48000; // RFC 7587 specifies always 48 kHz for Opus
break;
default:
log_msg(LOG_LEVEL_ERROR, "[SDP] Currently only PCMA, PCMU and OPUS audio codecs are supported!\n");
log_msg(LOG_LEVEL_ERROR, "[SDP] Currently only PCMA, PCMU and Opus audio codecs are supported!\n");
return -2;
}