Skip to content

Commit

Permalink
unity ai denoiser and windows quickstart
Browse files Browse the repository at this point in the history
  • Loading branch information
saudsami committed Dec 22, 2023
2 parents c96500b + a228ea6 commit 24f5276
Show file tree
Hide file tree
Showing 27 changed files with 318 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,12 @@
- <Link to="{{Global.API_REF_MACOS_ROOT_RTC_KIT}}/audio_ains_mode">AUDIO_AINS_MODE</Link>
</PlatformWrapper>

</PlatformWrapper>
<PlatformWrapper platform="unity">
Enable AI noise suppression when you configure the engine.

```csharp
agoraEngine.SetAINSMode(true, AUDIO_AINS_MODE.AINS_MODE_AGGRESSIVE);
```
* <Link to = "{{global.API_REF_UNITY_ROOT}}/class_irtcengine.html#api_irtcengine_setainsmode">setAINSMode</Link>
</PlatformWrapper>
5 changes: 5 additions & 0 deletions assets/code/video-sdk/ai-noise-suppression/import-library.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ import { useConnectionState } from 'agora-rtc-react';
import { useAgoraContext } from "../agora-manager/agoraManager";
```
</PlatformWrapper>
<PlatformWrapper platform="unity">
```csharp
using Agora.Rtc;
```
</PlatformWrapper>
47 changes: 47 additions & 0 deletions assets/code/video-sdk/get-started-sdk/create-engine.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,50 @@
- <Link to="{{Global.API_REF_RNJS_ROOT}}/functions/AgoraRTCProvider.html">AgoraRTCProvider</Link>

</PlatformWrapper>
<PlatformWrapper platform="windows">
<ProductWrapper notAllowed="voice-calling">

```cpp
void AgoraManager::setupVideoSDKEngine()
{
// Check if the engine initialized successfully.
agoraEngine = createAgoraRtcEngine();
if (!agoraEngine)
{
return;
}
AgoraEventStrategy->SetMsgReceiver(gui->getGuiWindowReference());

// Create an instance of RtcEngineContext to initialize the engine.
RtcEngineContext context;
// Pass your app ID to the context.
context.appId = appId.c_str();
// Pass an object of agoraEventHandler class to receive callbacks.
context.eventHandler = AgoraEventStrategy.get();
// Set channel profile in the engine to the CHANNEL_PROFILE_LIVE_BROADCASTING.
context.channelProfile = CHANNEL_PROFILE_LIVE_BROADCASTING;
// Initialize the engine using the context variable.
agoraEngine->initialize(context);
// Set the user role to Host.
agoraEngine->setClientRole(CLIENT_ROLE_TYPE::CLIENT_ROLE_BROADCASTER);

// Enable the microphone to create the local audio stream.
agoraEngine->enableAudio();
// Enable the local video capturer.
agoraEngine->enableVideo();
}
```
- <Link to="{{Global.API_REF_CPP_ROOT}}/class_irtcengine.html#api_irtcengine_createagorartcengine">createAgoraRtcEngine</Link>

- <Link to="{{Global.API_REF_CPP_ROOT}}/class_irtcengine.html#api_irtcengine_initialize">initialize</Link>

- <Link to="{{Global.API_REF_CPP_ROOT}}/class_irtcengine.html#api_irtcengine_setclientrole">setClientRole</Link>

- <Link to="{{Global.API_REF_CPP_ROOT}}/class_irtcengine.html#api_irtcengine_enablevideo">enableVideo</Link>

- <Link to="{{Global.API_REF_CPP_ROOT}}/class_irtcengine.html#api_irtcengine_enableaudio">enableAudio</Link>

</ProductWrapper>
</PlatformWrapper>


14 changes: 14 additions & 0 deletions assets/code/video-sdk/get-started-sdk/declare-variables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,17 @@
const [joined, setJoined] = useState(false);
```
</PlatformWrapper>
<PlatformWrapper platform="windows">

```cpp
IRtcEngine* agoraEngine = nullptr;
std::string appId = "";
std::string channelName = "";
std::string token = "";
u_int remoteUId;
std::shared_ptr<AgoraManagerEventHandler> AgoraEventStrategy;
int tokenRole = 1; // The token role: Broadcaster or Audience
uid_t uid = 1; // An integer that identifies the user
```

