Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 22244fe

Browse files
committed
windows spatial audio
1 parent 6c5df19 commit 22244fe

19 files changed

+827
-36
lines changed

windows/APIExample/APIExample/AGVideoWnd.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ BEGIN_MESSAGE_MAP(CAGInfoWnd, CWnd)
2929
END_MESSAGE_MAP()
3030

3131

32-
void CAGInfoWnd::ShowTips(BOOL bShow)
32+
void CAGInfoWnd::ShowTips(CString str, BOOL bShow)
3333
{
3434
m_bShowTip = bShow;
3535

3636
if (bShow)
3737
ShowWindow(SW_SHOW);
3838
else
3939
ShowWindow(SW_HIDE);
40-
41-
Invalidate(FALSE);
40+
strText = str;
41+
Invalidate(TRUE);
4242
}
4343

4444
void CAGInfoWnd::SetVideoResolution(int nWidth, int nHeight)
@@ -85,8 +85,8 @@ void CAGInfoWnd::OnPaint()
8585
// 640x480,15fps,400k
8686
GetClientRect(&rcClient);
8787
rcClient.top += 4;
88-
strTip.Format(_T("%dx%d, %dfps, %dK \n %u"), m_nWidth, m_nHeight, m_nFps, m_nBitrate, m_nUID);
89-
dc.DrawText(strTip, &rcClient, DT_VCENTER | DT_CENTER);
88+
//strTip.Format(_T("%dx%d, %dfps, %dK \n %u"), m_nWidth, m_nHeight, m_nFps, m_nBitrate, m_nUID);
89+
dc.DrawText(strText, &rcClient, DT_VCENTER | DT_CENTER);
9090
}
9191
}
9292

@@ -105,6 +105,7 @@ BOOL CAGInfoWnd::OnEraseBkgnd(CDC* pDC)
105105

106106
IMPLEMENT_DYNAMIC(CAGVideoWnd, CWnd)
107107

108+
108109
CAGVideoWnd::CAGVideoWnd()
109110
: m_nUID(0)
110111
, m_crBackColor(RGB(0x58, 0x58, 0x58))
@@ -123,6 +124,7 @@ CAGVideoWnd::~CAGVideoWnd()
123124
BEGIN_MESSAGE_MAP(CAGVideoWnd, CWnd)
124125
ON_WM_ERASEBKGND()
125126
ON_WM_LBUTTONDOWN()
127+
ON_WM_LBUTTONUP()
126128
ON_WM_RBUTTONDOWN()
127129
ON_WM_CREATE()
128130
ON_WM_PAINT()
@@ -143,16 +145,6 @@ BOOL CAGVideoWnd::OnEraseBkgnd(CDC* pDC)
143145
GetClientRect(&rcClient);
144146

145147
pDC->FillSolidRect(&rcClient, m_crBackColor);
146-
/*if (!m_imgBackGround.GetImageInfo(0, &imgInfo))
147-
return TRUE;
148-
149-
ptDraw.SetPoint((rcClient.Width() - imgInfo.rcImage.right) / 2, (rcClient.Height() - imgInfo.rcImage.bottom) / 2);
150-
if (ptDraw.x < 0)
151-
ptDraw.x = 0;
152-
if (ptDraw.y <= 0)
153-
ptDraw.y = 0;
154-
155-
m_imgBackGround.Draw(pDC, 0, ptDraw, ILD_NORMAL);*/
156148
return TRUE;
157149
}
158150

@@ -229,11 +221,19 @@ void CAGVideoWnd::OnLButtonDown(UINT nFlags, CPoint point)
229221
{
230222
// TODO: add message handle code and /or call default values here
231223

232-
::SendMessage(GetParent()->GetSafeHwnd(), WM_SHOWBIG, (WPARAM)this, (LPARAM)m_nUID);
224+
::SendMessage(GetParent()->GetSafeHwnd(), WM_LBUTTON_DOWN_WND, (WPARAM)point.x, (LPARAM)point.y);
233225

234226
CWnd::OnLButtonDown(nFlags, point);
235227
}
236228

