Skip to content

Commit bdf343b

Browse files
author
xia ning
authored
Merge pull request #213 from AgoraIO/dev/3.5.0.3
Dev/3.5.0.3
2 parents 8a8df5a + a87c3a5 commit bdf343b

10 files changed

Lines changed: 83 additions & 25 deletions

File tree

iOS/APIExample/Common/KeyCenter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
struct KeyCenter {
1010
static let AppId: String = <#Your App Id#>
11-
11+
1212
// assign token to nil if you have not enabled app certificate
1313
static var Token: String? = <#Temp Access Token#>
1414
}

windows/APIExample/APIExample/APIExample.vcxproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ if exist $(SolutionDir)MediaPlayerPart (copy $(SolutionDir)MediaPlayerPart\dll\A
129129
<ManifestResourceCompile>
130130
<ResourceOutputFileName>$(IntDir)$(TargetName)$(TargetExt).embed.manifest.res</ResourceOutputFileName>
131131
</ManifestResourceCompile>
132+
<PreBuildEvent>
133+
<Command>$(SolutionDir)installThirdParty.bat</Command>
134+
</PreBuildEvent>
132135
</ItemDefinitionGroup>
133136
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
134137
<ClCompile>
@@ -338,7 +341,7 @@ if exist en.ini (copy en.ini $(SolutionDir)$(Platform)\$(Configuration))
338341
<ClCompile Include="CSceneDialog.cpp" />
339342
<ClCompile Include="d3d\D3DRender.cpp" />
340343
<ClCompile Include="DirectShow\AGDShowAudioCapture.cpp">
341-
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
344+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
342345
</ClCompile>
343346
<ClCompile Include="DirectShow\AGDShowVideoCapture.cpp">
344347
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>

windows/APIExample/APIExample/APIExampleDlg.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ BEGIN_MESSAGE_MAP(CAPIExampleDlg, CDialogEx)
8686
//ON_MESSAGE(WM_MSGID(EID_JOINCHANNEL_SUCCESS), &CAPIExampleDlg::OnEIDJoinLeaveChannel)
8787
ON_NOTIFY(TVN_SELCHANGING, IDC_LIST_ADVANCED, &CAPIExampleDlg::OnSelchangingListAdvanced)
8888
ON_BN_CLICKED(IDC_BUTTON_DOCUMENT_WEBSITE, &CAPIExampleDlg::OnBnClickedButtonDocumentWebsite)
89+
ON_WM_DESTROY()
90+
ON_WM_CLOSE()
8991
END_MESSAGE_MAP()
9092

9193

@@ -671,3 +673,29 @@ BOOL CAPIExampleDlg::PreTranslateMessage(MSG* pMsg)
671673
}
672674
return CDialogEx::PreTranslateMessage(pMsg);
673675
}
676+
677+
678+
void CAPIExampleDlg::OnDestroy()
679+
{
680+
CDialogEx::OnDestroy();
681+
682+
683+
}
684+
685+
686+
void CAPIExampleDlg::OnClose()
687+
{
688+
// TODO: Add your message handler code here and/or call default
689+
690+
CDialogEx::OnClose();
691+
HTREEITEM hItem = m_lstBasicScene.GetSelectedItem();
692+
if (hItem) {
693+
ReleaseScene(m_lstBasicScene, hItem);
694+
return;
695+
}
696+
697+
hItem = m_lstAdvanced.GetSelectedItem();
698+
if (hItem) {
699+
ReleaseScene(m_lstBasicScene, hItem);
700+
}
701+
}

windows/APIExample/APIExample/APIExampleDlg.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class CAPIExampleDlg : public CDialogEx
101101
CString m_preSelectedItemText = _T("");
102102
std::vector<CString> m_vecBasic, m_vecAdvanced;
103103

104-
104+
CString m_curSelectedItemText = _T("");
105105

