nack is nativly implemented by pion webrtc v3, gstreamer has 25 fps with no additional parameters
This commit is contained in:
parent
29fc67aff9
commit
e57fe5efac
@ -50,7 +50,7 @@ var pipelinesLock sync.Mutex
|
||||
var registry *C.GstRegistry
|
||||
|
||||
const (
|
||||
videoSrc = "ximagesrc display-name=%s show-pointer=true use-damage=false ! video/x-raw ! videoconvert ! queue ! "
|
||||
videoSrc = "ximagesrc display-name=%s show-pointer=true use-damage=false ! video/x-raw,framerate=30/1 ! videoconvert ! queue ! "
|
||||
audioSrc = "pulsesrc device=%s ! audio/x-raw,channels=2 ! audioconvert ! "
|
||||
)
|
||||
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/pion/interceptor"
|
||||
"github.com/pion/rtcp"
|
||||
"github.com/pion/webrtc/v3"
|
||||
"github.com/pion/webrtc/v3/pkg/media"
|
||||
"github.com/rs/zerolog"
|
||||
@ -145,9 +144,8 @@ func (manager *WebRTCManager) CreatePeer(id string, session types.Session) (stri
|
||||
Msg("connection state has changed")
|
||||
})
|
||||
|
||||
rtpSender, viderr := connection.AddTrack(manager.videoTrack)
|
||||
if viderr != nil {
|
||||
return "", manager.config.ICELite, manager.config.ICEServers, viderr
|
||||
if _, err = connection.AddTrack(manager.videoTrack); err != nil {
|
||||
return "", manager.config.ICELite, manager.config.ICEServers, err
|
||||
}
|
||||
|
||||
if _, err = connection.AddTrack(manager.audioTrack); err != nil {
|
||||
@ -199,33 +197,6 @@ func (manager *WebRTCManager) CreatePeer(id string, session types.Session) (stri
|
||||
}
|
||||
})
|
||||
|
||||
// Read incoming RTCP packets
|
||||
// Before these packets are retuned they are processed by interceptors. For things
|
||||
// like NACK this needs to be called.
|
||||
go func() {
|
||||
rtcpBuf := make([]byte, 1500)
|
||||
|
||||
for {
|
||||
n, _, err := rtpSender.Read(rtcpBuf)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
ps, err := rtcp.Unmarshal(rtcpBuf[:n])
|
||||
if err != nil {
|
||||
manager.logger.Warn().Err(err).Msg("unmarshal RTCP failed")
|
||||
continue
|
||||
}
|
||||
|
||||
for _, p := range ps {
|
||||
switch p.(type) {
|
||||
case *rtcp.TransportLayerNack:
|
||||
manager.logger.Warn().Msg("got a nack")
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
if err := session.SetPeer(&Peer{
|
||||
id: id,
|
||||
api: api,
|
||||
@ -244,29 +215,23 @@ func (manager *WebRTCManager) CreatePeer(id string, session types.Session) (stri
|
||||
func (m *WebRTCManager) createTrack(codecName string) (*webrtc.TrackLocalStaticSample, webrtc.RTPCodecParameters, error) {
|
||||
var codec webrtc.RTPCodecParameters
|
||||
|
||||
fba := []webrtc.RTCPFeedback{}
|
||||
fbv := []webrtc.RTCPFeedback{
|
||||
{"goog-remb", ""},
|
||||
{"nack", ""},
|
||||
{"nack", "pli"},
|
||||
{"ccm", "fir"},
|
||||
}
|
||||
fb := []webrtc.RTCPFeedback{}
|
||||
|
||||
switch codecName {
|
||||
case "VP8":
|
||||
codec = webrtc.RTPCodecParameters{RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: "video/VP8", ClockRate: 90000, Channels: 0, SDPFmtpLine: "", RTCPFeedback: fbv}, PayloadType: 96}
|
||||
codec = webrtc.RTPCodecParameters{RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: "video/VP8", ClockRate: 90000, Channels: 0, SDPFmtpLine: "", RTCPFeedback: fb}, PayloadType: 96}
|
||||
case "VP9":
|
||||
codec = webrtc.RTPCodecParameters{RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: "video/VP9", ClockRate: 90000, Channels: 0, SDPFmtpLine: "", RTCPFeedback: fbv}, PayloadType: 98}
|
||||
codec = webrtc.RTPCodecParameters{RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: "video/VP9", ClockRate: 90000, Channels: 0, SDPFmtpLine: "", RTCPFeedback: fb}, PayloadType: 98}
|
||||
case "H264":
|
||||
codec = webrtc.RTPCodecParameters{RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: "video/H264", ClockRate: 90000, Channels: 0, SDPFmtpLine: "level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f", RTCPFeedback: fbv}, PayloadType: 102}
|
||||
codec = webrtc.RTPCodecParameters{RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: "video/H264", ClockRate: 90000, Channels: 0, SDPFmtpLine: "level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f", RTCPFeedback: fb}, PayloadType: 102}
|
||||
case "Opus":
|
||||
codec = webrtc.RTPCodecParameters{RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: "audio/opus", ClockRate: 48000, Channels: 2, SDPFmtpLine: "", RTCPFeedback: fba}, PayloadType: 111}
|
||||
codec = webrtc.RTPCodecParameters{RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: "audio/opus", ClockRate: 48000, Channels: 2, SDPFmtpLine: "", RTCPFeedback: fb}, PayloadType: 111}
|
||||
case "G722":
|
||||
codec = webrtc.RTPCodecParameters{RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: "audio/G722", ClockRate: 8000, Channels: 0, SDPFmtpLine: "", RTCPFeedback: fba}, PayloadType: 9}
|
||||
codec = webrtc.RTPCodecParameters{RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: "audio/G722", ClockRate: 8000, Channels: 0, SDPFmtpLine: "", RTCPFeedback: fb}, PayloadType: 9}
|
||||
case "PCMU":
|
||||
codec = webrtc.RTPCodecParameters{RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: "audio/PCMU", ClockRate: 8000, Channels: 0, SDPFmtpLine: "", RTCPFeedback: fba}, PayloadType: 0}
|
||||
codec = webrtc.RTPCodecParameters{RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: "audio/PCMU", ClockRate: 8000, Channels: 0, SDPFmtpLine: "", RTCPFeedback: fb}, PayloadType: 0}
|
||||
case "PCMA":
|
||||
codec = webrtc.RTPCodecParameters{RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: "audio/PCMA", ClockRate: 8000, Channels: 0, SDPFmtpLine: "", RTCPFeedback: fba}, PayloadType: 8}
|
||||
codec = webrtc.RTPCodecParameters{RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: "audio/PCMA", ClockRate: 8000, Channels: 0, SDPFmtpLine: "", RTCPFeedback: fb}, PayloadType: 8}
|
||||
default:
|
||||
return nil, codec, fmt.Errorf("unknown codec %s", codecName)
|
||||
}
|
||||
|
Reference in New Issue
Block a user