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

Commit

Permalink
Add ListenType enum (#293)
Browse files Browse the repository at this point in the history
Also adding ui for joining as a streaming listener
  • Loading branch information
graduad authored Sep 12, 2023
1 parent c593cb0 commit 6bc2ecd
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 7 deletions.
20 changes: 15 additions & 5 deletions example/src/screens/JoinScreen/JoinScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Space from '@ui/Space';
import Text from '@ui/Text';

import styles from './JoinScreen.style';
import { SpatialAudioStyle } from '@dolbyio/comms-sdk-react-native/models';
import { ListenType, SpatialAudioStyle } from '@dolbyio/comms-sdk-react-native/models';
import { View } from 'react-native';
import { MenuOptionsButton, type Options } from '@ui/MenuOptionsButton/MenuOptionsButton';
import ExtendedOptions from '@ui/ExtendedOptions';
Expand All @@ -36,8 +36,12 @@ const JoinScreen: FunctionComponent = () => {
await createAndJoin(alias, { dolbyVoice: isDolbyVoice, liveRecording: isLiveRecording, spatialAudioStyle: spatialAudioStyle });
}

const listenConference = () => {
listen(alias);
const joinAsRegularListener = () => {
listen(alias, ListenType.REGULAR);
};

const joinAsStreamingListener = () => {
listen(alias, ListenType.MIXED);
};

const replayLastConference = () => {
Expand Down Expand Up @@ -133,8 +137,14 @@ const JoinScreen: FunctionComponent = () => {
</Space>
<Space mt="m">
<Button
text="Join as listener"
onPress={listenConference}
text="Join as regular listener"
onPress={joinAsRegularListener}
/>
</Space>
<Space mt="m">
<Button
text="Join as streaming listener"
onPress={joinAsStreamingListener}
/>
</Space>
<Space mt="m">
Expand Down
34 changes: 34 additions & 0 deletions ios/Services/Models/ListenTypeExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import Foundation
import VoxeetSDK

// MARK: - ReactModelValueMappable
extension ListenType: ReactModelValueMappable {

typealias ReactModelValueType = String?

static func create(with value: String?) -> ListenType? {
guard let value = value else {
return nil
}
switch value {
case "MIXED":
return .mixed
case "REGULAR":
return .regular
default:
return nil
}
}

func toReactModelValue() -> ReactModelValueType {
switch self {
case .mixed:
return "MIXED"
case .regular:
return "REGULAR"
@unknown default:
return nil
}
}
}

5 changes: 3 additions & 2 deletions ios/Services/Models/VTListenOptionsExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ internal extension VTListenOptions {
listenOptions.spatialAudio = spatialAudio?.boolValue ?? false
let strategy: String? = dictionary.value(for: Keys.videoForwardingStrategy)
listenOptions.videoForwardingStrategy = VideoForwardingStrategy.fromReactModel(value: strategy)

let listenType: String? = dictionary.value(for: Keys.listenType)
listenOptions.type = ListenType.create(with: listenType) ?? .regular
return listenOptions
}
}
Expand All @@ -34,5 +35,5 @@ extension VTListenOptions: ReactModelMappable {

// MARK: - ReactModel Keys
private enum Keys: String {
case maxVideoForwarding, conferenceAccessToken, spatialAudio, videoForwardingStrategy
case maxVideoForwarding, conferenceAccessToken, spatialAudio, videoForwardingStrategy, listenType
}

0 comments on commit 6bc2ecd

Please sign in to comment.