gst

package module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2022 License: Apache-2.0 Imports: 9 Imported by: 12

README

gst

a small go gstreamer binding

Install

Ubuntu or Dedian

apt-get install pkg-config
apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-ugly gstreamer1.0-libav


// set GST_PLUGIN_PATH on linux, may diff on your system
export GST_PLUGIN_PATH=/usr/local/lib:/usr/lib/x86_64-linux-gnu/gstreamer-1.0

Mac os

brew install gstreamer
brew install gst-plugins-base
brew install gst-plugins-good
brew install gst-plugins-bad
brew install gst-plugins-ugly


// set GST_PLUGIN_PATH on mac 
export GST_PLUGIN_PATH=/opt/homebrew/lib/gstreamer-1.0/

Then

go get github.com/notedit/gst

Examples

https://github.com/notedit/gst-go-demo

Documentation

Index

Constants

View Source
const (
	PAD_UNKNOWN = PadDirection(C.GST_PAD_UNKNOWN)
	PAD_SRC     = PadDirection(C.GST_PAD_SRC)
	PAD_SINK    = PadDirection(C.GST_PAD_SINK)
)
View Source
const (
	PadLinkOk             PadLinkReturn = C.GST_PAD_LINK_OK
	PadLinkWrongHierarchy               = C.GST_PAD_LINK_WRONG_HIERARCHY
	PadLinkWasLinked                    = C.GST_PAD_LINK_WAS_LINKED
	PadLinkWrongDirection               = C.GST_PAD_LINK_WRONG_DIRECTION
	PadLinkNoFormat                     = C.GST_PAD_LINK_NOFORMAT
	PadLinkNoSched                      = C.GST_PAD_LINK_NOSCHED
	PadLinkRefused                      = C.GST_PAD_LINK_REFUSED
)

Variables

This section is empty.

Functions

func BufferGetData

func BufferGetData(gstBuffer *Buffer) (data []byte, err error)

func CheckPlugins

func CheckPlugins(plugins []string) error

Types

type Bin

type Bin struct {
	Element
}

func BinNew

func BinNew(name string) (bin *Bin)

func ParseBinFromDescription added in v0.0.4

func ParseBinFromDescription(binStr string, ghostPads bool) (bin *Bin, err error)

func (*Bin) Add

func (b *Bin) Add(child *Element)

func (*Bin) AddMany

func (b *Bin) AddMany(elements ...*Element)

func (*Bin) GetByName

func (b *Bin) GetByName(name string) (element *Element)

func (*Bin) Remove

func (b *Bin) Remove(child *Element)

type Buffer

type Buffer struct {
	C *C.GstBuffer
}

func BufferNewAndAlloc

func BufferNewAndAlloc(size uint) (gstBuffer *Buffer, err error)

func BufferNewWrapped

func BufferNewWrapped(data []byte) (gstBuffer *Buffer, err error)

type Bus

type Bus struct {
	C *C.GstBus
}

func (*Bus) HavePending

func (b *Bus) HavePending() bool

func (*Bus) Pop

func (b *Bus) Pop() (message *Message)

func (*Bus) PopTimed added in v0.0.9

func (b *Bus) PopTimed() (message *Message, err error)

func (*Bus) Pull

func (b *Bus) Pull(messageType MessageType) (message *Message)

func (*Bus) TimedPopFiltered added in v0.0.8

func (b *Bus) TimedPopFiltered(timeout time.Duration, messageType MessageType) (message *Message)

type Caps

type Caps struct {
	// contains filtered or unexported fields
}

func CapsFromString

func CapsFromString(caps string) (gstCaps *Caps)

func (*Caps) GetStructure added in v0.0.9

func (c *Caps) GetStructure(index int) (structure *Structure)

func (*Caps) String added in v0.0.3

func (c *Caps) String() (str string)

func (*Caps) ToString

func (c *Caps) ToString() (str string)

type Clock

type Clock struct {
	C *C.GstClock
}

func (*Clock) GetClockTime

func (c *Clock) GetClockTime() uint64

type Element

type Element struct {
	GstElement *C.GstElement
	// contains filtered or unexported fields
}

func ElementFactoryMake

func ElementFactoryMake(factoryName string, name string) (e *Element, err error)

func (*Element) AddPad

func (e *Element) AddPad(pad *Pad) bool

