Skip to content

Commit 498edd0

Browse files
committed
Stability improvements made by reverting channelized packet distribution to queue based.
2 parents 53887a9 + 87c27af commit 498edd0

40 files changed

Lines changed: 1027 additions & 843 deletions

go.mod

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,25 @@ require (
77
github.com/joho/godotenv v1.5.1
88
github.com/pion/dtls/v3 v3.0.7
99
github.com/pion/ice/v4 v4.0.10
10-
github.com/pion/interceptor v0.1.41
10+
github.com/pion/interceptor v0.1.42
1111
github.com/pion/rtcp v1.2.16
12-
github.com/pion/rtp v1.8.24
12+
github.com/pion/rtp v1.8.25
1313
github.com/pion/webrtc/v4 v4.1.6
1414
)
1515

16-
require (
17-
github.com/davecgh/go-spew v1.1.1 // indirect
18-
github.com/pmezard/go-difflib v1.0.0 // indirect
19-
gopkg.in/yaml.v3 v3.0.1 // indirect
20-
)
21-
2216
require (
2317
github.com/pion/datachannel v1.5.10 // indirect
2418
github.com/pion/logging v0.2.4 // indirect
25-
github.com/pion/mdns/v2 v2.0.7 // indirect
19+
github.com/pion/mdns/v2 v2.1.0 // indirect
2620
github.com/pion/randutil v0.1.0 // indirect
2721
github.com/pion/sctp v1.8.40 // indirect
2822
github.com/pion/sdp/v3 v3.0.16
2923
github.com/pion/srtp/v3 v3.0.8 // indirect
30-
github.com/pion/stun/v3 v3.0.0 // indirect
31-
github.com/pion/transport/v3 v3.0.8 // indirect
32-
github.com/pion/turn/v4 v4.1.1 // indirect
33-
github.com/stretchr/testify v1.11.1
24+
github.com/pion/stun/v3 v3.0.1 // indirect
25+
github.com/pion/transport/v3 v3.1.1 // indirect
26+
github.com/pion/turn/v4 v4.1.3 // indirect
3427
github.com/wlynxg/anet v0.0.5 // indirect
35-
golang.org/x/crypto v0.43.0 // indirect
36-
golang.org/x/net v0.46.0 // indirect
37-
golang.org/x/sys v0.37.0 // indirect
28+
golang.org/x/crypto v0.44.0 // indirect
29+
golang.org/x/net v0.47.0 // indirect
30+
golang.org/x/sys v0.38.0 // indirect
3831
)

