@@ -19,7 +19,31 @@ type TrackLocalWriter interface {
19
19
20
20
// TrackLocalContext is the Context passed when a TrackLocal has been Binded/Unbinded from a PeerConnection, and used
21
21
// in Interceptors.
22
- type TrackLocalContext struct {
22
+ type TrackLocalContext interface {
23
+ // CodecParameters returns the negotiated RTPCodecParameters. These are the codecs supported by both
24
+ // PeerConnections and the SSRC/PayloadTypes
25
+ CodecParameters () []RTPCodecParameters
26
+
27
+ // HeaderExtensions returns the negotiated RTPHeaderExtensionParameters. These are the header extensions supported by
28
+ // both PeerConnections and the SSRC/PayloadTypes
29
+ HeaderExtensions () []RTPHeaderExtensionParameter
30
+
31
+ // SSRC requires the negotiated SSRC of this track
32
+ // This track may have multiple if RTX is enabled
33
+ SSRC () SSRC
34
+
35
+ // WriteStream returns the WriteStream for this TrackLocal. The implementer writes the outbound
36
+ // media packets to it
37
+ WriteStream () TrackLocalWriter
38
+
39
+ // ID is a unique identifier that is used for both Bind/Unbind
40
+ ID () string
41
+
42
+ // RTCPReader returns the RTCP interceptor for this TrackLocal. Used to read RTCP of this TrackLocal.
43
+ RTCPReader () interceptor.RTCPReader
44
+ }
45
+
46
+ type baseTrackLocalContext struct {
23
47
id string
24
48
params RTPParameters
25
49
ssrc SSRC
@@ -29,35 +53,35 @@ type TrackLocalContext struct {
29
53
30
54
// CodecParameters returns the negotiated RTPCodecParameters. These are the codecs supported by both
31
55
// PeerConnections and the SSRC/PayloadTypes
32
- func (t * TrackLocalContext ) CodecParameters () []RTPCodecParameters {
56
+ func (t * baseTrackLocalContext ) CodecParameters () []RTPCodecParameters {
33
57
return t .params .Codecs
34
58
}
35
59
36
60
// HeaderExtensions returns the negotiated RTPHeaderExtensionParameters. These are the header extensions supported by
37
61
// both PeerConnections and the SSRC/PayloadTypes
38
- func (t * TrackLocalContext ) HeaderExtensions () []RTPHeaderExtensionParameter {
62
+ func (t * baseTrackLocalContext ) HeaderExtensions () []RTPHeaderExtensionParameter {
39
63
return t .params .HeaderExtensions
40
64
}
41
65
42
66
// SSRC requires the negotiated SSRC of this track
43
67
// This track may have multiple if RTX is enabled
44
- func (t * TrackLocalContext ) SSRC () SSRC {
68
+ func (t * baseTrackLocalContext ) SSRC () SSRC {
45
69
return t .ssrc
46
70
}
47
71
48
72
// WriteStream returns the WriteStream for this TrackLocal. The implementer writes the outbound
49
73
// media packets to it
50
- func (t * TrackLocalContext ) WriteStream () TrackLocalWriter {
74
+ func (t * baseTrackLocalContext ) WriteStream () TrackLocalWriter {
51
75
return t .writeStream
52
76
}
53
77
54
78
// ID is a unique identifier that is used for both Bind/Unbind
55
- func (t * TrackLocalContext ) ID () string {
79
+ func (t * baseTrackLocalContext ) ID () string {
56
80
return t .id
57
81
}
58
82
59
83
// RTCPReader returns the RTCP interceptor for this TrackLocal. Used to read RTCP of this TrackLocal.
60
- func (t * TrackLocalContext ) RTCPReader () interceptor.RTCPReader {
84
+ func (t * baseTrackLocalContext ) RTCPReader () interceptor.RTCPReader {
61
85
return t .rtcpInterceptor
62
86
}
63
87
0 commit comments