Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 6ff691b

Browse files
authored
2.4.2 C++ SDK Support With Audio devices refactor, Video support refactor, VFS (#144)
* Removed unity submodule - Removed Unity plugin packaging from workflow - Moved to 2.4.2 C++ SDK - Refactored Audio devices management - Added proper video support based on 2.4.2 C++ SDK Refactor - Added VFS and Simulcast Connection options - Added a binary package for unity SDK - Bumped version to 1.2.0-beta.1 - Publish workflow
1 parent 3623b86 commit 6ff691b

36 files changed

+377
-104
lines changed

.github/actions/configure/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ runs:
2222
- name: Configure
2323
shell: ${{ inputs.shell }}
2424
working-directory: ${{github.workspace}}/build
25-
run: cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" ${{github.workspace}}
25+
run: cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DUNITY_BUILD=OFF ${{github.workspace}}

.github/workflows/package.yml

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Package Artifacts
2-
on: workflow_dispatch
3-
2+
on:
3+
- workflow_dispatch
4+
- workflow_call
5+
46
jobs:
57
build-runtimes:
68
name: build-${{ matrix.os }}
@@ -79,20 +81,6 @@ jobs:
7981
name: nugets
8082
path: ${{github.workspace}}/build/bin/DolbyIO.Comms.Sdk.*.nupkg
8183

82-
- run: 7z x "${{github.workspace}}/build/bin/DolbyIO.Comms.Sdk.Runtime.*.nupkg" -o${{github.workspace}}/build "runtimes/*"
83-
working-directory: ${{github.workspace}}/build
84-
85-
- run: rm -f Plugins/osx-universal/native/*.dylib
86-
working-directory: ${{github.workspace}}/unity
87-
88-
- run: cp -r ${{github.workspace}}/build/runtimes/* ${{github.workspace}}/unity/Plugins
89-
working-directory: ${{github.workspace}}/unity
90-
91-
- uses: actions/upload-artifact@v3
92-
with:
93-
name: dolbyio-comms-unity-plugin
94-
path: ${{github.workspace}}/unity/
95-
9684
- run: dotnet publish dotnet/DolbyCMD/DolbyCMD.csproj -o CmdLine
9785
working-directory: ${{github.workspace}}/build
9886

@@ -101,3 +89,10 @@ jobs:
10189
name: CmdLine
10290
path: ${{github.workspace}}/build/CmdLine/
10391

92+
- run: 7z x "${{github.workspace}}/build/bin/DolbyIO.Comms.Sdk.Runtime.*.nupkg" -o${{github.workspace}}/build "runtimes/*"
93+
working-directory: ${{github.workspace}}/build
94+
95+
- uses: actions/upload-artifact@v3
96+
with:
97+
name: dolbyio-dotnet-binaries
98+
path: ${{github.workspace}}/build/runtimes/

.github/workflows/publish.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Publish Nuget
2+
on: workflow_dispatch
3+
4+
jobs:
5+
package:
6+
uses: ./.github/workflows/package.yml
7+
secrets: inherit
8+
9+
publish:
10+
runs-on: macos-latest
11+
steps:
12+
- name: Download nuget packages
13+
uses: actions/download-artifact@v3
14+
with:
15+
name: nugets
16+

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.15)
22

33
option(BUILD_TESTS "Build Tests" ON)
4-
option(BUILD_UNITY "Package Unity Plugin" ON)
4+
option(BUILD_UNITY "Copy Binaries to Unity Plugin" OFF)
55

66
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
77

cmake/externals/cpp-sdk.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
include(FetchContent)
22

3-
set(CPP_SDK_VERSION 2.3.1)
3+
set(CPP_SDK_VERSION 2.4.2)
44

55
if (WIN32)
66
set(CPP_SDK_FILENAME cppsdk-${CPP_SDK_VERSION}-windows64.zip)

cmake/unity.cmake

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
option(BUILD_UNITY "Build unity package" ON)
2-
31
if (BUILD_UNITY)
2+
if (NOT DEFINED ENV{UNITY_PLUGIN_PATH})
3+
message(FATAL_ERROR "Please set UNITY_PLUGIN_PATH")
4+
endif()
5+
set(UNITY_PLUGIN_PATH $ENV{UNITY_PLUGIN_PATH})
6+
47
if (WIN32)
5-
set(UNITY_RUNTIME_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/unity/Plugins/win-x64/native")
8+
set(UNITY_RUNTIME_DIRECTORY "${UNITY_PLUGIN_PATH}/Plugins/win-x64/native")
69
elseif(APPLE)
7-
set(UNITY_RUNTIME_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/unity/Plugins/osx-universal/native")
10+
set(UNITY_RUNTIME_DIRECTORY "${UNITY_PLUGIN_PATH}/Plugins/osx-universal/native")
811
endif()
912

10-
set(UNITY_ASSEMBLY_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/unity/Runtime/Assembly")
13+
set(UNITY_ASSEMBLY_DIRECTORY "${UNITY_PLUGIN_PATH}/Runtime/Assembly")
1114

1215
add_custom_target(UnityPackage ALL
1316
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:DolbyioComms::sdk> "${UNITY_RUNTIME_DIRECTORY}/$<TARGET_FILE_NAME:DolbyioComms::sdk>"

cmake/version.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
set(CSSDK_MAJOR 1)
2-
set(CSSDK_MINOR 1)
3-
set(CSSDK_PATH 0)
2+
set(CSSDK_MINOR 2)
3+
set(CSSDK_PATH 0-beta.1)

samples/CmdLine/Main.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,14 @@ await _sdk.InitAsync(appKey, () =>
155155
Log.Debug($"OnDeviceAdded: {device.Name}");
156156
});
157157

158-
_sdk.MediaDevice.AudioDeviceRemoved = new AudioDeviceRemovedEventHandler((byte[] uid) =>
158+
_sdk.MediaDevice.AudioDeviceRemoved = new AudioDeviceRemovedEventHandler((DeviceIdentity id)=>
159159
{
160-
Log.Debug($"OnDeviceRemoved: {uid}");
160+
Log.Debug("OnDeviceRemoved");
161161
});
162162

163-
_sdk.MediaDevice.AudioDeviceChanged = new AudioDeviceChangedEventHandler((AudioDevice device, bool noDevice) =>
163+
_sdk.MediaDevice.AudioDeviceChanged = new AudioDeviceChangedEventHandler((DeviceIdentity id, bool noDevice) =>
164164
{
165-
Log.Debug($"OnDeviceChanged: {device.Name}");
165+
Log.Debug("OnDeviceChanged");
166166
});
167167

168168
UserInfo user = new UserInfo();
@@ -206,9 +206,6 @@ await _sdk.Conference.SetSpatialEnvironmentAsync
206206

207207
await _sdk.Conference.SetSpatialPositionAsync(_sdk.Session.User.Id, new Vector3(0.0f, 0.0f, 0.0f));
208208

209-
210-
await _sdk.Video.Remote.SetVideoSinkAsync(_sink);
211-
212209
await InputLoop();
213210
}
214211
catch (DolbyIOException e)
@@ -261,10 +258,10 @@ private static async Task ListDevices()
261258
try
262259
{
263260
List<AudioDevice> audioDevices = await _sdk.MediaDevice.GetAudioDevicesAsync();
264-
audioDevices.ForEach(d => Console.WriteLine(d.Uid + " : " + d.Name));
261+
audioDevices.ForEach(d => Console.WriteLine(d.Name));
265262

266263
List<VideoDevice> videoDevices = await _sdk.MediaDevice.GetVideoDevicesAsync();
267-
videoDevices.ForEach(d => Console.WriteLine(d.Uid + " : " + d.Name));
264+
videoDevices.ForEach(d => Console.WriteLine(d.Name));
268265

269266
var device = await _sdk.MediaDevice.GetCurrentAudioInputDeviceAsync();
270267
await _sdk.MediaDevice.SetPreferredAudioInputDeviceAsync(device);
@@ -351,12 +348,12 @@ private static void OnActiveSpeakerChange(string conferenceId, int count, string
351348

352349
public class Sink : VideoSink {
353350
public Sink() : base() {}
354-
public override void OnFrame(string streamId, string trackId, VideoFrame frame)
351+
public override void OnFrame(VideoFrame frame)
355352
{
356353
using(frame)
357354
{
358355

359-
Log.Debug($"OnFrame {streamId} {frame.Width}x{frame.Height} : {frame.DangerousGetHandle()}");
356+
Log.Debug($"OnFrame {frame.Width}x{frame.Height} : {frame.DangerousGetHandle()}");
360357
try
361358
{
362359
var buffer = frame.GetBuffer();

src/DolbyIO.Comms.Native/conference.cc

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,27 @@ extern "C" {
7878
}
7979
);
8080
}
81-
81+
82+
EXPORT_API void SetOnConferenceVideoTrackAddedHandler(on_conference_video_track_added::type handler) {
83+
handle<on_conference_video_track_added>(sdk->conference(), handler,
84+
[handler](const on_conference_video_track_added::event& e) {
85+
video_track t;
86+
no_alloc_to_c(&t, e.track);
87+
handler(t);
88+
}
89+
);
90+
}
91+
92+
EXPORT_API void SetOnConferenceVideoTrackRemovedHandler(on_conference_video_track_removed::type handler) {
93+
handle<on_conference_video_track_removed>(sdk->conference(), handler,
94+
[handler](const on_conference_video_track_removed::event& e) {
95+
video_track t;
96+
no_alloc_to_c(&t, e.track);
97+
handler(t);
98+
}
99+
);
100+
}
101+
82102
EXPORT_API int Create(dolbyio::comms::native::conference_options* opts, dolbyio::comms::native::conference* conf) {
83103
return call { [&]() {
84104
auto options = to_cpp<dolbyio::comms::services::conference::conference_options>(opts);

src/DolbyIO.Comms.Native/conference.h

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ namespace dolbyio::comms::native {
5252
* @brief C# ConnectionOptions C struct.
5353
*/
5454
struct connection_options {
55-
// max forwarding
55+
int max_video_forwarding;
5656
char* conference_access_token;
5757
bool spatial_audio;
58+
bool simulcast;
5859
};
5960

6061
/**
@@ -94,6 +95,19 @@ namespace dolbyio::comms::native {
9495
bool audible_locally;
9596
};
9697

98+
/**
99+
* @brief C# Video Track C Struct
100+
*/
101+
struct video_track {
102+
char* peer_id;
103+
char* stream_id;
104+
char* track_id;
105+
char* sdp_track_id;
106+
107+
bool is_screenshare;
108+
bool remote;
109+
};
110+
97111
struct on_conference_status_updated {
98112
using event = dolbyio::comms::conference_status_updated;
99113
using type = void (*)(int status, const char* conferenceId);
@@ -125,7 +139,7 @@ namespace dolbyio::comms::native {
125139
};
126140

127141
struct on_active_speaker_change {
128-
using event = dolbyio::comms::active_speaker_change;
142+
using event = dolbyio::comms::active_speaker_changed;
129143
using type = void (*)(char* conference_id, int count, char* active_speakers[]);
130144
static constexpr const char* name = "on_active_speaker_change";
131145
};
@@ -142,6 +156,18 @@ namespace dolbyio::comms::native {
142156
static constexpr const char* name = "on_conference_invitation_received";
143157
};
144158

159+
struct on_conference_video_track_added {
160+
using event = dolbyio::comms::video_track_added;
161+
using type = void (*)(video_track track);
162+
static constexpr const char* name = "on_conference_video_track_added";
163+
};
164+
165+
struct on_conference_video_track_removed {
166+
using event = dolbyio::comms::video_track_removed;
167+
using type = void (*)(video_track track);
168+
static constexpr const char* name = "on_conference_video_track_removed";
169+
};
170+
145171
template<typename Traits>
146172
struct translator<dolbyio::comms::native::conference_options, dolbyio::comms::services::conference::conference_options, Traits> {
147173
static void to_c(typename Traits::c_type* dest, const typename Traits::cpp_type& src) {
@@ -190,13 +216,17 @@ namespace dolbyio::comms::native {
190216
template<typename Traits>
191217
struct translator<dolbyio::comms::native::connection_options, dolbyio::comms::services::conference::connection_options, Traits> {
192218
static void to_c(typename Traits::c_type* dest, const typename Traits::cpp_type& src) {
219+
dest->max_video_forwarding = src.max_video_forwarding.value_or(25);
193220
dest->conference_access_token = strdup(src.conference_access_token.value_or(""));
194221
dest->spatial_audio = src.spatial_audio;
222+
dest->simulcast = src.simulcast;
195223
}
196224

197225
static void to_cpp(typename Traits::cpp_type& dest, typename Traits::c_type* src) {
226+
dest.max_video_forwarding = src->max_video_forwarding;
198227
dest.conference_access_token = src->conference_access_token;
199228
dest.spatial_audio = src->spatial_audio;
229+
dest.simulcast = src->simulcast;
200230
}
201231
};
202232

@@ -268,6 +298,29 @@ namespace dolbyio::comms::native {
268298
}
269299
};
270300

301+
template<typename Traits>
302+
struct translator<dolbyio::comms::native::video_track, dolbyio::comms::video_track, Traits> {
303+
static void to_c(typename Traits::c_type* dest, const typename Traits::cpp_type& src) {
304+
dest->peer_id = strdup(src.peer_id);
305+
dest->stream_id = strdup(src.stream_id);
306+
dest->track_id = strdup(src.track_id);
307+
dest->sdp_track_id = strdup(src.sdp_track_id);
308+
309+
dest->is_screenshare = src.is_screenshare;
310+
dest->remote = src.remote;
311+
}
312+
313+
static void to_cpp(typename Traits::cpp_type& dest, typename Traits::c_type* src) {
314+
dest.peer_id = std::string(src->peer_id);
315+
dest.stream_id = std::string(src->stream_id);
316+
dest.track_id = std::string(src->track_id);
317+
dest.sdp_track_id = std::string(src->sdp_track_id);
318+
319+
dest.is_screenshare = src->is_screenshare;
320+
dest.remote = src->remote;
321+
}
322+
};
323+
271324
} // namespace dolbyio::comms::native
272325

273326
#endif // _CONFERENCE_H_

0 commit comments

Comments
 (0)