Skip to content

Commit 82e4f64

Browse files
author
xia ning
authored
Merge pull request #188 from AgoraIO/dev/3.6.200-win
fix windows bug
2 parents 83a4a0d + 06aa7fa commit 82e4f64

7 files changed

Lines changed: 66 additions & 13 deletions

File tree

windows/APIExample/APIExample/Advanced/AudioEffect/CAgoraEffectDlg.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ bool CAgoraEffectDlg::InitAgora()
107107
//create Agora RTC engine
108108
m_rtcEngine = createAgoraRtcEngine();
109109
if (!m_rtcEngine) {
110-
m_lstInfo.InsertString(m_lstInfo.GetCount() - 1, _T("createAgoraRtcEngine failed"));
110+
m_lstInfo.InsertString(m_lstInfo.GetCount(), _T("createAgoraRtcEngine failed"));
111111
return false;
112112
}
113113
//set message notify receiver window
@@ -345,12 +345,14 @@ void CAgoraEffectDlg::OnBnClickedButtonPlayEffect()
345345
}
346346
CString strEffect;
347347
m_cmbEffect.GetWindowText(strEffect);
348-
std::string strFile;
349-
strFile = cs2utf8(strEffect).c_str();
348+
std::string strFile = cs2utf8(strEffect);
350349
CString strLoops;
351350
m_edtLoops.GetWindowText(strLoops);
352351
int loops = _ttol(strLoops);
353-
352+
if (loops == 0) {
353+
m_edtLoops.SetWindowText(_T("1"));
354+
loops = 1;
355+
}
354356
CString strPitch;
355357
m_edtPitch.GetWindowText(strPitch);
356358
double pitch = _ttof(strPitch);
@@ -365,11 +367,13 @@ void CAgoraEffectDlg::OnBnClickedButtonPlayEffect()
365367

366368
BOOL publish = m_chkPublish.GetCheck();
367369
//play effect by effect path.
368-
m_rtcEngine->playEffect(m_mapEffect[strEffect], strFile.c_str(), loops, pitch, pan, gain, publish);
370+
int ret = m_rtcEngine->playEffect(m_mapEffect[strEffect], strFile.c_str(), loops, pitch, pan, gain, publish);
369371

370372
CString strInfo;
371-
strInfo.Format(_T("play effect :path:%s,loops:%d,pitch:%.1f,pan:%.0f,gain:%d,publish:%d"),
372-
strEffect, loops, pitch, pan, gain, publish);
373+
strInfo.Format(_T("play effect :path:%s, ret:%d"), strEffect, ret);
374+
m_lstInfo.InsertString(m_lstInfo.GetCount(), strInfo);
375+
strInfo.Format(_T("loops:%d,pitch:%.1f,pan:%.0f,gain:%d,publish:%d"),
376+
loops, pitch, pan, gain, publish);
373377
m_lstInfo.InsertString(m_lstInfo.GetCount(), strInfo);
374378
}
375379

