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

Add support for gstreamer 1.16 by putting 1.18 specific stuff behind a build tag #35

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
152 changes: 0 additions & 152 deletions gst/gst_values.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,155 +558,3 @@ func (i *IntRangeValue) ToGValue() (*glib.Value, error) {
)
return val, nil
}

// TypeValueArray is the GType for a GstValueArray
var TypeValueArray = glib.Type(C.gst_value_array_get_type())

// ValueArrayValue represets a GstValueArray.
type ValueArrayValue glib.Value

// ValueArray converts the given slice of Go types into a ValueArrayValue.
// This function can return nil on any conversion or memory allocation errors.
func ValueArray(ss []interface{}) *ValueArrayValue {
v, err := glib.ValueAlloc()
if err != nil {
return nil
}
C.gst_value_array_init(
(*C.GValue)(unsafe.Pointer(v.GValue)),
C.guint(len(ss)),
)
for _, s := range ss {
val, err := glib.GValue(s)
if err != nil {
return nil
}
C.gst_value_array_append_value(
(*C.GValue)(unsafe.Pointer(v.GValue)),
(*C.GValue)(unsafe.Pointer(val.GValue)),
)
}
out := ValueArrayValue(*v)
return &out
}

// Size returns the size of the array.
func (v *ValueArrayValue) Size() uint {
return uint(C.gst_value_array_get_size((*C.GValue)(unsafe.Pointer(v.GValue))))
}

// ValueAt returns the value at the index in the array, or nil on any error.
func (v *ValueArrayValue) ValueAt(idx uint) interface{} {
gval := C.gst_value_array_get_value(
(*C.GValue)(unsafe.Pointer(v.GValue)),
C.guint(idx),
)
if gval == nil {
return nil
}
out, err := glib.ValueFromNative(unsafe.Pointer(gval)).GoValue()
if err != nil {
return nil
}
return out
}

// ToGValue implements a glib.ValueTransformer.
func (v *ValueArrayValue) ToGValue() (*glib.Value, error) {
out := glib.Value(*v)
return &out, nil
}

// TypeValueList is the GType for a GstValueList
var TypeValueList = glib.Type(C.gst_value_list_get_type())

// ValueListValue represets a GstValueList.
type ValueListValue glib.Value

// ValueList converts the given slice of Go types into a ValueListValue.
// This function can return nil on any conversion or memory allocation errors.
func ValueList(ss []interface{}) *ValueListValue {
v, err := glib.ValueAlloc()
if err != nil {
return nil
}
C.gst_value_list_init(
(*C.GValue)(unsafe.Pointer(v.GValue)),
C.guint(len(ss)),
)
for _, s := range ss {
val, err := glib.GValue(s)
if err != nil {
return nil
}
C.gst_value_list_append_value(
(*C.GValue)(unsafe.Pointer(v.GValue)),
(*C.GValue)(unsafe.Pointer(val.GValue)),
)
}
out := ValueListValue(*v)
return &out
}

// Size returns the size of the list.
func (v *ValueListValue) Size() uint {
return uint(C.gst_value_list_get_size((*C.GValue)(unsafe.Pointer(v.GValue))))
}

// ValueAt returns the value at the index in the lise, or nil on any error.
func (v *ValueListValue) ValueAt(idx uint) interface{} {
gval := C.gst_value_list_get_value(
(*C.GValue)(unsafe.Pointer(v.GValue)),
C.guint(idx),
)
if gval == nil {
return nil
}
out, err := glib.ValueFromNative(unsafe.Pointer(gval)).GoValue()
if err != nil {
return nil
}
return out
}

// Concat concatenates copies of this list and value into a new list. Values that are not of type
// TypeValueList are treated as if they were lists of length 1. dest will be initialized to the type
// TypeValueList.
func (v *ValueListValue) Concat(value *ValueListValue) *ValueListValue {
out, err := glib.ValueAlloc()
if err != nil {
return nil
}
C.gst_value_list_concat(
(*C.GValue)(unsafe.Pointer(out.GValue)),
(*C.GValue)(unsafe.Pointer(v.GValue)),
(*C.GValue)(unsafe.Pointer(value.GValue)),
)
o := ValueListValue(*out)
return &o
}

// Merge merges copies of value into this list. Values that are not of type TypeValueList are treated as
// if they were lists of length 1.
//
// The result will be put into a new value and will either be a list that will not contain any duplicates,
// or a non-list type (if the lists were equal).
func (v *ValueListValue) Merge(value *ValueListValue) *ValueListValue {
out, err := glib.ValueAlloc()
if err != nil {
return nil
}
C.gst_value_list_merge(
(*C.GValue)(unsafe.Pointer(out.GValue)),
(*C.GValue)(unsafe.Pointer(v.GValue)),
(*C.GValue)(unsafe.Pointer(value.GValue)),
)
o := ValueListValue(*out)
return &o
}

// ToGValue implements a glib.ValueTransformer.
func (v *ValueListValue) ToGValue() (*glib.Value, error) {
out := glib.Value(*v)
return &out, nil
}
167 changes: 167 additions & 0 deletions gst/gst_values_118.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
//go:build !gst116
// +build !gst116

package gst

/*
#include "gst.go.h"
*/
import "C"

