Skip to content

Commit 515f40c

Browse files
committed
WIP: scaleResolutionDownTo 追加中
1 parent 6a6bf12 commit 515f40c

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
## develop
1313

14+
- [ADD] サイマルキャストの映像のエンコーディングパラメーター `scaleResolutionDownTo` を追加する
15+
- @zztkm
1416
- [UPDATE] WebRTC m132.6834.5.3 に上げる
1517
- @zztkm
1618
- [CHANGE] connect メッセージの `multistream` を true 固定で送信する処理を削除する破壊的変更

Sora/PeerChannel.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,11 @@ extension RTCRtpSender {
12071207
Logger.debug(type: .peerChannel, message: "scaleResolutionDownBy: \(value)")
12081208
oldEncoding.scaleResolutionDownBy = NSNumber(value: value)
12091209
}
1210+
1211+
if let value = encoding.scaleResolutionDownTo {
1212+
Logger.debug(type: .peerChannel, message: "scaleResolutionDownTo: \(ObjectIdentifier(value))")
1213+
oldEncoding.scaleResolutionDownTo = value
1214+
}
12101215

12111216
if let value = encoding.scalabilityMode {
12121217
Logger.debug(type: .peerChannel, message: "scalabilityMode: \(value)")

Sora/Signaling.swift

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,9 @@ public struct SignalingOffer {
388388
/// 映像解像度を送信前に下げる度合
389389
public let scaleResolutionDownBy: Double?
390390

391+
/// 解像度の
392+
public let scaleResolutionDownTo: RTCResolutionRestriction?
393+
391394
/// scalability mode
392395
public let scalabilityMode: String?
393396

@@ -404,6 +407,9 @@ public struct SignalingOffer {
404407
if let value = scaleResolutionDownBy {
405408
params.scaleResolutionDownBy = NSNumber(value: value)
406409
}
410+
if let value = scaleResolutionDownTo {
411+
params.scaleResolutionDownTo = value
412+
}
407413
params.scalabilityMode = scalabilityMode
408414
return params
409415
}
@@ -981,6 +987,24 @@ extension SignalingOffer.Configuration: Codable {
981987
}
982988
}
983989

990+
fileprivate struct ScaleResolutionDownTo {
991+
fileprivate let maxWidth: Int
992+
fileprivate let maxHeight: Int
993+
}
994+
995+
extension ScaleResolutionDownTo: Codable {
996+
enum CodingKeys: String, CodingKey {
997+
case maxWidth
998+
case maxHeight
999+
}
1000+
1001+
public init(from decoder: Decoder) throws {
1002+
let container = try decoder.container(keyedBy: CodingKeys.self)
1003+
maxWidth = try container.decode(Int.self, forKey: .maxWidth)
1004+
maxHeight = try container.decode(Int.self, forKey: .maxHeight)
1005+
}
1006+
}
1007+
9841008
/// :nodoc:
9851009
extension SignalingOffer.Encoding: Codable {
9861010
enum CodingKeys: String, CodingKey {
@@ -989,19 +1013,28 @@ extension SignalingOffer.Encoding: Codable {
9891013
case maxBitrate
9901014
case maxFramerate
9911015
case scaleResolutionDownBy
1016+
case scaleResolutionDownTo
9921017
case scalabilityMode
9931018
}
994-
1019+
9951020
public init(from decoder: Decoder) throws {
9961021
let container = try decoder.container(keyedBy: CodingKeys.self)
9971022
rid = try container.decodeIfPresent(String.self, forKey: .rid)
9981023
active = try container.decodeIfPresent(Bool.self, forKey: .active) ?? true
9991024
maxBitrate = try container.decodeIfPresent(Int.self, forKey: .maxBitrate)
10001025
maxFramerate = try container.decodeIfPresent(Double.self, forKey: .maxFramerate)
1001-
scaleResolutionDownBy = try container.decodeIfPresent(Double.self,
1002-
forKey: .scaleResolutionDownBy)
1003-
scalabilityMode = try container.decodeIfPresent(String.self,
1004-
forKey: .scalabilityMode)
1026+
scaleResolutionDownBy = try container.decodeIfPresent(Double.self, forKey: .scaleResolutionDownBy)
1027+
1028+
if let _scleResolutionDownTo = try container.decodeIfPresent(ScaleResolutionDownTo.self, forKey: .scaleResolutionDownTo) {
1029+
let restriction = RTCResolutionRestriction()
1030+
restriction.maxWidth = NSNumber(value: _scleResolutionDownTo.maxWidth)
1031+
restriction.maxHeight = NSNumber(value: _scleResolutionDownTo.maxHeight)
1032+
scaleResolutionDownTo = restriction
1033+
} else {
1034+
scaleResolutionDownTo = nil
1035+
}
1036+
1037+
scalabilityMode = try container.decodeIfPresent(String.self, forKey: .scalabilityMode)
10051038
}
10061039

10071040
public func encode(to encoder: Encoder) throws {

0 commit comments

Comments
 (0)