Archived
2
0

nack is nativly implemented by pion webrtc v3, gstreamer has 25 fps with no additional parameters

This commit is contained in:
Marcel Battista 2021-02-14 22:50:49 +00:00
parent 29fc67aff9
commit e57fe5efac
2 changed files with 11 additions and 46 deletions

View File

@ -50,7 +50,7 @@ var pipelinesLock sync.Mutex
var registry *C.GstRegistry var registry *C.GstRegistry
const ( 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 ! " audioSrc = "pulsesrc device=%s ! audio/x-raw,channels=2 ! audioconvert ! "
) )

View File

@ -7,7 +7,6 @@ import (
"strings" "strings"
"github.com/pion/interceptor" "github.com/pion/interceptor"
"github.com/pion/rtcp"
"github.com/pion/webrtc/v3" "github.com/pion/webrtc/v3"
"github.com/pion/webrtc/v3/pkg/media" "github.com/pion/webrtc/v3/pkg/media"
"github.com/rs/zerolog" "github.com/rs/zerolog"
@ -145,9 +144,8 @@ func (manager *WebRTCManager) CreatePeer(id string, session types.Session) (stri
Msg("connection state has changed") Msg("connection state has changed")
}) })
rtpSender, viderr := connection.AddTrack(manager.videoTrack) if _, err = connection.AddTrack(manager.videoTrack); err != nil {
if viderr != nil { return "", manager.config.ICELite, manager.config.ICEServers, err
return "", manager.config.ICELite, manager.config.ICEServers, viderr
} }
if _, err = connection.AddTrack(manager.audioTrack); err != nil { 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{ if err := session.SetPeer(&Peer{
id: id, id: id,
api: api, 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) { func (m *WebRTCManager) createTrack(codecName string) (*webrtc.TrackLocalStaticSample, webrtc.RTPCodecParameters, error) {
var codec webrtc.RTPCodecParameters var codec webrtc.RTPCodecParameters
fba := []webrtc.RTCPFeedback{} fb := []webrtc.RTCPFeedback{}
fbv := []webrtc.RTCPFeedback{
{"goog-remb", ""},
{"nack", ""},
{"nack", "pli"},
{"ccm", "fir"},
}
switch codecName { switch codecName {
case "VP8": 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": 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": 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": 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": 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": 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": 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: default:
return nil, codec, fmt.Errorf("unknown codec %s", codecName) return nil, codec, fmt.Errorf("unknown codec %s", codecName)
} }