mirror of
https://github.com/go-gst/go-gst.git
synced 2025-10-05 16:06:55 +08:00
fix examples with new casing of EOS and others
This commit is contained in:
@@ -37,7 +37,7 @@ func createPipeline() (gst.Pipeline, error) {
|
|||||||
// Pull the sample that triggered this callback
|
// Pull the sample that triggered this callback
|
||||||
sample := sink.PullSample()
|
sample := sink.PullSample()
|
||||||
if sample == nil {
|
if sample == nil {
|
||||||
return gst.FlowEos
|
return gst.FlowEOS
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the buffer from the sample
|
// Retrieve the buffer from the sample
|
||||||
@@ -101,7 +101,7 @@ func runPipeline(pipeline gst.Pipeline) error {
|
|||||||
signal.Notify(c, os.Interrupt)
|
signal.Notify(c, os.Interrupt)
|
||||||
go func() {
|
go func() {
|
||||||
<-c
|
<-c
|
||||||
pipeline.SendEvent(gst.NewEventEos())
|
pipeline.SendEvent(gst.NewEventEOS())
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Loop over messsages from the pipeline
|
// Loop over messsages from the pipeline
|
||||||
|
@@ -37,7 +37,7 @@ func createPipeline() (gst.Pipeline, error) {
|
|||||||
// by creating a video info with the given format and creating caps from it for the appsrc element.
|
// by creating a video info with the given format and creating caps from it for the appsrc element.
|
||||||
videoInfo := gstvideo.NewVideoInfo()
|
videoInfo := gstvideo.NewVideoInfo()
|
||||||
|
|
||||||
ok := videoInfo.SetFormat(gstvideo.VideoFormatRGBA, width, height)
|
ok := videoInfo.SetFormat(gstvideo.VideoFormatRgba, width, height)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("failed to set video format")
|
return nil, fmt.Errorf("failed to set video format")
|
||||||
@@ -56,7 +56,7 @@ func createPipeline() (gst.Pipeline, error) {
|
|||||||
var i int
|
var i int
|
||||||
|
|
||||||
// Get all 256 colors in the RGB8P palette.
|
// Get all 256 colors in the RGB8P palette.
|
||||||
palette := gstvideo.VideoFormatGetPalette(gstvideo.VideoFormatRGB8P)
|
palette := gstvideo.VideoFormatGetPalette(gstvideo.VideoFormatRgb8p)
|
||||||
|
|
||||||
// Since our appsrc element operates in pull mode (it asks us to provide data),
|
// Since our appsrc element operates in pull mode (it asks us to provide data),
|
||||||
// we add a handler for the need-data callback and provide new data from there.
|
// we add a handler for the need-data callback and provide new data from there.
|
||||||
|
@@ -71,7 +71,7 @@ func createPipeline() (gst.Pipeline, error) {
|
|||||||
// however displayed this way for demonstration purposes.
|
// however displayed this way for demonstration purposes.
|
||||||
sink.CallAsync(func(el gst.Element) {
|
sink.CallAsync(func(el gst.Element) {
|
||||||
fmt.Println("Send EOS is true, sending eos")
|
fmt.Println("Send EOS is true, sending eos")
|
||||||
if !pipeline.SendEvent(gst.NewEventEos()) {
|
if !pipeline.SendEvent(gst.NewEventEOS()) {
|
||||||
fmt.Println("WARNING: Failed to send EOS to pipeline")
|
fmt.Println("WARNING: Failed to send EOS to pipeline")
|
||||||
}
|
}
|
||||||
fmt.Println("Sent EOS")
|
fmt.Println("Sent EOS")
|
||||||
|
@@ -64,7 +64,7 @@ func main() {
|
|||||||
// Once all sinks are done handling the EOS event (and all buffers that were before the
|
// Once all sinks are done handling the EOS event (and all buffers that were before the
|
||||||
// EOS event in the pipeline already), the pipeline would post an EOS message on the bus,
|
// EOS event in the pipeline already), the pipeline would post an EOS message on the bus,
|
||||||
// essentially telling the application that the pipeline is completely drained.
|
// essentially telling the application that the pipeline is completely drained.
|
||||||
pipeline.SendEvent(gst.NewEventEos())
|
pipeline.SendEvent(gst.NewEventEOS())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@@ -90,7 +90,7 @@ func encodeGif() error {
|
|||||||
pipeline.Add(appSink)
|
pipeline.Add(appSink)
|
||||||
jpegenc.Link(appSink)
|
jpegenc.Link(appSink)
|
||||||
appSink.SyncStateWithParent()
|
appSink.SyncStateWithParent()
|
||||||
appSink.SetWaitOnEos(false)
|
appSink.SetWaitOnEOS(false)
|
||||||
|
|
||||||
// We can query the decodebin for the duration of the video it received. We can then
|
// We can query the decodebin for the duration of the video it received. We can then
|
||||||
// use this value to calculate the total number of frames we expect to produce.
|
// use this value to calculate the total number of frames we expect to produce.
|
||||||
@@ -111,7 +111,7 @@ func encodeGif() error {
|
|||||||
// will be a new jpeg image from the pipeline.
|
// will be a new jpeg image from the pipeline.
|
||||||
var frameNum int
|
var frameNum int
|
||||||
|
|
||||||
appSink.ConnectEos(func(self gstapp.AppSink) {
|
appSink.ConnectEOS(func(self gstapp.AppSink) {
|
||||||
fmt.Println("\nWriting the results of the gif to", outFile)
|
fmt.Println("\nWriting the results of the gif to", outFile)
|
||||||
file, err := os.Create(outFile)
|
file, err := os.Create(outFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -136,7 +136,7 @@ func encodeGif() error {
|
|||||||
// signal the main loop to quit.
|
// signal the main loop to quit.
|
||||||
// This needs to be done from a goroutine to not block the app sink
|
// This needs to be done from a goroutine to not block the app sink
|
||||||
// callback.
|
// callback.
|
||||||
return gst.FlowEos
|
return gst.FlowEOS
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pull the sample from the sink
|
// Pull the sample from the sink
|
||||||
@@ -164,7 +164,7 @@ func encodeGif() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a new paletted image with the same bounds as the pulled one
|
// Create a new paletted image with the same bounds as the pulled one
|
||||||
frame := image.NewPaletted(img.Bounds(), gstvideo.VideoFormatGetPalette(gstvideo.VideoFormatRGB8P))
|
frame := image.NewPaletted(img.Bounds(), gstvideo.VideoFormatGetPalette(gstvideo.VideoFormatRgb8p))
|
||||||
|
|
||||||
// Iterate the bounds of the image and set the pixels in their correct place.
|
// Iterate the bounds of the image and set the pixels in their correct place.
|
||||||
for x := 1; x <= img.Bounds().Dx(); x++ {
|
for x := 1; x <= img.Bounds().Dx(); x++ {
|
||||||
|
Reference in New Issue
Block a user