229+
void CAGVideoWnd::OnLButtonUp(UINT nFlags, CPoint point)
230+
{
231+
// TODO: add message handle code and /or call default values here
232+
233+
::SendMessage(GetParent()->GetSafeHwnd(), WM_LBUTTON_UP_WND, (WPARAM)point.x, (LPARAM)point.y);
234+
235+
CWnd::OnLButtonDown(nFlags, point);
236+
}
237237

238238
void CAGVideoWnd::OnRButtonDown(UINT nFlags, CPoint point)
239239
{
@@ -256,11 +256,11 @@ int CAGVideoWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
256256
}
257257

258258

259-
void CAGVideoWnd::ShowVideoInfo(BOOL bShow)
259+
void CAGVideoWnd::ShowVideoInfo(CString str, BOOL bShow)
260260
{
261261
m_bShowVideoInfo = bShow;
262262

263-
m_wndInfo.ShowTips(bShow);
263+
m_wndInfo.ShowTips(str, bShow);
264264
Invalidate(TRUE);
265265
}
266266

windows/APIExample/APIExample/AGVideoWnd.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#pragma once
22

33
#define WM_SHOWMODECHANGED WM_USER+300
4-
#define WM_SHOWBIG WM_USER+301
5-
4+
#define WM_LBUTTON_DOWN_WND WM_USER+301
5+
#define WM_LBUTTON_UP_WND WM_USER+302
66
#define WND_VIDEO_WIDTH 192
77
#define WND_VIDEO_HEIGHT 144
88

9-
#define WND_INFO_WIDTH 192
9+
#define WND_INFO_WIDTH 400
1010
#define WND_INFO_HEIGHT 36
1111

1212
class CAGInfoWnd : public CWnd
@@ -17,7 +17,7 @@ class CAGInfoWnd : public CWnd
1717
CAGInfoWnd();
1818
virtual ~CAGInfoWnd();
1919

20-
void ShowTips(BOOL bShow = TRUE);
20+
void ShowTips(CString str, BOOL bShow = TRUE);
2121
void SetVideoResolution(int nWidth, int nHeight);
2222
void SetFrameRateInfo(int nFPS);
2323
void SetBitrateInfo(int nBitrate);
@@ -38,7 +38,7 @@ class CAGInfoWnd : public CWnd
3838
int m_nHeight;
3939
int m_nFps;
4040
int m_nBitrate;
41-
41+
CString strText;
4242
CBrush m_brBack;
4343
UINT m_nUID = 0;
4444
};
@@ -69,7 +69,7 @@ class CAGVideoWnd : public CWnd
6969
void SetFrameRateInfo(int nReceiveFrameRate);
7070
int GetFrameRateInfo() { return m_nFrameRate; };
7171

72-
void ShowVideoInfo(BOOL bShow);
72+
void ShowVideoInfo(CString str, BOOL bShow);
7373
BOOL IsVideoInfoShowed() { return m_bShowVideoInfo; };
7474

7575
void SetBigShowFlag(BOOL bBigShow);
@@ -82,7 +82,7 @@ class CAGVideoWnd : public CWnd
8282
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
8383
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
8484
afx_msg void OnSize(UINT nType, int cx, int cy);
85-
85+
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
8686
DECLARE_MESSAGE_MAP()
8787

8888
private:

windows/APIExample/APIExample/APIExample.rc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,16 @@ BEGIN
630630
CONTROL "",IDC_SLIDER_SMOOTHNESS,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,222,346,117,15
631631
END
632632

