Skip to content

Commit

Permalink
Generated code for closed captions (#595)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmitrevski authored and ipavlidakis committed Nov 12, 2024
1 parent c71d241 commit 05fe4e1
Show file tree
Hide file tree
Showing 19 changed files with 336 additions and 16 deletions.
6 changes: 6 additions & 0 deletions Sources/StreamVideo/CallState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ public class CallState: ObservableObject {
break
case .typeUserUpdatedEvent:
break
case .typeCallClosedCaptionsFailedEvent:
break
case .typeCallClosedCaptionsStartedEvent:
break
case .typeCallClosedCaptionsStoppedEvent:
break
}
}

Expand Down
42 changes: 42 additions & 0 deletions Sources/StreamVideo/OpenApi/generated/APIs/DefaultAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,25 @@ open class DefaultAPI: DefaultAPIEndpoints, @unchecked Sendable {
}
}

open func startClosedCaptions(type: String, id: String) async throws -> StartClosedCaptionsResponse {
var path = "/video/call/{type}/{id}/start_closed_captions"

let typePreEscape = "\(APIHelper.mapValueToPathItem(type))"
let typePostEscape = typePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
path = path.replacingOccurrences(of: String(format: "{%@}", "type"), with: typePostEscape, options: .literal, range: nil)
let idPreEscape = "\(APIHelper.mapValueToPathItem(id))"
let idPostEscape = idPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
path = path.replacingOccurrences(of: String(format: "{%@}", "id"), with: idPostEscape, options: .literal, range: nil)

let urlRequest = try makeRequest(
uriPath: path,
httpMethod: "POST"
)
return try await send(request: urlRequest) {
try self.jsonDecoder.decode(StartClosedCaptionsResponse.self, from: $0)
}
}

open func startRecording(
type: String,
id: String,
Expand Down Expand Up @@ -759,6 +778,25 @@ open class DefaultAPI: DefaultAPIEndpoints, @unchecked Sendable {
}
}

open func stopClosedCaptions(type: String, id: String) async throws -> StopClosedCaptionsResponse {
var path = "/video/call/{type}/{id}/stop_closed_captions"

let typePreEscape = "\(APIHelper.mapValueToPathItem(type))"
let typePostEscape = typePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
path = path.replacingOccurrences(of: String(format: "{%@}", "type"), with: typePostEscape, options: .literal, range: nil)
let idPreEscape = "\(APIHelper.mapValueToPathItem(id))"
let idPostEscape = idPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
path = path.replacingOccurrences(of: String(format: "{%@}", "id"), with: idPostEscape, options: .literal, range: nil)

let urlRequest = try makeRequest(
uriPath: path,
httpMethod: "POST"
)
return try await send(request: urlRequest) {
try self.jsonDecoder.decode(StopClosedCaptionsResponse.self, from: $0)
}
}