func (*Element) DumpDot added in v0.0.8

func (e *Element) DumpDot(filePath string)

func (*Element) EndOfStream added in v0.0.9

func (e *Element) EndOfStream() (err error)

func (*Element) GetBus added in v0.0.8

func (e *Element) GetBus() (bus *Bus)

func (*Element) GetClock

func (e *Element) GetClock() (gstClock *Clock)

func (*Element) GetClockBaseTime

func (e *Element) GetClockBaseTime() uint64

func (*Element) GetPadTemplate

func (e *Element) GetPadTemplate(name string) (padTemplate *PadTemplate)

func (*Element) GetRequestPad

func (e *Element) GetRequestPad(padTemplate *PadTemplate, name string, caps *Caps) (pad *Pad)

func (*Element) GetStaticPad

func (e *Element) GetStaticPad(name string) (pad *Pad)

func (*Element) IsEOS

func (e *Element) IsEOS() bool

appsink

func (e *Element) Link(dst *Element) bool

func (*Element) Name

func (e *Element) Name() (name string)

func (*Element) PullSample

func (e *Element) PullSample() (sample *Sample, err error)

func (*Element) PushBuffer

func (e *Element) PushBuffer(data []byte) (err error)

func (*Element) Query added in v0.0.8

func (e *Element) Query(q *Query) bool

func (*Element) QueryDuration added in v0.0.7

func (e *Element) QueryDuration() (time.Duration, error)

func (*Element) QueryPosition added in v0.0.7

func (e *Element) QueryPosition() (time.Duration, error)

func (*Element) Seek added in v0.0.9

func (e *Element) Seek(duration time.Duration) bool

func (*Element) SeekSimple added in v0.0.8

func (e *Element) SeekSimple(format FormatOptions, flags SeekFlags, seekPos time.Duration) bool

func (*Element) SendEvent added in v0.0.6

func (e *Element) SendEvent(event *Event) bool

func (*Element) SetObject

func (e *Element) SetObject(name string, value interface{})

func (*Element) SetPadAddedCallback

func (e *Element) SetPadAddedCallback(callback PadAddedCallback)

func (*Element) SetState added in v0.0.8

func (e *Element) SetState(state StateOptions) StateChangeReturn

func (*Element) VideoOverlayExpose added in v0.0.6

func (e *Element) VideoOverlayExpose()

VideoOverlayExpose tells an overlay that it has been exposed. This will redraw the current frame in the drawable even if the pipeline is PAUSED.

func (*Element) VideoOverlayHandleEvents added in v0.0.6

func (e *Element) VideoOverlayHandleEvents(handleEvents bool)

VideoOverlayHandleEvents tells an overlay that it should handle events from the window system. These events are forwarded upstream as navigation events. In some window system, events are not propagated in the window hierarchy if a client is listening for them. This method allows you to disable events handling completely from the GstVideoOverlay.

func (*Element) VideoOverlaySetWindowHandle added in v0.0.6

func (e *Element) VideoOverlaySetWindowHandle(windowID uintptr)

VideoOverlaySetWindowHandle will call the video overlay's set_window_handle method. You should use this method to tell to an overlay to display video output to a specific window (e.g. an XWindow on X11). Passing 0 as the handle will tell the overlay to stop using that window and create an internal one. registers the windowID for video output of the element.

type Event added in v0.0.6

type Event struct {
	GstEvent *C.GstEvent
}

func NewEosEvent added in v0.0.6

func NewEosEvent() (event *Event)

type FormatOptions added in v0.0.8

type FormatOptions int

type GMainLoop

type GMainLoop struct {
	C *C.GMainLoop
}

func MainLoopNew

func MainLoopNew() (loop *GMainLoop)

func (*GMainLoop) IsRuning added in v0.0.2

func (l *GMainLoop) IsRuning() bool

func (*GMainLoop) Quit added in v0.0.2

func (l *GMainLoop) Quit()

func (*GMainLoop) Run

func (l *GMainLoop) Run()

type Message

type Message struct {
	C *C.GstMessage
}

func (*Message) GetName

func (message *Message) GetName() (name string)

func (*Message) GetStructure

func (message *Message) GetStructure() (structure *Structure)

func (*Message) GetType

func (message *Message) GetType() (messageType MessageType)

func (*Message) ParseStateChanged added in v0.0.8

