From 581908bdb72433cd7c436839692bd15b58f34016 Mon Sep 17 00:00:00 2001 From: kbetl-dlb <107930816+kbetl-dlb@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:03:12 +0200 Subject: [PATCH] Feature/listen type enum (#286) * Add ListenType enum for RN and android. Extend ConferenceListenOption for RN to use ListenType enum * Add documentation for listen type * Add missing stream mapping on RN Participant model when get current conference and getParticipant methods was called --- .../mapper/ConferenceListenOptionsMapper.kt | 2 ++ .../reactnative/mapper/ListenTypeMapper.kt | 20 +++++++++++++ docs/enums/internal.ListenType.md | 28 +++++++++++++++++++ .../internal.ConferenceListenOptions.md | 9 ++++++ docs/modules/internal.md | 1 + .../DolbyIOProvider/DolbyIOProvider.tsx | 9 ++++-- .../conference/__tests__/index.test.ts | 2 ++ src/services/conference/models.ts | 12 ++++++++ src/services/conference/transformers.ts | 3 +- 9 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 android/src/main/java/io/dolby/sdk/comms/reactnative/mapper/ListenTypeMapper.kt create mode 100644 docs/enums/internal.ListenType.md diff --git a/android/src/main/java/io/dolby/sdk/comms/reactnative/mapper/ConferenceListenOptionsMapper.kt b/android/src/main/java/io/dolby/sdk/comms/reactnative/mapper/ConferenceListenOptionsMapper.kt index 7631965f..776f9673 100644 --- a/android/src/main/java/io/dolby/sdk/comms/reactnative/mapper/ConferenceListenOptionsMapper.kt +++ b/android/src/main/java/io/dolby/sdk/comms/reactnative/mapper/ConferenceListenOptionsMapper.kt @@ -30,6 +30,7 @@ class ConferenceListenOptionsMapper { it.getOptionalInt(CONFERENCE_LISTEN_OPTIONS_MAX_VIDEO_FORWARDING) ?.let(::setMaxVideoForwarding) it.getOptionalBoolean(CONFERENCE_LISTEN_OPTIONS_SPATIAL_AUDIO)?.let(::setSpatialAudio) + it.getString(CONFERENCE_LISTEN_OPTIONS_LISTEN_TYPE)?.let(ListenTypeMapper::convertToModel)?.let(::setListenType) } } .build() @@ -45,5 +46,6 @@ class ConferenceListenOptionsMapper { private const val CONFERENCE_LISTEN_OPTIONS_ACCESS_TOKEN = "conferenceAccessToken" private const val CONFERENCE_LISTEN_OPTIONS_MAX_VIDEO_FORWARDING = "maxVideoForwarding" private const val CONFERENCE_LISTEN_OPTIONS_VIDEO_FORWARDING_STRATEGY = "videoForwardingStrategy" + private const val CONFERENCE_LISTEN_OPTIONS_LISTEN_TYPE = "listenType" } } diff --git a/android/src/main/java/io/dolby/sdk/comms/reactnative/mapper/ListenTypeMapper.kt b/android/src/main/java/io/dolby/sdk/comms/reactnative/mapper/ListenTypeMapper.kt new file mode 100644 index 00000000..281df2fa --- /dev/null +++ b/android/src/main/java/io/dolby/sdk/comms/reactnative/mapper/ListenTypeMapper.kt @@ -0,0 +1,20 @@ +package io.dolby.sdk.comms.reactnative.mapper + +import com.voxeet.sdk.models.ListenType +import java.security.InvalidParameterException + +object ListenTypeMapper { + fun convertToRN(listenType: ListenType) = when(listenType) { + ListenType.REGULAR -> "REGULAR" + ListenType.MIXED -> "MIXED" + } + + fun convertToModel(listenRNType: String) = when(listenRNType) { + REGULAR -> ListenType.REGULAR + MIXED -> ListenType.MIXED + else -> throw InvalidParameterException("Invalid value for listen type") + } + + private const val REGULAR = "REGULAR" + private const val MIXED = "MIXED" +} diff --git a/docs/enums/internal.ListenType.md b/docs/enums/internal.ListenType.md new file mode 100644 index 00000000..688c4dd8 --- /dev/null +++ b/docs/enums/internal.ListenType.md @@ -0,0 +1,28 @@ +# Enumeration: ListenType + +[internal](../modules/internal.md).ListenType + +The ListenType model gathers the possible types of listeners. This model is available in SDK 3.11 and later. + +## Table of contents + +### Enumeration Members + +- [REGULAR](internal.ListenType.md#regular) +- [MIXED](internal.ListenType.md#mixed) + +## Enumeration Members + +### REGULAR + +• **REGULAR** = ``"REGULAR"`` + +A regular listener who receives one mixed audio stream from a conference and one video stream from each participant who sends video to a conference. + +___ + +### MIXED + +• **MIXED** = ``"MIXED"`` + +A participant who receives one mixed audio stream and one mixed video stream from a conference, which increases the conference capacity. The platform can support up to 60,000 mixed listeners while maintaining under half a second of latency. diff --git a/docs/interfaces/internal.ConferenceListenOptions.md b/docs/interfaces/internal.ConferenceListenOptions.md index b76db472..2b22b5e7 100644 --- a/docs/interfaces/internal.ConferenceListenOptions.md +++ b/docs/interfaces/internal.ConferenceListenOptions.md @@ -12,6 +12,7 @@ The ConferenceListenOptions interface defines how the application expects to joi - [maxVideoForwarding](internal.ConferenceListenOptions.md#maxvideoforwarding) - [spatialAudio](internal.ConferenceListenOptions.md#spatialaudio) - [videoForwardingStrategy](internal.ConferenceListenOptions.md#videoforwardingstrategy) +- [listenType](internal.ConferenceListenOptions.md#listentype) ## Properties @@ -51,3 +52,11 @@ ___ • `Optional` **videoForwardingStrategy**: [`VideoForwardingStrategy`](../enums/internal.VideoForwardingStrategy.md) Changes the video forwarding strategy for the local participant. This option is available only in SDK 3.6 and later. + +___ + +### listenType + +• `Optional` **listenType**: [`ListenType`](../enums/internal.ListenType.md) + +the listener type that indicates whether a participant wishes to join a conference as a regular listener or a mixed listener. This property is available in SDK 3.11 and later. diff --git a/docs/modules/internal.md b/docs/modules/internal.md index 9c766aae..181e6781 100644 --- a/docs/modules/internal.md +++ b/docs/modules/internal.md @@ -82,6 +82,7 @@ - [MediaStreamType](../enums/internal.MediaStreamType.md) - [SpatialAudioStyle](../enums/internal.SpatialAudioStyle.md) - [VideoForwardingStrategy](../enums/internal.VideoForwardingStrategy.md) +- [ListenType](../enums/internal.ListenType.md) - [RecordingStatus](../enums/internal.RecordingStatus.md) - [VideoPresentationState](../enums/internal.VideoPresentationState.md) diff --git a/example/src/components/DolbyIOProvider/DolbyIOProvider.tsx b/example/src/components/DolbyIOProvider/DolbyIOProvider.tsx index 3d71486c..9a46a04b 100644 --- a/example/src/components/DolbyIOProvider/DolbyIOProvider.tsx +++ b/example/src/components/DolbyIOProvider/DolbyIOProvider.tsx @@ -18,9 +18,11 @@ import type { UnsubscribeFunction, ConferenceCreateParameters, ConferenceServiceEventNames, + ConferenceListenOptions, } from '@dolbyio/comms-sdk-react-native/models'; import { Codec, + ListenType, RTCPMode, SpatialAudioStyle, SubscriptionType @@ -42,7 +44,7 @@ export interface IDolbyIOProvider { closeSession: () => Promise; isOpen: () => Promise; createAndJoin: (alias: string, params: ConferenceCreateParameters) => void; - listen: (alias: string) => void; + listen: (alias: string, listenType?: ListenType) => void; joinWithId: (conferenceId: string) => void; replay: () => void; getCurrentConference: () => void; @@ -262,7 +264,7 @@ const DolbyIOProvider: React.FC = ({ children }) => { } }; - const listen = async (alias: string) => { + const listen = async (alias: string, listenType: ListenType = ListenType.REGULAR) => { try { const conferenceParams = { rtcpMode: RTCPMode.AVERAGE, @@ -279,9 +281,10 @@ const DolbyIOProvider: React.FC = ({ children }) => { conferenceOptions ); - const listenOptions = { + const listenOptions: ConferenceListenOptions = { maxVideoForwarding: 4, spatialAudio: false, + listenType: listenType }; const joinedConference = await CommsAPI.conference.listen( createdConference, diff --git a/src/services/conference/__tests__/index.test.ts b/src/services/conference/__tests__/index.test.ts index 56eaff25..7bfa81ad 100644 --- a/src/services/conference/__tests__/index.test.ts +++ b/src/services/conference/__tests__/index.test.ts @@ -465,6 +465,7 @@ describe('ConferenceService - transformers', () => { id: '111', status: undefined, type: undefined, + streams: undefined, }, ], alias: 'Conference', @@ -492,6 +493,7 @@ describe('ConferenceService - transformers', () => { id: '111', status: undefined, type: undefined, + streams: undefined, }); }); }); diff --git a/src/services/conference/models.ts b/src/services/conference/models.ts index 09e618ff..eb20b44d 100644 --- a/src/services/conference/models.ts +++ b/src/services/conference/models.ts @@ -141,6 +141,8 @@ export interface ConferenceListenOptions { spatialAudio?: boolean; /** Changes the video forwarding strategy for the local participant. This option is available only in SDK 3.6 and later. */ videoForwardingStrategy?: VideoForwardingStrategy; + /** the listener type that indicates whether a participant wishes to join a conference as a regular listener or a mixed listener. This property is available in SDK 3.11 and later. */ + listenType?: ListenType; } /** The ConferenceReplayOptions interface gathers properties responsible for replaying conferences. */ @@ -498,3 +500,13 @@ export interface VideoForwardingOptions { /** The strategy that defines how the SDK should select conference participants whose videos will be transmitted to the local participant. The selection can be either based on the participants' audio volume or the distance from the local participant. */ strategy?: VideoForwardingStrategy; } + +/** + * The ListenType model gathers the possible types of listeners. This model is available in SDK 3.11 and later. + */ +export enum ListenType { + /** A regular listener who receives one mixed audio stream from a conference and one video stream from each participant who sends video to a conference. */ + REGULAR = 'REGULAR', + /** A participant who receives one mixed audio stream and one mixed video stream from a conference, which increases the conference capacity. The platform can support up to 60,000 mixed listeners while maintaining under half a second of latency. */ + MIXED = 'MIXED', +} diff --git a/src/services/conference/transformers.ts b/src/services/conference/transformers.ts index 4b9e61a0..53b62687 100644 --- a/src/services/conference/transformers.ts +++ b/src/services/conference/transformers.ts @@ -13,11 +13,12 @@ export const transformToConference = (c: Conference) => { }; export const transformToParticipant = (p: Participant) => { - const { id, info, status, type } = p; + const { id, info, status, type, streams } = p; return { id, info, status, type, + streams: streams, }; };