633+
IDD_DIALOG_SPATIAL_AUDIO DIALOGEX 0, 0, 632, 400
634+
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
635+
FONT 8, "MS Shell Dlg", 400, 0, 0x1
636+
BEGIN
637+
LTEXT " ",IDC_STATIC_VIDEO,2,3,484,308,SS_SUNKEN | NOT WS_VISIBLE | WS_BORDER,WS_EX_CLIENTEDGE
638+
LISTBOX IDC_LIST_INFO_BROADCASTING,491,0,139,312,LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP
639+
LTEXT "",IDC_STATIC_DETAIL,460,325,163,58
640+
PUSHBUTTON "Start",IDC_BUTTON_START,187,351,50,14
641+
END
642+
633643

634644
/////////////////////////////////////////////////////////////////////////////
635645
//
@@ -789,6 +799,12 @@ BEGIN
789799
RIGHTMARGIN, 630
790800
BOTTOMMARGIN, 397
791801
END
802+
803+
IDD_DIALOG_SPATIAL_AUDIO, DIALOG
804+
BEGIN
805+
RIGHTMARGIN, 630
806+
BOTTOMMARGIN, 397
807+
END
792808
END
793809
#endif // APSTUDIO_INVOKED
794810

@@ -923,6 +939,11 @@ BEGIN
923939
0
924940
END
925941

942+
IDD_DIALOG_SPATIAL_AUDIO AFX_DIALOG_LAYOUT
943+
BEGIN
944+
0
945+
END
946+
926947

927948
/////////////////////////////////////////////////////////////////////////////
928949
//

