Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion iOS/APIExample/Common/KeyCenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

struct KeyCenter {
static let AppId: String = <#Your App Id#>

// assign token to nil if you have not enabled app certificate
static var Token: String? = <#Temp Access Token#>
}
20 changes: 10 additions & 10 deletions windows/APIExample/APIExample.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ProcessScreenShare", "APIEx
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Win32 = Release|Win32
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Debug|Win32.ActiveCfg = Debug|Win32
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Debug|Win32.Build.0 = Debug|Win32
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Debug|x64.ActiveCfg = Debug|x64
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Debug|x64.Build.0 = Debug|x64
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Debug|x86.ActiveCfg = Debug|Win32
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Debug|x86.Build.0 = Debug|Win32
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Release|Win32.ActiveCfg = Release|Win32
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Release|Win32.Build.0 = Release|Win32
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Release|x64.ActiveCfg = Release|x64
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Release|x64.Build.0 = Release|x64
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Release|x86.ActiveCfg = Release|Win32
{DB16CA2F-3910-4449-A5BD-6A602B33BE0F}.Release|x86.Build.0 = Release|Win32
{2B345C3C-4BEA-4DA3-B754-43F9AD219D4A}.Debug|Win32.ActiveCfg = Debug|Win32
{2B345C3C-4BEA-4DA3-B754-43F9AD219D4A}.Debug|Win32.Build.0 = Debug|Win32
{2B345C3C-4BEA-4DA3-B754-43F9AD219D4A}.Debug|x64.ActiveCfg = Debug|Win32
{2B345C3C-4BEA-4DA3-B754-43F9AD219D4A}.Debug|x86.ActiveCfg = Debug|Win32
{2B345C3C-4BEA-4DA3-B754-43F9AD219D4A}.Debug|x86.Build.0 = Debug|Win32
{2B345C3C-4BEA-4DA3-B754-43F9AD219D4A}.Release|Win32.ActiveCfg = Release|Win32
{2B345C3C-4BEA-4DA3-B754-43F9AD219D4A}.Release|Win32.Build.0 = Release|Win32
{2B345C3C-4BEA-4DA3-B754-43F9AD219D4A}.Release|x64.ActiveCfg = Release|Win32
{2B345C3C-4BEA-4DA3-B754-43F9AD219D4A}.Release|x86.ActiveCfg = Release|Win32
{2B345C3C-4BEA-4DA3-B754-43F9AD219D4A}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
5 changes: 4 additions & 1 deletion windows/APIExample/APIExample/APIExample.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ if exist $(SolutionDir)MediaPlayerPart (copy $(SolutionDir)MediaPlayerPart\dll\A
<ManifestResourceCompile>
<ResourceOutputFileName>$(IntDir)$(TargetName)$(TargetExt).embed.manifest.res</ResourceOutputFileName>
</ManifestResourceCompile>
<PreBuildEvent>
<Command>$(SolutionDir)installThirdParty.bat</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
Expand Down Expand Up @@ -338,7 +341,7 @@ if exist en.ini (copy en.ini $(SolutionDir)$(Platform)\$(Configuration))
<ClCompile Include="CSceneDialog.cpp" />
<ClCompile Include="d3d\D3DRender.cpp" />
<ClCompile Include="DirectShow\AGDShowAudioCapture.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
</ClCompile>
<ClCompile Include="DirectShow\AGDShowVideoCapture.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
Expand Down
28 changes: 28 additions & 0 deletions windows/APIExample/APIExample/APIExampleDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ BEGIN_MESSAGE_MAP(CAPIExampleDlg, CDialogEx)
//ON_MESSAGE(WM_MSGID(EID_JOINCHANNEL_SUCCESS), &CAPIExampleDlg::OnEIDJoinLeaveChannel)
ON_NOTIFY(TVN_SELCHANGING, IDC_LIST_ADVANCED, &CAPIExampleDlg::OnSelchangingListAdvanced)
ON_BN_CLICKED(IDC_BUTTON_DOCUMENT_WEBSITE, &CAPIExampleDlg::OnBnClickedButtonDocumentWebsite)
ON_WM_DESTROY()
ON_WM_CLOSE()
END_MESSAGE_MAP()


Expand Down Expand Up @@ -671,3 +673,29 @@ BOOL CAPIExampleDlg::PreTranslateMessage(MSG* pMsg)
}
return CDialogEx::PreTranslateMessage(pMsg);
}


