Merge pull request #4 from everycastlabs/add-feature-rank

Add feature rank
This commit is contained in:
Wilhelm Bartel
2023-08-24 10:41:19 +02:00
committed by GitHub
4 changed files with 66 additions and 8 deletions

View File

@@ -0,0 +1,47 @@
// This example shows how to use the feature ranking.
package main
import (
"fmt"
"github.com/go-gst/go-gst/examples"
"github.com/go-gst/go-gst/gst"
)
func start() (error) {
gst.Init(nil)
registry := gst.GetRegistry()
higherThanHighRank := (gst.Rank)(258)
codec, codecErr := registry.LookupFeature("vtdec_hw")
if codecErr == nil {
codec.SetPluginRank(higherThanHighRank)
rank := codec.GetPluginRank()
fmt.Println("vtdec_hw rank is:", rank)
}
codec, codecErr = registry.LookupFeature("vtdec_hw")
if codecErr == nil {
codec.SetPluginRank(gst.RankPrimary)
rank := codec.GetPluginRank()
fmt.Println("vtdec_hw rank is now:", rank)
}
//add a feature you expect to be available to you here and change it's rank
return codecErr
}
func main() {
examples.Run(func() error {
var err error
if err = start(); err != nil {
return err
}
return nil
})
}

View File

@@ -490,6 +490,16 @@ const (
PadProbeTypeScheduling PadProbeType = C.GST_PAD_PROBE_TYPE_SCHEDULING // (12288) probe push and pull PadProbeTypeScheduling PadProbeType = C.GST_PAD_PROBE_TYPE_SCHEDULING // (12288) probe push and pull
) )
// Rank casts GstRank
type Rank uint
const (
RankNone Rank = C.GST_RANK_NONE // (0) - will be chosen last or not at all
RankMarginal Rank = C.GST_RANK_MARGINAL // (64) unlikely to be chosen
RankSecondary Rank = C.GST_RANK_SECONDARY // (128) likely to be chosen
RankPrimary Rank = C.GST_RANK_PRIMARY // (256) will be chosen first
)
// SchedulingFlags casts GstSchedulingFlags // SchedulingFlags casts GstSchedulingFlags
type SchedulingFlags int type SchedulingFlags int

View File

@@ -100,14 +100,6 @@ func ElementUnlinkMany(elems ...*Element) {
} }
} }
// Rank represents a level of importance when autoplugging elements.
type Rank uint
// For now just a single RankNone is provided
const (
RankNone Rank = 0
)
// RegisterElement creates a new elementfactory capable of instantiating objects of the given GoElement // RegisterElement creates a new elementfactory capable of instantiating objects of the given GoElement
// and adds the factory to the plugin. A higher rank means more importance when autoplugging. // and adds the factory to the plugin. A higher rank means more importance when autoplugging.
func RegisterElement(plugin *Plugin, name string, rank Rank, elem glib.GoObjectSubclass, extends glib.Extendable, interfaces ...glib.Interface) bool { func RegisterElement(plugin *Plugin, name string, rank Rank, elem glib.GoObjectSubclass, extends glib.Extendable, interfaces ...glib.Interface) bool {

View File

@@ -30,3 +30,12 @@ func (p *PluginFeature) GetPluginName() string {
} }
return C.GoString(pluginName) return C.GoString(pluginName)
} }
func (p *PluginFeature) SetPluginRank(rank Rank) {
C.gst_plugin_feature_set_rank((*C.GstPluginFeature)(p.Instance()), C.guint(rank))
}
func (p *PluginFeature) GetPluginRank() int {
rank := C.gst_plugin_feature_get_rank((*C.GstPluginFeature)(p.Instance()))
return int(rank)
}