@@ -2669,7 +2669,8 @@ srs_error_t SrsConfig::check_normal_config()
2669
2669
if (m != " enabled" && m != " nack" && m != " twcc" && m != " nack_no_copy"
2670
2670
&& m != " bframe" && m != " aac" && m != " stun_timeout" && m != " stun_strict_check"
2671
2671
&& m != " dtls_role" && m != " dtls_version" && m != " drop_for_pt" && m != " rtc_to_rtmp"
2672
- && m != " pli_for_rtmp" && m != " rtmp_to_rtc" && m != " keep_bframe" ) {
2672
+ && m != " pli_for_rtmp" && m != " rtmp_to_rtc" && m != " keep_bframe" && m != " opus_bitrate"
2673
+ && m != " aac_bitrate" ) {
2673
2674
return srs_error_new (ERROR_SYSTEM_CONFIG_INVALID, " illegal vhost.rtc.%s of %s" , m.c_str (), vhost->arg0 ().c_str ());
2674
2675
}
2675
2676
}
@@ -4641,6 +4642,74 @@ bool SrsConfig::get_rtc_twcc_enabled(string vhost)
4641
4642
return SRS_CONF_PERFER_TRUE (conf->arg0 ());
4642
4643
}
4643
4644
4645
+ int SrsConfig::get_rtc_opus_bitrate (string vhost)
4646
+ {
4647
+ static int DEFAULT = 48000 ;
4648
+
4649
+ string opus_bitrate = srs_getenv (" srs.vhost.rtc.opus_bitrate" ); // SRS_VHOST_RTC_OPUS_BITRATE
4650
+ if (!opus_bitrate.empty ()) {
4651
+ int v = ::atoi (opus_bitrate.c_str ());
4652
+ if (v < 8000 || v > 320000 ) {
4653
+ srs_warn (" Reset opus btirate %d to %d" , v, DEFAULT);
4654
+ v = DEFAULT;
4655
+ }
4656
+
4657
+ return v;
4658
+ }
4659
+
4660
+ SrsConfDirective* conf = get_rtc (vhost);
4661
+ if (!conf) {
4662
+ return DEFAULT;
4663
+ }
4664
+
4665
+ conf = conf->get (" opus_bitrate" );
4666
+ if (!conf || conf->arg0 ().empty ()) {
4667
+ return DEFAULT;
4668
+ }
4669
+
4670
+ int v = ::atoi (conf->arg0 ().c_str ());
4671
+ if (v < 8000 || v > 320000 ) {
4672
+ srs_warn (" Reset opus btirate %d to %d" , v, DEFAULT);
4673
+ return DEFAULT;
4674
+ }
4675
+
4676
+ return v;
4677
+ }
4678
+
4679
+ int SrsConfig::get_rtc_aac_bitrate (string vhost)
4680
+ {
4681
+ static int DEFAULT = 48000 ;
4682
+
4683
+ string aac_bitrate = srs_getenv (" srs.vhost.rtc.aac_bitrate" ); // SRS_VHOST_RTC_AAC_BITRATE
4684
+ if (!aac_bitrate.empty ()) {
4685
+ int v = ::atoi (aac_bitrate.c_str ());
4686
+ if (v < 8000 || v > 320000 ) {
4687
+ srs_warn (" Reset aac btirate %d to %d" , v, DEFAULT);
4688
+ v = DEFAULT;
4689
+ }
4690
+
4691
+ return v;
4692
+ }
4693
+
4694
+ SrsConfDirective* conf = get_rtc (vhost);
4695
+ if (!conf) {
4696
+ return DEFAULT;
4697
+ }
4698
+
4699
+ conf = conf->get (" aac_bitrate" );
4700
+ if (!conf || conf->arg0 ().empty ()) {
4701
+ return DEFAULT;
4702
+ }
4703
+
4704
+ int v = ::atoi (conf->arg0 ().c_str ());
4705
+ if (v < 8000 || v > 320000 ) {
4706
+ srs_warn (" Reset aac btirate %d to %d" , v, DEFAULT);
4707
+ return DEFAULT;
4708
+ }
4709
+
4710
+ return v;
4711
+ }
4712
+
4644
4713
SrsConfDirective* SrsConfig::get_vhost (string vhost, bool try_default_vhost)
4645
4714
{
4646
4715
srs_assert (root);
0 commit comments