Add comments and improve repackaging
This commit is contained in:
+14
-3
@@ -161,9 +161,8 @@ func Dial(rawURL string) (core.Producer, error) {
|
||||
}
|
||||
|
||||
if client.isHEVC {
|
||||
// We need to replace the SDP codecs with the real ones from Skill.
|
||||
// The actual media comes via DataChannel, not RTP tracks.
|
||||
|
||||
// Tuya responds with H264/90000 even for HEVC streams
|
||||
// So we need to replace video codecs with HEVC ones from API
|
||||
for _, media := range client.conn.Medias {
|
||||
if media.Kind == core.KindVideo {
|
||||
codecs := client.api.GetVideoCodecs()
|
||||
@@ -173,6 +172,9 @@ func Dial(rawURL string) (core.Producer, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// Audio codecs from API as well
|
||||
// Tuya responds with multiple audio codecs (PCMU, PCMA)
|
||||
// But the quality is bad if we use PCMU and skill only has PCMA
|
||||
for _, media := range client.conn.Medias {
|
||||
if media.Kind == core.KindAudio {
|
||||
codecs := client.api.GetAudioCodecs()
|
||||
@@ -356,6 +358,8 @@ func (c *Client) AddTrack(media *core.Media, codec *core.Codec, track *core.Rece
|
||||
|
||||
sender := core.NewSender(media, codec)
|
||||
|
||||
switch track.Codec.Name {
|
||||
case core.CodecPCMA, core.CodecPCMU, core.CodecPCM, core.CodecPCML:
|
||||
// Frame size affects audio delay with Tuya cameras:
|
||||
// Browser sends standard 20ms frames (160 bytes for G.711), but this causes
|
||||
// up to 4s delay on some Tuya cameras. Increasing to 240 bytes (30ms) reduces
|
||||
@@ -394,6 +398,13 @@ func (c *Client) AddTrack(media *core.Media, codec *core.Codec, track *core.Rece
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
sender.Handler = func(packet *rtp.Packet) {
|
||||
c.conn.Send += packet.MarshalSize()
|
||||
_ = localTrack.WriteRTP(payloadType, packet)
|
||||
}
|
||||
}
|
||||
|
||||
sender.HandleRTP(track)
|
||||
c.conn.Senders = append(c.conn.Senders, sender)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user