Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 25a82f4
Author: Hiroshi Horie <[email protected]>
Date:   Tue Feb 22 14:32:25 2022 +0700

    use 0.9.8

commit 361a1d9
Author: Hiroshi Horie <[email protected]>
Date:   Tue Feb 22 02:10:55 2022 +0700

    Update RoomView.swift

commit c918593
Author: Hiroshi Horie <[email protected]>
Date:   Mon Feb 21 19:40:51 2022 +0700

    Update Package.resolved

commit c8a56d5
Author: Hiroshi Horie <[email protected]>
Date:   Mon Feb 21 19:18:32 2022 +0700

    adjustments

commit d11eae4
Author: Hiroshi Horie <[email protected]>
Date:   Sat Feb 19 00:43:43 2022 +0700

    center align

commit 4f1f565
Author: Hiroshi Horie <[email protected]>
Date:   Fri Feb 18 15:30:10 2022 +0700

    show video stats
  • Loading branch information
hiroshihorie committed Feb 22, 2022
1 parent 3f70ef4 commit 4d2e166
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"repositoryURL": "https://github.com/webrtc-sdk/Specs.git",
"state": {
"branch": null,
"revision": "f83999edabf06600cf4ff8ccd5647c333ba27e98",
"version": "93.4577.2"
"revision": "063f852f5e6150c9006ba884c2664ed1c868ddb1",
"version": "97.4692.2"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion LiveKitExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@
repositoryURL = "https://github.com/livekit/client-sdk-swift";
requirement = {
kind = exactVersion;
version = 0.9.7;
version = 0.9.8;
};
};
68816CBF27B4D6BC00E24622 /* XCRemoteSwiftPackageReference "KeychainAccess" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/livekit/client-sdk-swift",
"state": {
"branch": null,
"revision": "3bb9469ddc88f7355ff4a56b04a8a7bb27f81140",
"version": "0.9.7"
"revision": "600994caf57ebe0052e339462a3c0786bdf3f981",
"version": "0.9.8"
}
},
{
Expand Down Expand Up @@ -42,8 +42,8 @@
"repositoryURL": "https://github.com/webrtc-sdk/Specs.git",
"state": {
"branch": null,
"revision": "f83999edabf06600cf4ff8ccd5647c333ba27e98",
"version": "93.4577.2"
"revision": "063f852f5e6150c9006ba884c2664ed1c868ddb1",
"version": "97.4692.2"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableAddressSanitizer = "YES"
enableASanStackUseAfterReturn = "YES"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
Expand Down
8 changes: 7 additions & 1 deletion Shared/Controllers/RoomContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ final class RoomContext: ObservableObject {

extension RoomContext: RoomDelegate {

func room(_ room: Room, didUpdate connectionState: ConnectionState) {
func room(_ room: Room, didUpdate connectionState: ConnectionState, oldValue: ConnectionState) {

guard !connectionState.isEqual(to: oldValue, includingAssociatedValues: false) else {
print("Skipping same conectionState")
return
}

print("Did update connectionState \(connectionState) \(room.connectionState)")

if let error = connectionState.disconnectedWithError {
Expand Down
11 changes: 9 additions & 2 deletions Shared/ExampleObservableRoom.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,15 @@ class ExampleObservableRoom: ObservableRoom {

// MARK: - RoomDelegate

override func room(_ room: Room, didUpdate connectionState: ConnectionState) {
super.room(room, didUpdate: connectionState)
override func room(_ room: Room, didUpdate connectionState: ConnectionState, oldValue: ConnectionState) {

super.room(room, didUpdate: connectionState, oldValue: oldValue)

guard !connectionState.isEqual(to: oldValue, includingAssociatedValues: false) else {
print("Skipping same conectionState")
return
}

if case .disconnected = connectionState {
DispatchQueue.main.async {
// Reset state
Expand Down
65 changes: 48 additions & 17 deletions Shared/ParticipantView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct ParticipantView: View {
var onTap: ((_ participant: ObservableParticipant) -> Void)?

@State private var dimensions: Dimensions?
@State private var trackStats: TrackStats?

func bgView(systemSymbol: SFSymbol, geometry: GeometryProxy) -> some View {
Image(systemSymbol: systemSymbol)
Expand Down Expand Up @@ -43,31 +44,61 @@ struct ParticipantView: View {
mode: videoViewMode,
mirrored: appCtx.videoViewMirrored ? !shouldMirror : shouldMirror,
dimensions: $dimensions,
trackStats: $trackStats,
preferMetal: appCtx.preferMetal)
.background(Color.black)
// .scaleEffect(CGSize(width: -1.0, height: 1.0))// flip local view horizontally

// Show the actual video dimensions (if enabled)
if appCtx.showInformationOverlay {
VStack(alignment: .leading) {
Text("Metal: \(String(describing: appCtx.preferMetal))")
.foregroundColor(Color.white)
.padding(3)
.background(Color.black)
.cornerRadius(8)
Text("Mirrored: \(String(describing: shouldMirror))")
.foregroundColor(Color.white)
.padding(3)
.background(Color.black)
.cornerRadius(8)
if let dimensions = dimensions {
Text("\(dimensions.width)x\(dimensions.height)")
.foregroundColor(Color.white)
.padding(3)
.background(Color.lkBlue)
.cornerRadius(8)
HStack(alignment: .top, spacing: 5) {

VStack(alignment: .leading, spacing: 5) {
Text("View")
.fontWeight(.bold)
Text("metal: \(String(describing: appCtx.preferMetal))")
Text("mirror: \(String(describing: shouldMirror))")
}
.font(.system(size: 10))
.foregroundColor(Color.white)
.padding(5)
.background(Color.black.opacity(0.5))
.cornerRadius(8)

VStack(alignment: .leading, spacing: 5) {
Text("Video")
.fontWeight(.bold)

HStack(alignment: .top, spacing: 3) {
if let dimensions = dimensions {
Text("\(dimensions.width)x\(dimensions.height)")
}
if let codecName = trackStats?.codecName {
HStack(spacing: 3) {
Text(codecName)
.fontWeight(.bold)
}
}
}

if let trackStats = trackStats, trackStats.bpsSent != 0 {
HStack(spacing: 3) {
Image(systemSymbol: .arrowUpCircle)
Text(trackStats.formattedBpsSent())
}
}
if let trackStats = trackStats, trackStats.bpsReceived != 0 {
HStack(spacing: 3) {
Image(systemSymbol: .arrowDownCircle)
Text(trackStats.formattedBpsReceived())
}
}
}
.font(.system(size: 10))
.foregroundColor(Color.white)
.padding(5)
.background(Color.black.opacity(0.5))
.cornerRadius(8)
}
.padding()
}
Expand Down
15 changes: 10 additions & 5 deletions Shared/RoomView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ struct RoomView: View {
.toolbar {
ToolbarItemGroup(placement: toolbarPlacement) {

#if os(macOS)
if let name = room.room.name {
Text(name)
.fontWeight(.bold)
Expand All @@ -230,6 +231,7 @@ struct RoomView: View {
if let identity = room.room.localParticipant?.identity {
Text(identity)
}
#endif

#if os(macOS)
// Pin on top
Expand Down Expand Up @@ -412,12 +414,12 @@ struct RoomView: View {
struct ParticipantLayout<Content: View>: View {

let views: [AnyView]
let spacing: CGFloat?
let spacing: CGFloat

init<Data: RandomAccessCollection>(
_ data: Data,
id: KeyPath<Data.Element, Data.Element> = \.self,
spacing: CGFloat? = nil,
spacing: CGFloat,
@ViewBuilder content: @escaping (Data.Element) -> Content) {
self.spacing = spacing
self.views = data.map { AnyView(content($0[keyPath: id])) }
Expand All @@ -430,14 +432,17 @@ struct ParticipantLayout<Content: View>: View {
return (x: c[0], y: c[1])
}

func grid(axis: Axis) -> some View {
func grid(axis: Axis, geometry: GeometryProxy) -> some View {
ScrollView([ axis == .vertical ? .vertical : .horizontal ]) {
HorVGrid(axis: axis, columns: [GridItem(.flexible())], spacing: spacing) {
ForEach(0..<views.count, id: \.self) { i in
views[i]
.aspectRatio(1, contentMode: .fill)
}
}
.padding(axis == .horizontal ? [.leading, .trailing] : [.top, .bottom],
max(0, ((axis == .horizontal ? geometry.size.width : geometry.size.height)
- ((axis == .horizontal ? geometry.size.height : geometry.size.width) * CGFloat(views.count)) - (spacing * CGFloat(views.count - 1))) / 2))
}
}

Expand All @@ -446,9 +451,9 @@ struct ParticipantLayout<Content: View>: View {
if views.isEmpty {
EmptyView()
} else if geometry.size.width <= 300 {
grid(axis: .vertical)
grid(axis: .vertical, geometry: geometry)
} else if geometry.size.height <= 300 {
grid(axis: .horizontal)
grid(axis: .horizontal, geometry: geometry)
} else {

let verticalWhenTall: Axis = geometry.isTall ? .vertical : .horizontal
Expand Down

0 comments on commit 4d2e166

Please sign in to comment.