windows/APIExample/APIExample/APIExample.vcxproj

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ if exist $(SolutionDir)libs (copy $(SolutionDir)libs\x86\*.dll $(SolutionDir)$(C
119119
if exist zh-cn.ini (copy zh-cn.ini $(SolutionDir)$(Configuration))
120120
if exist en.ini (copy en.ini $(SolutionDir)$(Configuration))
121121
if exist $(SolutionDir)MediaPlayerPart (copy $(SolutionDir)MediaPlayerPart\dll\AgoraMediaPlayer.dll $(SolutionDir)$(Configuration))
122-
if exist $(SolutionDir)MediaPlayerPart (copy $(SolutionDir)MediaPlayerPart\dll\libagora-player-ffmpeg.dll $(SolutionDir)$(Configuration))</Command>
122+
if exist $(SolutionDir)MediaPlayerPart (copy $(SolutionDir)MediaPlayerPart\dll\libagora-player-ffmpeg.dll $(SolutionDir)$(Configuration))
123+
if exist $(SolutionDir)APIExample\res (copy $(SolutionDir)APIExample\res\remote.bmp $(SolutionDir)$(Configuration))
124+
if exist $(SolutionDir)APIExample\res (copy $(SolutionDir)APIExample\res\local.bmp $(SolutionDir)$(Configuration))</Command>
123125
</PostBuildEvent>
124126
<Manifest>
125127
<AdditionalManifestFiles>
@@ -167,7 +169,8 @@ if exist en.ini (copy en.ini $(SolutionDir)$(Platform)\$(Configuration))
167169
copy Advanced\MediaIOCustomVideoCaptrue\screen.yuv $(SolutionDir)$(Platform)\$(Configuration)
168170
if exist $(SolutionDir)MediaPlayerPart64 (copy $(SolutionDir)MediaPlayerPart64\dll\AgoraMediaPlayer.dll $(SolutionDir)$(Platform)\$(Configuration))
169171
if exist $(SolutionDir)MediaPlayerPart64 (copy $(SolutionDir)MediaPlayerPart64\dll\libagora-player-ffmpeg.dll $(SolutionDir)$(Platform)\$(Configuration))
170-
</Command>
172+
if exist $(SolutionDir)APIExample\res (copy $(SolutionDir)APIExample\res\remote.bmp $(SolutionDir)$(Configuration))
173+
if exist $(SolutionDir)APIExample\res (copy $(SolutionDir)APIExample\res\local.bmp $(SolutionDir)$(Configuration))</Command>
171174
</PostBuildEvent>
172175
<Manifest>
173176
<EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>
@@ -211,7 +214,9 @@ if exist $(SolutionDir)MediaPlayerPart64 (copy $(SolutionDir)MediaPlayerPart64\d
211214
if exist $(SolutionDir)libs (copy $(SolutionDir)libs\x86\*.dll $(SolutionDir)$(Configuration))
212215
if exist zh-cn.ini (copy zh-cn.ini $(SolutionDir)$(Configuration))
213216
if exist en.ini (copy en.ini $(SolutionDir)$(Configuration))
214-
if exist $(SolutionDir)MediaPlayerPart (copy $(SolutionDir)MediaPlayerPart\dll\AgoraMediaPlayer.dll $(SolutionDir)$(Configuration))</Command>
217+
if exist $(SolutionDir)MediaPlayerPart (copy $(SolutionDir)MediaPlayerPart\dll\AgoraMediaPlayer.dll $(SolutionDir)$(Configuration))
218+
if exist $(SolutionDir)APIExample\res (copy $(SolutionDir)APIExample\res\remote.bmp $(SolutionDir)$(Configuration))
219+
if exist $(SolutionDir)APIExample\res (copy $(SolutionDir)APIExample\res\local.bmp $(SolutionDir)$(Configuration))</Command>
215220
</PostBuildEvent>
216221
<ManifestResourceCompile>
217222
<ResourceOutputFileName>
@@ -261,6 +266,8 @@ if exist en.ini (copy en.ini $(SolutionDir)$(Platform)\$(Configuration))
261266
copy Advanced\MediaIOCustomVideoCaptrue\screen.yuv $(SolutionDir)$(Platform)\$(Configuration)
262267
if exist $(SolutionDir)MediaPlayerPart64 (copy $(SolutionDir)MediaPlayerPart64\dll\AgoraMediaPlayer.dll $(SolutionDir)$(Platform)\$(Configuration))
263268
if exist $(SolutionDir)MediaPlayerPart64 (copy $(SolutionDir)MediaPlayerPart64\dll\libagora-player-ffmpeg.dll $(SolutionDir)$(Platform)\$(Configuration))
269+
if exist $(SolutionDir)APIExample\res (copy $(SolutionDir)APIExample\res\remote.bmp $(SolutionDir)$(Configuration))
270+
if exist $(SolutionDir)APIExample\res (copy $(SolutionDir)APIExample\res\local.bmp $(SolutionDir)$(Configuration))
264271
</Command>
265272
</PostBuildEvent>
266273
<Manifest>
@@ -294,6 +301,7 @@ if exist $(SolutionDir)MediaPlayerPart64 (copy $(SolutionDir)MediaPlayerPart64\d
294301
<ClInclude Include="Advanced\ReportInCall\CAgoraReportInCallDlg.h" />
295302
<ClInclude Include="Advanced\RTMPStream\AgoraRtmpStreaming.h" />
296303
<ClInclude Include="Advanced\ScreenShare\AgoraScreenCapture.h" />
304+
<ClInclude Include="Advanced\SpatialAudio\CAgoraSpatialAudioDlg.h" />
297305
<ClInclude Include="Advanced\VideoMetadata\CAgoraMetaDataDlg.h" />
298306
<ClInclude Include="Advanced\VideoProfile\CAgoraVideoProfileDlg.h" />
299307
<ClInclude Include="AGVideoTestWnd.h" />
@@ -348,6 +356,7 @@ if exist $(SolutionDir)MediaPlayerPart64 (copy $(SolutionDir)MediaPlayerPart64\d
348356
<ClCompile Include="Advanced\ReportInCall\CAgoraReportInCallDlg.cpp" />
349357
<ClCompile Include="Advanced\RTMPStream\AgoraRtmpStreaming.cpp" />
350358
<ClCompile Include="Advanced\ScreenShare\AgoraScreenCapture.cpp" />
359+
<ClCompile Include="Advanced\SpatialAudio\CAgoraSpatialAudioDlg.cpp" />
351360
<ClCompile Include="Advanced\VideoMetadata\CAgoraMetaDataDlg.cpp" />
352361
<ClCompile Include="Advanced\VideoProfile\CAgoraVideoProfileDlg.cpp" />
353362
<ClCompile Include="AGVideoTestWnd.cpp" />

windows/APIExample/APIExample/APIExample.vcxproj.filters

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@
106106
<Filter Include="Advanced\MultiVideoSource">
107107
<UniqueIdentifier>{d9f16a5e-5aad-4e80-9fbc-6f6c1b11cf74}</UniqueIdentifier>
108108
</Filter>
109+
<Filter Include="Advanced\SpatialAudio">
110+
<UniqueIdentifier>{05abbd2e-b373-4b3d-8b15-138a2dd55edb}</UniqueIdentifier>
111+
</Filter>
109112
</ItemGroup>
110113
<ItemGroup>
111114
<ClInclude Include="APIExample.h">
@@ -264,6 +267,9 @@
264267
<ClInclude Include="Advanced\MultiVideoSource\commonFun.h">
265268
<Filter>Header Files</Filter>
266269
</ClInclude>
270+
<ClInclude Include="Advanced\SpatialAudio\CAgoraSpatialAudioDlg.h">
271+
<Filter>Advanced\SpatialAudio</Filter>
272+
</ClInclude>
267273
</ItemGroup>
268274
<ItemGroup>
269275
<ClCompile Include="APIExample.cpp">
@@ -398,6 +404,9 @@
398404
<ClCompile Include="Advanced\MultiVideoSource\commonFun.cpp">
399405
<Filter>Source Files</Filter>
400406
</ClCompile>
407+
<ClCompile Include="Advanced\SpatialAudio\CAgoraSpatialAudioDlg.cpp">
408+
<Filter>Advanced\SpatialAudio</Filter>
409+
</ClCompile>
401410
</ItemGroup>
402411
<ItemGroup>
403412
<ResourceCompile Include="APIExample.rc">

windows/APIExample/APIExample/APIExampleDlg.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ void CAPIExampleDlg::InitSceneDialog()
237237
m_vecAdvanced.push_back(advancedRegionConn);
238238
m_vecAdvanced.push_back(advancedCrossChannel);
239239
m_vecAdvanced.push_back(advancedMultiVideoSource);
240-
240+
m_vecAdvanced.push_back(SpatialAudio);
241241
//rtmp
242242
m_pRtmpStreamingDlg = new CAgoraRtmpStreamingDlg(&m_staMainArea);
243243
m_pRtmpStreamingDlg->Create(CAgoraRtmpStreamingDlg::IDD);
@@ -360,6 +360,11 @@ void CAPIExampleDlg::InitSceneDialog()
360360
m_pMultiVideoSourceDlg->Create(CAgoraMutilVideoSourceDlg::IDD);
361361
m_pMultiVideoSourceDlg->MoveWindow(&rcWnd);
362362

363+
// spatial audio
364+
m_pSpatialAudioDlg = new CAgoraSpatialAudioDlg(&m_staMainArea);
365+
m_pSpatialAudioDlg->Create(CAgoraSpatialAudioDlg::IDD);
366+
m_pSpatialAudioDlg->MoveWindow(&rcWnd);
367+
363368
}
364369

365370
void CAPIExampleDlg::InitSceneList()
@@ -561,6 +566,10 @@ void CAPIExampleDlg::CreateScene(CTreeCtrl& treeScene, CString selectedText)
561566
m_pMultiVideoSourceDlg->InitAgora();
562567
m_pMultiVideoSourceDlg->ShowWindow(SW_SHOW);
563568
}
569+
else if (selectedText.Compare(SpatialAudio) == 0) {
570+
m_pSpatialAudioDlg->InitAgora();
571+
m_pSpatialAudioDlg->ShowWindow(SW_SHOW);
572+
}
564573
}
565574

566575
void CAPIExampleDlg::ReleaseScene(CTreeCtrl& treeScene, HTREEITEM& hSelectItem)
@@ -644,6 +653,10 @@ void CAPIExampleDlg::ReleaseScene(CTreeCtrl& treeScene, HTREEITEM& hSelectItem)
644653
m_pMultiVideoSourceDlg->UnInitAgora();
645654
m_pMultiVideoSourceDlg->ShowWindow(SW_HIDE);
646655
}
656+
else if (str.Compare(SpatialAudio) == 0) {
657+
m_pSpatialAudioDlg->UnInitAgora();
658+
m_pSpatialAudioDlg->ShowWindow(SW_HIDE);
659+
}
647660
}
648661

649662
LRESULT CAPIExampleDlg::OnEIDJoinLeaveChannel(WPARAM wParam, LPARAM lParam)

windows/APIExample/APIExample/APIExampleDlg.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "Advanced/RegionConn/CAgoraRegionConnDlg.h"
2929
#include "Advanced/CrossChannel/CAgoraCrossChannelDlg.h"
3030
#include "Advanced/MultiVideoSource/CAgoraMutilVideoSourceDlg.h"
31-
31+
#include "Advanced/SpatialAudio/CAgoraSpatialAudioDlg.h"
3232
#include <vector>
3333
#include <map>
3434
const int MAIN_AREA_BOTTOM = 15;
@@ -98,6 +98,7 @@ class CAPIExampleDlg : public CDialogEx
9898
CAgoraRegionConnDlg *m_pRegionConnDlg = nullptr;
9999
CAgoraCrossChannelDlg *m_pCrossChannelDlg = nullptr;
100100
CAgoraMutilVideoSourceDlg *m_pMultiVideoSourceDlg = nullptr;
101+
CAgoraSpatialAudioDlg *m_pSpatialAudioDlg = nullptr;
101102
CString m_preSelectedItemText = _T("");
102103
std::vector<CString> m_vecBasic, m_vecAdvanced;
103104

