;; path must be a valid URI to media
(bind-func xtm_play
(lambda (path)
(gst_init null null)
(if vplay
(begin (printf "Wait to finish the running video first!\n") 1)
(let ((playz (gst_element_factory_make "playbin" "play"))
(sinkz (gst_element_factory_make "appsink" "app_sink"))
(bus (gst_pipeline_get_bus (cast playz GstPipeline*)))
(caps:GstCaps* (gst_caps_from_string "video/x-raw,format=RGB,width=1200,height=800"))
(rgbFilter:GstElement* (gst_element_factory_make "capsfilter" "rgb_filter"))
(appBin:GstElement* (gst_bin_new "app_bin"))
(rgbSinkPad:GstPad* null)
(ghostPad:GstPad* null)
(gv:GValue* (alloc)))
;; force video decode to RGB 1200x800
(gst_app_sink_set_caps (cast sinkz i8*) caps)
;; Replace the default window sink with appsink,
(g_value_init gv G_TYPE_OBJECT)
(g_value_set_object gv (cast sinkz gpointer))
(g_object_set_property (cast playz GObject*) "video-sink" gv)
;; URI to load media from
(g_value_unset gv)
(g_value_init gv G_TYPE_STRING)
(g_value_set_string gv path)
(g_object_set_property (cast playz GObject*) "uri" gv)
;; start decoding the media!
(gst_element_set_state playz GST_STATE_PLAYING)
(callback (now) xtm_decode playz sinkz (now) 1024 1)
1))))