</PlatformWrapper>
60 changes: 60 additions & 0 deletions assets/code/video-sdk/get-started-sdk/handle-events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,63 @@ func rtcEngine(_ engine: AgoraRtcEngineKit, didOfflineOfUid uid: UInt, reason: A
```
</ProductWrapper>
</PlatformWrapper>
<PlatformWrapper platform="windows">

You use `IRtcEngineEventHandler` to implement callback functions.

```cpp
class AgoraManagerEventHandler : public IRtcEngineEventHandler
{
public:
// Set the message notify window handler
void SetMsgReceiver(HWND hWnd) { m_hMsgHandler = hWnd; }

virtual HWND getMsgEventHandler() { return m_hMsgHandler; }
virtual void onJoinChannelSuccess(const char* channel, uid_t uid, int elapsed) override;
virtual void onUserJoined(uid_t uid, int elapsed) override;
virtual void onUserOffline(uid_t uid, USER_OFFLINE_REASON_TYPE reason) override;
virtual void onLeaveChannel(const RtcStats& stats) override;
virtual void onTokenPrivilegeWillExpire(const char* token) override;
public:
HWND m_hMsgHandler;
};
```
Provide definitions for the callbacks you declare in `AgoraEventHandler`.
```cpp
void AgoraManagerEventHandler::onJoinChannelSuccess(const char* channel, uid_t uid, int elapsed)
{
// Occurs when you join a channel.
}

void AgoraManagerEventHandler::onUserOffline(uid_t uid, USER_OFFLINE_REASON_TYPE reason)
{
// Occurs when the remote user drops offline or leave the channel.
MessageBox(NULL, L"Remote user Leave the channel", L"Notification", NULL);

}
void AgoraManagerEventHandler::onLeaveChannel(const RtcStats& stats)
{
// Occurs when you leave a channel.
MessageBox(NULL, L"You left the channel", L"Notification", NULL);
}

void AgoraManagerEventHandler::onUserJoined(uid_t uid, int elapsed)
{
HWND MsgEventHandler = getMsgEventHandler();
// Send a notification to AgoraManager class to setup a remote video view.
if (MsgEventHandler)
{
::PostMessage(MsgEventHandler, WM_MSGID(EID_USER_JOINED), (WPARAM)uid, (LPARAM)elapsed);
}

}
```
- <Link to="{{Global.API_REF_CPP_ROOT}}/class_irtcengineeventhandler.html#class_irtcengineeventhandler">IRtcEngineEventHandler</Link>
- <Link to="{{Global.API_REF_CPP_ROOT}}/class_irtcengineeventhandler.html#callback_irtcengineeventhandler_onjoinchannelsuccess">onJoinChannelSuccess</Link>
- <Link to="{{Global.API_REF_CPP_ROOT}}/class_irtcengineeventhandler.html#callback_irtcengineeventhandler_onuseroffline">onUserOffline</Link>
- <Link to="{{Global.API_REF_CPP_ROOT}}/class_irtcengineeventhandler.html#callback_irtcengineeventhandler_onleavechannel">onLeaveChannel</Link>
</PlatformWrapper>
25 changes: 25 additions & 0 deletions assets/code/video-sdk/get-started-sdk/import-library.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,29 @@
} from "agora-rtc-react";
import { IMicrophoneAudioTrack, ICameraVideoTrack } from "agora-rtc-sdk-ng";
```
</PlatformWrapper>
<PlatformWrapper platform="windows">

From **Solution Explorer**, open the `pch.h` file and add the following lines after `#include "framework.h"`:

```cpp
#ifndef PCH_H
#define PCH_H
#define _AFX_ALL_WARNINGS
#include <string>
// For handling config.json for user input
#include <json/json.h>
#include <IAgoraRtcEngine.h>
#include <IAgoraMediaEngine.h>
#pragma comment(lib, "agora_rtc_sdk.dll.lib")
#pragma comment(lib, "libagora_segmentation_extension.dll.lib")
#pragma comment(lib, "libagora-ffmpeg.dll.lib")
using namespace agora;
using namespace agora::rtc;
using namespace agora::media;
#define WM_MSGID(code) (WM_USER+0x200+code)
#define EID_USER_JOINED 0x00000003
#define EID_TOKEN_PRIVILEGE_WILL_EXPIRE 0x00000023
#endif //PCH_H
```
</PlatformWrapper>
18 changes: 18 additions & 0 deletions assets/code/video-sdk/get-started-sdk/join-channel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,21 @@ func joinBroadcastStream(

- <Link to="{{Global.API_REF_RNJS_ROOT}}/functions/useJoin.html">useJoin</Link>
</PlatformWrapper>
<PlatformWrapper platform = "windows">

```cpp
void AgoraManager::join()
{

if (0 != agoraEngine->joinChannel(token.c_str(), channelName.c_str(), 0, NULL))
{
MessageBox(NULL, L"AgoraManager::joinChannel() error.", L"Error!", MB_ICONEXCLAMATION | MB_OK);
return;

}
}
```
- <Link to="{{Global.API_REF_CPP_ROOT}}/class_irtcengine.html#api_irtcengine_joinchannel2">joinChannel</Link>

</PlatformWrapper>

25 changes: 25 additions & 0 deletions assets/code/video-sdk/get-started-sdk/leave-channel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,29 @@
- <Link target="_blank" to="{{global.API_REF_WEB_ROOT}}/interfaces/iagorartcclient.html#leave">leave</Link>
</ProductWrapper>
</PlatformWrapper>
<PlatformWrapper platform="windows">

```cpp
void AgoraManager::leave()
{
// Leave the channel to end the call.
agoraEngine->leaveChannel();
// Stop the local video preview.
agoraEngine->stopPreview();
// Disable the local video capturer.
agoraEngine->disableVideo();
// Disable the local microphone.
agoraEngine->disableAudio();
}
```

- <Link to="{{Global.API_REF_CPP_ROOT}}/class_irtcengine.html#api_irtcengine_leavechannel">leaveChannel</Link>

- <Link to="{{Global.API_REF_CPP_ROOT}}/class_irtcengine.html#api_irtcengine_stoppreview">stopPreview</Link>

- <Link to="{{Global.API_REF_CPP_ROOT}}/class_irtcengine.html#api_irtcengine_disableaudio">disableAudio</Link>

- <Link to="{{Global.API_REF_CPP_ROOT}}/class_irtcengine.html#api_irtcengine_disablevideo">disableVideo</Link>

</PlatformWrapper>

21 changes: 21 additions & 0 deletions assets/code/video-sdk/get-started-sdk/local-video.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,24 @@
```
- <Link to="{{Global.API_REF_RNJS_ROOT}}/functions/LocalAudioTrack.html">LocalAudioTrack</Link>
</PlatformWrapper>
<PlatformWrapper platform="windows">

```cpp
// Setup a video canvas to render the local video.
VideoCanvas canvas;
// Assign the local user ID to canvas for identification.
canvas.uid = 1;
// Pass the local view window handle to canvas to render the local video.
canvas.view = gui->localView;
// Select a local video source.
canvas.sourceType = VIDEO_SOURCE_CAMERA;
// Render the local video.
agoraEngine->setupLocalVideo(canvas);
//agora::rtc::uid_t uid = this->uid;
// Preview the local video.
agoraEngine->startPreview();
```
- <Link to="{{Global.API_REF_CPP_ROOT}}/class_irtcengine.html#api_irtcengine_setuplocalvideo">setupLocalVideo</Link>

- <Link to="{{Global.API_REF_CPP_ROOT}}/class_irtcengine.html#api_irtcengine_startpreview">startPreview</Link>
</PlatformWrapper>
32 changes: 32 additions & 0 deletions assets/code/video-sdk/get-started-sdk/remote-video.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,35 @@ See [`AgoraVideoCanvasView`](https://github.com/AgoraIO/video-sdk-samples-macos/
```
- <Link to="{{Global.API_REF_RNJS_ROOT}}/functions/RemoteVideoTrack.html">RemoteVideoTrack</Link>
</PlatformWrapper>
<PlatformWrapper platform="windows">

```cpp
LRESULT AgoraManager::OnEIDUserJoined(WPARAM wParam, LPARAM lParam)
{
// Setup a video canvas to render the remote video.
VideoCanvas canvas;
// Choose a video render mode.
canvas.renderMode = media::base::RENDER_MODE_FIT;
// Assign the remote user ID to the canvas for identification.
canvas.uid = wParam;
// Pass the remote view window handle to canvas to render the remote video.
canvas.view = gui->remoteView;
// Render the remote video.
agoraEngine->setupRemoteVideo(canvas);
// Save the remote user ID for reuse.
remoteUId = wParam;
// Notify the parent window
HWND hwndParent = GetParent(gui->getGuiWindowReference());

if (hwndParent != NULL)
{
PostMessage(hwndParent, WM_MSGID(EID_USER_JOINED), TRUE, 0);
}

return 0;
}
```
- <Link to="{{Global.API_REF_CPP_ROOT}}/class_irtcengineeventhandler.html#callback_irtcengineeventhandler_onuserjoined">onUserJoined</Link>

- <Link to="{{Global.API_REF_CPP_ROOT}}/class_irtcengine.html#api_irtcengine_setupremotevideo">setupRemoteVideo</Link>
</PlatformWrapper>
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,4 @@
)
}
```
</PlatformWrapper>
<PlatformWrapper platform="unity">
```csharp
public void PublishScreenTrack()
{
// Publish the screen track
ChannelMediaOptions channelOptions = new ChannelMediaOptions();
channelOptions.publishScreenTrack.SetValue(true);
channelOptions.publishMicrophoneTrack.SetValue(true);
channelOptions.publishSecondaryScreenTrack.SetValue(true);
channelOptions.publishCameraTrack.SetValue(false);
agoraEngine.UpdateChannelMediaOptions(channelOptions);
}

