gst push function.

This commit is contained in:
Miroslav Šedivý 2021-11-28 22:37:17 +01:00
parent 710d0c9cd0
commit 7bc9a40677
3 changed files with 21 additions and 0 deletions

View File

@ -82,3 +82,13 @@ void gstreamer_pipeline_stop(GstElement *pipeline) {
gst_element_set_state(pipeline, GST_STATE_NULL); gst_element_set_state(pipeline, GST_STATE_NULL);
gst_object_unref(pipeline); gst_object_unref(pipeline);
} }
void gstreamer_pipeline_push(GstElement *pipeline, char *sinkName, void *buffer, int bufferLen) {
GstElement *src = gst_bin_get_by_name(GST_BIN(pipeline), sinkName);
if (src != NULL) {
gpointer p = g_memdup(buffer, bufferLen);
GstBuffer *buffer = gst_buffer_new_wrapped(p, bufferLen);
gst_app_src_push_buffer(GST_APP_SRC(src), buffer);
gst_object_unref(src);
}
}

View File

@ -74,6 +74,16 @@ func (p *Pipeline) Stop() {
C.gstreamer_pipeline_stop(p.Pipeline) C.gstreamer_pipeline_stop(p.Pipeline)
} }
func (p *Pipeline) Push(sinkName string, buffer []byte) {
sinkNameUnsafe := C.CString(sinkName)
defer C.free(unsafe.Pointer(sinkNameUnsafe))
bytes := C.CBytes(buffer)
defer C.free(bytes)
C.gstreamer_pipeline_push(p.Pipeline, sinkNameUnsafe, bytes, C.int(len(buffer)))
}
// gst-inspect-1.0 // gst-inspect-1.0
func CheckPlugins(plugins []string) error { func CheckPlugins(plugins []string) error {
var plugin *C.GstPlugin var plugin *C.GstPlugin

View File

@ -9,5 +9,6 @@ void gstreamer_pipeline_attach_appsink(GstElement *pipeline, char *sinkName, int
GstElement *gstreamer_pipeline_create(char *pipelineStr, GError **error); GstElement *gstreamer_pipeline_create(char *pipelineStr, GError **error);
void gstreamer_pipeline_play(GstElement *pipeline); void gstreamer_pipeline_play(GstElement *pipeline);
void gstreamer_pipeline_stop(GstElement *pipeline); void gstreamer_pipeline_stop(GstElement *pipeline);
void gstreamer_pipeline_push(GstElement *pipeline, char *sinkName, void *buffer, int bufferLen);
void gstreamer_init(void); void gstreamer_init(void);