mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
gst emit video keyframe on demand. (#27)
This commit is contained in:
parent
2364facd60
commit
bfabee12e2
@ -200,3 +200,15 @@ gboolean gstreamer_pipeline_set_caps_resolution(GstPipelineCtx *ctx, const gchar
|
||||
gst_object_unref(el);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean gstreamer_pipeline_emit_video_keyframe(GstPipelineCtx *ctx) {
|
||||
GstClock *clock = gst_pipeline_get_clock(GST_PIPELINE(ctx->pipeline));
|
||||
gst_object_ref(clock);
|
||||
|
||||
GstClockTime time = gst_clock_get_time(clock);
|
||||
GstClockTime now = time - gst_element_get_base_time(ctx->pipeline);
|
||||
gst_object_unref(clock);
|
||||
|
||||
GstEvent *keyFrameEvent = gst_video_event_new_downstream_force_key_unit(now, time, now, TRUE, 0);
|
||||
return gst_element_send_event(GST_ELEMENT(ctx->pipeline), keyFrameEvent);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package gst
|
||||
|
||||
/*
|
||||
#cgo pkg-config: gstreamer-1.0 gstreamer-app-1.0
|
||||
#cgo pkg-config: gstreamer-1.0 gstreamer-app-1.0 gstreamer-video-1.0
|
||||
|
||||
#include "gst.h"
|
||||
*/
|
||||
@ -46,6 +46,8 @@ type Pipeline interface {
|
||||
SetPropInt(binName string, prop string, value int) bool
|
||||
SetCapsFramerate(binName string, numerator, denominator int) bool
|
||||
SetCapsResolution(binName string, width, height int) bool
|
||||
// emit video keyframe
|
||||
EmitVideoKeyframe() bool
|
||||
}
|
||||
|
||||
type pipeline struct {
|
||||
@ -177,6 +179,11 @@ func (p *pipeline) SetCapsResolution(binName string, width, height int) bool {
|
||||
return ok == C.TRUE
|
||||
}
|
||||
|
||||
func (p *pipeline) EmitVideoKeyframe() bool {
|
||||
ok := C.gstreamer_pipeline_emit_video_keyframe(p.ctx)
|
||||
return ok == C.TRUE
|
||||
}
|
||||
|
||||
// gst-inspect-1.0
|
||||
func CheckPlugins(plugins []string) error {
|
||||
var plugin *C.GstPlugin
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <stdio.h>
|
||||
#include <gst/gst.h>
|
||||
#include <gst/app/gstappsrc.h>
|
||||
#include <gst/video/video.h>
|
||||
|
||||
typedef struct GstPipelineCtx {
|
||||
int pipelineId;
|
||||
@ -25,3 +26,4 @@ void gstreamer_pipeline_push(GstPipelineCtx *ctx, void *buffer, int bufferLen);
|
||||
gboolean gstreamer_pipeline_set_prop_int(GstPipelineCtx *ctx, char *binName, char *prop, gint value);
|
||||
gboolean gstreamer_pipeline_set_caps_framerate(GstPipelineCtx *ctx, const gchar* binName, gint numerator, gint denominator);
|
||||
gboolean gstreamer_pipeline_set_caps_resolution(GstPipelineCtx *ctx, const gchar* binName, gint width, gint height);
|
||||
gboolean gstreamer_pipeline_emit_video_keyframe(GstPipelineCtx *ctx);
|
||||
|
Loading…
Reference in New Issue
Block a user