106106
BOOL m_bJoinChannel = FALSE;
107107
public:
@@ -127,5 +127,7 @@ class CAPIExampleDlg : public CDialogEx
127127
CButton m_btnDocWebsite;
128128
CStatic m_grpDoc;
129129
virtual BOOL PreTranslateMessage(MSG* pMsg);
130+
afx_msg void OnDestroy();
131+
afx_msg void OnClose();
130132
};
131133

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ LRESULT CAgoraCaptureAduioDlg::OnEIDRemoteVideoStateChanged(WPARAM wParam, LPARA
9191

9292
CAgoraCaptureAduioDlg::CAgoraCaptureAduioDlg(CWnd* pParent /*=nullptr*/)
9393
: CDialogEx(IDD_DIALOG_CUSTOM_CAPTURE_AUDIO, pParent)
94+
, m_capAudioInfo{48000, 2}
95+
, m_renderAudioInfo {48000, 2}
9496
{
9597
m_audioFrame.buffer = new BYTE[48000 * 4 * 4];
9698
}
@@ -123,6 +125,7 @@ bool CAgoraCaptureAduioDlg::InitAgora()
123125
context.eventHandler = &m_eventHandler;
124126
//initialize the Agora RTC engine context.
125127
int ret = m_rtcEngine->initialize(context);
128+
mediaEngine.queryInterface(m_rtcEngine, agora::AGORA_IID_MEDIA_ENGINE);
126129
if (ret != 0) {
127130
m_initialize = false;
128131
CString strInfo;
@@ -164,6 +167,8 @@ void CAgoraCaptureAduioDlg::UnInitAgora()
164167
//disable video in the engine.
165168
m_rtcEngine->disableVideo();
166169
m_lstInfo.InsertString(m_lstInfo.GetCount(), _T("disableVideo"));
170+
m_agAudioCaptureDevice.Stop();
171+
mediaEngine->release();
167172
//release engine.
168173
m_rtcEngine->release(true);
169174
m_lstInfo.InsertString(m_lstInfo.GetCount(), _T("release rtc engine"));
@@ -282,8 +287,6 @@ void CAgoraCaptureAduioDlg::EnableCaputre(BOOL bEnable) {
282287
m_audioFrame.samplesPerSec = waveFormat.nSamplesPerSec;
283288
m_audioFrame.samples = m_audioFrame.samplesPerSec / 100;
284289

285-
//set recording audio frame parameters in the engine.
286-
m_rtcEngine->setRecordingAudioFrameParameters(waveFormat.nSamplesPerSec, waveFormat.nChannels, RAW_AUDIO_FRAME_OP_MODE_READ_WRITE, waveFormat.nSamplesPerSec * waveFormat.nChannels / 100);
287290
//create audio capture filter.
288291
if (!m_agAudioCaptureDevice.CreateCaptureFilter())
289292
return;
@@ -297,6 +300,15 @@ void CAgoraCaptureAduioDlg::EnableCaputre(BOOL bEnable) {
297300
m_extenalCaptureAudio = !m_extenalCaptureAudio;
298301
}
299302

303+
void CAgoraCaptureAduioDlg::PushAudioFrame(uint8_t* data, int size, uint64_t ts)
304+
{
305+
if (m_extenalCaptureAudio && mediaEngine) {
306+
memcpy(m_audioFrame.buffer, data, size);
307+
m_audioFrame.renderTimeMs = ts;
308+
mediaEngine->pushAudioFrame(&m_audioFrame);
309+
}
310+
}
311+
300312
void CAgoraCaptureAduioDlg::PushAudioFrameThread(CAgoraCaptureAduioDlg * self)
301313
{
302314
agora::util::AutoPtr<agora::media::IMediaEngine> mediaEngine;
@@ -308,8 +320,7 @@ void CAgoraCaptureAduioDlg::PushAudioFrameThread(CAgoraCaptureAduioDlg * self)
308320
SIZE_T nSize = self->m_audioFrame.samples * self->m_audioFrame.channels * self->m_audioFrame.bytesPerSample;
309321
unsigned int readByte = 0;
310322
int timestamp = 0;
311-
if (!CircleBuffer::GetInstance()->readBuffer(self->m_audioFrame.buffer, nSize, &readByte, timestamp))
312-
{
323+
if (!CircleBuffer::GetInstance()->readBuffer(self->m_audioFrame.buffer, nSize, &readByte, timestamp)){
313324
Sleep(1);
314325
continue;
315326
}
@@ -364,8 +375,9 @@ void CAgoraCaptureAduioDlg::OnBnClickedButtonStartCaputre()
364375
EnableExtendAudioCapture(TRUE);
365376
//start capture
366377
EnableCaputre(TRUE);
367-
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PushAudioFrameThread, this, 0, NULL);
378+
//CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PushAudioFrameThread, this, 0, NULL);
368379
m_lstInfo.InsertString(m_lstInfo.GetCount(), _T("use external audio source"));
380+
m_agAudioCaptureDevice.SetCaptureDlg(this);
369381
}
370382
else {
371383
m_btnSetAudioCtx.SetWindowText(customAudioCaptureCtrlSetExternlCapture);
@@ -374,6 +386,7 @@ void CAgoraCaptureAduioDlg::OnBnClickedButtonStartCaputre()
374386
//stop capture.
375387
EnableCaputre(FALSE);
376388
m_lstInfo.InsertString(m_lstInfo.GetCount(), _T("use inner audio source"));
389+
m_agAudioCaptureDevice.SetCaptureDlg(nullptr);
377390
}
378391

379392
}

windows/APIExample/APIExample/Advanced/CustomAudioCapture/CAgoraCaptureAudioDlg.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class CAgoraCaptureAduioDlg : public CDialogEx
129129
// start or stop capture.
130130
// if bEnable is true start capture otherwise stop capture.
131131
void EnableCaputre(BOOL bEnable);
132-
132+
void PushAudioFrame(uint8_t* data, int size, uint64_t ts);
133133

134134

135135
bool m_joinChannel = false;
@@ -138,6 +138,8 @@ class CAgoraCaptureAduioDlg : public CDialogEx
138138
bool m_extenalCaptureAudio = false;
139139
bool m_extenalRenderAudio = false;
140140
IRtcEngine* m_rtcEngine = nullptr;
141+
agora::util::AutoPtr<agora::media::IMediaEngine> mediaEngine;
142+
141143
CAGVideoWnd m_localVideoWnd;
142144
CAgoraCaptureAduioDlgEngineEventHandler m_eventHandler;
143145
CAGDShowAudioCapture m_agAudioCaptureDevice;

windows/APIExample/APIExample/DirectShow/AGDShowAudioCapture.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
#include "stdafx.h"
12
#include "AGDShowAudioCapture.h"
23
#include "DShowHelper.h"
34
#include "CircleBuffer.hpp"
45
#include <Dvdmedia.h>
5-
6+
#include "..\Advanced\CustomAudioCapture\CAgoraCaptureAudioDlg.h"
67

78

89

@@ -629,7 +630,10 @@ void CAGDShowAudioCapture::Receive(bool video, IMediaSample *sample)
629630
if (FAILED(sample->GetPointer(&pBuffer)))
630631
return;
631632

632-
CircleBuffer::GetInstance()->writeBuffer(pBuffer, size, GetTickCount());
633+
if (dlgCapture) {
634+
dlgCapture->PushAudioFrame(pBuffer, size, GetTickCount64());
635+
}
636+
//CircleBuffer::GetInstance()->writeBuffer(pBuffer, size, GetTickCount());
633637
}
634638

635639
void CAGDShowAudioCapture::GetDeviceName(LPTSTR deviceName, SIZE_T *nDeviceLen)
@@ -707,4 +711,8 @@ BOOL CAGDShowAudioCapture::DisconnectPins()
707711
}
708712
ATLASSERT(SUCCEEDED(hr));
709713
return TRUE;
710-
}
714+
}
715+
void CAGDShowAudioCapture::SetCaptureDlg(CAgoraCaptureAduioDlg* dlg)
716+
{
717+
dlgCapture = dlg;
718+
}

windows/APIExample/APIExample/DirectShow/AGDShowAudioCapture.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <DShow.h>
66
#include "IAGDShowDevice.h"
77
#include "capture-filter.hpp"
8+
class CAgoraCaptureAduioDlg;
89
class CAGDShowAudioCapture
910
: public IDShowCaptureDevice
1011
{
@@ -43,7 +44,7 @@ class CAGDShowAudioCapture
4344

4445
virtual BOOL GetAudioCap(int nIndex, WAVEFORMATEX *lpWaveInfo);
4546
virtual BOOL GetCurrentAudioCap(WAVEFORMATEX *lpWaveInfo);
46-
47+
void SetCaptureDlg(CAgoraCaptureAduioDlg* dlg);
4748
protected:
4849
BOOL ConnectFilters();
4950
BOOL ConnectPins(const GUID &category, const GUID &type,
@@ -52,13 +53,14 @@ class CAGDShowAudioCapture
5253
void Receive(bool video, IMediaSample *sample);
5354
void GetDeviceName(LPTSTR deviceName, SIZE_T *nDeviceLen);
5455
BOOL FindPin(IPin **ppInputPin, IPin **ppOutputPin);
56+
5557
private:
5658
TCHAR m_szActiveDeviceID[MAX_PATH];
5759
CAtlList<AGORA_DEVICE_INFO> m_listDeviceInfo;
5860

5961
AUDIO_STREAM_CONFIG_CAPS m_ascStreamCfgCaps;
6062
int m_nCapSelected;
61-
63+
CAgoraCaptureAduioDlg* dlgCapture = nullptr;
6264
// private dshow object
6365
private:
6466
CComPtr<IGraphBuilder> m_ptrGraphBuilder;

windows/APIExample/APIExample/d3d/D3DRender.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,11 @@ int D3DRender::Init(HWND hwnd, unsigned int nWidth, unsigned int nHeight, bool i
3636
if (FAILED(lRet))
3737
return -1;
3838

39-
if (isYuv) {
40-
lRet = m_pDirect3DDevice->CreateOffscreenPlainSurface(nWidth, nHeight, (D3DFORMAT)'21VY', D3DPOOL_DEFAULT, &m_pDirect3DSurfaceRender, NULL);
41-
if (FAILED(lRet))
42-
return -1;
43-
}
44-
else {
45-
lRet = m_pDirect3DDevice->CreateOffscreenPlainSurface(nWidth, nHeight, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &m_pDirect3DSurfaceRender, NULL);
46-
if (FAILED(lRet))
47-
return -1;
48-
}
49-
39+
D3DFORMAT format = isYuv ? (D3DFORMAT)'21VY' : D3DFMT_X8R8G8B8;
40+
lRet = m_pDirect3DDevice->CreateOffscreenPlainSurface(nWidth, nHeight, format, D3DPOOL_DEFAULT, &m_pDirect3DSurfaceRender, NULL);
41+
if (FAILED(lRet))
42+
return -1;
43+
5044
m_nWidth = nWidth;
5145
m_nHeight = nHeight;
5246
m_bIsYuv = isYuv;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
cd /d %~dp0
22

3+
if not exist .\libs (
4+
if exist ..\..\..\libs (
5+
echo d | xcopy ..\..\..\libs .\libs /Y /E /Q
6+
)
7+
)
8+
39
powershell.exe -command ^
410
"& {set-executionpolicy Remotesigned -Scope Process; ./'install.ps1'}"

0 commit comments

Comments
 (0)