mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-23 01:52:44 +02:00
Add chunks in TimelineVoiceBroadcastDetails
This commit is contained in:
+5
-6
@@ -76,7 +76,7 @@ final class TimelineVoiceBroadcastCoordinator: Coordinator, Presentable, VoiceBr
|
||||
}
|
||||
|
||||
func canEndVoiceBroadcast() -> Bool {
|
||||
// TODO: check is voicebroadcast stopped
|
||||
// TODO: VB check is voicebroadcast stopped
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -104,14 +104,13 @@ final class TimelineVoiceBroadcastCoordinator: Coordinator, Presentable, VoiceBr
|
||||
// to add the SDK as a dependency to it. We need to translate from one to the other on this level.
|
||||
func buildTimelineVoiceBroadcastFrom(_ voiceBroadcast: VoiceBroadcastProtocol) -> TimelineVoiceBroadcastDetails {
|
||||
|
||||
return TimelineVoiceBroadcastDetails(closed: voiceBroadcast.isClosed,
|
||||
type: voiceBroadcastKindToTimelineVoiceBroadcastType(voiceBroadcast.kind))
|
||||
return TimelineVoiceBroadcastDetails(chunks: Array(voiceBroadcast.chunks), type: voiceBroadcastKindToTimelineVoiceBroadcastType(voiceBroadcast.kind))
|
||||
}
|
||||
|
||||
private func voiceBroadcastKindToTimelineVoiceBroadcastType(_ kind: VoiceBroadcastKind) -> TimelineVoiceBroadcastType {
|
||||
let mapping = [VoiceBroadcastKind.disclosed: TimelineVoiceBroadcastType.disclosed,
|
||||
VoiceBroadcastKind.undisclosed: TimelineVoiceBroadcastType.undisclosed]
|
||||
let mapping = [VoiceBroadcastKind.player: TimelineVoiceBroadcastType.player,
|
||||
VoiceBroadcastKind.recorder: TimelineVoiceBroadcastType.recorder]
|
||||
|
||||
return mapping[kind] ?? .disclosed
|
||||
return mapping[kind] ?? .player
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,21 +16,12 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
//TODO: VB remove duplicated class or struct
|
||||
/// Represents user live location
|
||||
struct VoiceBroadcastChunk {
|
||||
var userId: String {
|
||||
avatarData.matrixItemId
|
||||
}
|
||||
|
||||
var displayName: String {
|
||||
avatarData.displayName ?? userId
|
||||
}
|
||||
|
||||
let avatarData: AvatarInputProtocol
|
||||
|
||||
/// Chunk sequence number
|
||||
let sequence: UInt
|
||||
|
||||
// TODO: VB add chunk attachment here
|
||||
let attachmentUrl: URL
|
||||
|
||||
/// Chunk file url
|
||||
let url: URL
|
||||
}
|
||||
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
class VoiceBroadcastPlaybackService: VoiceBroadcastPlaybackServiceProtocol {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
private(set) var voiceBroadcastChunks: [VoiceBroadcastChunk] = []
|
||||
private let roomId: String
|
||||
|
||||
// MARK: Private
|
||||
|
||||
|
||||
// MARK: Public
|
||||
|
||||
var didUpdateVoiceBroadcastChunks: (([VoiceBroadcastChunk]) -> Void)?
|
||||
|
||||
// MARK: - Setup
|
||||
|
||||
init(roomId: String) {
|
||||
self.roomId = roomId
|
||||
|
||||
updateVoiceBroadcastChunks(notifyUpdate: false)
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
func startPlayingVoiceBroadcast() {
|
||||
|
||||
}
|
||||
|
||||
func pausePlayingVoiceBroadcast() {
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func updateVoiceBroadcastChunks(notifyUpdate: Bool) {
|
||||
// TODO: VB udpate voicebroadcast chunks. We already have a listener on voicebroadcast events in VoiceBroadcastAggregator
|
||||
|
||||
if notifyUpdate {
|
||||
didUpdateVoiceBroadcastChunks?(voiceBroadcastChunks)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,18 +30,17 @@ enum TimelineVoiceBroadcastViewModelResult {
|
||||
}
|
||||
|
||||
enum TimelineVoiceBroadcastType {
|
||||
case disclosed
|
||||
case undisclosed
|
||||
case player
|
||||
case recorder
|
||||
}
|
||||
|
||||
struct TimelineVoiceBroadcastDetails {
|
||||
var closed: Bool
|
||||
var type: TimelineVoiceBroadcastType
|
||||
var chunks: [VoiceBroadcastChunk]
|
||||
|
||||
init(closed: Bool,
|
||||
type: TimelineVoiceBroadcastType) {
|
||||
self.closed = closed
|
||||
init(chunks: [VoiceBroadcastChunk], type: TimelineVoiceBroadcastType) {
|
||||
self.type = type
|
||||
self.chunks = chunks
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ enum MockTimelineVoiceBroadcastScreenState: MockScreenState, CaseIterable {
|
||||
|
||||
/// Generate the view struct for the screen state.
|
||||
var screenView: ([Any], AnyView) {
|
||||
let voiceBroadcast = TimelineVoiceBroadcastDetails(closed: false, type: TimelineVoiceBroadcastType.disclosed)
|
||||
let voiceBroadcast = TimelineVoiceBroadcastDetails(chunks: [], type: TimelineVoiceBroadcastType.player)
|
||||
|
||||
let viewModel = TimelineVoiceBroadcastViewModel(timelineVoiceBroadcastDetails: voiceBroadcast)
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ class TimelineVoiceBroadcastViewModel: TimelineVoiceBroadcastViewModelType, Time
|
||||
|
||||
/// Listen voice broadcast
|
||||
private func play() {
|
||||
// TODO: VB call voice broadcast playback service to play the chunks
|
||||
completion?(.played)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user