fix ios ci test callsdpnormalization
This commit is contained in:
1 parent
85c06165e8
commit
10e18eecb6
2 files changed
+52
-38
No files matched your search
@@ -1631,18 +1631,19 @@ enum CallSDPOrdering {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum CallSDPNormalization {
|
enum CallSDPNormalization {
|
||||||
/// Martin 3.2.4 expects CRLF between lines and unconditionally drops the
|
|
||||||
/// final two characters of its input. Give it one, and only one, trailing
|
|
||||||
/// CRLF so the last character of an SSRC/MSID value is never discarded.
|
|
||||||
static func martinParseInput(_ webRTCSDP: String) -> String {
|
static func martinParseInput(_ webRTCSDP: String) -> String {
|
||||||
var normalized =
|
let lfNormalized =
|
||||||
webRTCSDP
|
webRTCSDP
|
||||||
.replacingOccurrences(of: "\r\n", with: "\n")
|
.replacingOccurrences(of: "\r\n", with: "\n")
|
||||||
.replacingOccurrences(of: "\r", with: "\n")
|
.replacingOccurrences(of: "\r", with: "\n")
|
||||||
while normalized.hasSuffix("\n") {
|
|
||||||
normalized.removeLast()
|
var lines = lfNormalized.components(separatedBy: "\n")
|
||||||
|
|
||||||
|
while lines.last?.isEmpty == true {
|
||||||
|
lines.removeLast()
|
||||||
}
|
}
|
||||||
return normalized.replacingOccurrences(of: "\n", with: "\r\n") + "\r\n"
|
|
||||||
|
return lines.joined(separator: "\r\n") + "\r\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import XCTest
|
import XCTest
|
||||||
|
|
||||||
@testable import Luma
|
@testable import Luma
|
||||||
|
|
||||||
final class CallSDPOrderingTests: XCTestCase {
|
final class CallSDPOrderingTests: XCTestCase {
|
||||||
@@ -49,18 +50,27 @@ final class CallSDPOrderingTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testMartinParseInputPreservesFinalMSIDCharacter() {
|
func testMartinParseInputPreservesFinalMSIDCharacter() {
|
||||||
let raw = [
|
let raw =
|
||||||
"v=0",
|
[
|
||||||
"m=video 9 UDP/TLS/RTP/SAVPF 96",
|
"v=0",
|
||||||
"a=ssrc-group:FID 2408145738 2025569816",
|
"m=video 9 UDP/TLS/RTP/SAVPF 96",
|
||||||
"a=ssrc:2408145738 msid:luma-stream luma-video-0435",
|
"a=ssrc-group:FID 2408145738 2025569816",
|
||||||
"a=ssrc:2025569816 msid:luma-stream luma-video-0435"
|
"a=ssrc:2408145738 msid:luma-stream luma-video-0435",
|
||||||
].joined(separator: "\r\n") + "\n"
|
"a=ssrc:2025569816 msid:luma-stream luma-video-0435",
|
||||||
|
].joined(separator: "\r\n") + "\n"
|
||||||
|
|
||||||
let parseInput = CallSDPNormalization.martinParseInput(raw)
|
let result = CallSDPNormalization.martinParseInput(raw)
|
||||||
|
|
||||||
XCTAssertTrue(parseInput.hasSuffix("luma-video-0435\r\n"))
|
let expected =
|
||||||
XCTAssertTrue(String(parseInput.dropLast(2)).hasSuffix("luma-video-0435"))
|
[
|
||||||
|
"v=0",
|
||||||
|
"m=video 9 UDP/TLS/RTP/SAVPF 96",
|
||||||
|
"a=ssrc-group:FID 2408145738 2025569816",
|
||||||
|
"a=ssrc:2408145738 msid:luma-stream luma-video-0435",
|
||||||
|
"a=ssrc:2025569816 msid:luma-stream luma-video-0435",
|
||||||
|
].joined(separator: "\r\n") + "\r\n"
|
||||||
|
|
||||||
|
XCTAssertEqual(result, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testMartinParseInputUsesExactlyOneTrailingCRLF() {
|
func testMartinParseInputUsesExactlyOneTrailingCRLF() {
|
||||||
@@ -80,7 +90,7 @@ final class CallSDPOrderingTests: XCTestCase {
|
|||||||
],
|
],
|
||||||
msids: [
|
msids: [
|
||||||
"primary": "luma-stream luma-video-9FBECB58-45C5-445B-9F4E-0598594F4F2D",
|
"primary": "luma-stream luma-video-9FBECB58-45C5-445B-9F4E-0598594F4F2D",
|
||||||
"rtx": "luma-stream luma-video-9FBECB58-45C5-445B-9F4E-0598594F4F2"
|
"rtx": "luma-stream luma-video-9FBECB58-45C5-445B-9F4E-0598594F4F2",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -92,12 +102,12 @@ final class CallSDPOrderingTests: XCTestCase {
|
|||||||
let repaired = CallSDPCompatibility.canonicalFIDMSIDs(
|
let repaired = CallSDPCompatibility.canonicalFIDMSIDs(
|
||||||
groups: [
|
groups: [
|
||||||
.init(semantics: "fid", sources: ["primary", "rtx"]),
|
.init(semantics: "fid", sources: ["primary", "rtx"]),
|
||||||
.init(semantics: "SIM", sources: ["sim-a", "sim-b"])
|
.init(semantics: "SIM", sources: ["sim-a", "sim-b"]),
|
||||||
],
|
],
|
||||||
msids: [
|
msids: [
|
||||||
"primary": "stream video-track",
|
"primary": "stream video-track",
|
||||||
"sim-a": "stream camera-a",
|
"sim-a": "stream camera-a",
|
||||||
"sim-b": "stream camera-b"
|
"sim-b": "stream camera-b",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -107,26 +117,29 @@ final class CallSDPOrderingTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testCandidateDispatchWaitsForRemoteAnswerAndFullJID() {
|
func testCandidateDispatchWaitsForRemoteAnswerAndFullJID() {
|
||||||
XCTAssertFalse(CallCandidateDispatchGate.canSend(
|
XCTAssertFalse(
|
||||||
initialDescriptionWasSignaled: true,
|
CallCandidateDispatchGate.canSend(
|
||||||
hasLocalDescription: true,
|
initialDescriptionWasSignaled: true,
|
||||||
hasRemoteDescription: false,
|
hasLocalDescription: true,
|
||||||
hasFullPeerJID: true
|
hasRemoteDescription: false,
|
||||||
))
|
hasFullPeerJID: true
|
||||||
XCTAssertFalse(CallCandidateDispatchGate.canSend(
|
))
|
||||||
initialDescriptionWasSignaled: true,
|
XCTAssertFalse(
|
||||||
hasLocalDescription: true,
|
CallCandidateDispatchGate.canSend(
|
||||||
hasRemoteDescription: true,
|
initialDescriptionWasSignaled: true,
|
||||||
hasFullPeerJID: false
|
hasLocalDescription: true,
|
||||||
))
|
hasRemoteDescription: true,
|
||||||
|
hasFullPeerJID: false
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
func testCandidateDispatchOpensAfterSessionAccept() {
|
func testCandidateDispatchOpensAfterSessionAccept() {
|
||||||
XCTAssertTrue(CallCandidateDispatchGate.canSend(
|
XCTAssertTrue(
|
||||||
initialDescriptionWasSignaled: true,
|
CallCandidateDispatchGate.canSend(
|
||||||
hasLocalDescription: true,
|
initialDescriptionWasSignaled: true,
|
||||||
hasRemoteDescription: true,
|
hasLocalDescription: true,
|
||||||
hasFullPeerJID: true
|
hasRemoteDescription: true,
|
||||||
))
|
hasFullPeerJID: true
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user