Skip to content

Commit

Permalink
Merge pull request #40 from DolbyIO/bugfix/configure-list-view-primar…
Browse files Browse the repository at this point in the history
…y-video-quality

Pass ListView's primary video quality as a configurable option for the screen
  • Loading branch information
aravind-raveendran authored Oct 18, 2023
2 parents 376ab33 + 1659536 commit 5ac5969
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
13 changes: 9 additions & 4 deletions Sources/DolbyIORTSUIKit/Private/ViewModels/StreamViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ final class StreamViewModel: ObservableObject {

let streamDetail: StreamDetail
let settingsMode: SettingsMode
let listViewPrimaryVideoQuality: VideoQuality

@Published private(set) var state: State = .loading

Expand Down Expand Up @@ -87,13 +88,15 @@ final class StreamViewModel: ObservableObject {
}

init(
streamDetail: StreamDetail,
context: StreamingScreen.Context,
listViewPrimaryVideoQuality: VideoQuality,
streamOrchestrator: StreamOrchestrator = .shared,
settingsManager: SettingsManager = .shared
) {
self.streamOrchestrator = streamOrchestrator
self.settingsManager = settingsManager
self.streamDetail = streamDetail
self.streamDetail = context.streamDetail
self.listViewPrimaryVideoQuality = context.listViewPrimaryVideoQuality
self.settingsMode = .stream(streamName: streamDetail.streamName, accountID: streamDetail.accountID)

startObservers()
Expand Down Expand Up @@ -179,6 +182,7 @@ final class StreamViewModel: ObservableObject {
case .list:
let secondaryVideoSources = secondaryVideoSources(sources, matchingSource)
let showSourceLabels = settings.showSourceLabels
let primaryVideoQuality = matchingSource.videoQualityList.contains(listViewPrimaryVideoQuality) ? listViewPrimaryVideoQuality : .auto

let listViewModel = ListViewModel(
primaryVideoViewModel: VideoRendererViewModel(
Expand All @@ -187,7 +191,7 @@ final class StreamViewModel: ObservableObject {
isSelectedAudioSource: matchingSource.id == selectedAudioSource?.id,
showSourceLabel: showSourceLabels,
showAudioIndicator: matchingSource.id == selectedAudioSource?.id,
videoQuality: .auto
videoQuality: primaryVideoQuality
),
secondaryVideoViewModels: secondaryVideoSources.map {
VideoRendererViewModel(
Expand Down Expand Up @@ -312,6 +316,7 @@ final class StreamViewModel: ObservableObject {
case .list:
let secondaryVideoSources = sortedSources.filter { $0.id != selectedVideoSource.id }
let showSourceLabels = settings.showSourceLabels
let primaryVideoQuality = selectedVideoSource.videoQualityList.contains(listViewPrimaryVideoQuality) ? listViewPrimaryVideoQuality : .auto

let listViewModel = ListViewModel(
primaryVideoViewModel: VideoRendererViewModel(
Expand All @@ -320,7 +325,7 @@ final class StreamViewModel: ObservableObject {
isSelectedAudioSource: selectedVideoSource.id == selectedAudioSource?.id,
showSourceLabel: showSourceLabels,
showAudioIndicator: selectedVideoSource.id == selectedAudioSource?.id,
videoQuality: .auto
videoQuality: primaryVideoQuality
),
secondaryVideoViewModels: secondaryVideoSources.map {
VideoRendererViewModel(
Expand Down
27 changes: 24 additions & 3 deletions Sources/DolbyIORTSUIKit/Public/Screens/Media/StreamingScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ import DolbyIORTSCore
import DolbyIOUIKit

public struct StreamingScreen: View {

public struct Context: Identifiable {
public let id = UUID()
public let streamDetail: StreamDetail
public let listViewPrimaryVideoQuality: VideoQuality

public init(streamName: String, accountID: String, listViewPrimaryVideoQuality: VideoQuality) {
self.streamDetail = StreamDetail(streamName: streamName, accountID: accountID)
self.listViewPrimaryVideoQuality = listViewPrimaryVideoQuality
}
}

@StateObject private var viewModel: StreamViewModel
@State private var isShowingSingleViewScreen: Bool = false
@State private var isShowingSettingsScreen: Bool = false
Expand All @@ -15,9 +27,18 @@ public struct StreamingScreen: View {
private let onClose: () -> Void

private var theme: Theme { themeManager.theme }

public init(streamDetail: StreamDetail, onClose: @escaping () -> Void) {
_viewModel = StateObject(wrappedValue: .init(streamDetail: streamDetail))

public init(
context: Context,
listViewPrimaryVideoQuality: VideoQuality = .auto,
onClose: @escaping () -> Void
) {
_viewModel = StateObject(
wrappedValue: .init(
context: context,
listViewPrimaryVideoQuality: listViewPrimaryVideoQuality
)
)
self.onClose = onClose
}

Expand Down

0 comments on commit 5ac5969

Please sign in to comment.