Skip to content

Commit

Permalink
remove windows Event
Browse files Browse the repository at this point in the history
  • Loading branch information
sbd021 committed Mar 26, 2021
1 parent 56afbce commit 4107d87
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
5 changes: 0 additions & 5 deletions src/Agora/agorartcengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,18 +392,13 @@ 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;
}

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;
Expand Down
1 change: 1 addition & 0 deletions src/Agora/agorartcengine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 8 additions & 12 deletions src/forms/window-agora-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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);
Expand All @@ -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();

}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion src/forms/window-agora-main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4107d87

Please sign in to comment.