func (message *Message) ParseStateChanged() (oldState, newState, pending StateOptions)

type MessageType

type MessageType C.GstMessageType
const (
	MessageUnknown         MessageType = C.GST_MESSAGE_UNKNOWN
	MessageEos             MessageType = C.GST_MESSAGE_EOS
	MessageError           MessageType = C.GST_MESSAGE_ERROR
	MessageWarning         MessageType = C.GST_MESSAGE_WARNING
	MessageInfo            MessageType = C.GST_MESSAGE_INFO
	MessageTag             MessageType = C.GST_MESSAGE_TAG
	MessageBuffering       MessageType = C.GST_MESSAGE_BUFFERING
	MessageStateChanged    MessageType = C.GST_MESSAGE_STATE_CHANGED
	MessageStateDirty      MessageType = C.GST_MESSAGE_STATE_DIRTY
	MessageStepDone        MessageType = C.GST_MESSAGE_STEP_DONE
	MessageClockProvide    MessageType = C.GST_MESSAGE_CLOCK_PROVIDE
	MessageClockLost       MessageType = C.GST_MESSAGE_CLOCK_LOST
	MessageStructureChange MessageType = C.GST_MESSAGE_STREAM_STATUS
	MessageApplication     MessageType = C.GST_MESSAGE_APPLICATION
	MessageElement         MessageType = C.GST_MESSAGE_ELEMENT
	MessageSegmentStart    MessageType = C.GST_MESSAGE_SEGMENT_START
	MessageSegmentDone     MessageType = C.GST_MESSAGE_SEGMENT_DONE
	MessageDurationChanged MessageType = C.GST_MESSAGE_DURATION_CHANGED
	MessageLatency         MessageType = C.GST_MESSAGE_LATENCY
	MessageAsyncStart      MessageType = C.GST_MESSAGE_ASYNC_START
	MessageAsyncDone       MessageType = C.GST_MESSAGE_ASYNC_DONE
	MessageRequestState    MessageType = C.GST_MESSAGE_REQUEST_STATE
	MessageStepStart       MessageType = C.GST_MESSAGE_STEP_START
	MessageQos             MessageType = C.GST_MESSAGE_QOS
	MessageProgress        MessageType = C.GST_MESSAGE_PROGRESS
	MessageToc             MessageType = C.GST_MESSAGE_TOC
	MessageResetTime       MessageType = C.GST_MESSAGE_RESET_TIME
	MessageStreamStart     MessageType = C.GST_MESSAGE_STREAM_START
	MessageNeedContext     MessageType = C.GST_MESSAGE_NEED_CONTEXT
	MessageHaveContext     MessageType = C.GST_MESSAGE_HAVE_CONTEXT
	MessageExtended        MessageType = C.GST_MESSAGE_EXTENDED
	MessageDeviceAdded     MessageType = C.GST_MESSAGE_DEVICE_ADDED
	MessageDeviceRemoved   MessageType = C.GST_MESSAGE_DEVICE_REMOVED
	//MessagePropertyNotify   MessageType = C.GST_MESSAGE_PROPERTY_NOTIFY
	//MessageStreamCollection MessageType = C.GST_MESSAGE_STREAM_COLLECTION
	//MessageStreamsSelected  MessageType = C.GST_MESSAGE_STREAMS_SELECTED
	//MessageRedirect         MessageType = C.GST_MESSAGE_REDIRECT
	MessageAny MessageType = C.GST_MESSAGE_ANY
)

type Pad

type Pad struct {
	// contains filtered or unexported fields
}

func (*Pad) GetCurrentCaps

func (p *Pad) GetCurrentCaps() (gstCaps *Caps)

func (*Pad) IsEOS

func (p *Pad) IsEOS() bool

func (*Pad) IsLinked added in v0.0.3

func (p *Pad) IsLinked() bool
func (p *Pad) Link(sink *Pad) (padLinkReturn PadLinkReturn)

func (*Pad) Name added in v0.0.3

func (p *Pad) Name() string

func (*Pad) SetObject added in v0.0.8

func (e *Pad) SetObject(name string, value interface{})
func (p *Pad) Unlink(sink *Pad) (padLinkReturn PadLinkReturn)

type PadAddedCallback

type PadAddedCallback func(element *Element, pad *Pad)

type PadDirection

type PadDirection C.GstPadDirection