open func stopLive(type: String, id: String) async throws -> StopLiveResponse {
var path = "/video/call/{type}/{id}/stop_live"

Expand Down Expand Up @@ -1127,6 +1165,8 @@ protocol DefaultAPIEndpoints {

func startHLSBroadcasting(type: String, id: String) async throws -> StartHLSBroadcastingResponse

func startClosedCaptions(type: String, id: String) async throws -> StartClosedCaptionsResponse

func startRecording(type: String, id: String, startRecordingRequest: StartRecordingRequest) async throws
-> StartRecordingResponse

Expand All @@ -1137,6 +1177,8 @@ protocol DefaultAPIEndpoints {

func stopHLSBroadcasting(type: String, id: String) async throws -> StopHLSBroadcastingResponse

func stopClosedCaptions(type: String, id: String) async throws -> StopClosedCaptionsResponse

func stopLive(type: String, id: String) async throws -> StopLiveResponse

func stopRecording(type: String, id: String) async throws -> StopRecordingResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,37 @@ public final class CallClosedCaption: @unchecked Sendable, Codable, JSONEncodabl
public var speakerId: String
public var startTime: Date
public var text: String
public var user: UserResponse?

public init(endTime: Date, speakerId: String, startTime: Date, text: String) {
public init(endTime: Date, speakerId: String, startTime: Date, text: String, user: UserResponse? = nil) {
self.endTime = endTime
self.speakerId = speakerId
self.startTime = startTime
self.text = text
self.user = user
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case endTime = "end_time"
case speakerId = "speaker_id"
case startTime = "start_time"
case text
case user
}

public static func == (lhs: CallClosedCaption, rhs: CallClosedCaption) -> Bool {
lhs.endTime == rhs.endTime &&
lhs.speakerId == rhs.speakerId &&
lhs.startTime == rhs.startTime &&
lhs.text == rhs.text
lhs.text == rhs.text &&
lhs.user == rhs.user
}

public func hash(into hasher: inout Hasher) {
hasher.combine(endTime)
hasher.combine(speakerId)
hasher.combine(startTime)
hasher.combine(text)
hasher.combine(user)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// Copyright © 2024 Stream.io Inc. All rights reserved.
//

import Foundation

public final class CallClosedCaptionsFailedEvent: @unchecked Sendable, Event, Codable, JSONEncodable, Hashable, WSCallEvent {

public var callCid: String
public var createdAt: Date
public var type: String = "call.closed_captions_failed"

public init(callCid: String, createdAt: Date) {
self.callCid = callCid
self.createdAt = createdAt
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case callCid = "call_cid"
case createdAt = "created_at"
case type
}

public static func == (lhs: CallClosedCaptionsFailedEvent, rhs: CallClosedCaptionsFailedEvent) -> Bool {
lhs.callCid == rhs.callCid &&
lhs.createdAt == rhs.createdAt &&
lhs.type == rhs.type
}

public func hash(into hasher: inout Hasher) {
hasher.combine(callCid)
hasher.combine(createdAt)
hasher.combine(type)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// Copyright © 2024 Stream.io Inc. All rights reserved.
//

import Foundation

public final class CallClosedCaptionsStartedEvent: @unchecked Sendable, Event, Codable, JSONEncodable, Hashable, WSCallEvent {

public var callCid: String
public var createdAt: Date
public var type: String = "call.closed_captions_started"

public init(callCid: String, createdAt: Date) {
self.callCid = callCid
self.createdAt = createdAt
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case callCid = "call_cid"
case createdAt = "created_at"
case type
}

public static func == (lhs: CallClosedCaptionsStartedEvent, rhs: CallClosedCaptionsStartedEvent) -> Bool {
lhs.callCid == rhs.callCid &&
lhs.createdAt == rhs.createdAt &&
lhs.type == rhs.type
}

public func hash(into hasher: inout Hasher) {
hasher.combine(callCid)
hasher.combine(createdAt)
hasher.combine(type)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// Copyright © 2024 Stream.io Inc. All rights reserved.
//

import Foundation

public final class CallClosedCaptionsStoppedEvent: @unchecked Sendable, Event, Codable, JSONEncodable, Hashable, WSCallEvent {

public var callCid: String
public var createdAt: Date
public var type: String = "call.closed_captions_stopped"

public init(callCid: String, createdAt: Date) {
self.callCid = callCid
self.createdAt = createdAt
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case callCid = "call_cid"
case createdAt = "created_at"
case type
}

public static func == (lhs: CallClosedCaptionsStoppedEvent, rhs: CallClosedCaptionsStoppedEvent) -> Bool {
lhs.callCid == rhs.callCid &&
lhs.createdAt == rhs.createdAt &&
lhs.type == rhs.type
}

public func hash(into hasher: inout Hasher) {
hasher.combine(callCid)
hasher.combine(createdAt)
hasher.combine(type)
}
}
24 changes: 18 additions & 6 deletions Sources/StreamVideo/OpenApi/generated/Models/CallEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,74 @@ import Foundation
public final class CallEvent: @unchecked Sendable, Codable, JSONEncodable, Hashable {

public var _internal: Bool
public var additional: [String: RawJSON]?
public var category: String?
public var component: String?
public var description: String
public var endTimestamp: Int
public var issueTags: [String]?
public var kind: String?
public var severity: Int
public var timestamp: Int
public var type: String

public init(
_internal: Bool,
additional: [String: RawJSON]? = nil,
category: String? = nil,
component: String? = nil,
description: String,
endTimestamp: Int,
issueTags: [String]? = nil,
kind: String? = nil,
severity: Int,
timestamp: Int,
type: String
) {
self._internal = _internal
self.additional = additional
self.category = category
self.component = component
self.description = description
self.endTimestamp = endTimestamp
self.issueTags = issueTags
self.kind = kind
self.severity = severity
self.timestamp = timestamp
self.type = type
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case _internal = "internal"
case additional
case category
case component
case description
case endTimestamp = "end_timestamp"
case issueTags = "issue_tags"
case kind
case severity
case timestamp
case type
}

public static func == (lhs: CallEvent, rhs: CallEvent) -> Bool {
lhs._internal == rhs._internal &&
lhs.additional == rhs.additional &&
lhs.category == rhs.category &&
lhs.component == rhs.component &&
lhs.description == rhs.description &&
lhs.endTimestamp == rhs.endTimestamp &&
lhs.issueTags == rhs.issueTags &&
lhs.kind == rhs.kind &&
lhs.severity == rhs.severity &&
lhs.timestamp == rhs.timestamp &&
lhs.type == rhs.type
}

public func hash(into hasher: inout Hasher) {
hasher.combine(_internal)
hasher.combine(additional)
hasher.combine(category)
hasher.combine(component)
hasher.combine(description)
hasher.combine(endTimestamp)
hasher.combine(issueTags)
hasher.combine(kind)
hasher.combine(severity)
hasher.combine(timestamp)
hasher.combine(type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public final class CallResponse: @unchecked Sendable, Codable, JSONEncodable, Ha

public var backstage: Bool
public var blockedUserIds: [String]
public var captioning: Bool?
public var cid: String
public var createdAt: Date
public var createdBy: UserResponse
Expand All @@ -31,6 +32,7 @@ public final class CallResponse: @unchecked Sendable, Codable, JSONEncodable, Ha
public init(
backstage: Bool,
blockedUserIds: [String],
captioning: Bool? = nil,
cid: String,
createdAt: Date,
createdBy: UserResponse,
Expand All @@ -53,6 +55,7 @@ public final class CallResponse: @unchecked Sendable, Codable, JSONEncodable, Ha
) {
self.backstage = backstage
self.blockedUserIds = blockedUserIds
self.captioning = captioning
self.cid = cid
self.createdAt = createdAt
self.createdBy = createdBy
Expand All @@ -77,6 +80,7 @@ public final class CallResponse: @unchecked Sendable, Codable, JSONEncodable, Ha
public enum CodingKeys: String, CodingKey, CaseIterable {
case backstage
case blockedUserIds = "blocked_user_ids"
case captioning
case cid
case createdAt = "created_at"
case createdBy = "created_by"
Expand All @@ -101,6 +105,7 @@ public final class CallResponse: @unchecked Sendable, Codable, JSONEncodable, Ha
public static func == (lhs: CallResponse, rhs: CallResponse) -> Bool {
lhs.backstage == rhs.backstage &&
lhs.blockedUserIds == rhs.blockedUserIds &&
lhs.captioning == rhs.captioning &&
lhs.cid == rhs.cid &&
lhs.createdAt == rhs.createdAt &&
lhs.createdBy == rhs.createdBy &&
Expand All @@ -125,6 +130,7 @@ public final class CallResponse: @unchecked Sendable, Codable, JSONEncodable, Ha
public func hash(into hasher: inout Hasher) {
hasher.combine(backstage)
hasher.combine(blockedUserIds)
hasher.combine(captioning)
hasher.combine(cid)
hasher.combine(createdAt)
hasher.combine(createdBy)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ public enum OwnCapability: String, Sendable, Codable, CaseIterable {
case sendAudio = "send-audio"
case sendVideo = "send-video"
case startBroadcastCall = "start-broadcast-call"
case startClosedCaptionsCall = "start-closed-captions-call"
case startRecordCall = "start-record-call"
case startTranscriptionCall = "start-transcription-call"
case stopBroadcastCall = "stop-broadcast-call"
case stopClosedCaptionsCall = "stop-closed-captions-call"
case stopRecordCall = "stop-record-call"
case stopTranscriptionCall = "stop-transcription-call"
case updateCall = "update-call"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Copyright © 2024 Stream.io Inc. All rights reserved.
//

import Foundation

public final class StartClosedCaptionsResponse: @unchecked Sendable, Codable, JSONEncodable, Hashable {

public var duration: String

public init(duration: String) {
self.duration = duration
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case duration
}

public static func == (lhs: StartClosedCaptionsResponse, rhs: StartClosedCaptionsResponse) -> Bool {
lhs.duration == rhs.duration
}

public func hash(into hasher: inout Hasher) {
hasher.combine(duration)
}
}
Loading

0 comments on commit 05fe4e1

Please sign in to comment.