From 4107d87c5942b2d939a40eda7b543cc1effc3f8f Mon Sep 17 00:00:00 2001 From: lina07 Date: Fri, 26 Mar 2021 10:00:53 +0800 Subject: [PATCH] remove windows Event --- src/Agora/agorartcengine.cpp | 5 ----- src/Agora/agorartcengine.hpp | 1 + src/forms/window-agora-main.cpp | 20 ++++++++------------ src/forms/window-agora-main.hpp | 4 +++- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/Agora/agorartcengine.cpp b/src/Agora/agorartcengine.cpp index fa0ac28d..9079c1d8 100644 --- a/src/Agora/agorartcengine.cpp +++ b/src/Agora/agorartcengine.cpp @@ -392,7 +392,6 @@ int AgoraRtcEngine::joinChannel(const std::string &key, options.autoSubscribeVideo = muteVideo; int r = m_rtcEngine->joinChannel(key.data(), channel.data(), "", uid, options); - m_bJoinChannel = true; return r; } @@ -400,10 +399,6 @@ int AgoraRtcEngine::leaveChannel() { if (!m_bInitialize || !m_bJoinChannel) return -1; - /*if (fp) { - fclose(fp); - fp = nullptr; - }*/ m_bJoinChannel = false; int r = m_rtcEngine->leaveChannel(); return r; diff --git a/src/Agora/agorartcengine.hpp b/src/Agora/agorartcengine.hpp index babae793..ad655357 100644 --- a/src/Agora/agorartcengine.hpp +++ b/src/Agora/agorartcengine.hpp @@ -100,6 +100,7 @@ class AgoraRtcEngine : public QObject void MuteAllRemoteAudio(bool bMute); void release(); + void SetJoinChannel(bool bJoin) { m_bJoinChannel = bJoin; } signals: void onJoinChannelSuccess(const char* channel, unsigned int uid, int elapsed); void onLeaveChannel(const RtcStats &stats); diff --git a/src/forms/window-agora-main.cpp b/src/forms/window-agora-main.cpp index 59144be4..ffedb6bf 100644 --- a/src/forms/window-agora-main.cpp +++ b/src/forms/window-agora-main.cpp @@ -119,7 +119,7 @@ AgoraBasic::AgoraBasic(QMainWindow *parent) connect(&aCloseEventHandler, &ACloseEvent::AgoraClose, closeEvent_slot); mainWindow->installEventFilter(&aCloseEventHandler); - stopSignal = CreateEvent(nullptr, true, false, nullptr); + //stopSignal = CreateEvent(nullptr, true, false, nullptr); } AgoraBasic::~AgoraBasic() @@ -203,9 +203,10 @@ void AgoraBasic::on_agoraSteramButton_clicked() StopAgoraOutput(); AgoraRtcEngine::GetInstance()->stopPreview(); - ResetEvent(stopSignal); + //ResetEvent(stopSignal); AgoraRtcEngine::GetInstance()->leaveChannel(); - SetEvent(stopSignal); + //SetEvent(stopSignal); + if (!m_agoraToolSettings.agora_url.empty()) AgoraRtcEngine::GetInstance()->RemovePublishStreamUrl(m_agoraToolSettings.agora_url.c_str()); ui->agoraSteramButton->setText(stopping_text); @@ -231,11 +232,6 @@ void AgoraBasic::closeEvent(QCloseEvent *event) { QString str = ui->agoraSteramButton->text(); if (stop_text.compare(str) == 0) { - /*obs_remove_raw_video_callback(RawVideoCallback, this); - ResetEvent(stopSignal); - AgoraRtcEngine::GetInstance()->leaveChannel(); - SetEvent(stopSignal); - StopAgoraOutput();*/ on_agoraSteramButton_clicked(); } @@ -580,8 +576,8 @@ void AgoraBasic::RawVideoCallback (void *param, struct video_data *frame) { struct obs_video_info ovi; AgoraBasic* basic = (AgoraBasic*)param; - bool time_out = WaitForSingleObject(basic->stopSignal, 10); - if (obs_get_video_info(&ovi) && !time_out) { + //bool time_out = WaitForSingleObject(basic->stopSignal, 10); + if (obs_get_video_info(&ovi) ) { AgoraRtcEngine::GetInstance()->PushVideoFrame(frame); } @@ -644,8 +640,8 @@ void AgoraBasic::onJoinChannelSuccess_slot(const char* channel, unsigned int uid local_uid = uid; ui->agoraSteramButton->setText(stop_text); ui->exitButton->setEnabled(false); - m_agoraToolSettings.uid = uid; + AgoraRtcEngine::GetInstance()->SetJoinChannel(true); if (!m_agoraToolSettings.rtmp_url.empty()) { if (m_agoraToolSettings.rtmp_width == 0 || m_agoraToolSettings.rtmp_height == 0 @@ -656,7 +652,7 @@ void AgoraBasic::onJoinChannelSuccess_slot(const char* channel, unsigned int uid SetLiveTranscoding(); AgoraRtcEngine::GetInstance()->AddPublishStreamUrl(m_agoraToolSettings.rtmp_url.c_str(), true); } - SetEvent(stopSignal); + } void AgoraBasic::onLeaveChannel_slot(const RtcStats &stats) diff --git a/src/forms/window-agora-main.hpp b/src/forms/window-agora-main.hpp index 9ce311b5..5ee376e0 100644 --- a/src/forms/window-agora-main.hpp +++ b/src/forms/window-agora-main.hpp @@ -132,7 +132,9 @@ class AgoraBasic : public QMainWindow { bool joinFailed = false; bool started = false; - HANDLE stopSignal = NULL; + //HANDLE stopSignal = NULL; + + virtual void showEvent(QShowEvent *event)override; virtual void hideEvent(QHideEvent *event)override;