@@ -57,6 +57,15 @@ public struct Origin: Equatable, CustomStringConvertible {
57
57
return
58
58
" \( self . username) \( self . sessionId) \( self . sessionVersion) \( self . networkType) \( self . addressType) \( self . unicastAddress) "
59
59
}
60
+
61
+ public init ( username: String , sessionId: UInt64 , sessionVersion: UInt64 , networkType: String , addressType: String , unicastAddress: String ) {
62
+ self . username = username
63
+ self . sessionId = sessionId
64
+ self . sessionVersion = sessionVersion
65
+ self . networkType = networkType
66
+ self . addressType = addressType
67
+ self . unicastAddress = unicastAddress
68
+ }
60
69
}
61
70
62
71
/// SessionName describes a structured representations for the "s=" field
@@ -82,6 +91,11 @@ public struct TimeZone: Equatable, CustomStringConvertible {
82
91
public var description : String {
83
92
return " \( self . adjustmentTime) \( self . offset) "
84
93
}
94
+
95
+ public init ( adjustmentTime: UInt64 , offset: Int64 ) {
96
+ self . adjustmentTime = adjustmentTime
97
+ self . offset = offset
98
+ }
85
99
}
86
100
87
101
/// Timing defines the "t=" field's structured representation for the start and
@@ -93,6 +107,11 @@ public struct Timing: Equatable, CustomStringConvertible {
93
107
public var description : String {
94
108
return " \( self . startTime) \( self . stopTime) "
95
109
}
110
+
111
+ public init ( startTime: UInt64 , stopTime: UInt64 ) {
112
+ self . startTime = startTime
113
+ self . stopTime = stopTime
114
+ }
96
115
}
97
116
98
117
/// RepeatTime describes the "r=" fields of the session description which
@@ -109,6 +128,12 @@ public struct RepeatTime: Equatable, CustomStringConvertible {
109
128
}
110
129
return output
111
130
}
131
+
132
+ public init ( interval: Int64 , duration: Int64 , offsets: [ Int64 ] ) {
133
+ self . interval = interval
134
+ self . duration = duration
135
+ self . offsets = offsets
136
+ }
112
137
}
113
138
114
139
/// TimeDescription describes "t=", "r=" fields of the session description
@@ -132,13 +157,18 @@ public struct TimeDescription: Equatable, CustomStringConvertible {
132
157
}
133
158
return result
134
159
}
160
+
161
+ public init ( timing: Timing , repeatTimes: [ RepeatTime ] ) {
162
+ self . timing = timing
163
+ self . repeatTimes = repeatTimes
164
+ }
135
165
}
136
166
137
167
/// https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-26#section-5.2.1
138
168
/// Session ID is recommended to be constructed by generating a 64-bit
139
169
/// quantity with the highest bit set to zero and the remaining 63-bits
140
170
/// being cryptographically random.
141
- func newSessionId( ) -> UInt64 {
171
+ public func newSessionId( ) -> UInt64 {
142
172
let c = UInt64 . max ^ ( UInt64 ( 1 ) << 63 )
143
173
return UInt64 . random ( in: UInt64 . min... UInt64 . max) & c
144
174
}
@@ -229,7 +259,7 @@ public struct SessionDescription: Equatable, CustomStringConvertible {
229
259
return self . marshal ( )
230
260
}
231
261
232
- init ( ) {
262
+ public init ( ) {
233
263
self . version = 0
234
264
self . origin = Origin (
235
265
username: " " ,
@@ -253,7 +283,7 @@ public struct SessionDescription: Equatable, CustomStringConvertible {
253
283
self . mediaDescriptions = [ ]
254
284
}
255
285
256
- init ( identity: Bool ) {
286
+ public init ( identity: Bool ) {
257
287
self . version = 0
258
288
self . origin = Origin (
259
289
username: " - " ,
@@ -285,7 +315,7 @@ public struct SessionDescription: Equatable, CustomStringConvertible {
285
315
self . mediaDescriptions = [ ]
286
316
}
287
317
288
- init ( version: Version ,
318
+ public init ( version: Version ,
289
319
origin: Origin ,
290
320
sessionName: SessionName ,
291
321
sessionInformation: Information ? = nil ,
0 commit comments