-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Huddly.Sdk" Version="2.3.1" /> | ||
<PackageReference Include="Huddly.Sdk.Extensions" Version="2.3.1" /> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using Huddly.Device.Model; | ||
using Huddly.Sdk; | ||
using Huddly.Sdk.Devices; | ||
using Huddly.Sdk.Models; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Crew | ||
{ | ||
internal class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
var cts = new CancellationTokenSource(); | ||
var services = new ServiceCollection(); | ||
services.AddLogging(configure => configure.AddConsole().SetMinimumLevel(LogLevel.Debug)); | ||
|
||
services.AddHuddlySdk(configure => | ||
{ | ||
configure.UseUsbDeviceMonitor(); | ||
configure.UseIpDeviceMonitor(); | ||
}); | ||
|
||
var sp = services.BuildServiceProvider(); | ||
|
||
// Should always be disposed after use | ||
using var huddlySdk = sp.GetRequiredService<ISdk>(); | ||
|
||
IDevice? lastDevice = null; | ||
huddlySdk.DeviceConnected += async (o, e) => | ||
{ | ||
if (!(e.Device is { Model: DeviceModel.Crew } and IMultiCameraDevice)) | ||
{ | ||
Console.WriteLine($"Device {e.Device.Model} is not a Crew-device"); | ||
return; | ||
} | ||
|
||
// Crew devices support most normal IDevice methods as seen in the other samples. | ||
// In addition, it has an API that is unique for only multicamera devices, which is demonstrated here | ||
|
||
lastDevice = e.Device; | ||
|
||
IMultiCameraDevice crewDevice = (IMultiCameraDevice)e.Device; | ||
Result<IList<CameraStatus>> connectedCamerasResult = await crewDevice.GetConnectedCameras(); | ||
if (!connectedCamerasResult.IsSuccess) | ||
{ | ||
Console.WriteLine($"Failed getting connected cameras: {connectedCamerasResult.Message}"); | ||
return; | ||
} | ||
IList<CameraStatus> crewCameraStatuses = connectedCamerasResult.Value; | ||
Console.WriteLine($"Crew system with the following cameras connected:"); | ||
foreach (CameraStatus cameraStatus in crewCameraStatuses) | ||
{ | ||
Console.WriteLine($"\tSerial: {cameraStatus.Serial}, Type: {cameraStatus.Type}, Availability: {cameraStatus.Availability}"); | ||
} | ||
}; | ||
huddlySdk.DeviceDisconnected += (o, e) => | ||
{ | ||
Console.WriteLine($"Device {e.Device.Id} disconnected"); | ||
if (e.Device.Id == lastDevice?.Id) | ||
{ | ||
lastDevice = null; | ||
} | ||
}; | ||
|
||
huddlySdk.StartMonitoring(); | ||
Console.ReadKey(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters