added all turn serer credentials

This commit is contained in:
harshabose
2025-07-14 14:53:47 +05:30
parent cf0279fb52
commit 0e4d856bcb
4 changed files with 32 additions and 22 deletions

View File

@@ -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
}

View File

@@ -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
)

View File

@@ -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

View File

@@ -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,