Skip to content

Commit

Permalink
forwarding_filters 対応
Browse files Browse the repository at this point in the history
  • Loading branch information
zztkm committed Dec 26, 2024
1 parent 306c5c1 commit 8d99fc7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Sora/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ public struct Configuration {

/// 転送フィルターの設定
public var forwardingFilter: ForwardingFilter?

/// リスト形式の転送フィルターの設定
public var forwardingFilters: [ForwardingFilter]?

/// VP9 向け映像コーデックパラメーター
public var videoVp9Params: Encodable?
Expand Down Expand Up @@ -323,6 +326,12 @@ public enum ForwardingFilterAction: String, Encodable {
転送フィルターに関する設定です。
*/
public struct ForwardingFilter {
/// name
public var name: String?

/// priority
public var priority: Int?

/// action
public var action: ForwardingFilterAction?

Expand All @@ -343,7 +352,9 @@ public struct ForwardingFilter {
- parameter version: version (オプショナル)
- parameter metadata: metadata (オプショナル)
*/
public init(action: ForwardingFilterAction? = nil, rules: [[ForwardingFilterRule]], version: String? = nil, metadata: Encodable? = nil) {
public init(name: String? = nil, priority: Int? = nil, action: ForwardingFilterAction? = nil, rules: [[ForwardingFilterRule]], version: String? = nil, metadata: Encodable? = nil) {
self.name = name
self.priority = priority
self.action = action
self.rules = rules
self.version = version
Expand All @@ -353,6 +364,8 @@ public struct ForwardingFilter {

extension ForwardingFilter: Encodable {
enum CodingKeys: String, CodingKey {
case name
case priority
case action
case rules
case version
Expand All @@ -361,6 +374,8 @@ extension ForwardingFilter: Encodable {

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(name, forKey: .name)
try container.encodeIfPresent(priority, forKey: .priority)
try container.encodeIfPresent(action, forKey: .action)
try container.encode(rules, forKey: .rules)
try container.encodeIfPresent(version, forKey: .version)
Expand Down
1 change: 1 addition & 0 deletions Sora/PeerChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ class PeerChannel: NSObject, RTCPeerConnectionDelegate {
audioStreamingLanguageCode: configuration.audioStreamingLanguageCode,
redirect: redirect,
forwardingFilter: configuration.forwardingFilter,
forwardingFilters: configuration.forwardingFilters,
vp9Params: configuration.videoVp9Params,
av1Params: configuration.videoAv1Params,
h264Params: configuration.videoH264Params
Expand Down
5 changes: 5 additions & 0 deletions Sora/Signaling.swift
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ public struct SignalingConnect {

/// 転送フィルターの設定
public var forwardingFilter: ForwardingFilter?

/// リスト形式の転送フィルターの設定
public var forwardingFilters: [ForwardingFilter]?

/// VP9 向け映像コーデックパラメーター
public var vp9Params: Encodable?
Expand Down Expand Up @@ -784,6 +787,7 @@ extension SignalingConnect: Codable {
case audio_streaming_language_code
case redirect
case forwarding_filter
case forwarding_filters
}

enum VideoCodingKeys: String, CodingKey {
Expand Down Expand Up @@ -834,6 +838,7 @@ extension SignalingConnect: Codable {
try container.encodeIfPresent(audioStreamingLanguageCode, forKey: .audio_streaming_language_code)
try container.encodeIfPresent(redirect, forKey: .redirect)
try container.encodeIfPresent(forwardingFilter, forKey: .forwarding_filter)
try container.encodeIfPresent(forwardingFilters, forKey: .forwarding_filters)

if videoEnabled {
if videoCodec != .default || videoBitRate != nil || vp9Params != nil || av1Params != nil || h264Params != nil {
Expand Down

0 comments on commit 8d99fc7

Please sign in to comment.