From 0e8e550ae55ece37ac633957c5970a403083e377 Mon Sep 17 00:00:00 2001 From: Martin Mitrevski Date: Mon, 26 Aug 2024 17:09:08 +0200 Subject: [PATCH] Generated code for participant count session event (#494) --- Sources/StreamVideo/CallState.swift | 4 ++ .../Models/CallRtmpBroadcastFailedEvent.swift | 45 ++++++++++++++++ ...SessionParticipantCountsUpdatedEvent.swift | 51 +++++++++++++++++++ .../Models/CallSessionResponse.swift | 11 +++- .../OpenApi/generated/Models/WSEvent.swift | 21 +++++++- StreamVideo.xcodeproj/project.pbxproj | 8 +++ .../Mock/MockResponseBuilder.swift | 2 + .../Dummy/CallSessionResponse+Dummy.swift | 2 + 8 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 Sources/StreamVideo/OpenApi/generated/Models/CallRtmpBroadcastFailedEvent.swift create mode 100644 Sources/StreamVideo/OpenApi/generated/Models/CallSessionParticipantCountsUpdatedEvent.swift diff --git a/Sources/StreamVideo/CallState.swift b/Sources/StreamVideo/CallState.swift index f6b486200..754785c1d 100644 --- a/Sources/StreamVideo/CallState.swift +++ b/Sources/StreamVideo/CallState.swift @@ -233,6 +233,10 @@ public class CallState: ObservableObject { break case .typeCallUserMutedEvent: break + case .typeCallRtmpBroadcastFailedEvent: + break + case .typeCallSessionParticipantCountsUpdatedEvent: + break } } diff --git a/Sources/StreamVideo/OpenApi/generated/Models/CallRtmpBroadcastFailedEvent.swift b/Sources/StreamVideo/OpenApi/generated/Models/CallRtmpBroadcastFailedEvent.swift new file mode 100644 index 000000000..24e503d2a --- /dev/null +++ b/Sources/StreamVideo/OpenApi/generated/Models/CallRtmpBroadcastFailedEvent.swift @@ -0,0 +1,45 @@ +// +// CallRtmpBroadcastFailedEvent.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation +/** This event is sent when a call RTMP broadcast has failed */ + +public struct CallRtmpBroadcastFailedEvent: @unchecked Sendable, Event, Codable, JSONEncodable, Hashable, WSCallEvent { + /** The unique identifier for a call (:) */ + public var callCid: String + /** Date/time of creation */ + public var createdAt: Date + /** Name of the given RTMP broadcast */ + public var name: String + /** The type of event: \"call.rtmp_broadcast_failed\" in this case */ + public var type: String = "call.rtmp_broadcast_failed" + + public init(callCid: String, createdAt: Date, name: String, type: String = "call.rtmp_broadcast_failed") { + self.callCid = callCid + self.createdAt = createdAt + self.name = name + self.type = type + } + + public enum CodingKeys: String, CodingKey, CaseIterable { + case callCid = "call_cid" + case createdAt = "created_at" + case name + case type + } + + // Encodable protocol methods + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(callCid, forKey: .callCid) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(name, forKey: .name) + try container.encode(type, forKey: .type) + } +} + diff --git a/Sources/StreamVideo/OpenApi/generated/Models/CallSessionParticipantCountsUpdatedEvent.swift b/Sources/StreamVideo/OpenApi/generated/Models/CallSessionParticipantCountsUpdatedEvent.swift new file mode 100644 index 000000000..90ad4ce67 --- /dev/null +++ b/Sources/StreamVideo/OpenApi/generated/Models/CallSessionParticipantCountsUpdatedEvent.swift @@ -0,0 +1,51 @@ +// +// CallSessionParticipantCountsUpdatedEvent.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation +/** This event is sent when the participant counts in a call session are updated */ + +public struct CallSessionParticipantCountsUpdatedEvent: @unchecked Sendable, Event, Codable, JSONEncodable, Hashable, WSCallEvent { + public var anonymousParticipantCount: Int + public var callCid: String + public var createdAt: Date + public var participantsCountByRole: [String: Int] + /** Call session ID */ + public var sessionId: String + /** The type of event: \"call.session_participant_count_updated\" in this case */ + public var type: String = "call.session_participant_count_updated" + + public init(anonymousParticipantCount: Int, callCid: String, createdAt: Date, participantsCountByRole: [String: Int], sessionId: String, type: String = "call.session_participant_count_updated") { + self.anonymousParticipantCount = anonymousParticipantCount + self.callCid = callCid + self.createdAt = createdAt + self.participantsCountByRole = participantsCountByRole + self.sessionId = sessionId + self.type = type + } + + public enum CodingKeys: String, CodingKey, CaseIterable { + case anonymousParticipantCount = "anonymous_participant_count" + case callCid = "call_cid" + case createdAt = "created_at" + case participantsCountByRole = "participants_count_by_role" + case sessionId = "session_id" + case type + } + + // Encodable protocol methods + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(anonymousParticipantCount, forKey: .anonymousParticipantCount) + try container.encode(callCid, forKey: .callCid) + try container.encode(createdAt, forKey: .createdAt) + try container.encode(participantsCountByRole, forKey: .participantsCountByRole) + try container.encode(sessionId, forKey: .sessionId) + try container.encode(type, forKey: .type) + } +} + diff --git a/Sources/StreamVideo/OpenApi/generated/Models/CallSessionResponse.swift b/Sources/StreamVideo/OpenApi/generated/Models/CallSessionResponse.swift index ec8369917..504eda601 100644 --- a/Sources/StreamVideo/OpenApi/generated/Models/CallSessionResponse.swift +++ b/Sources/StreamVideo/OpenApi/generated/Models/CallSessionResponse.swift @@ -10,22 +10,26 @@ import Foundation public struct CallSessionResponse: Codable, JSONEncodable, Hashable { public var acceptedBy: [String: Date] + public var anonymousParticipantCount: Int? public var endedAt: Date? public var id: String public var liveEndedAt: Date? public var liveStartedAt: Date? + public var missedBy: [String: Date]? public var participants: [CallParticipantResponse] public var participantsCountByRole: [String: Int] public var rejectedBy: [String: Date] public var startedAt: Date? public var timerEndsAt: Date? - public init(acceptedBy: [String: Date], endedAt: Date? = nil, id: String, liveEndedAt: Date? = nil, liveStartedAt: Date? = nil, participants: [CallParticipantResponse], participantsCountByRole: [String: Int], rejectedBy: [String: Date], startedAt: Date? = nil, timerEndsAt: Date? = nil) { + public init(acceptedBy: [String: Date], anonymousParticipantCount: Int?, endedAt: Date? = nil, id: String, liveEndedAt: Date? = nil, liveStartedAt: Date? = nil, missedBy: [String: Date]?, participants: [CallParticipantResponse], participantsCountByRole: [String: Int], rejectedBy: [String: Date], startedAt: Date? = nil, timerEndsAt: Date? = nil) { self.acceptedBy = acceptedBy + self.anonymousParticipantCount = anonymousParticipantCount self.endedAt = endedAt self.id = id self.liveEndedAt = liveEndedAt self.liveStartedAt = liveStartedAt + self.missedBy = missedBy self.participants = participants self.participantsCountByRole = participantsCountByRole self.rejectedBy = rejectedBy @@ -35,10 +39,12 @@ public struct CallSessionResponse: Codable, JSONEncodable, Hashable { public enum CodingKeys: String, CodingKey, CaseIterable { case acceptedBy = "accepted_by" + case anonymousParticipantCount = "anonymous_participant_count" case endedAt = "ended_at" case id case liveEndedAt = "live_ended_at" case liveStartedAt = "live_started_at" + case missedBy = "missed_by" case participants case participantsCountByRole = "participants_count_by_role" case rejectedBy = "rejected_by" @@ -51,10 +57,12 @@ public struct CallSessionResponse: Codable, JSONEncodable, Hashable { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(acceptedBy, forKey: .acceptedBy) + try container.encodeIfPresent(anonymousParticipantCount, forKey: .anonymousParticipantCount) try container.encodeIfPresent(endedAt, forKey: .endedAt) try container.encode(id, forKey: .id) try container.encodeIfPresent(liveEndedAt, forKey: .liveEndedAt) try container.encodeIfPresent(liveStartedAt, forKey: .liveStartedAt) + try container.encodeIfPresent(missedBy, forKey: .missedBy) try container.encode(participants, forKey: .participants) try container.encode(participantsCountByRole, forKey: .participantsCountByRole) try container.encode(rejectedBy, forKey: .rejectedBy) @@ -62,3 +70,4 @@ public struct CallSessionResponse: Codable, JSONEncodable, Hashable { try container.encodeIfPresent(timerEndsAt, forKey: .timerEndsAt) } } + diff --git a/Sources/StreamVideo/OpenApi/generated/Models/WSEvent.swift b/Sources/StreamVideo/OpenApi/generated/Models/WSEvent.swift index 29efbdc3b..f8903974c 100644 --- a/Sources/StreamVideo/OpenApi/generated/Models/WSEvent.swift +++ b/Sources/StreamVideo/OpenApi/generated/Models/WSEvent.swift @@ -37,9 +37,11 @@ public enum VideoEvent: Codable, JSONEncodable, Hashable { case typeCallRecordingStoppedEvent(CallRecordingStoppedEvent) case typeCallRejectedEvent(CallRejectedEvent) case typeCallRingEvent(CallRingEvent) + case typeCallRtmpBroadcastFailedEvent(CallRtmpBroadcastFailedEvent) case typeCallRtmpBroadcastStartedEvent(CallRtmpBroadcastStartedEvent) case typeCallRtmpBroadcastStoppedEvent(CallRtmpBroadcastStoppedEvent) case typeCallSessionEndedEvent(CallSessionEndedEvent) + case typeCallSessionParticipantCountsUpdatedEvent(CallSessionParticipantCountsUpdatedEvent) case typeCallSessionParticipantJoinedEvent(CallSessionParticipantJoinedEvent) case typeCallSessionParticipantLeftEvent(CallSessionParticipantLeftEvent) case typeCallSessionStartedEvent(CallSessionStartedEvent) @@ -101,12 +103,16 @@ public enum VideoEvent: Codable, JSONEncodable, Hashable { return value.type case .typeCallRingEvent(let value): return value.type + case .typeCallRtmpBroadcastFailedEvent(let value): + return value.type case .typeCallRtmpBroadcastStartedEvent(let value): return value.type case .typeCallRtmpBroadcastStoppedEvent(let value): return value.type case .typeCallSessionEndedEvent(let value): return value.type + case .typeCallSessionParticipantCountsUpdatedEvent(let value): + return value.type case .typeCallSessionParticipantJoinedEvent(let value): return value.type case .typeCallSessionParticipantLeftEvent(let value): @@ -189,12 +195,16 @@ public enum VideoEvent: Codable, JSONEncodable, Hashable { return value case .typeCallRingEvent(let value): return value + case .typeCallRtmpBroadcastFailedEvent(let value): + return value case .typeCallRtmpBroadcastStartedEvent(let value): return value case .typeCallRtmpBroadcastStoppedEvent(let value): return value case .typeCallSessionEndedEvent(let value): return value + case .typeCallSessionParticipantCountsUpdatedEvent(let value): + return value case .typeCallSessionParticipantJoinedEvent(let value): return value case .typeCallSessionParticipantLeftEvent(let value): @@ -278,12 +288,16 @@ public enum VideoEvent: Codable, JSONEncodable, Hashable { try container.encode(value) case .typeCallRingEvent(let value): try container.encode(value) + case .typeCallRtmpBroadcastFailedEvent(let value): + try container.encode(value) case .typeCallRtmpBroadcastStartedEvent(let value): try container.encode(value) case .typeCallRtmpBroadcastStoppedEvent(let value): try container.encode(value) case .typeCallSessionEndedEvent(let value): try container.encode(value) + case .typeCallSessionParticipantCountsUpdatedEvent(let value): + try container.encode(value) case .typeCallSessionParticipantJoinedEvent(let value): try container.encode(value) case .typeCallSessionParticipantLeftEvent(let value): @@ -399,6 +413,9 @@ public enum VideoEvent: Codable, JSONEncodable, Hashable { } else if dto.type == "call.ring" { let value = try container.decode(CallRingEvent.self) self = .typeCallRingEvent(value) + } else if dto.type == "call.rtmp_broadcast_failed" { + let value = try container.decode(CallRtmpBroadcastFailedEvent.self) + self = .typeCallRtmpBroadcastFailedEvent(value) } else if dto.type == "call.rtmp_broadcast_started" { let value = try container.decode(CallRtmpBroadcastStartedEvent.self) self = .typeCallRtmpBroadcastStartedEvent(value) @@ -408,6 +425,9 @@ public enum VideoEvent: Codable, JSONEncodable, Hashable { } else if dto.type == "call.session_ended" { let value = try container.decode(CallSessionEndedEvent.self) self = .typeCallSessionEndedEvent(value) + } else if dto.type == "call.session_participant_count_updated" { + let value = try container.decode(CallSessionParticipantCountsUpdatedEvent.self) + self = .typeCallSessionParticipantCountsUpdatedEvent(value) } else if dto.type == "call.session_participant_joined" { let value = try container.decode(CallSessionParticipantJoinedEvent.self) self = .typeCallSessionParticipantJoinedEvent(value) @@ -456,4 +476,3 @@ public enum VideoEvent: Codable, JSONEncodable, Hashable { } } - diff --git a/StreamVideo.xcodeproj/project.pbxproj b/StreamVideo.xcodeproj/project.pbxproj index 868bc70b3..1af1e3221 100644 --- a/StreamVideo.xcodeproj/project.pbxproj +++ b/StreamVideo.xcodeproj/project.pbxproj @@ -891,6 +891,8 @@ 84D6494429E9AD08002CA428 /* CallIngressResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D6494229E9AD08002CA428 /* CallIngressResponse.swift */; }; 84D6494729E9F2D0002CA428 /* WebRTCClient_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D6494629E9F2D0002CA428 /* WebRTCClient_Tests.swift */; }; 84D6E53A2B3AD10000D0056C /* RepeatingTimer_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D6E5392B3AD10000D0056C /* RepeatingTimer_Tests.swift */; }; + 84D91E9C2C7CB0AA00B163A0 /* CallSessionParticipantCountsUpdatedEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D91E9A2C7CB0AA00B163A0 /* CallSessionParticipantCountsUpdatedEvent.swift */; }; + 84D91E9D2C7CB0AA00B163A0 /* CallRtmpBroadcastFailedEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D91E9B2C7CB0AA00B163A0 /* CallRtmpBroadcastFailedEvent.swift */; }; 84DC382D29A8B9EC00946713 /* CallParticipantMenuAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84DC382C29A8B9EC00946713 /* CallParticipantMenuAction.swift */; }; 84DC382F29A8BB8D00946713 /* CallParticipantsInfoViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84DC382E29A8BB8D00946713 /* CallParticipantsInfoViewModel.swift */; }; 84DC388F29ADFCFD00946713 /* CodableHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84DC383D29ADFCFB00946713 /* CodableHelper.swift */; }; @@ -1923,6 +1925,8 @@ 84D6494229E9AD08002CA428 /* CallIngressResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CallIngressResponse.swift; sourceTree = ""; }; 84D6494629E9F2D0002CA428 /* WebRTCClient_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebRTCClient_Tests.swift; sourceTree = ""; }; 84D6E5392B3AD10000D0056C /* RepeatingTimer_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RepeatingTimer_Tests.swift; sourceTree = ""; }; + 84D91E9A2C7CB0AA00B163A0 /* CallSessionParticipantCountsUpdatedEvent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CallSessionParticipantCountsUpdatedEvent.swift; sourceTree = ""; }; + 84D91E9B2C7CB0AA00B163A0 /* CallRtmpBroadcastFailedEvent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CallRtmpBroadcastFailedEvent.swift; sourceTree = ""; }; 84DC382C29A8B9EC00946713 /* CallParticipantMenuAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallParticipantMenuAction.swift; sourceTree = ""; }; 84DC382E29A8BB8D00946713 /* CallParticipantsInfoViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallParticipantsInfoViewModel.swift; sourceTree = ""; }; 84DC383D29ADFCFB00946713 /* CodableHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CodableHelper.swift; sourceTree = ""; }; @@ -4084,6 +4088,8 @@ 84DC383E29ADFCFC00946713 /* Models */ = { isa = PBXGroup; children = ( + 84D91E9B2C7CB0AA00B163A0 /* CallRtmpBroadcastFailedEvent.swift */, + 84D91E9A2C7CB0AA00B163A0 /* CallSessionParticipantCountsUpdatedEvent.swift */, 841AE1892C738CCC005B6560 /* LayoutSettings.swift */, 844982432C738A830029734D /* DeleteCallRequest.swift */, 844982402C738A830029734D /* DeleteCallResponse.swift */, @@ -5315,6 +5321,7 @@ 8409465629AF4EEC007AF5BF /* CallReactionEvent.swift in Sources */, 84DCA21F2A39DA15000C3411 /* APIHelper.swift in Sources */, 84DC38D329ADFCFD00946713 /* CallEndedEvent.swift in Sources */, + 84D91E9D2C7CB0AA00B163A0 /* CallRtmpBroadcastFailedEvent.swift in Sources */, 84A737D028F4716E001A6769 /* models.pb.swift in Sources */, 846D16222A52B8D00036CE4C /* MicrophoneManager.swift in Sources */, 842E70DB2B91BE1700D2D68B /* ListTranscriptionsResponse.swift in Sources */, @@ -5345,6 +5352,7 @@ 8490DD1F298D39D9007E53D2 /* JsonEventDecoder.swift in Sources */, 40FB15192BF77EE700D5E580 /* StreamCallStateMachine+IdleStage.swift in Sources */, 84BAD7842A6C01AF00733156 /* BroadcastBufferReader.swift in Sources */, + 84D91E9C2C7CB0AA00B163A0 /* CallSessionParticipantCountsUpdatedEvent.swift in Sources */, 846E4AF529CDEA66003733AB /* ConnectUserDetailsRequest.swift in Sources */, 846D16262A52CE8C0036CE4C /* SpeakerManager.swift in Sources */, 841BAA3A2BD15CDE000C73E4 /* Location.swift in Sources */, diff --git a/StreamVideoTests/Mock/MockResponseBuilder.swift b/StreamVideoTests/Mock/MockResponseBuilder.swift index d4355c2de..61ee1bccd 100644 --- a/StreamVideoTests/Mock/MockResponseBuilder.swift +++ b/StreamVideoTests/Mock/MockResponseBuilder.swift @@ -175,10 +175,12 @@ class MockResponseBuilder { ) -> CallSessionResponse { CallSessionResponse( acceptedBy: acceptedBy, + anonymousParticipantCount: 0, endedAt: liveEndedAt, id: cid, liveEndedAt: liveEndedAt, liveStartedAt: liveStartedAt, + missedBy: [:], participants: [], participantsCountByRole: [:], rejectedBy: rejectedBy, diff --git a/StreamVideoTests/Utilities/Dummy/CallSessionResponse+Dummy.swift b/StreamVideoTests/Utilities/Dummy/CallSessionResponse+Dummy.swift index a4b53b249..91490d7f8 100644 --- a/StreamVideoTests/Utilities/Dummy/CallSessionResponse+Dummy.swift +++ b/StreamVideoTests/Utilities/Dummy/CallSessionResponse+Dummy.swift @@ -19,10 +19,12 @@ extension CallSessionResponse { ) -> CallSessionResponse { .init( acceptedBy: acceptedBy, + anonymousParticipantCount: 0, endedAt: endedAt, id: id, liveEndedAt: liveEndedAt, liveStartedAt: liveStartedAt, + missedBy: [:], participants: participants, participantsCountByRole: participantsCountByRole, rejectedBy: rejectedBy,