Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register GstSample marshaling functions #57

Open
wants to merge 48 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
326907e
add ability to set and get plugin feature rank
danjenkins Jul 6, 2022
b833049
fix func declaration to include return type
danjenkins Jul 6, 2022
9664ac5
add in rank constants
danjenkins Aug 15, 2022
6064421
make feature rank use a proper rank type
danjenkins Sep 6, 2022
c7cd728
Register GstSample marshaling functions (#2)
biglittlebigben Feb 10, 2023
d0fc9e9
change module name and use new golang version
RSWilli Aug 11, 2023
6f0f2b4
add banner
RSWilli Aug 11, 2023
ca1a83e
change clockTime type, add more bindings
RSWilli Aug 11, 2023
7180598
interpolationcontrol source set timed value
RSWilli Aug 14, 2023
d7144e2
add docs to NewElementWithProperties
RSWilli Aug 14, 2023
769c885
Merge pull request #1 from go-gst/clocks_and_more_bindings
RSWilli Aug 14, 2023
304b4c8
add micro version number
danjenkins Mar 10, 2023
2573f5f
add the ability to unlink and unlink many elems
danjenkins Sep 6, 2022
f9daac4
deal with usign g_free for NULL
danjenkins Mar 20, 2023
8656b9b
Merge pull request #6 from everycastlabs/add-micro-version-number
RSWilli Aug 23, 2023
8cc7462
Merge pull request #7 from everycastlabs/add-unlink-many
RSWilli Aug 23, 2023
e8f4bbf
Merge pull request #8 from everycastlabs/bux-fix-free-to-g-free
RSWilli Aug 23, 2023
f5a125d
Merge branch 'main' into add-feature-rank
danjenkins Aug 23, 2023
36e112e
change ulong over to GstClockTime
danjenkins Aug 23, 2023
ab35b40
fix -1 for ClockTimeNone
danjenkins Aug 23, 2023
60f8c35
cast name to a gpointer
danjenkins Aug 23, 2023
c5309cf
add a feature rank example
danjenkins Aug 23, 2023
587663a
now add an example of using a non standard rank
danjenkins Aug 23, 2023
7826f5d
Merge pull request #12 from everycastlabs/fix-errors-mac-windows
RSWilli Aug 24, 2023
4aef7e3
Merge pull request #4 from everycastlabs/add-feature-rank
RSWilli Aug 24, 2023
63773b8
improve goreport by fixing typos and formatting issues
RSWilli Aug 24, 2023
9586f80
Merge pull request #18 from go-gst/goreport
RSWilli Aug 24, 2023
8fd5e46
initial commit of device monitor
danjenkins Aug 15, 2022
6dd84c0
add some missing methods
danjenkins Aug 15, 2022
9ed2804
fix incoirrect int vs uint
danjenkins Aug 15, 2022
4e393d6
add basic support for device provider
danjenkins Aug 15, 2022
b7e1481
add watching bus ability
danjenkins Aug 15, 2022
8253c81
fix some comments from copy/paste
danjenkins Aug 16, 2022
0a4e5ae
change module url
danjenkins Aug 23, 2023
074f909
update to use proper handling of c pointers etc
danjenkins Aug 24, 2023
b549813
Add GitHub action build and lint (#21)
danjenkins Aug 26, 2023
620e9fe
add the ability to set audio metadata on a buffer
danjenkins Jul 5, 2022
6561655
pass in NULL/nil temporarily
danjenkins Jul 5, 2022
f4c5ddb
total hack for windows compile
danjenkins Jul 13, 2022
0948e67
change the module url
danjenkins Aug 23, 2023
7c7d4d5
make audio meta use glib's transfer none
danjenkins Aug 25, 2023
2430d40
fix errors
danjenkins Aug 26, 2023
dec9519
change more time.Durations to gst.ClockTime
RSWilli Aug 24, 2023
d7905fb
Merge pull request #26 from go-gst/device-monitor
RSWilli Aug 28, 2023
847657b
Merge pull request #27 from go-gst/audio-metadata-non-interlaced
RSWilli Aug 28, 2023
b007afd
Merge pull request #17 from go-gst/remove_time_duration
RSWilli Aug 28, 2023
39bee53
Merge remote-tracking branch 'go-gst/main' into benjamin/gst_sample_m…
biglittlebigben Aug 28, 2023
f8c5604
Change take sample ownership
biglittlebigben Aug 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions .github/Dockerfile

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build

on:
pull_request:
branches:
- main

jobs:
matrix:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, 'macos-latest']
runs-on: ${{ matrix.os }}
steps:
- name: Setup GStreamer
id: setup_gstreamer
uses: blinemedical/setup-gstreamer@45324555100927b587d390d8cf3940f91fd3bdc9
with:
version: 1.22.0
- uses: actions/setup-go@v4
with:
go-version: '^1.21.0'
- name: checkout
uses: actions/checkout@v3
- name: build the appsink
run: cd examples/appsink && go build -x .


29 changes: 18 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
name: Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
branches:
- main

jobs:

setup:
name: Tests
runs-on: ubuntu-20.04
name: Tests on codebase
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Check formatting
uses: Jerome1337/gofmt-action@v1.0.5
with:
gofmt-path: '.'
gofmt-flags: '-l -d'

- name: Check spellings
uses: reviewdog/action-misspell@v1
with:
locale: "US"
fail_on_error: true

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Lint all packages
run: |
make docker-lint
7 changes: 0 additions & 7 deletions .golangci.yml

This file was deleted.

20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# go-gst
![banner](./img/go-gst-banner.png)

Go bindings for the GStreamer C libraries
# go-gst: Go bindings for the GStreamer C libraries

[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-rounded)](https://pkg.go.dev/github.com/tinyzimmer/go-gst)
[![godoc reference](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/tinyzimmer/go-gst)
[![GoReportCard](https://goreportcard.com/badge/github.com/nanomsg/mangos)](https://goreportcard.com/report/github.com/tinyzimmer/go-gst)
![](https://github.com/tinyzimmer/go-gst/workflows/Tests/badge.svg)
[![godoc reference](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/go-gst/go-gst)
[![GoReportCard](https://goreportcard.com/badge/github.com/go-gst/go-gst)](https://goreportcard.com/report/github.com/go-gst/go-gst)
<!-- ![](https://github.com/go-gst/go-gst/workflows/Tests/badge.svg) -->

See the [godoc.org](https://godoc.org/github.com/tinyzimmer/go-gst) or [pkg.go.dev](https://pkg.go.dev/github.com/tinyzimmer/go-gst) references for documentation and examples.
As the latter requires published tags, see godoc.org for the latest documentation of master at any point in time.
See [pkg.go.dev](https://pkg.go.dev/github.com/go-gst/go-gst) references for documentation and examples.

**This library has not been thoroughly tested and as such is not recommended for mission critical applications yet. If you'd like to try it out and encounter any bugs, feel free to open an Issue or PR. For more information see the [Contributing](#contributing) section.**

Expand Down Expand Up @@ -40,7 +38,7 @@ PS> $env:PKG_CONFIG_PATH='C:\gstreamer\1.0\mingw_x86_64\lib\pkgconfig'
PS> go build .
```

For more information, take a look at [this comment](https://github.com/tinyzimmer/go-gst/issues/3#issuecomment-760648278) with a good run down of the process from compilation to execution.
For more information, take a look at [this comment](https://github.com/go-gst/go-gst/issues/3#issuecomment-760648278) with a good run down of the process from compilation to execution.

## Quickstart

Expand All @@ -56,8 +54,8 @@ import (
"os"
"strings"

"github.com/tinyzimmer/go-glib/glib"
"github.com/tinyzimmer/go-gst/gst"
"github.com/go-gst/go-glib/glib"
"github.com/go-gst/go-gst/gst"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions cmd/gst-plugin-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ import "C"
import (
"unsafe"

"github.com/tinyzimmer/go-gst/gst"
"github.com/go-gst/go-gst/gst"
{{- if (.Config.Element.Subclass | extendsFromBase) }}
"github.com/tinyzimmer/go-gst/gst/base"
"github.com/go-gst/go-gst/gst/base"
{{- end }}
)

Expand Down
9 changes: 4 additions & 5 deletions examples/appsink/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import (
"math"
"os"
"os/signal"
"time"

"github.com/tinyzimmer/go-gst/examples"
"github.com/tinyzimmer/go-gst/gst"
"github.com/tinyzimmer/go-gst/gst/app"
"github.com/go-gst/go-gst/examples"
"github.com/go-gst/go-gst/gst"
"github.com/go-gst/go-gst/gst/app"
)

func createPipeline() (*gst.Pipeline, error) {
Expand Down Expand Up @@ -116,7 +115,7 @@ func mainLoop(pipeline *gst.Pipeline) error {

// Loop over messsages from the pipeline
for {
msg := bus.TimedPop(time.Duration(-1))
msg := bus.TimedPop(gst.ClockTimeNone)
if msg == nil {
break
}
Expand Down
12 changes: 6 additions & 6 deletions examples/appsrc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"image/color"
"time"

"github.com/tinyzimmer/go-glib/glib"
"github.com/tinyzimmer/go-gst/examples"
"github.com/tinyzimmer/go-gst/gst"
"github.com/tinyzimmer/go-gst/gst/app"
"github.com/tinyzimmer/go-gst/gst/video"
"github.com/go-gst/go-glib/glib"
"github.com/go-gst/go-gst/examples"
"github.com/go-gst/go-gst/gst"
"github.com/go-gst/go-gst/gst/app"
"github.com/go-gst/go-gst/gst/video"
)

const width = 320
Expand Down Expand Up @@ -76,7 +76,7 @@ func createPipeline() (*gst.Pipeline, error) {

// For each frame we produce, we set the timestamp when it should be displayed
// The autovideosink will use this information to display the frame at the right time.
buffer.SetPresentationTimestamp(time.Duration(i) * 500 * time.Millisecond)
buffer.SetPresentationTimestamp(gst.ClockTime(time.Duration(i) * 500 * time.Millisecond))

// Produce an image frame for this iteration.
pixels := produceImageFrame(palette[i])
Expand Down
6 changes: 3 additions & 3 deletions examples/bins/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package main

import (
"fmt"
"github.com/tinyzimmer/go-glib/glib"
"github.com/tinyzimmer/go-gst/examples"
"github.com/tinyzimmer/go-gst/gst"
"github.com/go-gst/go-glib/glib"
"github.com/go-gst/go-gst/examples"
"github.com/go-gst/go-gst/gst"
"os"
)

Expand Down
2 changes: 1 addition & 1 deletion examples/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package examples
import (
"fmt"

"github.com/tinyzimmer/go-glib/glib"
"github.com/go-gst/go-glib/glib"
)

// Run is used to wrap the given function in a main loop and print any error
Expand Down
6 changes: 3 additions & 3 deletions examples/custom_events/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"fmt"
"time"

"github.com/tinyzimmer/go-glib/glib"
"github.com/tinyzimmer/go-gst/examples"
"github.com/tinyzimmer/go-gst/gst"
"github.com/go-gst/go-glib/glib"
"github.com/go-gst/go-gst/examples"
"github.com/go-gst/go-gst/gst"
)

// ExampleCustomEvent demonstrates a custom event structue. Currerntly nested structs
Expand Down
14 changes: 7 additions & 7 deletions examples/decodebin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Before the pipeline hasn't been prerolled, the decodebin can't possibly know what
// format it gets as its input. So at first, the pipeline looks like this:
//
// {filesrc} - {decodebin}
// {filesrc} - {decodebin}
//
// As soon as the decodebin has detected the stream format, it will try to decode every
// contained stream to its raw format.
Expand All @@ -18,9 +18,9 @@
// So for a file that contains one audio and one video stream,
// the pipeline looks like the following:
//
// /-[audio]-{audioconvert}-{audioresample}-{autoaudiosink}
// {filesrc}-{decodebin}-|
// \-[video]-{videoconvert}-{videoscale}-{autovideosink}
// /-[audio]-{audioconvert}-{audioresample}-{autoaudiosink}
// {filesrc}-{decodebin}-|
// \-[video]-{videoconvert}-{videoscale}-{autovideosink}
//
// Both auto-sinks at the end automatically select the best available (actual) sink. Since the
// selection of available actual sinks is platform specific
Expand All @@ -38,9 +38,9 @@ import (
"os"
"strings"

"github.com/tinyzimmer/go-glib/glib"
"github.com/tinyzimmer/go-gst/examples"
"github.com/tinyzimmer/go-gst/gst"
"github.com/go-gst/go-glib/glib"
"github.com/go-gst/go-gst/examples"
"github.com/go-gst/go-gst/gst"
)

var srcFile string
Expand Down
75 changes: 75 additions & 0 deletions examples/device_monitor/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// This example uses gstreamer's device monitor api.
//
// https://gstreamer.freedesktop.org/documentation/gstreamer/gstdevicemonitor.html
package main

import (
"fmt"

"github.com/go-gst/go-glib/glib"
"github.com/go-gst/go-gst/examples"
"github.com/go-gst/go-gst/gst"
)

func runPipeline(loop *glib.MainLoop) error {

gst.Init(nil)
fmt.Println("Running device monitor")
// if len(os.Args) < 2 {
// fmt.Printf("USAGE: %s <uri>\n", os.Args[0])
// os.Exit(1)
// }

// uri := os.Args[1]
fmt.Println("Creating device monitor")

monitor := gst.NewDeviceMonitor()
fmt.Println("Created device monitor", monitor)

// if err != nil {
// fmt.Println("ERROR:", err)
// os.Exit(2)
// }
caps := gst.NewCapsFromString("video/x-raw")

monitor.AddFilter("Video/Source", caps)

fmt.Println("Getting device monitor bus")
bus := monitor.GetBus()
fmt.Println("Got device monitor bus", bus)

bus.AddWatch(func(msg *gst.Message) bool {
switch msg.Type() {
case gst.MessageDeviceAdded:
message := msg.ParseDeviceAdded().GetDisplayName()
fmt.Println("Added: ", message)
case gst.MessageDeviceRemoved:
message := msg.ParseDeviceRemoved().GetDisplayName()
fmt.Println("Removed: ", message)
default:
// All messages implement a Stringer. However, this is
// typically an expensive thing to do and should be avoided.
fmt.Println("Type: ", msg.Type())
fmt.Println("Message: ", msg)
}
return true
})

fmt.Println("Starting device monitor")
monitor.Start()
fmt.Println("Started device monitor")
devices := monitor.GetDevices()
for i, v := range devices {
fmt.Printf("Device: %d %s\n", i, v.GetDisplayName())
}

loop.Run()

return nil
}

func main() {
examples.RunLoop(func(loop *glib.MainLoop) error {
return runPipeline(loop)
})
}
Loading