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

Commit

Permalink
Feature/listen type enum (#286)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
kbetl-dlb authored Sep 6, 2023
1 parent b332623 commit 581908b
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
28 changes: 28 additions & 0 deletions docs/enums/internal.ListenType.md
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 9 additions & 0 deletions docs/interfaces/internal.ConferenceListenOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
1 change: 1 addition & 0 deletions docs/modules/internal.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 6 additions & 3 deletions example/src/components/DolbyIOProvider/DolbyIOProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ import type {
UnsubscribeFunction,
ConferenceCreateParameters,
ConferenceServiceEventNames,
ConferenceListenOptions,
} from '@dolbyio/comms-sdk-react-native/models';
import {
Codec,
ListenType,
RTCPMode,
SpatialAudioStyle,
SubscriptionType
Expand All @@ -42,7 +44,7 @@ export interface IDolbyIOProvider {
closeSession: () => Promise<void>;
isOpen: () => Promise<boolean>;
createAndJoin: (alias: string, params: ConferenceCreateParameters) => void;
listen: (alias: string) => void;
listen: (alias: string, listenType?: ListenType) => void;
joinWithId: (conferenceId: string) => void;
replay: () => void;
getCurrentConference: () => void;
Expand Down Expand Up @@ -262,7 +264,7 @@ const DolbyIOProvider: React.FC<DolbyProps> = ({ children }) => {
}
};

const listen = async (alias: string) => {
const listen = async (alias: string, listenType: ListenType = ListenType.REGULAR) => {
try {
const conferenceParams = {
rtcpMode: RTCPMode.AVERAGE,
Expand All @@ -279,9 +281,10 @@ const DolbyIOProvider: React.FC<DolbyProps> = ({ children }) => {
conferenceOptions
);

const listenOptions = {
const listenOptions: ConferenceListenOptions = {
maxVideoForwarding: 4,
spatialAudio: false,
listenType: listenType
};
const joinedConference = await CommsAPI.conference.listen(
createdConference,
Expand Down
2 changes: 2 additions & 0 deletions src/services/conference/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ describe('ConferenceService - transformers', () => {
id: '111',
status: undefined,
type: undefined,
streams: undefined,
},
],
alias: 'Conference',
Expand Down Expand Up @@ -492,6 +493,7 @@ describe('ConferenceService - transformers', () => {
id: '111',
status: undefined,
type: undefined,
streams: undefined,
});
});
});
Expand Down
12 changes: 12 additions & 0 deletions src/services/conference/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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',
}
3 changes: 2 additions & 1 deletion src/services/conference/transformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
};

0 comments on commit 581908b

Please sign in to comment.