windows/APIExample/APIExample/Advanced/AudioVolume/CAgoraAudioVolumeDlg.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class CAudioVolumeEventHandler : public IRtcEngineEventHandler
107107
@param uid User ID of the active speaker. A @p uid of 0 represents the local user.
108108
*/
109109
virtual void onActiveSpeaker(uid_t uid) override;
110+
void onAudioDeviceTestVolumeIndication(AudioDeviceTestVolumeType volumeType, int volume) override;
110111
private:
111112
HWND m_hMsgHanlder;
112113
};
@@ -149,7 +150,7 @@ class CAgoraAudioVolumeDlg : public CDialogEx
149150
LRESULT OnEIDUserOffline(WPARAM wParam, LPARAM lParam);
150151
LRESULT OnEIDAudioVolumeIndication(WPARAM wparam, LPARAM lparam);
151152
LRESULT OnEIDActiveSpeaker(WPARAM wparam, LPARAM lparam);
152-
153+
LRESULT OnEIDAudioVolumeTestIndication(WPARAM wparam, LPARAM lparam);
153154
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
154155
virtual BOOL OnInitDialog();
155156
virtual BOOL PreTranslateMessage(MSG* pMsg);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ void CScreenCaptureEventHandler::onScreenCaptureInfoUpdated(agora::rtc::ScreenCa
655655
{
656656
if (m_hMsgHanlder)
657657
{
658-
::PostMessage(m_hMsgHanlder, WM_MSGID(EID_SCREEN_CAPTURE_INFO_UPDATED), (WPARAM)info.cardType, (LPARAM)info.errCode);
658+
::PostMessage(m_hMsgHanlder, WM_MSGID(EID_SCREEN_CAPTURE_INFO_UPDATED), (WPARAM)info.graphicsCardType, (LPARAM)info.errCode);
659659
}
660660
}
661661

0 commit comments

Comments
 (0)