-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2079691
commit 8a2a853
Showing
9 changed files
with
1,885 additions
and
1,660 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
StreamVideoTests/WebRTC/v2/SDP Parsing/SDPParser_Tests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// | ||
// Copyright © 2024 Stream.io Inc. All rights reserved. | ||
// | ||
|
||
@testable import StreamVideo | ||
import XCTest | ||
|
||
final class SDPParser_Tests: XCTestCase { | ||
|
||
private var visitor: RTPMapVisitor! = .init() | ||
private var subject: SDPParser! = .init() | ||
|
||
override func setUp() { | ||
super.setUp() | ||
subject.registerVisitor(visitor) | ||
} | ||
|
||
override func tearDown() { | ||
subject = nil | ||
visitor = nil | ||
super.tearDown() | ||
} | ||
|
||
// MARK: - parse(sdp:) | ||
|
||
func test_parse_withValidSDP() async { | ||
let sdp = "v=0\r\no=- 46117317 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=rtpmap:96 opus/48000/2\r\na=rtpmap:97 VP8/90000\r\n" | ||
await subject.parse(sdp: sdp) | ||
XCTAssertEqual(visitor.payloadType(for: "opus"), 96) | ||
XCTAssertEqual(visitor.payloadType(for: "vp8"), 97) | ||
} | ||
|
||
func test_parse_withInvalidSDP() async { | ||
let sdp = """ | ||
v=0 | ||
o=- 46117317 2 IN IP4 127.0.0.1 | ||
s=- | ||
t=0 0 | ||
a=invalid:96 opus/48000/2 | ||
""" | ||
await subject.parse(sdp: sdp) | ||
XCTAssertNil(visitor.payloadType(for: "opus")) | ||
} | ||
|
||
func test_parse_withMultipleVisitors() async { | ||
let sdp = "v=0\r\no=- 46117317 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=rtpmap:96 opus/48000/2\r\na=rtpmap:97 VP8/90000\r\n" | ||
let visitor1 = RTPMapVisitor() | ||
let visitor2 = RTPMapVisitor() | ||
subject.registerVisitor(visitor1) | ||
subject.registerVisitor(visitor2) | ||
await subject.parse(sdp: sdp) | ||
XCTAssertEqual(visitor1.payloadType(for: "opus"), 96) | ||
XCTAssertEqual(visitor1.payloadType(for: "vp8"), 97) | ||
XCTAssertEqual(visitor2.payloadType(for: "opus"), 96) | ||
XCTAssertEqual(visitor2.payloadType(for: "vp8"), 97) | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
StreamVideoTests/WebRTC/v2/SDP Parsing/SupportedPrefix_Tests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// Copyright © 2024 Stream.io Inc. All rights reserved. | ||
// | ||
|
||
@testable import StreamVideo | ||
import XCTest | ||
|
||
final class SupportedPrefix_Tests: XCTestCase { | ||
|
||
// MARK: - SupportedPrefix Cases | ||
|
||
func test_supportedPrefixCases() { | ||
XCTAssertEqual(SupportedPrefix.rtmap.rawValue, "a=rtpmap:") | ||
} | ||
|
||
// MARK: - SupportedPrefix Set | ||
|
||
func test_supportedPrefixSetContainsRtmap() { | ||
let supportedPrefixes: Set<SupportedPrefix> = [.rtmap] | ||
XCTAssertTrue(supportedPrefixes.contains(.rtmap)) | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
StreamVideoTests/WebRTC/v2/SDP Parsing/Visitors/RTPMapVisitorTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// | ||
// Copyright © 2024 Stream.io Inc. All rights reserved. | ||
// | ||
|
||
@testable import StreamVideo | ||
import XCTest | ||
|
||
final class RTPMapVisitor_Tests: XCTestCase { | ||
|
||
private var subject: RTPMapVisitor! = .init() | ||
|
||
override func tearDown() { | ||
subject = nil | ||
super.tearDown() | ||
} | ||
|
||
// MARK: - visit(line:) | ||
|
||
func test_visit_withValidRTPMapLine() { | ||
let line = "a=rtpmap:96 opus/48000/2" | ||
subject.visit(line: line) | ||
XCTAssertEqual(subject.payloadType(for: "opus"), 96) | ||
} | ||
|
||
func test_visit_withInvalidRTPMapLine() { | ||
let line = "a=rtpmap:invalid opus/48000/2" | ||
subject.visit(line: line) | ||
XCTAssertNil(subject.payloadType(for: "opus")) | ||
} | ||
|
||
func test_visit_withMissingCodecName() { | ||
let line = "a=rtpmap:96" | ||
subject.visit(line: line) | ||
XCTAssertNil(subject.payloadType(for: "")) | ||
} | ||
|
||
func test_visit_withMultipleRTPMapLines() { | ||
let lines = [ | ||
"a=rtpmap:96 opus/48000/2", | ||
"a=rtpmap:97 VP8/90000", | ||
"a=rtpmap:98 H264/90000" | ||
] | ||
lines.forEach { subject.visit(line: $0) } | ||
XCTAssertEqual(subject.payloadType(for: "opus"), 96) | ||
XCTAssertEqual(subject.payloadType(for: "vp8"), 97) | ||
XCTAssertEqual(subject.payloadType(for: "h264"), 98) | ||
} | ||
|
||
// MARK: - payloadType(for:) | ||
|
||
func test_payloadType_forExistingCodec() { | ||
let line = "a=rtpmap:96 opus/48000/2" | ||
subject.visit(line: line) | ||
XCTAssertEqual(subject.payloadType(for: "opus"), 96) | ||
} | ||
|
||
func test_payloadType_forNonExistingCodec() { | ||
XCTAssertNil(subject.payloadType(for: "nonexistent")) | ||
} | ||
} |
Oops, something went wrong.