Skip to content

Commit

Permalink
Merge dev into main for release (#220)
Browse files Browse the repository at this point in the history
* Correction to docs for automatic archiving

* Fixes NullReferenceException in CreateSession (#114)

* Better handle WebExceptions that don't have a Response and send a customized exception on WebExceptionStatus.SendFailure errors (usually from TLS errors).
Fixes #108.

* Adding extra instructions regarding TLS to readme, adding new exception handling if TLS is incorrect

* removing erroneously added whitespace

* list archive by session id, better exception handling for validateSessionid

* removing extra whitespace from tests

* cleaning up other whitespace issues

* passing inner exception to OpenTokException

* Fixing comments, removing redundant fields

* adding custom layout for archiving

* fixing spacing issue, adding javadocs to StartArchive for layout

* revving to 3.4

* adding extra Archive Test

* Adding non-custom with stylesheet case

* adding contract annotations to ArchiveLayout to prevent invalid serialization of the stylesheet for non-custom layouts

* bringing balance to the force

* Dropping core 3.0 tests

* moving back to newer container

* removing .net core 2.x runs

* Silenced warnings in the test project.

* empty Statement Redundancy Fix

* Spell Fix

* Spell Fix

* Spell Fix | GetPartnerIdFromSessionId

Spell Fix | GetPartnerIdFromSessionId method's Property

* moving dotnet version

* specifying test framework

* Changed Javadoc comments to XML comments.

* Replace <see href with <a href.

* Added additional comments.

* Revving to 3.5.0

* automatic release on new GitHub release

* adding OUTPUT_PATH

* fixing Windows CI issue

* updating nexmo/github-actions branch to main

* screenshare layout

* more tests

* Adding SetArchiveLayout, updating unit tests

* moving null ignore to data structure

* fixing error message

* fixing screenshareType

* revving to 3.6.0

* Removing travis config

* Removing travis, fixing GitHub Actions definitions and adding package settings in project file (#164)

* Docs corrections (#161)

Co-authored-by: Stephen Lorello <42971704+slorello89@users.noreply.github.com>
Co-authored-by: slorello89 <slorello89@gmail.com>
Co-authored-by: Dirk Lemstra <dirk@lemstra.org>
Co-authored-by: onpoc <gupta.pradeep506@gmail.com>
Co-authored-by: Matt Hunt <mattlethargic@gmail.com>
Co-authored-by: Jeff Swartz <jeff.swartz@vonage.com>

* Implementing Dial method for initiating a SIP call (#166)

* Adding Dial method, test fails

* Adding dial async and tests

* Adding session validation

* Removing key from appsettings

* Adding valid session id to tests

* Docs edits for Dial API

... and other minor docs corrections

Co-authored-by: Jeff Swartz <jeff.swartz@vonage.com>

* Rev the version to 3.7.0

* Adding Force and Disable Mute (#167)

* Adding Force and Disable Mute

* Docs edits for the Force Mute API enhancements

* Fixing PlayDTMF methods that had wrong URL

Co-authored-by: Jeff Swartz <jeff.swartz@vonage.com>
Co-authored-by: matt-lethargic <matt-lethargic@gmail.com>

* Docs edits for v3.7.0 (#169)

* Changing version number (#170)

* Docs corrections

* Selective adding of streams for archive and broadcast (#174)

* Selective adding of streams for archive and broadcast

* Minor docs edits for StreamMode additions

* bumping version to 3.8.0

* Another version bump

Co-authored-by: Jeff Swartz <jeff.swartz@vonage.com>

* Devx 5778 (#179)

* Moving tests

* refactoring test base

* CreateSession async

* Start Archive Async

* Fixing dial issue

* Removing duplicate version tags in proj file and updating README with Async methods

Co-authored-by: matt-lethargic <matt-lethargic@gmail.com>

* Minor docs typo correction (#181)

* Adding GetArchive and DeleteArchive async methods (#182)

* Adding GetArchive and DeleteArchive async methods

* Adding readme info and adding methods to Archieve object

* DVR and LowLatency changes added (#183)

* DVR and LowLatency changes added

* Update OpenTok/OpenTok.cs

Co-authored-by: Jeff Swartz <jeff.swartz@vonage.com>

* Fixing comments for PR

* Adding Broadcast settings summary

* Docs edits

 for BroadcastHlsSettings and related content.

Co-authored-by: Jeff Swartz <jeff.swartz@vonage.com>

* Devx 5971 - StopArchive and ListArchive Async Methods (#184)

* Adding Stop Archive and ListArchive async methods

* Minor docs edit

Co-authored-by: Jeff Swartz <jeff.swartz@vonage.com>

* Adding StopBroadcast and GetBroadcast methods (#186)

* Adding GetStream and ListStreams async methods (#187)

* Adding SetBroadcastLayout and SetArchiveLayout async methods (#188)

* Adding SetBroadcastLayout and SetArchiveLayout async methods

* Minor docs edit

* Fixing merge conflict issues

Co-authored-by: Jeff Swartz <jeff.swartz@vonage.com>
Co-authored-by: matt-lethargic <matt-lethargic@gmail.com>

* Fixing some merge issues

* Devx 5946 (#191)

* added SetStreamListsAsync

* SignalAsync methods added

* Adding StartBroadcast async methods
Refactoring tests

* Devx 5915 - Update .NET Server SDK for 1080p Archive/Broadcast (#207)

* Add all available resolutions for archiving in README.md

* Add all available resolutions on XML documentation for Broadcast.cs

* Add all available resolutions on Broadcasting sample app

* Upgrade System.Net.Http to 4.3.2 as suggested by Whitesource

* Upgrade System.Net.Http to 4.3.4 as suggested by Whitesource

* Initialize publisherOptions for HelloWorld sample (#209)

* DEVX-6497 - Add Experience Composer to the OpenTok .NET Server SDK (#210)

* Create object and implement parsing for StartRender operation

* Fix wrong allowed resolution

* Implement request creation with various values, including optional ones

* Fix warning for http (test value)

* Kill last mutants for threshold values

* Implement POST call to start a rendering

* Make StartRenderResponse immutable

* Implement StopRenderAsync

* Implement ListRendersRequest parsing

* Kill mutants for http headers

* Fix type in ListRenders

* Implement ListRendersAsync

* Implement GetRenderAsync

* Kill mutants on StartRenderRequest, make all responses as struct for value equality

* Fix request formatting issue - last test round

* Add missing Xml comments

* Amend TODO comments

* Experience Composer Render API docs edits

* Make ScreenResolutionConverter private

* Rename ScreenResolution into RenderResolution

* Remove StatusCallbackUrl

* Make StreamName optional, expect a PublisherProperties when creating a StartRenderRequest

Co-authored-by: Jeff Swartz <jeff.swartz@vonage.com>

* Devx 6491 - Update.NET Server SDK for Multiple Archives and Records (#208)

* Add multiArchiveTag on Archive.cs

* Fix wrong assertion in ArchiveTests.cs

* Add multiBroadcastTag on Broadcast.cs

* Add missing Xml documentation for new parameters

* Upgrade System.Net.Http to 4.3.4 as suggested by Whitesource

* Docs edits for simultaneous archive/broadcast features

* Fix conflict with MultiBroadcastTag

Co-authored-by: Jeff Swartz <jeff.swartz@vonage.com>

* Rev version to 3.9.0 (#212)

* DEVX-5909 - Add Audio Streamer to OpenTok .Net SDK  (#211)

* Implement ConnectRequest parsing

* Implement StopAudioStreamer

* Renaming elements for AudioConnector, fix xml documentations, flatten namespaces

Rename AudioStreamer by AudioConnector
Rename ConnectRequest by AudioConnectorStartRequest
Rename ConnectResponse by AudioConnector

* Update README with AudioConnector snippet

* Fix merge conflicts

* README edits

* Minor docs edit

---------

Co-authored-by: Jeff Swartz <jeff.swartz@vonage.com>

---------

Co-authored-by: Jeff Swartz <jeff.swartz@vonage.com>
Co-authored-by: Paul Ardeleanu <paul.ardeleanu@vonage.com>
Co-authored-by: Patrick Childers <patrick@aliihealthcare.com>
Co-authored-by: Stephen Lorello <42971704+slorello89@users.noreply.github.com>
Co-authored-by: slorello89 <slorello89@gmail.com>
Co-authored-by: Dirk Lemstra <dirk@lemstra.org>
Co-authored-by: onpoc <gupta.pradeep506@gmail.com>
Co-authored-by: Matt Hunt <mattlethargic@gmail.com>
Co-authored-by: matt-lethargic <matt-lethargic@gmail.com>
  • Loading branch information
10 people authored Mar 9, 2023
1 parent 36c7b5e commit c0b97d0
Show file tree
Hide file tree
Showing 8 changed files with 540 additions and 16 deletions.
20 changes: 20 additions & 0 deletions OpenTok/AudioConnector.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace OpenTokSDK
{
/// <summary>
/// Represents an Audio Connector.
/// </summary>
public struct AudioConnector
{
/// <summary>
/// The OpenTok connection ID for the Audio Connector WebSocket connection in the OpenTok session.
/// </summary>
public string ConnectionId { get; set; }

/// <summary>
/// A unique ID identifying the Audio Connector WebSocket connection.
/// </summary>
public string Id { get; set; }


}
}
148 changes: 148 additions & 0 deletions OpenTok/AudioConnectorStartRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
using System;
using System.Collections.Generic;
using OpenTokSDK.Exception;

namespace OpenTokSDK
{
/// <summary>
/// Represents a request to send audio from a Vonage Video API session to a WebSocket.
/// </summary>
public class AudioConnectorStartRequest
{
private const int MinimumUrlLength = 15;
private const int MaximumUrlLength = 2048;

/// <summary>
/// Indicates SessionId needs to be provided.
/// </summary>
public const string MissingSessionId = "SessionId needs to be provided.";

/// <summary>
/// Indicates Token needs to be provided.
/// </summary>
public const string MissingToken = "Token needs to be provided.";

/// <summary>
/// Indicates Url length should be between 15 and 2048.
/// </summary>
public const string InvalidUrl = "Url length should be between 15 and 2048.";

/// <summary>
/// Creates a new instance of ConnectRequest.
/// </summary>
/// <param name="sessionId"> The OpenTok session ID that includes the OpenTok streams you want to include in the WebSocket stream.
/// </param>
/// <param name="token">
/// The OpenTok token to be used for the Audio Connector connection to the OpenTok session.
/// You can add token data to identify that the connection is the Audio Connector endpoint or for other identifying data.
/// (The OpenTok client libraries include properties for inspecting the connection data for a client connected to a session.)
/// See the <a href="https://tokbox.com/developer/guides/create-token/">Token Creation developer guide</a>.
/// </param>
/// <param name="socket">Options for configuring the connect call for WebSocket.</param>
public AudioConnectorStartRequest(string sessionId, string token, WebSocket socket)
{
ValidateSessionId(sessionId);
ValidateToken(token);
this.SessionId = sessionId;
this.Token = token;
this.Socket = socket;
}

/// <summary>
/// The ID of a session (generated with the same `APIKEY` as specified in the URL) where the streams will be gathered
/// from.
/// </summary>
public string SessionId { get; }

/// <summary>
/// A valid OpenTok token with a Subscriber role.
/// </summary>
public string Token { get; }

/// <summary>
/// Options for configuring the connect call for WebSocket.
/// </summary>
public WebSocket Socket { get; }

private static void ValidateSessionId(string sessionId)
{
if (string.IsNullOrWhiteSpace(sessionId))
{
throw new OpenTokException(MissingSessionId);
}
}

private static void ValidateToken(string token)
{
if (string.IsNullOrWhiteSpace(token))
{
throw new OpenTokException(MissingToken);
}
}

/// <summary>
/// Options for configuring the connect call for WebSocket.
/// </summary>
public class WebSocket
{
/// <summary>
/// Creates a new instance of WebSocket.
/// </summary>
/// <param name="uri">
/// A publicly reachable WebSocket URI controlled by the customer for the destination of the connect
/// call. (f.e. wss://service.com/wsendpoint)".
/// </param>
/// <param name="streams">
/// An array of stream IDs for the OpenTok streams you want to include in the WebSocket stream. If you omit this property, all streams in the session will be included.
/// </param>
/// <param name="headers">
/// An object of key-value pairs of headers to be sent to your WebSocket server with each message, with a maximum length of 512 bytes.
/// </param>
public WebSocket(Uri uri, string[] streams = null, Dictionary<string, string> headers = null)
{
ValidateUri(uri);
this.Uri = uri;
this.Streams = streams ?? new string[0];
this.Headers = headers ?? new Dictionary<string, string>();
}

/// <summary>
/// A publicly reachable WebSocket URI controlled by the customer for the destination of the connect call. (f.e.
/// wss://service.com/wsendpoint)"
/// </summary>
public Uri Uri { get; }

/// <summary>
/// The stream IDs of the participants' whose audio is going to be connected. If not provided, all streams in session
/// will be selected.
/// </summary>
public string[] Streams { get; }

/// <summary>
/// An object of key/val pairs with additional properties to send to your Websocket server, with a maximum length of
/// 512 bytes.
/// </summary>
public Dictionary<string, string> Headers { get; }

private static void ValidateUri(Uri url)
{
if (url.AbsoluteUri.Length < MinimumUrlLength || url.AbsoluteUri.Length > MaximumUrlLength)
{
throw new OpenTokException(InvalidUrl);
}
}
}

/// <summary>
/// Converts request to dictionary.
/// </summary>
/// <returns>Dictionary containing instance values.</returns>
public Dictionary<string, object> ToDataDictionary() =>
new Dictionary<string, object>
{
{"sessionId", this.SessionId},
{"token", this.Token},
{"webSocket", this.Socket},
};
}
}
33 changes: 33 additions & 0 deletions OpenTok/OpenTok.AudioConnector.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace OpenTokSDK
{
public partial class OpenTok
{
/// <summary>
/// Sends audio from a Vonage Video API session to a WebSocket. For more information, see the <a href="https://tokbox.com/developer/guides/audio-connector/">Audio Connector developer guide</a>.
/// </summary>
/// <param name="request">The request to start the audio connector.</param>
/// <returns>The response object from the server.</returns>
public async Task<AudioConnector> StartAudioConnectorAsync(AudioConnectorStartRequest request)
{
var response = await this.Client.PostAsync(
$"v2/project/{this.ApiKey}/connect",
GetHeaderDictionary("application/json"),
request.ToDataDictionary());
return JsonConvert.DeserializeObject<AudioConnector>(response);
}

/// <summary>
/// Stops sending audio for a Vonage Video API session.
/// </summary>
/// <param name="connectionId">The OpenTok connection ID for the Audio Connector WebSocket connection in the OpenTok session. See <see cref="AudioConnector.ConnectionId"/>.</param>
public async Task StopAudioConnectorAsync(string connectionId) =>
_ = await this.Client.PostAsync(
$"v2/project/{this.ApiKey}/connect/{connectionId}/stop",
new Dictionary<string, string>(),
new Dictionary<string, object>());
}
}
26 changes: 13 additions & 13 deletions OpenTok/OpenTok.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net452;net46;net461;netstandard2.0</TargetFrameworks>
Expand All @@ -24,30 +24,30 @@
<LangVersion>8</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net452|AnyCPU'">
<DocumentationFile/>
<DocumentationFile />
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net452'">
<PackageReference Include="JWT" Version="2.3.2"/>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3"/>
<PackageReference Include="JWT" Version="2.3.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net46'">
<PackageReference Include="JWT" Version="2.3.2"/>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3"/>
<PackageReference Include="JWT" Version="2.3.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="JWT" Version="7.2.1"/>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3"/>
<PackageReference Include="JWT" Version="7.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461'">
<PackageReference Include="JWT" Version="7.2.1"/>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3"/>
<PackageReference Include="JWT" Version="7.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' != 'netstandard2.0' ">
<Reference Include="System.Web"/>
<Reference Include="System.Web" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Enums.NET" Version="4.0.0"/>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
<PackageReference Include="Enums.NET" Version="4.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
Expand Down
69 changes: 69 additions & 0 deletions OpenTokTest/AudioConnectorStartRequestDataBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using AutoFixture;
using OpenTokSDK;

namespace OpenTokSDKTest
{
public class AudioConnectorStartRequestDataBuilder
{
private Dictionary<string, string> headers;
private string sessionId;
private List<string> streams;
private string token;
private Uri uri;

private AudioConnectorStartRequestDataBuilder()
{
var fixture = new Fixture();
this.sessionId = fixture.Create<string>();
this.token = fixture.Create<string>();
this.uri = fixture.Create<Uri>();
}

public static AudioConnectorStartRequestDataBuilder Build() => new AudioConnectorStartRequestDataBuilder();

public AudioConnectorStartRequestDataBuilder WithSessionId(string value)
{
this.sessionId = value;
return this;
}

public AudioConnectorStartRequestDataBuilder WithToken(string value)
{
this.token = value;
return this;
}

public AudioConnectorStartRequestDataBuilder WithUri(Uri value)
{
this.uri = value;
return this;
}

public AudioConnectorStartRequestDataBuilder WithStream(string value)
{
if (this.streams is null)
{
this.streams = new List<string>();
}

this.streams.Add(value);
return this;
}

public AudioConnectorStartRequestDataBuilder WithHeader(string key, string value)
{
if (this.headers is null)
{
this.headers = new Dictionary<string, string>();
}

this.headers.Add(key, value);
return this;
}

public AudioConnectorStartRequest Create() =>
new AudioConnectorStartRequest(this.sessionId, this.token, new AudioConnectorStartRequest.WebSocket(this.uri, this.streams?.ToArray(), this.headers));
}
}
Loading

0 comments on commit c0b97d0

Please sign in to comment.