From db4039a0385ac0c074c662c320add2deefc249c8 Mon Sep 17 00:00:00 2001 From: sbd021 Date: Thu, 19 Aug 2021 18:38:19 +0800 Subject: [PATCH] enable dual stream --- data/locale/en-US.ini | 3 +- data/locale/zh-CN.ini | 3 +- data/locale/zh-TW.ini | 3 +- src/Agora/agorartcengine.cpp | 5 +- src/Agora/agorartcengine.hpp | 2 +- src/forms/AgoraSettings.ui | 141 +++++++++++++++------------- src/forms/window-agora-main.cpp | 4 + src/forms/window-agora-main.hpp | 2 + src/forms/window-agora-settings.cpp | 11 +++ 9 files changed, 102 insertions(+), 72 deletions(-) diff --git a/data/locale/en-US.ini b/data/locale/en-US.ini index 129bfe94..f08f068d 100644 --- a/data/locale/en-US.ini +++ b/data/locale/en-US.ini @@ -95,4 +95,5 @@ Agora.Network.Testing="Network testing ......" Agora.Network.Testing.Info="You are testing network. Stop testing network first." Basic.Settings.Agora.Save.PCM="Save OBS PCM Data(in the path of obs logs)" Agora.System.CPU.Infomation="High CPU load detected, this may cause audio malfunction and influence stream experience. Please try ending irrelevant applications to reduce CPU usage." -Agora.CPU.Threshold="CPU Threshold" \ No newline at end of file +Agora.CPU.Threshold="CPU Threshold" +Agora.Settings.DualStream="Dual Stream" \ No newline at end of file diff --git a/data/locale/zh-CN.ini b/data/locale/zh-CN.ini index 8c3c3a52..4503b8d5 100644 --- a/data/locale/zh-CN.ini +++ b/data/locale/zh-CN.ini @@ -95,4 +95,5 @@ Agora.Network.Testing="测试中......" Agora.Network.Testing.Info="网络测试中,请先停止网络测试。" Basic.Settings.Agora.Save.PCM="保存音频原始数据(在obs的日志路径下)" Agora.System.CPU.Infomation="当前 CPU 负载过高,可能导致直播中音频异常,影响直播体验。请退出所有暂时无关的软件,以确保CPU负载维持正常水平。" -Agora.CPU.Threshold="CPU阈值" \ No newline at end of file +Agora.CPU.Threshold="CPU阈值" +Agora.Settings.DualStream="发送大小流" \ No newline at end of file diff --git a/data/locale/zh-TW.ini b/data/locale/zh-TW.ini index c5c8b042..893759a6 100644 --- a/data/locale/zh-TW.ini +++ b/data/locale/zh-TW.ini @@ -96,4 +96,5 @@ Agora.Network.Testing="測試中......" Agora.Network.Testing.Info="正在測試網絡,請先停止測試。" Basic.Settings.Agora.Save.PCM="保存音頻原始數據(在obs的日志路徑下)" Agora.System.CPU.Infomation="當前CPU 負載過高,可能導致直播中音頻異常,影響直播體驗。請退出所有暫時無關的軟體,以確保 CPU 負載維持正常水平。" -Agora.CPU.Threshold="CPU閾值" \ No newline at end of file +Agora.CPU.Threshold="CPU閾值" +Agora.Settings.DualStream="發送大小流" \ No newline at end of file diff --git a/src/Agora/agorartcengine.cpp b/src/Agora/agorartcengine.cpp index 0558460e..503da142 100644 --- a/src/Agora/agorartcengine.cpp +++ b/src/Agora/agorartcengine.cpp @@ -386,7 +386,7 @@ void AgoraRtcEngine::SetRecordBoost() } int AgoraRtcEngine::joinChannel(const std::string &key, - const std::string &channel, unsigned int uid, bool muteAudio , bool muteVideo) + const std::string &channel, unsigned int uid, bool enableDual, bool muteAudio , bool muteVideo) { if (m_bJoinChannel) return 0; @@ -412,6 +412,9 @@ int AgoraRtcEngine::joinChannel(const std::string &key, options.autoSubscribeAudio = muteAudio; options.autoSubscribeVideo = muteVideo; + if (enableDual) + m_rtcEngine->enableDualStreamMode(true); + int r = m_rtcEngine->joinChannel(key.data(), channel.data(), "", uid, options);// return r; } diff --git a/src/Agora/agorartcengine.hpp b/src/Agora/agorartcengine.hpp index 9eb81349..3847d1a5 100644 --- a/src/Agora/agorartcengine.hpp +++ b/src/Agora/agorartcengine.hpp @@ -48,7 +48,7 @@ class AgoraRtcEngine : public QObject void stopPreview(); void SetRecordBoost(); int joinChannel(const std::string &key, const std::string &channel, - unsigned uid, bool muteAudio = true, bool muteVideo = true); + unsigned uid, bool enableDual, bool muteAudio = true, bool muteVideo = true); int leaveChannel(); bool keepPreRotation(bool bRotate); diff --git a/src/forms/AgoraSettings.ui b/src/forms/AgoraSettings.ui index 9a03bbe0..f3701f33 100644 --- a/src/forms/AgoraSettings.ui +++ b/src/forms/AgoraSettings.ui @@ -6,7 +6,7 @@ 0 0 - 859 + 857 512 @@ -81,7 +81,7 @@ - 1 + 0 @@ -113,7 +113,7 @@ 0 0 - 564 + 679 435 @@ -267,13 +267,6 @@ - - - - Basic.Agora.AutoLoadConfig - - - @@ -340,6 +333,20 @@ + + + + Agora.Settings.DualStream + + + + + + + Basic.Agora.AutoLoadConfig + + + @@ -1074,8 +1081,8 @@ 0 0 - 698 - 423 + 650 + 241 @@ -1321,6 +1328,34 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + Agora.Settings.Video.Encoder + + + + + + + + Agora.Settings.Video.Agora.Bitrate + + + + + Agora.Settings.Video.OBS.Bitrate + + + + + + + + Agora.Settings.Video.FPS.Resolution + + + @@ -1383,39 +1418,6 @@ - - - - Agora.Settings.Video.Birate - - - - - - - Agora.Settings.Video.Devices - - - - - - - - 0 - 0 - - - - - - - true - - - error - - - @@ -1464,6 +1466,13 @@ + + + + Agora.Settings.Video.Birate + + + @@ -1483,34 +1492,32 @@ - - - - - + + - Agora.Settings.Video.Encoder + Agora.Settings.Video.Devices - - - - - Agora.Settings.Video.Agora.Bitrate - - - - - Agora.Settings.Video.OBS.Bitrate - - - + + - - + + + + + 0 + 0 + + - Agora.Settings.Video.FPS.Resolution + + + + true + + + error diff --git a/src/forms/window-agora-main.cpp b/src/forms/window-agora-main.cpp index ea703126..ee0f7e14 100644 --- a/src/forms/window-agora-main.cpp +++ b/src/forms/window-agora-main.cpp @@ -259,6 +259,7 @@ void AgoraBasic::InitBasicConfig() m_agoraToolSettings.obs_bitrate = config_get_int(globalAgoraConfig, "AgoraTool", "obs_bitrate"); m_agoraToolSettings.videoEncoder = config_get_int(globalAgoraConfig, "AgoraTool", "videoEncoder"); m_agoraToolSettings.muteAllRemoteAudioVideo = config_get_bool(globalAgoraConfig, "AgoraTool", "muteAllRemoteAudioVideo"); + m_agoraToolSettings.bDualStream = config_get_bool(globalAgoraConfig, "AgoraTool", "DualStream"); m_agoraToolSettings.bHighQuality = config_get_bool(globalAgoraConfig, "AgoraTool", "bHighQuality"); if (config_has_user_value(globalAgoraConfig, "AgoraTool", "InformationMode")) m_agoraToolSettings.info_mode = config_get_int(globalAgoraConfig, "AgoraTool", "InformationMode"); @@ -326,6 +327,8 @@ AgoraBasic::~AgoraBasic() config_set_int(globalAgoraConfig, "AgoraTool", "CPUThreshold", m_agoraToolSettings.cpuThreshold); config_set_bool(globalAgoraConfig, "AgoraTool", "muteAllRemoteAudioVideo", m_agoraToolSettings.muteAllRemoteAudioVideo); + config_set_bool(globalAgoraConfig, "AgoraTool", "DualStream", m_agoraToolSettings.bDualStream); + config_set_bool(globalAgoraConfig, "AgoraTool", "bHighQuality", m_agoraToolSettings.bHighQuality); config_set_bool(globalAgoraConfig, "AgoraTool", "savePersist", m_agoraToolSettings.savePersist); config_set_string(globalAgoraConfig, "AgoraTool", "InformationUrl", m_agoraToolSettings.information_url.c_str()); @@ -356,6 +359,7 @@ AgoraBasic::~AgoraBasic() config_set_int(globalAgoraConfig, "AgoraTool", "CPUThreshold", 0); config_set_bool(globalAgoraConfig, "AgoraTool", "muteAllRemoteAudioVideo", false); + config_set_bool(globalAgoraConfig, "AgoraTool", "DualStream", false); config_set_bool(globalAgoraConfig, "AgoraTool", "bHighQuality", false); config_set_bool(globalAgoraConfig, "AgoraTool", "savePersist", false); } diff --git a/src/forms/window-agora-main.hpp b/src/forms/window-agora-main.hpp index 695eb2ce..dda74d30 100644 --- a/src/forms/window-agora-main.hpp +++ b/src/forms/window-agora-main.hpp @@ -65,6 +65,8 @@ typedef struct tagAgoraToolSettings { bool SavePCM = false; int cpuThreshold = 95; + + bool bDualStream = false; } AgoraToolSettings, *PAgoraToolSettings; class DisplayResizeEvent : public QObject diff --git a/src/forms/window-agora-settings.cpp b/src/forms/window-agora-settings.cpp index e8169b86..3c9b5e21 100644 --- a/src/forms/window-agora-settings.cpp +++ b/src/forms/window-agora-settings.cpp @@ -79,6 +79,7 @@ AgoraSettings::AgoraSettings(QWidget *parent) ui->loadConfigButton->setText(tr("Basic.Settigs.Agora.LoadConfigButton")); ui->buttonAppid->setText(tr("Agora.General.Appid.Set")); ui->labUrl->setText(tr("Agora.Settings.Agora.APPTOKEN.URL")); + ui->chkDualStream->setText(tr("Agora.Settings.DualStream")); startTestNet = tr("Agora.Setting.TestNet.Start"); stopTestNet = tr("Agora.Setting.TestNet.Stop"); @@ -238,6 +239,8 @@ AgoraSettings::AgoraSettings(QWidget *parent) HookWidget(ui->chkPersistSaving, CHECK_CHANGED, GENERAL_CHANGED); HookWidget(ui->chkMuteAllRemoteAV, CHECK_CHANGED, GENERAL_CHANGED); + HookWidget(ui->chkDualStream, CHECK_CHANGED, GENERAL_CHANGED); + HookWidget(ui->playoutDevices, COMBO_CHANGED, AUDIO_CHANGED); HookWidget(ui->recordSampleRate, COMBO_CHANGED, AUDIO_CHANGED); HookWidget(ui->cmbRecordChannelSetup, COMBO_CHANGED, AUDIO_CHANGED); @@ -400,6 +403,8 @@ void AgoraSettings::SaveGeneralSettings() settings.muteAllRemoteAudioVideo = ui->chkMuteAllRemoteAV->isChecked(); settings.savePersistAppid = ui->chkPersistSaveAppid->isChecked(); + settings.bDualStream = ui->chkDualStream->isChecked(); + main->SetAgoraSetting(settings); SaveCheckBox(ui->chkPersistSaving, "AgoraSettings", "PersistSave"); @@ -439,6 +444,10 @@ void AgoraSettings::SaveGeneralSettings() SaveCheckBox(ui->chkMuteAllRemoteAV, "AgoraSettings", "MuteAllRemoteAudioVideo", settings.muteAllRemoteAudioVideo); + + SaveCheckBox(ui->chkDualStream, "AgoraSettings", + "DualStream", + settings.bDualStream); } } @@ -506,6 +515,7 @@ void AgoraSettings::LoadGeneralSettings() ui->chkPersistSaving->setChecked(settings.savePersist); ui->chkPersistSaveAppid->setChecked(settings.savePersistAppid); ui->chkMuteAllRemoteAV->setChecked(settings.muteAllRemoteAudioVideo); + ui->chkDualStream->setChecked(settings.bDualStream); QString strExpired = QString("%1").arg(settings.expiredTime); ui->lineEditExpiredTs->setText(strExpired); loading = false; @@ -632,6 +642,7 @@ void AgoraSettings::LoadAgoraSettings() ui->chkPersistSaving->setChecked(settings.savePersist); ui->chkPersistSaveAppid->setChecked(settings.savePersistAppid); ui->chkMuteAllRemoteAV->setChecked(settings.muteAllRemoteAudioVideo); + ui->chkDualStream->setChecked(settings.bDualStream); QString strExpired = QString("%1").arg(settings.expiredTime); ui->lineEditExpiredTs->setText(strExpired); loading = false;