Archived
2
0

remove ClockRate from gst pipelines.

This commit is contained in:
m1k1o 2021-02-14 20:26:35 +01:00
parent b1e358c0bc
commit f24c99f90c

View File

@ -42,7 +42,6 @@ type Pipeline struct {
Pipeline *C.GstElement Pipeline *C.GstElement
Sample chan types.Sample Sample chan types.Sample
CodecName string CodecName string
ClockRate float32
Src string Src string
id int id int
} }
@ -52,9 +51,6 @@ var pipelinesLock sync.Mutex
var registry *C.GstRegistry var registry *C.GstRegistry
const ( const (
videoClockRate = 90000
audioClockRate = 48000
pcmClockRate = 8000
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 ! videoconvert ! queue ! "
audioSrc = "pulsesrc device=%s ! audio/x-raw,channels=2 ! audioconvert ! " audioSrc = "pulsesrc device=%s ! audio/x-raw,channels=2 ! audioconvert ! "
) )
@ -76,15 +72,13 @@ func CreateRTMPPipeline(pipelineDevice string, pipelineDisplay string, pipelineS
pipelineStr = fmt.Sprintf("flvmux name=mux ! rtmpsink location='%s live=1' %s audio/x-raw,channels=2 ! audioconvert ! voaacenc ! mux. %s x264enc bframes=0 key-int-max=60 byte-stream=true tune=zerolatency speed-preset=veryfast ! mux.", pipelineRTMP, audio, video) pipelineStr = fmt.Sprintf("flvmux name=mux ! rtmpsink location='%s live=1' %s audio/x-raw,channels=2 ! audioconvert ! voaacenc ! mux. %s x264enc bframes=0 key-int-max=60 byte-stream=true tune=zerolatency speed-preset=veryfast ! mux.", pipelineRTMP, audio, video)
} }
return CreatePipeline(pipelineStr, "", 0) return CreatePipeline(pipelineStr, "")
} }
// CreateAppPipeline creates a GStreamer Pipeline // CreateAppPipeline creates a GStreamer Pipeline
func CreateAppPipeline(codecName string, pipelineDevice string, pipelineSrc string, bitrate int) (*Pipeline, error) { func CreateAppPipeline(codecName string, pipelineDevice string, pipelineSrc string, bitrate int) (*Pipeline, error) {
pipelineStr := " ! appsink name=appsink" pipelineStr := " ! appsink name=appsink"
var clockRate float32
switch codecName { switch codecName {
case "VP8": case "VP8":
// https://gstreamer.freedesktop.org/documentation/vpx/vp8enc.html?gi-language=c // https://gstreamer.freedesktop.org/documentation/vpx/vp8enc.html?gi-language=c
@ -94,8 +88,6 @@ func CreateAppPipeline(codecName string, pipelineDevice string, pipelineSrc stri
return nil, err return nil, err
} }
clockRate = videoClockRate
if pipelineSrc != "" { if pipelineSrc != "" {
pipelineStr = fmt.Sprintf(pipelineSrc+pipelineStr, pipelineDevice) pipelineStr = fmt.Sprintf(pipelineSrc+pipelineStr, pipelineDevice)
} else { } else {
@ -109,8 +101,6 @@ func CreateAppPipeline(codecName string, pipelineDevice string, pipelineSrc stri
return nil, err return nil, err
} }
clockRate = videoClockRate
// Causes panic! not sure why... // Causes panic! not sure why...
if pipelineSrc != "" { if pipelineSrc != "" {
pipelineStr = fmt.Sprintf(pipelineSrc+pipelineStr, pipelineDevice) pipelineStr = fmt.Sprintf(pipelineSrc+pipelineStr, pipelineDevice)
@ -125,8 +115,6 @@ func CreateAppPipeline(codecName string, pipelineDevice string, pipelineSrc stri
return nil, err return nil, err
} }
clockRate = videoClockRate
if pipelineSrc != "" { if pipelineSrc != "" {
pipelineStr = fmt.Sprintf(pipelineSrc+pipelineStr, pipelineDevice) pipelineStr = fmt.Sprintf(pipelineSrc+pipelineStr, pipelineDevice)
} else { } else {
@ -160,8 +148,6 @@ func CreateAppPipeline(codecName string, pipelineDevice string, pipelineSrc stri
return nil, err return nil, err
} }
clockRate = audioClockRate
if pipelineSrc != "" { if pipelineSrc != "" {
pipelineStr = fmt.Sprintf(pipelineSrc+pipelineStr, pipelineDevice) pipelineStr = fmt.Sprintf(pipelineSrc+pipelineStr, pipelineDevice)
} else { } else {
@ -175,8 +161,6 @@ func CreateAppPipeline(codecName string, pipelineDevice string, pipelineSrc stri
return nil, err return nil, err
} }
clockRate = audioClockRate
if pipelineSrc != "" { if pipelineSrc != "" {
pipelineStr = fmt.Sprintf(pipelineSrc+pipelineStr, pipelineDevice) pipelineStr = fmt.Sprintf(pipelineSrc+pipelineStr, pipelineDevice)
} else { } else {
@ -190,8 +174,6 @@ func CreateAppPipeline(codecName string, pipelineDevice string, pipelineSrc stri
return nil, err return nil, err
} }
clockRate = pcmClockRate
if pipelineSrc != "" { if pipelineSrc != "" {
pipelineStr = fmt.Sprintf(pipelineSrc+pipelineStr, pipelineDevice) pipelineStr = fmt.Sprintf(pipelineSrc+pipelineStr, pipelineDevice)
} else { } else {
@ -205,8 +187,6 @@ func CreateAppPipeline(codecName string, pipelineDevice string, pipelineSrc stri
return nil, err return nil, err
} }
clockRate = pcmClockRate
if pipelineSrc != "" { if pipelineSrc != "" {
pipelineStr = fmt.Sprintf(pipelineSrc+pipelineStr, pipelineDevice) pipelineStr = fmt.Sprintf(pipelineSrc+pipelineStr, pipelineDevice)
} else { } else {
@ -216,11 +196,11 @@ func CreateAppPipeline(codecName string, pipelineDevice string, pipelineSrc stri
return nil, fmt.Errorf("unknown codec %s", codecName) return nil, fmt.Errorf("unknown codec %s", codecName)
} }
return CreatePipeline(pipelineStr, codecName, clockRate) return CreatePipeline(pipelineStr, codecName)
} }
// CreatePipeline creates a GStreamer Pipeline // CreatePipeline creates a GStreamer Pipeline
func CreatePipeline(pipelineStr string, codecName string, clockRate float32) (*Pipeline, error) { func CreatePipeline(pipelineStr string, codecName string) (*Pipeline, error) {
pipelineStrUnsafe := C.CString(pipelineStr) pipelineStrUnsafe := C.CString(pipelineStr)
defer C.free(unsafe.Pointer(pipelineStrUnsafe)) defer C.free(unsafe.Pointer(pipelineStrUnsafe))
@ -231,7 +211,6 @@ func CreatePipeline(pipelineStr string, codecName string, clockRate float32) (*P
Pipeline: C.gstreamer_send_create_pipeline(pipelineStrUnsafe), Pipeline: C.gstreamer_send_create_pipeline(pipelineStrUnsafe),
Sample: make(chan types.Sample), Sample: make(chan types.Sample),
CodecName: codecName, CodecName: codecName,
ClockRate: clockRate,
Src: pipelineStr, Src: pipelineStr,
id: len(pipelines), id: len(pipelines),
} }