windows/APIExample/APIExample/Advanced/AudioMixing/CAgoraAudioMixingDlg.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ void CAgoraAudioMixingDlg::OnBnClickedButtonSetAudioMix()
248248
{
249249
CString strPath;
250250
m_edtAudioMix.GetWindowText(strPath);
251+
strPath.Replace(_T("file\/files"), _T("file\/api\/download"));
251252
std::string strAudioPath = cs2utf8(strPath);
253+
strAudioPath = UrlANSI(strAudioPath.c_str());
252254
BOOL bOnlyLocal = FALSE;
253255
BOOL bReplaceMicroPhone = TRUE;
254256
int iRepeatTimes = 1;
@@ -270,6 +272,7 @@ void CAgoraAudioMixingDlg::OnBnClickedButtonSetAudioMix()
270272
m_edtRepatTimes.SetWindowText(_T("1"));
271273
}
272274
//start audio mixing in the engine.
275+
//strAudioPath = "http://10.70.1.19:9091/file/api/download/electron-wayang/\%E5\%B9\%B4\%E5\%B0\%91\%E6\%9C\%89\%E4\%B8\%BA\%E6\%9D\%8E\%E8\%8D\%A3\%E6\%B5\%A9.mp3";
273276
int nRet = m_rtcEngine->startAudioMixing(strAudioPath.c_str(),
274277
bOnlyLocal,
275278
bReplaceMicroPhone,

windows/APIExample/APIExample/Advanced/MediaPlayer/CAgoraMediaPlayer.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void CAgoraMediaPlayer::ResumeStatus()
163163
InitCtrlText();
164164
m_staDetail.SetWindowText(_T(""));
165165
m_edtChannel.SetWindowText(_T(""));
166-
m_edtVideoSource.SetWindowText(_T("D:\\VID_20201109_120733.mp4"));
166+
167167
m_lstInfo.ResetContent();
168168
m_sldVideo.SetPos(0);
169169

@@ -347,25 +347,29 @@ void CAgoraMediaPlayer::OnBnClickedButtonPublishVideo()
347347
ChannelMediaOptions op;
348348
op.clientRoleType = CLIENT_ROLE_BROADCASTER;
349349
op.publishMediaPlayerVideoTrack = false;
350+
op.publishMediaPlayerAudioTrack = false;
350351
op.publishMediaPlayerId = m_mediaPlayer->getMediaPlayerId();
351352
int ret = m_rtcEngine->updateChannelMediaOptions(op);
352353
ChannelMediaOptions op2;
353354
op2.clientRoleType = CLIENT_ROLE_BROADCASTER;
354355
op2.publishCameraTrack = true;
355356
ret = m_rtcEngine->updateChannelMediaOptions(op2);
356357
m_publishMeidaplayer = false;
358+
m_btnPublishVideo.SetWindowText(mediaPlayerCtrlPublishVideo);
357359
}
358360
else {
359361
ChannelMediaOptions options;
360362
options.clientRoleType = CLIENT_ROLE_BROADCASTER;
361363
options.publishMediaPlayerVideoTrack = true;
364+
options.publishMediaPlayerAudioTrack = true;
362365
options.publishMediaPlayerId = m_mediaPlayer->getMediaPlayerId();
363366
options.publishCameraTrack = false;
364367
options.publishAudioTrack = false;
365368
options.autoSubscribeAudio = false;
366369
options.autoSubscribeVideo = false;
367370
m_rtcEngine->updateChannelMediaOptions(options);
368371
m_publishMeidaplayer = true;
372+
m_btnPublishVideo.SetWindowText(mediaPlayerCtrlUnPublishVideo);
369373
}
370374
}
371375

@@ -631,6 +635,9 @@ void CAgoraMediaPlayer::OnReleasedcaptureSliderVideo(NMHDR *pNMHDR, LRESULT *pRe
631635
{
632636
LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR);
633637
int pos = m_sldVideo.GetPos();
634-
//m_mediaPlayer->seek(pos);
638+
639+
int64_t playPos = 0;
640+
//m_mediaPlayer->getPlayPosition(playPos);
641+
m_mediaPlayer->seek(pos);
635642
*pResult = 0;
636643
}

windows/APIExample/APIExample/Advanced/PerCallTest/CAgoraPerCallTestDlg.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ void CAgoraPerCallTestDlg::OnBnClickedButtonAudioInputTest()
266266
//set audio recording device with device id.
267267
int ret = (*m_audioDeviceManager)->setRecordingDevice(m_mapAudioInput[strAudioInputName].c_str());
268268
//enable audio volume indication
269-
ret |= m_rtcEngine->enableAudioVolumeIndication(1000, 10);
270269
//start audio recording device test
271270
ret |= (*m_audioDeviceManager)->startRecordingDeviceTest(1000);
272271
if (ret == 0)
@@ -284,7 +283,6 @@ void CAgoraPerCallTestDlg::OnBnClickedButtonAudioInputTest()
284283
//stop audio recording device test.
285284
(*m_audioDeviceManager)->stopRecordingDeviceTest();
286285
//disable audio volume indication.
287-
m_rtcEngine->enableAudioVolumeIndication(1000, 10);
288286
m_btnAudioInputTest.SetWindowText(PerCallTestCtrlStartTest);
289287
m_lstInfo.InsertString(m_lstInfo.GetCount(), _T("stop audio recording device test."));
290288
}

windows/APIExample/APIExample/Basic/LiveBroadcasting/CLiveBroadcastingDlg.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,9 @@ void CLiveBroadcastingDlg::UnInitAgora()
288288
if(m_joinChannel)
289289
//leave channel
290290
m_rtcEngine->leaveChannel();
291+
m_lstInfo.InsertString(m_lstInfo.GetCount(), _T("leaveChannel"));
291292
//stop preview in the engine.
292-
m_rtcEngine->stopPreview();
293+
// m_rtcEngine->stopPreview();
293294
m_lstInfo.InsertString(m_lstInfo.GetCount(), _T("stopPreview"));
294295
//disable video in the engine.
295296
m_rtcEngine->disableVideo();

windows/APIExample/APIExample/stdafx.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,52 @@ std::string cs2utf8(CString str)
289289
return szBuf;
290290
}
291291

292+
std::string cs2ANSI(CString str)
293+
{
294+
char szBuf[2 * MAX_PATH] = { 0 };
295+
WideCharToMultiByte(CP_ACP, 0, str.GetBuffer(0), str.GetLength(), szBuf, 2 * MAX_PATH, NULL, NULL);
296+
return szBuf;
297+
}
292298
CString utf82cs(std::string utf8)
293299
{
294300
TCHAR szBuf[2 * MAX_PATH] = { 0 };
295301
MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(), 2 * MAX_PATH, szBuf, 2 * MAX_PATH);
296302
return szBuf;
297303
}
298304

305+
306+
std::string UrlANSI(const char *str)
307+
{
308+
std::string dd;
309+
std::string tt = str;
310+
size_t len = tt.length();
311+
for (size_t i = 0; i < len; i++)
312+
{
313+
BYTE b = (BYTE)tt.at(i);
314+
/*if (isalnum(b)
315+
|| b == '/'
316+
|| b == '.'
317+
|| b == ':')*/
318+
if (b >= 0 && b < 127)
319+
{
320+
char tempbuff[2] = { 0 };
321+
sprintf(tempbuff, "%c", (BYTE)tt.at(i));
322+
dd.append(tempbuff);
323+
}
324+
else if (isspace(b))
325+
{
326+
dd.append("+");
327+
}
328+
else
329+
{
330+
char tempbuff[4];
331+
sprintf(tempbuff, "%%%X%X", ((BYTE)tt.at(i)) >> 4, ((BYTE)tt.at(i)) % 16);
332+
dd.append(tempbuff);
333+
}
334+
}
335+
return dd;
336+
}
337+
299338
CString getCurrentTime()
300339
{
301340
SYSTEMTIME st = { 0 };

windows/APIExample/APIExample/stdafx.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,12 @@ typedef struct _tagAudioMixingState {
118118
int error;
119119

120120
}AudioMixingState, *PAudioMixingState;
121-
121+
std::string cs2ANSI(CString str);
122122
std::string cs2utf8(CString str);
123123
CString utf82cs(std::string utf8);
124124
CString getCurrentTime();
125125
CString GetExePath();
126+
std::string UrlANSI(const char *str);
126127
BOOL PASCAL SaveResourceToFile(LPCTSTR lpResourceType, WORD wResourceID, LPCTSTR lpFilePath);
127128

128129

0 commit comments

Comments
 (0)