func (PadDirection) String

func (p PadDirection) String() string

type PadLinkReturn

type PadLinkReturn int

type PadTemplate

type PadTemplate struct {
	C *C.GstPadTemplate
}

type Pipeline

type Pipeline struct {
	Bin
}

func ParseLaunch

func ParseLaunch(pipelineStr string) (p *Pipeline, err error)

func PipelineNew

func PipelineNew(name string) (e *Pipeline, err error)

func (*Pipeline) GetBus

func (p *Pipeline) GetBus() (bus *Bus)

func (*Pipeline) GetClock

func (p *Pipeline) GetClock() (clock *Clock)

func (*Pipeline) GetDelay

func (p *Pipeline) GetDelay() uint64

func (*Pipeline) GetLatency

func (p *Pipeline) GetLatency() uint64

func (*Pipeline) SetLatency

func (p *Pipeline) SetLatency(latency uint64)

func (*Pipeline) SetState

func (p *Pipeline) SetState(state StateOptions) StateChangeReturn

type Query added in v0.0.8

type Query struct {
	C *C.GstQuery
}

func QueryNewSeeking added in v0.0.8

func QueryNewSeeking(format FormatOptions) (q *Query, err error)

func (*Query) ParseSeeking added in v0.0.8

func (q *Query) ParseSeeking(format *FormatOptions) (seekable bool, segmentStart, segmentEnd time.Duration)

type Sample

type Sample struct {
	Data     []byte
	Duration uint64
	Pts      uint64
	Dts      uint64
	Offset   uint64
}

type SeekFlags added in v0.0.8

type SeekFlags int
const (
	SeekFlagNone                      SeekFlags = C.GST_SEEK_FLAG_NONE
	SeekFlagFlush                     SeekFlags = C.GST_SEEK_FLAG_FLUSH
	SeekFlagAccurate                  SeekFlags = C.GST_SEEK_FLAG_ACCURATE
	SeekFlagKeyUnit                   SeekFlags = C.GST_SEEK_FLAG_KEY_UNIT
	SeekFlagSegment                   SeekFlags = C.GST_SEEK_FLAG_SEGMENT
	SeekFlagTrickmode                 SeekFlags = C.GST_SEEK_FLAG_TRICKMODE
	SeekFlagSkip                      SeekFlags = C.GST_SEEK_FLAG_SKIP
	SeekFlagSnapBefore                SeekFlags = C.GST_SEEK_FLAG_SNAP_BEFORE
	SeekFlagSnapAfter                 SeekFlags = C.GST_SEEK_FLAG_SNAP_AFTER
	SeekFlagSnapNearest               SeekFlags = C.GST_SEEK_FLAG_SNAP_NEAREST
	SeekFlagTrickmodeKeyUnits         SeekFlags = C.GST_SEEK_FLAG_TRICKMODE_KEY_UNITS
	SeekFlagTrickmodeNoAudio          SeekFlags = C.GST_SEEK_FLAG_TRICKMODE_NO_AUDIO
	SeekFlagTrickmodeForwardPredicted SeekFlags = C.GST_SEEK_FLAG_TRICKMODE_FORWARD_PREDICTED
	SeekFlagInstantRateChange         SeekFlags = C.GST_SEEK_FLAG_INSTANT_RATE_CHANGE
)

type StateChangeReturn added in v0.0.8

type StateChangeReturn int

type StateOptions

type StateOptions int

type Structure

type Structure struct {
	C *C.GstStructure
}

func NewStructure

func NewStructure(name string) (structure *Structure)

func (*Structure) GetBool added in v0.0.7

func (s *Structure) GetBool(name string) (bool, error)

func (*Structure) GetInt added in v0.0.7

func (s *Structure) GetInt(name string) (int, error)

func (*Structure) GetInt64 added in v0.0.7

func (s *Structure) GetInt64(name string) (int64, error)

func (*Structure) GetName added in v0.0.7

func (s *Structure) GetName() string

func (*Structure) GetString added in v0.0.7

func (s *Structure) GetString(name string) (string, error)

func (*Structure) GetUint added in v0.0.7

func (s *Structure) GetUint(name string) (uint, error)

func (*Structure) SetValue

func (s *Structure) SetValue(name string, value interface{})

func (*Structure) ToString

func (s *Structure) ToString() (str string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL