| 6 |
| --- |
| 7 | tgcalls/group/GroupInstanceCustomImpl.cpp | 47 ++++++++++++++--------- |
| 8 | tgcalls/group/GroupInstanceCustomImpl.h | 1 + |
| 9 | 2 files changed, 30 insertions(+), 18 deletions(-) |
| 10 |
| 11 | diff --git a/tgcalls/group/GroupInstanceCustomImpl.cpp b/tgcalls/group/GroupInstanceCustomImpl.cpp |
| 12 | index f06bec4..d1e487d 100644 |
| 13 | --- a/tgcalls/group/GroupInstanceCustomImpl.cpp |
| 14 | +++ b/tgcalls/group/GroupInstanceCustomImpl.cpp |
| 15 | @@ -1335,6 +1335,8 @@ GroupLevelValue mappedAudioLevel(GroupLevelValue const &value) { |
| 16 |
| 17 | } // namespace |
| 18 |
| 19 | +int GroupInstanceCustomImpl::customAudioBitrate = 0; |
| 20 | + |
| 21 | class GroupInstanceCustomInternal : public sigslot::has_slots<>, public std::enable_shared_from_this<GroupInstanceCustomInternal> { |
| 22 | public: |
| 23 | GroupInstanceCustomInternal(GroupInstanceDescriptor &&descriptor, std::shared_ptr<Threads> threads) : |
| 24 | @@ -1375,8 +1377,11 @@ public: |
| 25 | _initialOutputDeviceId(std::move(descriptor.initialOutputDeviceId)), |
| 26 | _missingPacketBuffer(50), |
| 27 | _onMutedSpeechActivityDetected(std::move(descriptor.onMutedSpeechActivityDetected)) { |
| 28 | + RTC_LOG(LS_INFO) << "Init GroupInstanceCustomImpl with audio bitrate " << _outgoingAudioBitrateKbit << "kbps"; |
| 29 | assert(_threads->getMediaThread()->IsCurrent()); |
| 30 |
| 31 | + GroupInstanceCustomImpl::customAudioBitrate = _outgoingAudioBitrateKbit * 1000; |
| 32 | + |
| 33 | _threads->getWorkerThread()->BlockingCall([this] { |
| 34 | _workerThreadSafery = webrtc::PendingTaskSafetyFlag::Create(); |
| 35 | }); |
| 36 | @@ -1402,6 +1407,9 @@ public: |
| 37 | } |
| 38 |
| 39 | ~GroupInstanceCustomInternal() { |
| 40 | + RTC_LOG(LS_WARNING) << "~GroupInstanceCustomInternal, reset customAudioBitrate to zero"; |
| 41 | + GroupInstanceCustomImpl::customAudioBitrate = 0; |
| 42 | + |
| 43 | _incomingAudioChannels.clear(); |
| 44 | _incomingVideoChannels.clear(); |
| 45 | _serverBandwidthProbingVideoSsrc.reset(); |
| 46 | @@ -1429,16 +1437,18 @@ public: |
| 47 |
| 48 | const auto weak = std::weak_ptr<GroupInstanceCustomInternal>(shared_from_this()); |
| 49 |
| 50 | - webrtc::field_trial::InitFieldTrialsFromString( |
| 51 | - "WebRTC-DataChannel-Dcsctp/Enabled/" |
| 52 | - "WebRTC-Audio-Allocation/min:32kbps,max:32kbps/" |
| 53 | - "WebRTC-Audio-OpusMinPacketLossRate/Enabled-1/" |
| 54 | - "WebRTC-TaskQueuePacer/Enabled/" |
| 55 | - "WebRTC-VP8ConferenceTemporalLayers/1/" |
| 56 | - "WebRTC-Audio-MinimizeResamplingOnMobile/Enabled/" |
| 57 | - "WebRTC-BweLossExperiment/Enabled/" |
| 58 | - "WebRTC-Video-DiscardPacketsWithUnknownSsrc/Enabled/" |
| 59 | - ); |
| 60 | + std::stringstream stringStream; |
| 61 | + stringStream << "WebRTC-DataChannel-Dcsctp/Enabled/" |
| 62 | + "WebRTC-Audio-Allocation/min:" << _outgoingAudioBitrateKbit << "kbps,max:" << _outgoingAudioBitrateKbit << "kbps/" |
| 63 | + << "WebRTC-Audio-OpusMinPacketLossRate/Enabled-1/" |
| 64 | + << "WebRTC-TaskQueuePacer/Enabled/" |
| 65 | + << "WebRTC-VP8ConferenceTemporalLayers/1/" |
| 66 | + << "WebRTC-Audio-MinimizeResamplingOnMobile/Enabled/" |
| 67 | + << "WebRTC-BweLossExperiment/Enabled/" |
| 68 | + << "WebRTC-Video-DiscardPacketsWithUnknownSsrc/Enabled/"; |
| 69 | + |
| 70 | + auto webrtcInitStr = stringStream.str(); |
| 71 | + webrtc::field_trial::InitFieldTrialsFromString(webrtcInitStr.c_str()); |
| 72 |
| 73 | bool takeAudioLevelFromNetwork = _e2eEncryptDecrypt == nullptr; |
| 74 |
| 75 | @@ -1949,6 +1959,7 @@ public: |
| 76 |
| 77 | cricket::AudioOptions audioOptions; |
| 78 | if (_disableOutgoingAudioProcessing || _videoContentType == VideoContentType::Screencast) { |
| 79 | + RTC_LOG(LS_ERROR) << "outgoing audio processing disabled"; |
| 80 | audioOptions.echo_cancellation = false; |
| 81 | audioOptions.noise_suppression = false; |
| 82 | audioOptions.auto_gain_control = false; |
| 83 | @@ -1969,10 +1980,10 @@ public: |
| 84 | _outgoingAudioChannel->SetRtpTransport(_rtpTransport); |
| 85 | }); |
| 86 |
| 87 | - const uint8_t opusMinBitrateKbps = _outgoingAudioBitrateKbit; |
| 88 | - const uint8_t opusMaxBitrateKbps = _outgoingAudioBitrateKbit; |
| 89 | - const uint8_t opusStartBitrateKbps = _outgoingAudioBitrateKbit; |
| 90 | - const uint8_t opusPTimeMs = 120; |
| 91 | + int opusMinBitrateKbps = _outgoingAudioBitrateKbit; |
| 92 | + int opusMaxBitrateKbps = _outgoingAudioBitrateKbit; |
| 93 | + int opusStartBitrateKbps = _outgoingAudioBitrateKbit; |
| 94 | + const uint8_t opusPTimeMs = _outgoingAudioBitrateKbit == 32 ? 120 : 10; |
| 95 |
| 96 | cricket::AudioCodec opusCodec = cricket::CreateAudioCodec(111, "opus", 48000, 2); |
| 97 | opusCodec.AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamTransportCc)); |
| 98 | @@ -2446,11 +2457,11 @@ public: |
| 99 | preferences.max_bitrate_bps = std::max(preferences.min_bitrate_bps, (1020 + 32) * 1000); |
| 100 | } |
| 101 | } else { |
| 102 | - preferences.min_bitrate_bps = 32000; |
| 103 | + preferences.min_bitrate_bps = _outgoingAudioBitrateKbit * 1024; |
| 104 | if (resetStartBitrate) { |
| 105 | - preferences.start_bitrate_bps = 32000; |
| 106 | + preferences.start_bitrate_bps = _outgoingAudioBitrateKbit * 1024; |
| 107 | } |
| 108 | - preferences.max_bitrate_bps = 32000; |
| 109 | + preferences.max_bitrate_bps = _outgoingAudioBitrateKbit * 1024; |
| 110 | } |
| 111 |
| 112 | settings.min_bitrate_bps = preferences.min_bitrate_bps; |
| 113 | @@ -2843,7 +2854,7 @@ public: |
| 114 | _connectionMode = connectionMode; |
| 115 | _isUnifiedBroadcast = isUnifiedBroadcast; |
| 116 | onConnectionModeUpdated(previousMode, keepBroadcastIfWasEnabled); |
| 117 | - |
| 118 | + |
| 119 | GroupNetworkState effectiveNetworkState = _effectiveNetworkState; |
| 120 | effectiveNetworkState.connectionMode = _connectionMode; |
| 121 |
| 122 | diff --git a/tgcalls/group/GroupInstanceCustomImpl.h b/tgcalls/group/GroupInstanceCustomImpl.h |
| 123 | index b42ef71..836071e 100644 |
| 124 | --- a/tgcalls/group/GroupInstanceCustomImpl.h |
| 125 | +++ b/tgcalls/group/GroupInstanceCustomImpl.h |
| 126 | @@ -19,6 +19,7 @@ class Threads; |
| 127 |
| 128 | class GroupInstanceCustomImpl final : public GroupInstanceInterface { |
| 129 | public: |
| 130 | + static int customAudioBitrate; |
| 131 | explicit GroupInstanceCustomImpl(GroupInstanceDescriptor &&descriptor); |
| 132 | ~GroupInstanceCustomImpl(); |
| 133 |
| 134 | -- |
| 135 | 2.54.0.windows.1 |
| 136 |
| 137 |