void CAPIExampleDlg::OnDestroy()
{
CDialogEx::OnDestroy();


}


void CAPIExampleDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default

CDialogEx::OnClose();
HTREEITEM hItem = m_lstBasicScene.GetSelectedItem();
if (hItem) {
ReleaseScene(m_lstBasicScene, hItem);
return;
}

hItem = m_lstAdvanced.GetSelectedItem();
if (hItem) {
ReleaseScene(m_lstBasicScene, hItem);
}
}
4 changes: 3 additions & 1 deletion windows/APIExample/APIExample/APIExampleDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class CAPIExampleDlg : public CDialogEx
CString m_preSelectedItemText = _T("");
std::vector<CString> m_vecBasic, m_vecAdvanced;


CString m_curSelectedItemText = _T("");

BOOL m_bJoinChannel = FALSE;
public:
Expand All @@ -127,5 +127,7 @@ class CAPIExampleDlg : public CDialogEx
CButton m_btnDocWebsite;
CStatic m_grpDoc;
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg void OnDestroy();
afx_msg void OnClose();
};

Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ LRESULT CAgoraCaptureAduioDlg::OnEIDRemoteVideoStateChanged(WPARAM wParam, LPARA

CAgoraCaptureAduioDlg::CAgoraCaptureAduioDlg(CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_DIALOG_CUSTOM_CAPTURE_AUDIO, pParent)
, m_capAudioInfo{48000, 2}
, m_renderAudioInfo {48000, 2}
{
m_audioFrame.buffer = new BYTE[48000 * 4 * 4];
}
Expand Down Expand Up @@ -123,6 +125,7 @@ bool CAgoraCaptureAduioDlg::InitAgora()
context.eventHandler = &m_eventHandler;
//initialize the Agora RTC engine context.
int ret = m_rtcEngine->initialize(context);
mediaEngine.queryInterface(m_rtcEngine, agora::AGORA_IID_MEDIA_ENGINE);
if (ret != 0) {
m_initialize = false;
CString strInfo;
Expand Down Expand Up @@ -164,6 +167,8 @@ void CAgoraCaptureAduioDlg::UnInitAgora()
//disable video in the engine.
m_rtcEngine->disableVideo();
m_lstInfo.InsertString(m_lstInfo.GetCount(), _T("disableVideo"));
m_agAudioCaptureDevice.Stop();
mediaEngine->release();
//release engine.
m_rtcEngine->release(true);
m_lstInfo.InsertString(m_lstInfo.GetCount(), _T("release rtc engine"));
Expand Down Expand Up @@ -282,8 +287,6 @@ void CAgoraCaptureAduioDlg::EnableCaputre(BOOL bEnable) {
m_audioFrame.samplesPerSec = waveFormat.nSamplesPerSec;
m_audioFrame.samples = m_audioFrame.samplesPerSec / 100;

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

void CAgoraCaptureAduioDlg::PushAudioFrame(uint8_t* data, int size, uint64_t ts)
{
if (m_extenalCaptureAudio && mediaEngine) {
memcpy(m_audioFrame.buffer, data, size);
m_audioFrame.renderTimeMs = ts;
mediaEngine->pushAudioFrame(&m_audioFrame);
}
}

void CAgoraCaptureAduioDlg::PushAudioFrameThread(CAgoraCaptureAduioDlg * self)
{
agora::util::AutoPtr<agora::media::IMediaEngine> mediaEngine;
Expand All @@ -308,8 +320,7 @@ void CAgoraCaptureAduioDlg::PushAudioFrameThread(CAgoraCaptureAduioDlg * self)
SIZE_T nSize = self->m_audioFrame.samples * self->m_audioFrame.channels * self->m_audioFrame.bytesPerSample;
unsigned int readByte = 0;
int timestamp = 0;
if (!CircleBuffer::GetInstance()->readBuffer(self->m_audioFrame.buffer, nSize, &readByte, timestamp))
{
if (!CircleBuffer::GetInstance()->readBuffer(self->m_audioFrame.buffer, nSize, &readByte, timestamp)){
Sleep(1);
continue;
}
Expand Down Expand Up @@ -364,8 +375,9 @@ void CAgoraCaptureAduioDlg::OnBnClickedButtonStartCaputre()
EnableExtendAudioCapture(TRUE);
//start capture
EnableCaputre(TRUE);
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PushAudioFrameThread, this, 0, NULL);
//CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PushAudioFrameThread, this, 0, NULL);
m_lstInfo.InsertString(m_lstInfo.GetCount(), _T("use external audio source"));
m_agAudioCaptureDevice.SetCaptureDlg(this);
}
else {
m_btnSetAudioCtx.SetWindowText(customAudioCaptureCtrlSetExternlCapture);
Expand All @@ -374,6 +386,7 @@ void CAgoraCaptureAduioDlg::OnBnClickedButtonStartCaputre()
//stop capture.
EnableCaputre(FALSE);
m_lstInfo.InsertString(m_lstInfo.GetCount(), _T("use inner audio source"));
m_agAudioCaptureDevice.SetCaptureDlg(nullptr);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class CAgoraCaptureAduioDlg : public CDialogEx
// start or stop capture.
// if bEnable is true start capture otherwise stop capture.
void EnableCaputre(BOOL bEnable);

void PushAudioFrame(uint8_t* data, int size, uint64_t ts);


bool m_joinChannel = false;
Expand All @@ -138,6 +138,8 @@ class CAgoraCaptureAduioDlg : public CDialogEx
bool m_extenalCaptureAudio = false;
bool m_extenalRenderAudio = false;
IRtcEngine* m_rtcEngine = nullptr;
agora::util::AutoPtr<agora::media::IMediaEngine> mediaEngine;

CAGVideoWnd m_localVideoWnd;
CAgoraCaptureAduioDlgEngineEventHandler m_eventHandler;
CAGDShowAudioCapture m_agAudioCaptureDevice;
Expand Down
14 changes: 11 additions & 3 deletions windows/APIExample/APIExample/DirectShow/AGDShowAudioCapture.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include "stdafx.h"
#include "AGDShowAudioCapture.h"
#include "DShowHelper.h"
#include "CircleBuffer.hpp"
#include <Dvdmedia.h>

#include "..\Advanced\CustomAudioCapture\CAgoraCaptureAudioDlg.h"



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

CircleBuffer::GetInstance()->writeBuffer(pBuffer, size, GetTickCount());
if (dlgCapture) {
dlgCapture->PushAudioFrame(pBuffer, size, GetTickCount64());
}
//CircleBuffer::GetInstance()->writeBuffer(pBuffer, size, GetTickCount());
}

void CAGDShowAudioCapture::GetDeviceName(LPTSTR deviceName, SIZE_T *nDeviceLen)
Expand Down Expand Up @@ -707,4 +711,8 @@ BOOL CAGDShowAudioCapture::DisconnectPins()
}
ATLASSERT(SUCCEEDED(hr));
return TRUE;
}
}
void CAGDShowAudioCapture::SetCaptureDlg(CAgoraCaptureAduioDlg* dlg)
{
dlgCapture = dlg;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <DShow.h>
#include "IAGDShowDevice.h"
#include "capture-filter.hpp"
class CAgoraCaptureAduioDlg;
class CAGDShowAudioCapture
: public IDShowCaptureDevice
{
Expand Down Expand Up @@ -43,7 +44,7 @@ class CAGDShowAudioCapture

virtual BOOL GetAudioCap(int nIndex, WAVEFORMATEX *lpWaveInfo);
virtual BOOL GetCurrentAudioCap(WAVEFORMATEX *lpWaveInfo);

void SetCaptureDlg(CAgoraCaptureAduioDlg* dlg);
protected:
BOOL ConnectFilters();
BOOL ConnectPins(const GUID &category, const GUID &type,
Expand All @@ -52,13 +53,14 @@ class CAGDShowAudioCapture
void Receive(bool video, IMediaSample *sample);
void GetDeviceName(LPTSTR deviceName, SIZE_T *nDeviceLen);
BOOL FindPin(IPin **ppInputPin, IPin **ppOutputPin);

private:
TCHAR m_szActiveDeviceID[MAX_PATH];
CAtlList<AGORA_DEVICE_INFO> m_listDeviceInfo;

AUDIO_STREAM_CONFIG_CAPS m_ascStreamCfgCaps;
int m_nCapSelected;

CAgoraCaptureAduioDlg* dlgCapture = nullptr;
// private dshow object
private:
CComPtr<IGraphBuilder> m_ptrGraphBuilder;
Expand Down
16 changes: 5 additions & 11 deletions windows/APIExample/APIExample/d3d/D3DRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,11 @@ int D3DRender::Init(HWND hwnd, unsigned int nWidth, unsigned int nHeight, bool i
if (FAILED(lRet))
return -1;

if (isYuv) {
lRet = m_pDirect3DDevice->CreateOffscreenPlainSurface(nWidth, nHeight, (D3DFORMAT)'21VY', D3DPOOL_DEFAULT, &m_pDirect3DSurfaceRender, NULL);
if (FAILED(lRet))
return -1;
}
else {
lRet = m_pDirect3DDevice->CreateOffscreenPlainSurface(nWidth, nHeight, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &m_pDirect3DSurfaceRender, NULL);
if (FAILED(lRet))
return -1;
}

D3DFORMAT format = isYuv ? (D3DFORMAT)'21VY' : D3DFMT_X8R8G8B8;
lRet = m_pDirect3DDevice->CreateOffscreenPlainSurface(nWidth, nHeight, format, D3DPOOL_DEFAULT, &m_pDirect3DSurfaceRender, NULL);
if (FAILED(lRet))
return -1;

m_nWidth = nWidth;
m_nHeight = nHeight;
m_bIsYuv = isYuv;
Expand Down
2 changes: 1 addition & 1 deletion windows/APIExample/install.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$ThirdPartysrc = 'https://agora-adc-artifacts.oss-cn-beijing.aliyuncs.com/libs/ThirdParty.zip'
$ThirdPartydes = 'ThirdParty.zip'
$agora_sdk = 'https://download.agora.io/sdk/release/Agora_Native_SDK_for_Windows_v3_5_0_FULL.zip'
$agora_sdk = 'https://download.agora.io/sdk/release/Agora_Native_SDK_for_Windows_v3_5_0_3_FULL.zip'
$agora_des = 'Agora_Native_SDK_for_Windows.zip'
$MediaPlayerSDK = 'https://download.agora.io/sdk/release/Agora_Media_Player_for_Windows_x86_32597_20200923_2306.zip'
$MediaPlayerDes = 'MediaPlayerPartSave.zip'
Expand Down
6 changes: 6 additions & 0 deletions windows/APIExample/installThirdParty.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
cd /d %~dp0

if not exist .\libs (
if exist ..\..\..\libs (
echo d | xcopy ..\..\..\libs .\libs /Y /E /Q
)
)

powershell.exe -command ^
"& {set-executionpolicy Remotesigned -Scope Process; ./'install.ps1'}"