Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ init(
url: String,
credentials: Credentials? = nil,
transport: Transport = .tcp,
sessionIdPolicy: SessionIdPolicy = .defaultPolicy,
userAgent: String = "IPCamKit")

func start() async throws -> SessionDescription
Expand All @@ -63,16 +62,6 @@ enum Transport: Sendable {
}
```

### SessionIdPolicy

```swift
enum SessionIdPolicy: Sendable {
case defaultPolicy // Currently requireMatch
case requireMatch // Same session ID for all SETUP requests
case useFirst // Use first SETUP session ID, ignore changes
}
```

## Session Description

Returned by `start()` with stream metadata parsed from SDP.
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog

## 0.1.2
## 0.2.0

### Breaking changes

- Remove `SessionIdPolicy` enum and the `sessionIdPolicy:` parameter from `RTSPClientSession.init`. Audio SETUP responses that return a different session ID are now always accepted (latest wins) instead of being a configurable choice.

### Improvements

Expand Down
23 changes: 1 addition & 22 deletions Sources/IPCamKit/Client/RTSPSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,34 +61,22 @@ public struct SessionDescription: Sendable {
/// }
/// await session.stop()
/// ```
public enum SessionIdPolicy: Sendable {
/// Default policy: currently requireMatch.
case defaultPolicy
/// Requires the server to return the same session ID for all SETUP requests.
case requireMatch
/// Uses the session ID returned from the first SETUP request and ignores subsequent changes.
case useFirst
}

public final class RTSPClientSession: Sendable {
private let url: String
private let credentials: Credentials?
private let transport: Transport
private let sessionIdPolicy: SessionIdPolicy
private let userAgent: String
private let state: SessionState

public init(
url: String,
credentials: Credentials? = nil,
transport: Transport = .tcp,
sessionIdPolicy: SessionIdPolicy = .defaultPolicy,
userAgent: String = "IPCamKit"
) {
self.url = url
self.credentials = credentials
self.transport = transport
self.sessionIdPolicy = sessionIdPolicy
self.userAgent = userAgent
self.state = SessionState()
}
Expand All @@ -101,7 +89,6 @@ public final class RTSPClientSession: Sendable {
url: url,
credentials: credentials,
transport: transport,
sessionIdPolicy: sessionIdPolicy,
userAgent: userAgent
)
}
Expand Down Expand Up @@ -247,7 +234,6 @@ actor SessionState {
url: String,
credentials: Credentials?,
transport: Transport,
sessionIdPolicy: SessionIdPolicy,
userAgent: String
) async throws -> SessionDescription {
// Parse URL
Expand Down Expand Up @@ -343,14 +329,7 @@ actor SessionState {
method: .setup, url: audioSetupURL,
extraHeaders: audioSetupHeaders)
let audioSetup = try parseSetup(response: audioSetupResp)
if let sid = sessionId, sid != audioSetup.session.id {
if sessionIdPolicy == .useFirst {
// Ignore the new session ID
} else {
throw RTSPError.sessionSetupFailed(
statusCode: 0, reason: "Session ID changed from \(sid) to \(audioSetup.session.id)")
}
}
sessionId = audioSetup.session.id
audioSetupSSRC = audioSetup.ssrc
presMut.streams[audioIdx].state = .setup(
StreamStateInit(ssrc: audioSetup.ssrc, initialSeq: nil, initialRtptime: nil, ctx: .dummy))
Expand Down
Loading