import (
"unsafe"

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

// TypeValueArray is the GType for a GstValueArray
var TypeValueArray = glib.Type(C.gst_value_array_get_type())

// ValueArrayValue represets a GstValueArray.
type ValueArrayValue glib.Value

// ValueArray converts the given slice of Go types into a ValueArrayValue.
// This function can return nil on any conversion or memory allocation errors.
func ValueArray(ss []interface{}) *ValueArrayValue {
v, err := glib.ValueAlloc()
if err != nil {
return nil
}
C.gst_value_array_init(
(*C.GValue)(unsafe.Pointer(v.GValue)),
C.guint(len(ss)),
)
for _, s := range ss {
val, err := glib.GValue(s)
if err != nil {
return nil
}
C.gst_value_array_append_value(
(*C.GValue)(unsafe.Pointer(v.GValue)),
(*C.GValue)(unsafe.Pointer(val.GValue)),
)
}
out := ValueArrayValue(*v)
return &out
}

// Size returns the size of the array.
func (v *ValueArrayValue) Size() uint {
return uint(C.gst_value_array_get_size((*C.GValue)(unsafe.Pointer(v.GValue))))
}

// ValueAt returns the value at the index in the array, or nil on any error.
func (v *ValueArrayValue) ValueAt(idx uint) interface{} {
gval := C.gst_value_array_get_value(
(*C.GValue)(unsafe.Pointer(v.GValue)),
C.guint(idx),
)
if gval == nil {
return nil
}
out, err := glib.ValueFromNative(unsafe.Pointer(gval)).GoValue()
if err != nil {
return nil
}
return out
}

// ToGValue implements a glib.ValueTransformer.
func (v *ValueArrayValue) ToGValue() (*glib.Value, error) {
out := glib.Value(*v)
return &out, nil
}

// TypeValueList is the GType for a GstValueList
var TypeValueList = glib.Type(C.gst_value_list_get_type())

// ValueListValue represets a GstValueList.
type ValueListValue glib.Value

// ValueList converts the given slice of Go types into a ValueListValue.
// This function can return nil on any conversion or memory allocation errors.
func ValueList(ss []interface{}) *ValueListValue {
v, err := glib.ValueAlloc()
if err != nil {
return nil
}
C.gst_value_list_init(
(*C.GValue)(unsafe.Pointer(v.GValue)),
C.guint(len(ss)),
)
for _, s := range ss {
val, err := glib.GValue(s)
if err != nil {
return nil
}
C.gst_value_list_append_value(
(*C.GValue)(unsafe.Pointer(v.GValue)),
(*C.GValue)(unsafe.Pointer(val.GValue)),
)
}
out := ValueListValue(*v)
return &out
}

// Size returns the size of the list.
func (v *ValueListValue) Size() uint {
return uint(C.gst_value_list_get_size((*C.GValue)(unsafe.Pointer(v.GValue))))
}

// ValueAt returns the value at the index in the lise, or nil on any error.
func (v *ValueListValue) ValueAt(idx uint) interface{} {
gval := C.gst_value_list_get_value(
(*C.GValue)(unsafe.Pointer(v.GValue)),
C.guint(idx),
)
if gval == nil {
return nil
}
out, err := glib.ValueFromNative(unsafe.Pointer(gval)).GoValue()
if err != nil {
return nil
}
return out
}

// Concat concatenates copies of this list and value into a new list. Values that are not of type
// TypeValueList are treated as if they were lists of length 1. dest will be initialized to the type
// TypeValueList.
func (v *ValueListValue) Concat(value *ValueListValue) *ValueListValue {
out, err := glib.ValueAlloc()
if err != nil {
return nil
}
C.gst_value_list_concat(
(*C.GValue)(unsafe.Pointer(out.GValue)),
(*C.GValue)(unsafe.Pointer(v.GValue)),
(*C.GValue)(unsafe.Pointer(value.GValue)),
)
o := ValueListValue(*out)
return &o
}

// Merge merges copies of value into this list. Values that are not of type TypeValueList are treated as
// if they were lists of length 1.
//
// The result will be put into a new value and will either be a list that will not contain any duplicates,
// or a non-list type (if the lists were equal).
func (v *ValueListValue) Merge(value *ValueListValue) *ValueListValue {
out, err := glib.ValueAlloc()
if err != nil {
return nil
}
C.gst_value_list_merge(
(*C.GValue)(unsafe.Pointer(out.GValue)),
(*C.GValue)(unsafe.Pointer(v.GValue)),
(*C.GValue)(unsafe.Pointer(value.GValue)),
)
o := ValueListValue(*out)
return &o
}

// ToGValue implements a glib.ValueTransformer.
func (v *ValueListValue) ToGValue() (*glib.Value, error) {
out := glib.Value(*v)
return &out, nil
}
20 changes: 0 additions & 20 deletions gst/gst_wrappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,6 @@ func registerMarshalers() {
T: TypeIntRange,
F: marshalIntRange,
},
{
T: TypeValueArray,
F: marshalValueArray,
},
{
T: TypeValueList,
F: marshalValueList,
},
}

glib.RegisterGValueMarshalers(tm)
Expand All @@ -243,18 +235,6 @@ func toGValue(p uintptr) *C.GValue {
return (*C.GValue)((unsafe.Pointer)(p))
}

func marshalValueArray(p uintptr) (interface{}, error) {
val := toGValue(p)
out := ValueArrayValue(*glib.ValueFromNative(unsafe.Pointer(val)))
return &out, nil
}

func marshalValueList(p uintptr) (interface{}, error) {
val := glib.ValueFromNative(unsafe.Pointer(toGValue(p)))
out := ValueListValue(*glib.ValueFromNative(unsafe.Pointer(val)))
return &out, nil
}

func marshalInt64Range(p uintptr) (interface{}, error) {
v := toGValue(p)
return &Int64RangeValue{
Expand Down
Loading