public void UnPublishScreenTrack()
{
// Unpublish the screen track.
ChannelMediaOptions channelOptions = new ChannelMediaOptions();
channelOptions.publishScreenTrack.SetValue(false);
channelOptions.publishCameraTrack.SetValue(true);
channelOptions.publishMicrophoneTrack.SetValue(true);
agoraEngine.UpdateChannelMediaOptions(channelOptions);
}
```
</PlatformWrapper>
53 changes: 0 additions & 53 deletions assets/code/video-sdk/product-workflow/screen-sharer-target.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,56 +21,3 @@
}
```
</PlatformWrapper>
<PlatformWrapper platform="unity">
```csharp
private void StartScreenCaptureMobile(long sourceId)
{
// Configure screen capture parameters for Android.
var parameters2 = new ScreenCaptureParameters2();
parameters2.captureAudio = true;
parameters2.captureVideo = true;
// Start screen sharing.
agoraEngine.StartScreenCapture(parameters2);
}

private void StartScreenCaptureWindows(long sourceId)
{
// Configure screen capture parameters for Windows.
agoraEngine.StartScreenCaptureByDisplayId((uint)sourceId, default(Rectangle),
new ScreenCaptureParameters { captureMouseCursor = true, frameRate = 30 });
}
// Share the screen
public void StartSharing()
{
if (agoraEngine == null)
{
Debug.Log("Join a channel to start screen sharing");
return;
}

// Get a list of shareable screens and windows.
var captureSources = GetScreenCaptureSources();

if (captureSources != null && captureSources.Length > 0)
{
var sourceId = captureSources[0].sourceId;

// Start screen sharing based on platform.
#if UNITY_ANDROID || UNITY_IPHONE
StartScreenCaptureMobile(sourceId);
#else
StartScreenCaptureWindows(sourceId);
#endif

// Publish the screen track.
PublishScreenTrack();
}
else
{
Debug.LogWarning("No screen capture sources found.");
}
}
```
- <Link to="{{Global.API_REF_UNITY_ROOT}}/class_irtcengine.html#api_irtcengine_startscreencapturebydisplayid">StartScreenCaptureByDisplayId</Link>
- <Link to="{{Global.API_REF_UNITY_ROOT}}/class_irtcengine.html#api_irtcengine_startscreencapture">StartScreenCapture</Link>
</PlatformWrapper>
Loading

0 comments on commit 24f5276

Please sign in to comment.