diff --git a/pkg/datachannel/datachannel.go b/pkg/datachannel/datachannel.go index f65c863..61a3dc8 100644 --- a/pkg/datachannel/datachannel.go +++ b/pkg/datachannel/datachannel.go @@ -12,6 +12,7 @@ type DataChannel struct { label string datachannel *webrtc.DataChannel init *webrtc.DataChannelInit + channelOpen chan struct{} ctx context.Context } @@ -19,6 +20,7 @@ func CreateDataChannel(ctx context.Context, label string, peerConnection *webrtc dc := &DataChannel{ label: label, datachannel: nil, + channelOpen: make(chan struct{}), ctx: ctx, } @@ -63,6 +65,7 @@ func (dataChannel *DataChannel) Close() error { func (dataChannel *DataChannel) onOpen() *DataChannel { dataChannel.datachannel.OnOpen(func() { fmt.Printf("dataChannel Open with Label: %s\n", dataChannel.datachannel.Label()) + dataChannel.channelOpen <- struct{}{} }) return dataChannel } @@ -74,6 +77,10 @@ func (dataChannel *DataChannel) onClose() *DataChannel { return dataChannel } +func (dataChannel *DataChannel) WaitUntilOpen() <-chan struct{} { + return dataChannel.channelOpen +} + func (dataChannel *DataChannel) DataChannel() *webrtc.DataChannel { return dataChannel.datachannel } diff --git a/pkg/datachannel/options.go b/pkg/datachannel/options.go index 89494db..644bb22 100644 --- a/pkg/datachannel/options.go +++ b/pkg/datachannel/options.go @@ -12,7 +12,10 @@ func WithDataChannelInit(init *webrtc.DataChannelInit) Option { } var ( - OrderedTrue = true - NegotiatedTrue = true - IDOne uint16 = 1 + OrderedTrue = true + MaxRetransmits uint16 = 2 // either MaxRetransmits or MaxPacketLifeTime can be specified at once + MaxPacketLifeTime uint16 = 50 // milliseconds + Protocol = "binary" + NegotiatedTrue = true + IDOne uint16 = 1 ) diff --git a/pkg/transcode/multi_encoder.go b/pkg/transcode/multi_encoder.go index 667b070..b7b0efe 100644 --- a/pkg/transcode/multi_encoder.go +++ b/pkg/transcode/multi_encoder.go @@ -136,7 +136,7 @@ func NewMultiUpdateEncoder(ctx context.Context, config MultiConfig, builder *Gen for _, bitrate := range encoder.bitrates { // TODO: WARN: 90 size might be tooo high // TODO: Frame pool could be abstracted away - producer := newDummyMediaFrameProducer(buffer.CreateChannelBuffer(ctx2, 90, buffer.CreateFramePool()), describer) + producer := newDummyMediaFrameProducer(buffer.CreateChannelBuffer(ctx2, 10, buffer.CreateFramePool()), describer) if err := builder.UpdateBitrate(bitrate); err != nil { return nil, err diff --git a/rtc_config.go b/rtc_config.go index 4bcc19b..47637b0 100644 --- a/rtc_config.go +++ b/rtc_config.go @@ -12,24 +12,24 @@ func GetRTCConfiguration() webrtc.Configuration { { URLs: []string{os.Getenv("STUN_SERVER_URL")}, }, - // { - // URLs: []string{os.Getenv("TURN_UDP_SERVER_URL")}, - // Username: os.Getenv("TURN_SERVER_USERNAME"), - // Credential: os.Getenv("TURN_SERVER_PASSWORD"), - // CredentialType: webrtc.ICECredentialTypePassword, - // }, - // { - // URLs: []string{os.Getenv("TURN_TCP_SERVER_URL")}, - // Username: os.Getenv("TURN_SERVER_USERNAME"), - // Credential: os.Getenv("TURN_SERVER_PASSWORD"), - // CredentialType: webrtc.ICECredentialTypePassword, - // }, - // { - // URLs: []string{os.Getenv("TURN_TLS_SERVER_URL")}, - // Username: os.Getenv("TURN_SERVER_USERNAME"), - // Credential: os.Getenv("TURN_SERVER_PASSWORD"), - // CredentialType: webrtc.ICECredentialTypePassword, - // }, + { + URLs: []string{os.Getenv("TURN_UDP_SERVER_URL")}, + Username: os.Getenv("TURN_SERVER_USERNAME"), + Credential: os.Getenv("TURN_SERVER_PASSWORD"), + CredentialType: webrtc.ICECredentialTypePassword, + }, + { + URLs: []string{os.Getenv("TURN_TCP_SERVER_URL")}, + Username: os.Getenv("TURN_SERVER_USERNAME"), + Credential: os.Getenv("TURN_SERVER_PASSWORD"), + CredentialType: webrtc.ICECredentialTypePassword, + }, + { + URLs: []string{os.Getenv("TURN_TLS_SERVER_URL")}, + Username: os.Getenv("TURN_SERVER_USERNAME"), + Credential: os.Getenv("TURN_SERVER_PASSWORD"), + CredentialType: webrtc.ICECredentialTypePassword, + }, }, ICETransportPolicy: webrtc.ICETransportPolicyAll, BundlePolicy: webrtc.BundlePolicyMaxCompat,