go.sum

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,60 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
44
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
55
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
66
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
7-
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
8-
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
9-
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
10-
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
117
github.com/pion/datachannel v1.5.10 h1:ly0Q26K1i6ZkGf42W7D4hQYR90pZwzFOjTq5AuCKk4o=
128
github.com/pion/datachannel v1.5.10/go.mod h1:p/jJfC9arb29W7WrxyKbepTU20CFgyx5oLo8Rs4Py/M=
139
github.com/pion/dtls/v3 v3.0.7 h1:bItXtTYYhZwkPFk4t1n3Kkf5TDrfj6+4wG+CZR8uI9Q=
1410
github.com/pion/dtls/v3 v3.0.7/go.mod h1:uDlH5VPrgOQIw59irKYkMudSFprY9IEFCqz/eTz16f8=
1511
github.com/pion/ice/v4 v4.0.10 h1:P59w1iauC/wPk9PdY8Vjl4fOFL5B+USq1+xbDcN6gT4=
1612
github.com/pion/ice/v4 v4.0.10/go.mod h1:y3M18aPhIxLlcO/4dn9X8LzLLSma84cx6emMSu14FGw=
13+
github.com/pion/interceptor v0.1.40 h1:e0BjnPcGpr2CFQgKhrQisBU7V3GXK6wrfYrGYaU6Jq4=
14+
github.com/pion/interceptor v0.1.40/go.mod h1:Z6kqH7M/FYirg3frjGJ21VLSRJGBXB/KqaTIrdqnOic=
1715
github.com/pion/interceptor v0.1.41 h1:NpvX3HgWIukTf2yTBVjVGFXtpSpWgXjqz7IIpu7NsOw=
1816
github.com/pion/interceptor v0.1.41/go.mod h1:nEt4187unvRXJFyjiw00GKo+kIuXMWQI9K89fsosDLY=
17+
github.com/pion/interceptor v0.1.42 h1:0/4tvNtruXflBxLfApMVoMubUMik57VZ+94U0J7cmkQ=
18+
github.com/pion/interceptor v0.1.42/go.mod h1:g6XYTChs9XyolIQFhRHOOUS+bGVGLRfgTCUzH29EfVU=
1919
github.com/pion/logging v0.2.4 h1:tTew+7cmQ+Mc1pTBLKH2puKsOvhm32dROumOZ655zB8=
2020
github.com/pion/logging v0.2.4/go.mod h1:DffhXTKYdNZU+KtJ5pyQDjvOAh/GsNSyv1lbkFbe3so=
2121
github.com/pion/mdns/v2 v2.0.7 h1:c9kM8ewCgjslaAmicYMFQIde2H9/lrZpjBkN8VwoVtM=
2222
github.com/pion/mdns/v2 v2.0.7/go.mod h1:vAdSYNAT0Jy3Ru0zl2YiW3Rm/fJCwIeM0nToenfOJKA=
23+
github.com/pion/mdns/v2 v2.1.0 h1:3IJ9+Xio6tWYjhN6WwuY142P/1jA0D5ERaIqawg/fOY=
24+
github.com/pion/mdns/v2 v2.1.0/go.mod h1:pcez23GdynwcfRU1977qKU0mDxSeucttSHbCSfFOd9A=
2325
github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
2426
github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8=
27+
github.com/pion/rtcp v1.2.15 h1:LZQi2JbdipLOj4eBjK4wlVoQWfrZbh3Q6eHtWtJBZBo=
28+
github.com/pion/rtcp v1.2.15/go.mod h1:jlGuAjHMEXwMUHK78RgX0UmEJFV4zUKOFHR7OP+D3D0=
2529
github.com/pion/rtcp v1.2.16 h1:fk1B1dNW4hsI78XUCljZJlC4kZOPk67mNRuQ0fcEkSo=
2630
github.com/pion/rtcp v1.2.16/go.mod h1:/as7VKfYbs5NIb4h6muQ35kQF/J0ZVNz2Z3xKoCBYOo=
27-
github.com/pion/rtp v1.8.24 h1:+ICyZXUQDv95EsHN70RrA4XKJf5MGWyC6QQc1u6/ynI=
28-
github.com/pion/rtp v1.8.24/go.mod h1:rF5nS1GqbR7H/TCpKwylzeq6yDM+MM6k+On5EgeThEM=
31+
github.com/pion/rtp v1.8.22 h1:8NCVDDF+uSJmMUkjLJVnIr/HX7gPesyMV1xFt5xozXc=
32+
github.com/pion/rtp v1.8.22/go.mod h1:rF5nS1GqbR7H/TCpKwylzeq6yDM+MM6k+On5EgeThEM=
33+
github.com/pion/rtp v1.8.25 h1:b8+y44GNbwOJTYWuVan7SglX/hMlicVCAtL50ztyZHw=
34+
github.com/pion/rtp v1.8.25/go.mod h1:rF5nS1GqbR7H/TCpKwylzeq6yDM+MM6k+On5EgeThEM=
35+
github.com/pion/sctp v1.8.39 h1:PJma40vRHa3UTO3C4MyeJDQ+KIobVYRZQZ0Nt7SjQnE=
36+
github.com/pion/sctp v1.8.39/go.mod h1:cNiLdchXra8fHQwmIoqw0MbLLMs+f7uQ+dGMG2gWebE=
2937
github.com/pion/sctp v1.8.40 h1:bqbgWYOrUhsYItEnRObUYZuzvOMsVplS3oNgzedBlG8=
3038
github.com/pion/sctp v1.8.40/go.mod h1:SPBBUENXE6ThkEksN5ZavfAhFYll+h+66ZiG6IZQuzo=
3139
github.com/pion/sdp/v3 v3.0.16 h1:0dKzYO6gTAvuLaAKQkC02eCPjMIi4NuAr/ibAwrGDCo=
3240
github.com/pion/sdp/v3 v3.0.16/go.mod h1:9tyKzznud3qiweZcD86kS0ff1pGYB3VX+Bcsmkx6IXo=
41+
github.com/pion/srtp/v3 v3.0.7 h1:QUElw0A/FUg3MP8/KNMZB3i0m8F9XeMnTum86F7S4bs=
42+
github.com/pion/srtp/v3 v3.0.7/go.mod h1:qvnHeqbhT7kDdB+OGB05KA/P067G3mm7XBfLaLiaNF0=
3343
github.com/pion/srtp/v3 v3.0.8 h1:RjRrjcIeQsilPzxvdaElN0CpuQZdMvcl9VZ5UY9suUM=
3444
github.com/pion/srtp/v3 v3.0.8/go.mod h1:2Sq6YnDH7/UDCvkSoHSDNDeyBcFgWL0sAVycVbAsXFg=
3545
github.com/pion/stun/v3 v3.0.0 h1:4h1gwhWLWuZWOJIJR9s2ferRO+W3zA/b6ijOI6mKzUw=
3646
github.com/pion/stun/v3 v3.0.0/go.mod h1:HvCN8txt8mwi4FBvS3EmDghW6aQJ24T+y+1TKjB5jyU=
47+
github.com/pion/stun/v3 v3.0.1 h1:jx1uUq6BdPihF0yF33Jj2mh+C9p0atY94IkdnW174kA=
48+
github.com/pion/stun/v3 v3.0.1/go.mod h1:RHnvlKFg+qHgoKIqtQWMOJF52wsImCAf/Jh5GjX+4Tw=
49+
github.com/pion/transport/v3 v3.0.7 h1:iRbMH05BzSNwhILHoBoAPxoB9xQgOaJk+591KC9P1o0=
50+
github.com/pion/transport/v3 v3.0.7/go.mod h1:YleKiTZ4vqNxVwh77Z0zytYi7rXHl7j6uPLGhhz9rwo=
3751
github.com/pion/transport/v3 v3.0.8 h1:oI3myyYnTKUSTthu/NZZ8eu2I5sHbxbUNNFW62olaYc=
3852
github.com/pion/transport/v3 v3.0.8/go.mod h1:+c2eewC5WJQHiAA46fkMMzoYZSuGzA/7E2FPrOYHctQ=
53+
github.com/pion/transport/v3 v3.1.1 h1:Tr684+fnnKlhPceU+ICdrw6KKkTms+5qHMgw6bIkYOM=
54+
github.com/pion/transport/v3 v3.1.1/go.mod h1:+c2eewC5WJQHiAA46fkMMzoYZSuGzA/7E2FPrOYHctQ=
3955
github.com/pion/turn/v4 v4.1.1 h1:9UnY2HB99tpDyz3cVVZguSxcqkJ1DsTSZ+8TGruh4fc=
4056
github.com/pion/turn/v4 v4.1.1/go.mod h1:2123tHk1O++vmjI5VSD0awT50NywDAq5A2NNNU4Jjs8=
57+
github.com/pion/turn/v4 v4.1.3 h1:jVNW0iR05AS94ysEtvzsrk3gKs9Zqxf6HmnsLfRvlzA=
58+
github.com/pion/turn/v4 v4.1.3/go.mod h1:TD/eiBUf5f5LwXbCJa35T7dPtTpCHRJ9oJWmyPLVT3A=
59+
github.com/pion/webrtc/v4 v4.1.4 h1:/gK1ACGHXQmtyVVbJFQDxNoODg4eSRiFLB7t9r9pg8M=
60+
github.com/pion/webrtc/v4 v4.1.4/go.mod h1:Oab9npu1iZtQRMic3K3toYq5zFPvToe/QBw7dMI2ok4=
4161
github.com/pion/webrtc/v4 v4.1.6 h1:srHH2HwvCGwPba25EYJgUzgLqCQoXl1VCUnrGQMSzUw=
4262
github.com/pion/webrtc/v4 v4.1.6/go.mod h1:wKecGRlkl3ox/As/MYghJL+b/cVXMEhoPMJWPuGQFhU=
4363
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -46,14 +66,23 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
4666
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
4767
github.com/wlynxg/anet v0.0.5 h1:J3VJGi1gvo0JwZ/P1/Yc/8p63SoW98B5dHkYDmpgvvU=
4868
github.com/wlynxg/anet v0.0.5/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=
69+
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
70+
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
4971
golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04=
5072
golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0=
73+
golang.org/x/crypto v0.44.0 h1:A97SsFvM3AIwEEmTBiaxPPTYpDC47w720rdiiUvgoAU=
74+
golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvmc=
75+
golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I=
76+
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
5177
golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4=
5278
golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
79+
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
80+
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
81+
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
82+
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
5383
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
5484
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
55-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
56-
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
57-
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
85+
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
86+
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
5887
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
5988
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

