mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
gst destroy remove.
This commit is contained in:
parent
b932e94f77
commit
f9fe303b50
@ -131,7 +131,6 @@ void gstreamer_pipeline_pause(GstPipelineCtx *ctx) {
|
|||||||
void gstreamer_pipeline_destory(GstPipelineCtx *ctx) {
|
void gstreamer_pipeline_destory(GstPipelineCtx *ctx) {
|
||||||
gst_element_set_state(GST_ELEMENT(ctx->pipeline), GST_STATE_NULL);
|
gst_element_set_state(GST_ELEMENT(ctx->pipeline), GST_STATE_NULL);
|
||||||
gst_object_unref(ctx->pipeline);
|
gst_object_unref(ctx->pipeline);
|
||||||
free(ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gstreamer_pipeline_push(GstPipelineCtx *ctx, char *srcName, void *buffer, int bufferLen) {
|
void gstreamer_pipeline_push(GstPipelineCtx *ctx, char *srcName, void *buffer, int bufferLen) {
|
||||||
|
@ -9,6 +9,7 @@ import "C"
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
@ -25,6 +26,7 @@ type Pipeline struct {
|
|||||||
Sample chan types.Sample
|
Sample chan types.Sample
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var pSerial int32
|
||||||
var pipelines = make(map[int]*Pipeline)
|
var pipelines = make(map[int]*Pipeline)
|
||||||
var pipelinesLock sync.Mutex
|
var pipelinesLock sync.Mutex
|
||||||
var registry *C.GstRegistry
|
var registry *C.GstRegistry
|
||||||
@ -37,14 +39,14 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func CreatePipeline(pipelineStr string) (*Pipeline, error) {
|
func CreatePipeline(pipelineStr string) (*Pipeline, error) {
|
||||||
|
id := atomic.AddInt32(&pSerial, 1)
|
||||||
|
|
||||||
pipelineStrUnsafe := C.CString(pipelineStr)
|
pipelineStrUnsafe := C.CString(pipelineStr)
|
||||||
defer C.free(unsafe.Pointer(pipelineStrUnsafe))
|
defer C.free(unsafe.Pointer(pipelineStrUnsafe))
|
||||||
|
|
||||||
pipelinesLock.Lock()
|
pipelinesLock.Lock()
|
||||||
defer pipelinesLock.Unlock()
|
defer pipelinesLock.Unlock()
|
||||||
|
|
||||||
id := len(pipelines)
|
|
||||||
|
|
||||||
var gstError *C.GError
|
var gstError *C.GError
|
||||||
ctx := C.gstreamer_pipeline_create(pipelineStrUnsafe, C.int(id), &gstError)
|
ctx := C.gstreamer_pipeline_create(pipelineStrUnsafe, C.int(id), &gstError)
|
||||||
|
|
||||||
@ -54,7 +56,7 @@ func CreatePipeline(pipelineStr string) (*Pipeline, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
p := &Pipeline{
|
p := &Pipeline{
|
||||||
id: id,
|
id: int(id),
|
||||||
Src: pipelineStr,
|
Src: pipelineStr,
|
||||||
Ctx: ctx,
|
Ctx: ctx,
|
||||||
Sample: make(chan types.Sample),
|
Sample: make(chan types.Sample),
|
||||||
@ -81,8 +83,14 @@ func (p *Pipeline) Pause() {
|
|||||||
|
|
||||||
func (p *Pipeline) Destroy() {
|
func (p *Pipeline) Destroy() {
|
||||||
C.gstreamer_pipeline_destory(p.Ctx)
|
C.gstreamer_pipeline_destory(p.Ctx)
|
||||||
p.Ctx = nil
|
|
||||||
|
pipelinesLock.Lock()
|
||||||
|
delete(pipelines, p.id)
|
||||||
|
pipelinesLock.Unlock()
|
||||||
|
|
||||||
close(p.Sample)
|
close(p.Sample)
|
||||||
|
C.free(unsafe.Pointer(p.Ctx))
|
||||||
|
p = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pipeline) Push(srcName string, buffer []byte) {
|
func (p *Pipeline) Push(srcName string, buffer []byte) {
|
||||||
|
Loading…
Reference in New Issue
Block a user