mirror of
https://github.com/go-gst/go-gst.git
synced 2024-05-25 23:34:20 +08:00
make working with non-go-comparable object properties a little easier
This commit is contained in:
parent
37c529bedf
commit
d83b9c8b12
2
go.mod
2
go.mod
@ -4,5 +4,5 @@ go 1.15
|
||||
|
||||
require (
|
||||
github.com/mattn/go-pointer v0.0.1
|
||||
github.com/tinyzimmer/go-glib v0.0.2
|
||||
github.com/tinyzimmer/go-glib v0.0.3
|
||||
)
|
||||
|
2
go.sum
2
go.sum
@ -2,3 +2,5 @@ github.com/mattn/go-pointer v0.0.1 h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o
|
||||
github.com/mattn/go-pointer v0.0.1/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc=
|
||||
github.com/tinyzimmer/go-glib v0.0.2 h1:hdvjwrhcS6WrMMeqfxsf3e7/lOhV8gbVyJ9/sN3LfyY=
|
||||
github.com/tinyzimmer/go-glib v0.0.2/go.mod h1:D5rd0CvYn1p7TBhwlwnBXHSr4d8lwEY9JImPQ66S+Bs=
|
||||
github.com/tinyzimmer/go-glib v0.0.3 h1:yPax+QpAcmm16Ye3RZOsBVR0UpMZ9JnglJCgrlBN+C8=
|
||||
github.com/tinyzimmer/go-glib v0.0.3/go.mod h1:D5rd0CvYn1p7TBhwlwnBXHSr4d8lwEY9JImPQ66S+Bs=
|
||||
|
@ -117,9 +117,6 @@ func NewFloat64Param(name, nick, blurb string, min, max, defaultValue float64, f
|
||||
return &ParamSpec{paramSpec: paramSpec}
|
||||
}
|
||||
|
||||
// TypeCaps is the static Glib Type for a GstCaps.
|
||||
var TypeCaps = glib.Type(C.gst_caps_get_type())
|
||||
|
||||
// NewBoxedParam creates a new ParamSpec containing a boxed type. Some helper type castings are included
|
||||
// in these bindings.
|
||||
func NewBoxedParam(name, nick, blurb string, boxedType glib.Type, flags ParameterFlags) *ParamSpec {
|
||||
|
@ -21,6 +21,9 @@ import (
|
||||
"github.com/tinyzimmer/go-glib/glib"
|
||||
)
|
||||
|
||||
// TypeCaps is the static Glib Type for a GstCaps.
|
||||
var TypeCaps = glib.Type(C.gst_caps_get_type())
|
||||
|
||||
// Caps is a go wrapper around GstCaps.
|
||||
type Caps struct {
|
||||
native *C.GstCaps
|
||||
@ -72,30 +75,6 @@ func NewFullCaps(structures ...*Structure) *Caps {
|
||||
return caps
|
||||
}
|
||||
|
||||
// // NewSimpleCaps creates new caps with the given media format and key value pairs.
|
||||
// // The key of each pair must be a string, followed by any field that can be converted
|
||||
// // to a GType.
|
||||
// func NewSimpleCaps(mediaFormat string, fieldVals ...interface{}) (*Caps, error) {
|
||||
// if len(fieldVals)%2 != 0 {
|
||||
// return nil, errors.New("Received odd number of key/value pairs")
|
||||
// }
|
||||
// caps := NewEmptySimpleCaps(mediaFormat)
|
||||
// strParts := make([]string, 0)
|
||||
// for i := 0; i < len(fieldVals); i = i + 2 {
|
||||
// fieldKey, ok := fieldVals[i].(string)
|
||||
// if !ok {
|
||||
// return nil, errors.New("One or more field keys are not a valid string")
|
||||
// }
|
||||
// strParts = append(strParts, fmt.Sprintf("%s=%v", fieldKey, fieldVals[i+1]))
|
||||
// }
|
||||
// structure := NewStructureFromString(strings.Join(strParts, ", "))
|
||||
// if structure == nil {
|
||||
// return nil, errors.New("Could not build structure from the provided arguments")
|
||||
// }
|
||||
// caps.AppendStructure(structure)
|
||||
// return caps, nil
|
||||
// }
|
||||
|
||||
// NewCapsFromString creates a new Caps object from the given string.
|
||||
//
|
||||
// caps := gst.NewCapsFromString("audio/x-raw, channels=2")
|
||||
@ -120,6 +99,18 @@ func NewRawCaps(format string, rate, channels int) *Caps {
|
||||
|
||||
func (c *Caps) unsafe() unsafe.Pointer { return unsafe.Pointer(c.native) }
|
||||
|
||||
// ToGValue returns a GValue containing the given caps. Note that under unexpected circumstances in allocation
|
||||
// this function can return nil. A reference to these caps is taken by the resulting value, so they are safe to
|
||||
// unref if not needed anymore.
|
||||
func (c *Caps) ToGValue() *glib.Value {
|
||||
val, err := glib.ValueInit(glib.Type(C.getCapsType()))
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
C.gst_value_set_caps((*C.GValue)(unsafe.Pointer(val.GValue)), c.Instance())
|
||||
return val
|
||||
}
|
||||
|
||||
// Ref increases the ref count on these caps by one.
|
||||
//
|
||||
// From this point on, until the caller calls Unref or MakeWritable, it is guaranteed that the caps object
|
||||
|
Loading…
Reference in New Issue
Block a user