internal/environment/variables.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const (
88
NETWORK_TEST_ON_START = "NETWORK_TEST_ON_START"
99
INCLUDE_PUBLIC_IP_IN_NAT_1_TO_1_IP = "INCLUDE_PUBLIC_IP_IN_NAT_1_TO_1_IP"
1010
DISABLE_STATUS = "DISABLED_STATUS"
11+
ENABLE_PROFILING = "ENABLE_PROFILING"
1112

1213
// SSL
1314
USE_SSL = "USE_SSL"
@@ -59,4 +60,8 @@ const (
5960
LOGGING_NEW_FILE_ON_STARTUP = "LOGGING_NEW_FILE_ON_STARTUP"
6061
LOGGING_API_ENABLED = "LOGGING_API_ENABLED"
6162
LOGGING_API_KEY = "LOGGING_API_KEY"
63+
64+
// WHEP SESSION
65+
WHEP_SESSION_AUDIOCHANNEL_SIZE = "WHEP_SESSION_AUDIOCHANNEL_SIZE"
66+
WHEP_SESSION_VIDEOCHANNEL_SIZE = "WHEP_SESSION_VIDEOCHANNEL_SIZE"
6267
)

internal/server/handlers/sse.go

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package handlers
22

33
import (
4+
"context"
45
"fmt"
56
"log"
67
"net/http"
78
"os"
89
"strings"
10+
"time"
911

1012
"github.com/glimesh/broadcast-box/internal/environment"
1113
"github.com/glimesh/broadcast-box/internal/server/helpers"
@@ -45,7 +47,9 @@ func sseHandler(responseWriter http.ResponseWriter, request *http.Request) {
4547
for {
4648
select {
4749
case <-ctx.Done():
50+
log.Println("API.SSE: Client disconnected")
4851
return
52+
4953
case msg, ok := <-sseChannel:
5054
if debugSseMessages {
5155
log.Println("API.SSE Sending:", msg)
@@ -56,11 +60,30 @@ func sseHandler(responseWriter http.ResponseWriter, request *http.Request) {
5660
return
5761
}
5862

59-
if _, err := fmt.Fprintf(responseWriter, "%s\n", msg); err != nil {
60-
log.Println("API.SSE Error:", err)
63+
// Write with timeout
64+
writeCtx, cancel := context.WithTimeout(ctx, 500*time.Millisecond)
65+
done := make(chan error, 1)
66+
67+
go func() {
68+
_, err := fmt.Fprintf(responseWriter, "%s\n", msg)
69+
if err == nil {
70+
flusher.Flush()
71+
}
72+
done <- err
73+
}()
74+
75+
select {
76+
case err := <-done:
77+
cancel()
78+
if err != nil {
79+
log.Println("API.SSE Write error:", err)
80+
return
81+
}
82+
case <-writeCtx.Done():
83+
cancel()
84+
log.Println("API.SSE Write timeout")
85+
return
6186
}
62-
63-
flusher.Flush()
6487
}
6588
}
6689
}

internal/webrtc/codecs/trackMultiCodec.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ import (
77
"github.com/pion/webrtc/v4"
88
)
99

10+
type TrackPacket struct {
11+
Layer string
12+
Packet *rtp.Packet
13+
TimeDiff int64
14+
SequenceDiff int
15+
Codec TrackCodeType
16+
IsKeyframe bool
17+
}
18+
1019
type TrackMultiCodec struct {
1120
id string
1221
rid string

internal/webrtc/peerconnection/peerconnection_functions.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,14 @@ func disconnected(isWhip bool, streamKey string, sessionId string) {
6868
if isWhip {
6969
log.Println("WhipSession.Disconnected: Removing tracks", sessionId)
7070
whipSession.RemoveTracks()
71-
} else {
72-
log.Println("WhepSession.Disconnected: Removing session", sessionId)
73-
//TODO: Find a way to use the SSE connection to be considdered the tether to an open connection
74-
// whipSession.RemoveWhepSession(sessionId)
71+
72+
// Remove Whip session from manager if its empty
73+
log.Println("WhipSession.RemoveWhipSession: No Whep session, closing down")
74+
whipSession.ActiveContextCancel()
7575
}
7676

7777
// Do not conclude stream if whep sessions are still listening, or the host is still active
7878
if whipSession.HasWhepSessions() {
7979
return
8080
}
81-
82-
// Remove Whip session from manager if its empty
83-
log.Println("WhipSession.RemoveWhipSession: No Whep session, closing down")
84-
whipSession.ActiveContextCancel()
8581
}

internal/webrtc/peerconnection/peerconnection_whip_handlers.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,10 @@ func RegisterWhipHandlers(whipSession *whip.WhipSession, peerConnection *webrtc.
2424
whipSession.PeerConnection.OnConnectionStateChange(onConnectionStateChange(whipSession))
2525
}
2626

27-
func onWhipICEConnectionStateChangeHandler(
28-
streamKey string,
29-
sessionId string,
30-
) func(webrtc.ICEConnectionState) {
31-
27+
func onWhipICEConnectionStateChangeHandler(streamKey string, sessionId string) func(webrtc.ICEConnectionState) {
3228
return func(state webrtc.ICEConnectionState) {
3329
if state == webrtc.ICEConnectionStateFailed || state == webrtc.ICEConnectionStateClosed {
34-
35-
if strings.EqualFold("DEBUG_PEERCONNECTION_ENABLED", "true") {
36-
log.Println("WhepSession: Disconnected", streamKey, sessionId)
37-
}
38-
30+
log.Println("WhipSession.PeerConnection.OnICEConnectionStateChange", streamKey)
3931
disconnected(true, streamKey, sessionId)
4032
}
4133
}
@@ -55,6 +47,12 @@ func onWhipTrackHandler(whipSession *whip.WhipSession, peerConnection *webrtc.Pe
5547

5648
// Fires when track has stopped
5749
whipSession.OnTrackChangeChannel <- struct{}{}
50+
err := peerConnection.Close()
51+
if err != nil {
52+
log.Println("WhipSession.OnTrackHandler.PeerConnection.Close.Error:", err)
53+
}
54+
55+
log.Println("WhipSession.OnTrackHandler.TrackStopped", remoteTrack.RID())
5856
}
5957
}
6058

@@ -63,7 +61,9 @@ func onConnectionStateChange(whipSession *whip.WhipSession) func(webrtc.PeerConn
6361
log.Println("WhipSession.PeerConnection.OnConnectionStateChange", state)
6462

6563
if state == webrtc.PeerConnectionStateDisconnected || state == webrtc.PeerConnectionStateClosed || state == webrtc.PeerConnectionStateFailed {
64+
log.Println("WhipSession.PeerConnection.OnConnectionStateChange: Host removed")
6665
whipSession.ActiveContextCancel()
66+
whipSession.HasHost.Store(false)
6767
}
6868
}
6969
}

0 commit comments

Comments
 (0)