mirror of
https://github.com/notedit/gst.git
synced 2025-09-26 20:21:12 +08:00
Split arm and non-arm build
This commit is contained in:
29
element.go
29
element.go
@@ -13,8 +13,8 @@ import (
|
||||
"reflect"
|
||||
"runtime"
|
||||
"sync"
|
||||
"time"
|
||||
"unsafe"
|
||||
"time"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -107,28 +107,23 @@ func (e *Element) GetStaticPad(name string) (pad *Pad) {
|
||||
}
|
||||
|
||||
func (e *Element) QueryPosition() (time.Duration, error) {
|
||||
var position C.gint64
|
||||
var position C.gint64
|
||||
|
||||
if int(C.gst_element_query_position(e.GstElement, C.GST_FORMAT_TIME, &position)) == 0 {
|
||||
return 0, fmt.Errorf("position query failed")
|
||||
}
|
||||
if int(C.gst_element_query_position(e.GstElement, C.GST_FORMAT_TIME, &position)) == 0 {
|
||||
return 0, fmt.Errorf("position query failed")
|
||||
}
|
||||
|
||||
return time.Duration(position / C.GST_SECOND) * time.Second, nil
|
||||
return time.Duration(position/C.GST_SECOND) * time.Second, nil
|
||||
}
|
||||
|
||||
func (e *Element) QueryDuration() (time.Duration, error) {
|
||||
var duration C.gint64
|
||||
var duration C.gint64
|
||||
|
||||
if int(C.gst_element_query_duration(e.GstElement, C.GST_FORMAT_TIME, &duration)) == 0 {
|
||||
return 0, fmt.Errorf("duration query failed")
|
||||
}
|
||||
if int(C.gst_element_query_duration(e.GstElement, C.GST_FORMAT_TIME, &duration)) == 0 {
|
||||
return 0, fmt.Errorf("duration query failed")
|
||||
}
|
||||
|
||||
return time.Duration(duration / C.GST_SECOND) * time.Second, nil
|
||||
}
|
||||
|
||||
func (e *Element) Seek(duration time.Duration) bool {
|
||||
result := C.gst_element_seek_simple(e.GstElement, C.GST_FORMAT_TIME, C.GST_SEEK_FLAG_FLUSH, C.long(duration.Nanoseconds()))
|
||||
return result == C.TRUE
|
||||
return time.Duration(duration/C.GST_SECOND) * time.Second, nil
|
||||
}
|
||||
|
||||
func (e *Element) AddPad(pad *Pad) bool {
|
||||
|
13
element_arm.go
Normal file
13
element_arm.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package gst
|
||||
|
||||
/*
|
||||
#cgo pkg-config: gstreamer-1.0 gstreamer-app-1.0
|
||||
#include "gst.h"
|
||||
*/
|
||||
import "C"
|
||||
import "time"
|
||||
|
||||
func (e *Element) Seek(duration time.Duration) bool {
|
||||
result := C.gst_element_seek_simple(e.GstElement, C.GST_FORMAT_TIME, C.GST_SEEK_FLAG_FLUSH, C.longlong(duration.Nanoseconds()))
|
||||
return result == C.TRUE
|
||||
}
|
15
element_other.go
Normal file
15
element_other.go
Normal file
@@ -0,0 +1,15 @@
|
||||
// +build !arm
|
||||
|
||||
package gst
|
||||
|
||||
/*
|
||||
#cgo pkg-config: gstreamer-1.0 gstreamer-app-1.0
|
||||
#include "gst.h"
|
||||
*/
|
||||
import "C"
|
||||
import "time"
|
||||
|
||||
func (e *Element) Seek(duration time.Duration) bool {
|
||||
result := C.gst_element_seek_simple(e.GstElement, C.GST_FORMAT_TIME, C.GST_SEEK_FLAG_FLUSH, C.long(duration.Nanoseconds()))
|
||||
return result == C.TRUE
|
||||
}
|
68
message.go
68
message.go
@@ -11,44 +11,44 @@ import "unsafe"
|
||||
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
|
||||
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
|
||||
MessageAny MessageType = C.GST_MESSAGE_ANY
|
||||
)
|
||||
|
||||
type Message struct {
|
||||
|
66
structure.go
66
structure.go
@@ -7,9 +7,9 @@ package gst
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"unsafe"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type Structure struct {
|
||||
@@ -32,64 +32,64 @@ func NewStructure(name string) (structure *Structure) {
|
||||
}
|
||||
|
||||
func errNoSuchField(t, name string) error {
|
||||
return fmt.Errorf("structure does not have a %s named %s", t, name)
|
||||
return fmt.Errorf("structure does not have a %s named %s", t, name)
|
||||
}
|
||||
|
||||
func (s *Structure) GetName() string {
|
||||
return C.GoString(C.gst_structure_get_name(s.C))
|
||||
return C.GoString(C.gst_structure_get_name(s.C))
|
||||
}
|
||||
|
||||
func (s *Structure) GetBool(name string) (bool, error) {
|
||||
var out C.gboolean
|
||||
var out C.gboolean
|
||||
|
||||
if C.FALSE == C.gst_structure_get_boolean(s.C, C.CString(name), &out) {
|
||||
return false, errNoSuchField("bool", name)
|
||||
}
|
||||
if C.FALSE == C.gst_structure_get_boolean(s.C, C.CString(name), &out) {
|
||||
return false, errNoSuchField("bool", name)
|
||||
}
|
||||
|
||||
if out == C.TRUE {
|
||||
return true, nil
|
||||
}
|
||||
if out == C.TRUE {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, nil
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func (s *Structure) GetInt(name string) (int, error) {
|
||||
var out C.gint
|
||||
var out C.gint
|
||||
|
||||
if C.FALSE == C.gst_structure_get_int(s.C, C.CString(name), &out) {
|
||||
return 0, errNoSuchField("int", name)
|
||||
}
|
||||
if C.FALSE == C.gst_structure_get_int(s.C, C.CString(name), &out) {
|
||||
return 0, errNoSuchField("int", name)
|
||||
}
|
||||
|
||||
return int(out), nil
|
||||
return int(out), nil
|
||||
}
|
||||
|
||||
func (s *Structure) GetInt64(name string) (int64, error) {
|
||||
var out C.gint64
|
||||
var out C.gint64
|
||||
|
||||
if C.FALSE == C.gst_structure_get_int64(s.C, C.CString(name), &out) {
|
||||
return 0, errNoSuchField("int64", name)
|
||||
}
|
||||
if C.FALSE == C.gst_structure_get_int64(s.C, C.CString(name), &out) {
|
||||
return 0, errNoSuchField("int64", name)
|
||||
}
|
||||
|
||||
return int64(out), nil
|
||||
return int64(out), nil
|
||||
}
|
||||
|
||||
func (s *Structure) GetUint(name string) (uint, error) {
|
||||
var out C.guint
|
||||
var out C.guint
|
||||
|
||||
if C.FALSE == C.gst_structure_get_uint(s.C, C.CString(name), &out) {
|
||||
return 0, errNoSuchField("uint", name)
|
||||
}
|
||||
if C.FALSE == C.gst_structure_get_uint(s.C, C.CString(name), &out) {
|
||||
return 0, errNoSuchField("uint", name)
|
||||
}
|
||||
|
||||
return uint(out), nil
|
||||
return uint(out), nil
|
||||
}
|
||||
|
||||
func (s *Structure) GetString(name string) (string, error) {
|
||||
out := C.gst_structure_get_string(s.C, C.CString(name))
|
||||
if out == nil {
|
||||
return "", errNoSuchField("string", name)
|
||||
}
|
||||
out := C.gst_structure_get_string(s.C, C.CString(name))
|
||||
if out == nil {
|
||||
return "", errNoSuchField("string", name)
|
||||
}
|
||||
|
||||
return C.GoString(out), nil
|
||||
return C.GoString(out), nil
|
||||
}
|
||||
|
||||
func (s *Structure) SetValue(name string, value interface{}) {
|
||||
|
Reference in New Issue
Block a user