Skip to content
This repository was archived by the owner on Nov 1, 2024. It is now read-only.

Commit 41a861f

Browse files
committed
update window share
1 parent b992201 commit 41a861f

7 files changed

Lines changed: 57 additions & 20 deletions

File tree

windows/APIExample/APIExample/APIExample.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
3737
<ConfigurationType>Application</ConfigurationType>
3838
<UseDebugLibraries>false</UseDebugLibraries>
39-
<PlatformToolset>v141_xp</PlatformToolset>
39+
<PlatformToolset>v141</PlatformToolset>
4040
<WholeProgramOptimization>true</WholeProgramOptimization>
4141
<CharacterSet>Unicode</CharacterSet>
4242
<UseOfMfc>Dynamic</UseOfMfc>

windows/APIExample/APIExample/Advanced/CustomAudioCapture/CAgoraCaptureAudioDlg.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ void CAgoraCaptureAduioDlg::UnInitAgora()
215215
//disable video in the engine.
216216
m_rtcEngine->disableVideo();
217217
m_lstInfo.InsertString(m_lstInfo.GetCount(), _T("disableVideo"));
218-
//relase engine.
218+
//release engine.
219219
m_rtcEngine->release(true);
220220
m_lstInfo.InsertString(m_lstInfo.GetCount(), _T("release rtc engine"));
221221
m_rtcEngine = NULL;
@@ -317,7 +317,7 @@ void CAgoraCaptureAduioDlg::EnableCaputre(BOOL bEnable) {
317317
return;
318318
if (bEnable)
319319
{
320-
//select meida capture.
320+
//select media capture.
321321
m_agAudioCaptureDevice.SelectMediaCap(m_cmbAudioType.GetCurSel());
322322
//get current audio capture format.
323323
m_agAudioCaptureDevice.GetCurrentAudioCap(&waveFormat);
@@ -489,7 +489,7 @@ void CAgoraCaptureAduioDlgEngineEventHandler::onRemoteVideoStateChanged(uid_t ui
489489
}
490490

491491
/*
492-
initialize dialog, and set control proprety.
492+
initialize dialog, and set control property.
493493
*/
494494
BOOL CAgoraCaptureAduioDlg::OnInitDialog()
495495
{
@@ -568,7 +568,7 @@ void CAgoraCaptureAduioDlg::OnShowWindow(BOOL bShow, UINT nStatus)
568568
}
569569
}
570570

571-
//Enumerates the aduio capture devices and types,
571+
//Enumerates the audio capture devices and types,
572572
//and inserts them into the ComboBox
573573
void CAgoraCaptureAduioDlg::OnSelchangeComboCaptureAudioDevice()
574574
{
@@ -583,10 +583,10 @@ void CAgoraCaptureAduioDlg::OnSelchangeComboCaptureAudioDevice()
583583
m_agAudioCaptureDevice.CloseDevice();
584584

585585
if (nSel != -1)
586-
m_agAudioCaptureDevice.OpenDevice(nSel);
586+
if (!m_agAudioCaptureDevice.OpenDevice(nSel))return;
587587

588588
m_cmbAudioType.ResetContent();
589-
//enum current deivce support type.
589+
//enum current device support type.
590590
for (int nIndex = 0; nIndex < m_agAudioCaptureDevice.GetMediaCapCount(); nIndex++) {
591591
m_agAudioCaptureDevice.GetAudioCap(nIndex, &wavFormatEx);
592592
strInfo.Format(_T("%.1fkHz %dbits %dCh"), wavFormatEx.nSamplesPerSec / 1000.0, wavFormatEx.wBitsPerSample, wavFormatEx.nChannels);

windows/APIExample/APIExample/Advanced/CustomVideoCapture/CAgoraCaptureVideoDlg.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,12 @@ void CAgoraCaptureVideoDlg::ResumeStatus()
253253
void CAgoraCaptureVideoDlg::EnableCaputre(BOOL bEnable)
254254
{
255255
if (bEnable == (BOOL)m_extenalCaptureVideo)return;
256+
257+
int nIndex = m_cmbVideoType.GetCurSel();
256258
if (bEnable)
257259
{
258260
//select video capture type.
259-
m_agVideoCaptureDevice.SelectMediaCap(m_cmbVideoType.GetCurSel());
261+
m_agVideoCaptureDevice.SelectMediaCap(nIndex==-1?0:nIndex);
260262
VIDEOINFOHEADER videoInfo;
261263
VideoEncoderConfiguration config;
262264
//create video capture filter.
@@ -330,6 +332,11 @@ void CAgoraCaptureVideoDlg::OnClickedButtonStartCaputre()
330332
{
331333
if (!m_extenalCaptureVideo)
332334
{
335+
if (m_cmbVideoType.GetCurSel() == -1)
336+
{
337+
m_lstInfo.InsertString(m_lstInfo.GetCount(), _T("can not set vitrual video capture"));
338+
return;
339+
}
333340
EnableExtendVideoCapture(TRUE);
334341
//register agora video frame observer.
335342
EnableCaputre(TRUE);
@@ -499,19 +506,23 @@ void CAgoraCaptureVideoDlg::OnSelchangeComboCaptureVideoDevice()
499506
VIDEOINFOHEADER vidInfoHeader;
500507
CString strInfo;
501508
CString strCompress;
502-
//get current deivce name.
509+
//get current device name.
510+
m_cmbVideoType.ResetContent();
511+
503512
BOOL bSuccess = m_agVideoCaptureDevice.GetCurrentDevice(szDevicePath, &nPathLen);
504513
if (bSuccess)
505514
m_agVideoCaptureDevice.CloseDevice();
506515

507516
if (nSel != -1) {
508517
//open device.
509-
m_agVideoCaptureDevice.OpenDevice(nSel);
518+
if (!m_agVideoCaptureDevice.OpenDevice(nSel))
519+
{
520+
return;
521+
}
510522
//create capture filter.
511-
m_agVideoCaptureDevice.CreateCaptureFilter();
523+
//m_agVideoCaptureDevice.CreateCaptureFilter();
512524
}
513-
m_cmbVideoType.ResetContent();
514-
//enumrate video capture device type.
525+
//enumerate video capture device type.
515526
int count = m_agVideoCaptureDevice.GetMediaCapCount();
516527
for (int nIndex = 0; nIndex < count; nIndex++) {
517528
m_agVideoCaptureDevice.GetVideoCap(nIndex, &vidInfoHeader);
@@ -610,7 +621,7 @@ void CAgoraCaptureVideoDlgEngineEventHandler::onUserOffline(uid_t uid, USER_OFFL
610621
the total call time, the data traffic sent and received by THE SDK and other
611622
information. The App obtains the call duration and data statistics received
612623
or sent by the SDK through this callback.
613-
parametes:
624+
parameters:
614625
stats: Call statistics.
615626
*/
616627
void CAgoraCaptureVideoDlgEngineEventHandler::onLeaveChannel(const RtcStats& stats)

windows/APIExample/APIExample/Advanced/ScreenShare/AgoraScreenCapture.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#include "stdafx.h"
22
#include "APIExample.h"
33
#include "AgoraScreenCapture.h"
4-
4+
#include <dwmapi.h>
5+
#pragma comment(lib,"dwmapi.lib")
56

67
IMPLEMENT_DYNAMIC(CAgoraScreenCapture, CDialogEx)
78

@@ -443,6 +444,19 @@ void CScreenCaputreEventHandler::onRemoteVideoStateChanged(uid_t uid, REMOTE_VID
443444
}
444445
}
445446

447+
static
448+
BOOL IsWindowCloaked(HWND hwnd)
449+
{
450+
BOOL isCloaked = FALSE;
451+
return (SUCCEEDED(DwmGetWindowAttribute(hwnd, DWMWA_CLOAKED,
452+
&isCloaked, sizeof(isCloaked))) && isCloaked);
453+
}
454+
static
455+
BOOL IsWindowVisibleOnScreen(HWND hwnd)
456+
{
457+
return IsWindowVisible(hwnd) &&
458+
!IsWindowCloaked(hwnd);
459+
}
446460

447461
/*
448462
enum window callback function.
@@ -453,7 +467,11 @@ BOOL CALLBACK CAgoraScreenCapture::WndEnumProc(HWND hWnd, LPARAM lParam)
453467

454468
LONG lStyle = ::GetWindowLong(hWnd, GWL_STYLE);
455469

456-
if ((lStyle & WS_VISIBLE) != 0 && (lStyle & (WS_POPUP | WS_SYSMENU)) != 0 &&::IsZoomed(hWnd))
470+
if ((lStyle & WS_VISIBLE) != 0
471+
&& (lStyle & (WS_POPUP | WS_SYSMENU)) != 0
472+
&& IsWindowVisibleOnScreen(hWnd)
473+
&&::IsZoomed(hWnd)
474+
)
457475
lpListctrl->AddTail(hWnd);
458476

459477
return TRUE;

windows/APIExample/APIExample/DirectShow/AGDShowVideoCapture.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,10 @@ BOOL CAGDShowVideoCapture::OpenDevice(LPCTSTR lpDevicePath, LPCTSTR lpDeviceName
193193

194194
_tcscpy_s(m_szActiveDeviceID, MAX_PATH, lpDevicePath);
195195
SelectMediaCap(0);
196+
return TRUE;
196197
}
197198

198-
return false;
199+
return FALSE;
199200
}
200201

201202
BOOL CAGDShowVideoCapture::GetCurrentDevice(LPTSTR lpDevicePath, SIZE_T *nDevicePathLen)

windows/APIExample/APIExample/DirectShow/DShowHelper.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,12 @@ bool CDShowHelper::EnumDevice(const GUID &type, IMoniker *deviceInfo,
270270
hr = deviceInfo->BindToObject(NULL, 0, IID_IBaseFilter,
271271
(void**)&filter);
272272
if (SUCCEEDED(hr)) {
273-
if (deviceName.bstrVal && name && wcscmp(name, deviceName.bstrVal) != 0)
274-
return true;
275-
if (!devicePath.bstrVal || wcscmp(path, devicePath.bstrVal) != 0)
273+
if (deviceName.bstrVal && name && wcscmp(name, deviceName.bstrVal) != 0)
276274
return true;
275+
276+
if (!devicePath.bstrVal || wcscmp(path, devicePath.bstrVal) != 0)
277+
return true;
278+
277279
*outfilter = filter;
278280
return false;
279281
}

windows/APIExample/install.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ if (-not (Test-Path $ThirdPartydes)){
1111
Invoke-WebRequest -uri $ThirdPartysrc -OutFile $ThirdPartydes -TimeoutSec 10;
1212
Unblock-File $ThirdPartydes
1313
tar -zxvf $ThirdPartydes -C ThirdParty
14+
rm $ThirdPartydes
1415
}
1516

1617

@@ -20,4 +21,8 @@ if (-not (Test-Path $agora_des)){
2021
Unblock-File $agora_des
2122
tar -zxvf $agora_des -C .
2223
Move-Item Agora_Native_SDK_for_Windows_FULL\libs libs
24+
rm $agora_des
2325
}
26+
27+
28+

0 commit comments

Comments
 (0)