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 label string
datachannel *webrtc.DataChannel datachannel *webrtc.DataChannel
init *webrtc.DataChannelInit init *webrtc.DataChannelInit
channelOpen chan struct{}
ctx context.Context ctx context.Context
} }
@@ -19,6 +20,7 @@ func CreateDataChannel(ctx context.Context, label string, peerConnection *webrtc
dc := &DataChannel{ dc := &DataChannel{
label: label, label: label,
datachannel: nil, datachannel: nil,
channelOpen: make(chan struct{}),
ctx: ctx, ctx: ctx,
} }
@@ -63,6 +65,7 @@ func (dataChannel *DataChannel) Close() error {
func (dataChannel *DataChannel) onOpen() *DataChannel { func (dataChannel *DataChannel) onOpen() *DataChannel {
dataChannel.datachannel.OnOpen(func() { dataChannel.datachannel.OnOpen(func() {
fmt.Printf("dataChannel Open with Label: %s\n", dataChannel.datachannel.Label()) fmt.Printf("dataChannel Open with Label: %s\n", dataChannel.datachannel.Label())
dataChannel.channelOpen <- struct{}{}
}) })
return dataChannel return dataChannel
} }
@@ -74,6 +77,10 @@ func (dataChannel *DataChannel) onClose() *DataChannel {
return dataChannel return dataChannel
} }
func (dataChannel *DataChannel) WaitUntilOpen() <-chan struct{} {
return dataChannel.channelOpen
}
func (dataChannel *DataChannel) DataChannel() *webrtc.DataChannel { func (dataChannel *DataChannel) DataChannel() *webrtc.DataChannel {
return dataChannel.datachannel return dataChannel.datachannel
} }

View File

@@ -12,7 +12,10 @@ func WithDataChannelInit(init *webrtc.DataChannelInit) Option {
} }
var ( var (
OrderedTrue = true OrderedTrue = true
NegotiatedTrue = true MaxRetransmits uint16 = 2 // either MaxRetransmits or MaxPacketLifeTime can be specified at once
IDOne uint16 = 1 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 { for _, bitrate := range encoder.bitrates {
// TODO: WARN: 90 size might be tooo high // TODO: WARN: 90 size might be tooo high
// TODO: Frame pool could be abstracted away // 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 { if err := builder.UpdateBitrate(bitrate); err != nil {
return nil, err return nil, err

View File

@@ -12,24 +12,24 @@ func GetRTCConfiguration() webrtc.Configuration {
{ {
URLs: []string{os.Getenv("STUN_SERVER_URL")}, URLs: []string{os.Getenv("STUN_SERVER_URL")},
}, },
// { {
// URLs: []string{os.Getenv("TURN_UDP_SERVER_URL")}, URLs: []string{os.Getenv("TURN_UDP_SERVER_URL")},
// Username: os.Getenv("TURN_SERVER_USERNAME"), Username: os.Getenv("TURN_SERVER_USERNAME"),
// Credential: os.Getenv("TURN_SERVER_PASSWORD"), Credential: os.Getenv("TURN_SERVER_PASSWORD"),
// CredentialType: webrtc.ICECredentialTypePassword, CredentialType: webrtc.ICECredentialTypePassword,
// }, },
// { {
// URLs: []string{os.Getenv("TURN_TCP_SERVER_URL")}, URLs: []string{os.Getenv("TURN_TCP_SERVER_URL")},
// Username: os.Getenv("TURN_SERVER_USERNAME"), Username: os.Getenv("TURN_SERVER_USERNAME"),
// Credential: os.Getenv("TURN_SERVER_PASSWORD"), Credential: os.Getenv("TURN_SERVER_PASSWORD"),
// CredentialType: webrtc.ICECredentialTypePassword, CredentialType: webrtc.ICECredentialTypePassword,
// }, },
// { {
// URLs: []string{os.Getenv("TURN_TLS_SERVER_URL")}, URLs: []string{os.Getenv("TURN_TLS_SERVER_URL")},
// Username: os.Getenv("TURN_SERVER_USERNAME"), Username: os.Getenv("TURN_SERVER_USERNAME"),
// Credential: os.Getenv("TURN_SERVER_PASSWORD"), Credential: os.Getenv("TURN_SERVER_PASSWORD"),
// CredentialType: webrtc.ICECredentialTypePassword, CredentialType: webrtc.ICECredentialTypePassword,
// }, },
}, },
ICETransportPolicy: webrtc.ICETransportPolicyAll, ICETransportPolicy: webrtc.ICETransportPolicyAll,
BundlePolicy: webrtc.BundlePolicyMaxCompat, BundlePolicy: webrtc.BundlePolicyMaxCompat,