This project is a video calling application built using the Agora SDK in C++. The application has been further /aim/ to integrate NVIDIA Maxine's advanced AR SDK features, such as eye gaze tracking.
- Video Calling: Real-time video calling capabilities using the Agora SDK.
- Screen Sharing: Share your screen with other participants during the video call.
- User Management: Handle user joining and leaving events efficiently.
- NVIDIA Maxine Integration: Enhanced video communication with advanced features such as eye gaze tracking.
- Real Time Translane: Enable real time translane into our application.
- Live Potrait: Enhance video quality by using Live Potrait.
- Visual Studio: Ensure you have Visual Studio installed (recommended: Visual Studio 2019 or later). Install
- Agora SDK: Download the Agora SDK from the Agora Developer Portal.
- NVIDIA Maxine AR SDK: Download the NVIDIA Maxine AR SDK from the NVIDIA Developer Portal.
-
Clone the Repository
git clone https://github.com/your-username/agora-maxine-video-calling.git cd agora-maxine-video-calling
-
Setup Agora SDK
- Extract the downloaded Agora SDK.
- Copy the
sdk
folder into the project directory.
-
Setup NVIDIA Maxine AR SDK
- Extract the downloaded NVIDIA Maxine AR SDK.
- Follow the NVIDIA AR SDK System Guide to properly set up the SDK.
-
Open the Project
- Open the solution file
AgoraQuickStart.sln
in Visual Studio.
- Open the solution file
-
Configure App ID and Token
- Replace
APP_ID
andtoken
placeholders inAgoraQuickStartDlg.cpp
with your Agora App ID and temporary token.
#define APP_ID "your-agora-app-id" #define token "your-agora-token"
- Replace
-
Build the Project
- In Visual Studio, set the build configuration to
Release
and the target platform tox64
. - Build the solution (Ctrl + Shift + B).
- In Visual Studio, set the build configuration to
-
Run the Application
- After building the project, run the application (F5).
-
Joining a Channel
- Enter the channel name in the provided text box.
- Click the
Join
button to join the channel.
-
Leaving a Channel
- Click the
Leave
button to leave the channel.
- Click the
-
Screen Sharing
- Click the
Start/Stop Screen Sharing
button to toggle screen sharing.
- Click the
-
NVIDIA Maxine Integration
- Ensure the NVIDIA Maxine SDK is properly set up.
- The eye gaze feature will be automatically applied to the video feed.
The application utilizes the Agora SDK for WebRTC functionality, enabling real-time video and audio communication. Below is a summary of key components and their roles:
-
Agora SDK Initialization
The Agora SDK is initialized in the
CAgoraQuickStartDlg::OnInitDialog
method. This sets up the SDK context and enables video functionality.BOOL CAgoraQuickStartDlg::OnInitDialog() { // Set the message receiver m_eventHandler.SetMsgReceiver(m_hWnd); // Create rtcEngine object m_rtcEngine = createAgoraRtcEngine(); RtcEngineContext context; context.appId = APP_ID; context.eventHandler = &m_eventHandler; // Initialize int ret = m_rtcEngine->initialize(context); if (ret == 0) { m_initialize = true; } else { m_initialize = false; } // Enable the video module m_rtcEngine->enableVideo(); return TRUE; }
-
Joining a Channel
When the user clicks the
Join
button, theOnBnClickedBtnJoin
method is invoked. This method reads the channel name from the UI and uses the Agora SDK to join the specified channel.void CAgoraQuickStartDlg::OnBnClickedBtnJoin() { CString strChannelName; m_edtChannelName.GetWindowText(strChannelName); if (strChannelName.IsEmpty()) { AfxMessageBox(_T("Fill channel name first")); return; } ChannelMediaOptions option; option.channelProfile = CHANNEL_PROFILE_COMMUNICATION; option.clientRoleType = CLIENT_ROLE_BROADCASTER; option.autoSubscribeAudio = true; option.autoSubscribeVideo = true; int ret = m_rtcEngine->joinChannel(token, cs2utf8(strChannelName).c_str(), 0, option); VideoCanvas canvas; canvas.renderMode = RENDER_MODE_TYPE::RENDER_MODE_HIDDEN; canvas.uid = 0; canvas.view = m_staLocal.GetSafeHwnd(); m_rtcEngine->setupLocalVideo(canvas); }
-
Handling User Events
The application handles various user events through the
CAgoraQuickStartRtcEngineEventHandler
class. This class implements theIRtcEngineEventHandler
interface, which includes callbacks for events such as joining a channel, user joined, user offline, and error events.class CAgoraQuickStartRtcEngineEventHandler : public IRtcEngineEventHandler { public: void SetMsgReceiver(HWND hWnd) { m_hMsgHanlder = hWnd; } virtual void onJoinChannelSuccess(const char* channel, uid_t uid, int elapsed) override { if (m_hMsgHanlder) { ::PostMessage(m_hMsgHanlder, WM_MSGID(EID_JOIN_CHANNEL_SUCCESS), uid, 0); } } virtual void onUserJoined(uid_t uid, int elapsed) override { if (m_hMsgHanlder) { ::PostMessage(m_hMsgHanlder, WM_MSGID(EID_USER_JOINED), uid, 0); } } virtual void onUserOffline(uid_t uid, USER_OFFLINE_REASON_TYPE reason) override { if (m_hMsgHanlder) { ::PostMessage(m_hMsgHanlder, WM_MSGID(EID_USER_OFFLINE), uid, 0); } } virtual void onLeaveChannel(const RtcStats& stats) override { if (m_hMsgHanlder) { ::PostMessage(m_hMsgHanlder, WM_MSGID(EID_LEAVE_CHANNEL), 0, 0); } } virtual void onError(int err, const char* msg) override { if (m_hMsgHanlder) { char* message = new char[1024] {0}; memcpy(message, msg, strlen(msg)); ::PostMessage(m_hMsgHanlder, WM_MSGID(EID_ERROR), (WPARAM)message, err); } } private: HWND m_hMsgHanlder; };
-
Screen Sharing
The application allows users to share their screen by clicking the
Start/Stop Screen Sharing
button, which toggles the screen sharing status using the Agora SDK.void CAgoraQuickStartDlg::OnBnClickedWizfinish() { if (!m_initialize) { AfxMessageBox(_T("Please initialize the engine first")); return; } if (!m_isSharingScreen) { agora::rtc::ScreenCaptureParameters captureParams; captureParams.dimensions.width = 1920; captureParams.dimensions.height = 1080; captureParams.frameRate = 15; captureParams.bitrate = 0; captureParams.captureMouseCursor = true; captureParams.windowFocus = true; m_rtcEngine->startScreenCaptureByDisplayId(0, {}, captureParams); AfxMessageBox(_T("Screen sharing started")); } else { m_rtcEngine->stopScreenCapture(); AfxMessageBox(_T("Screen sharing stopped")); } m_isSharingScreen = !m_isSharingScreen; }
AgoraQuickStartDlg.h
andAgoraQuickStartDlg.cpp
: Contains the main dialog class for the application.CAgoraQuickStartRtcEngineEventHandler.h
andCAgoraQuickStartRtcEngineEventHandler.cpp
: Handles Agora RTC engine events.resource.h
,stdafx.h
,stdafx.cpp
: Standard MFC application files.res/
: Contains resources like icons and dialog templates.
- Agora.io for providing the real-time communication SDK.
- NVIDIA for the advanced AR SDK.
For any questions or inquiries, please contact [email protected].
This section provides an overview of how WebRTC functionality is implemented using the Agora SDK in your application. It covers initialization, joining channels, handling user events, and screen sharing, giving users a clear understanding of how the core communication features are integrated and managed.