Пример #1
0
        /// <summary>
        /// Wraps the passed byte array in a GStreamer buffer object
        /// </summary>
        /// <param name="data">C# byte pointer to be wrapped</param>
        /// <returns>GstBuffer pointer wrapping data argument</returns>
        public static GstBuffer BufferNewWrapped(byte[] data)
        {
            ulong size = (ulong)data.Length;

            return(GstNativeMethods.gst_buffer_new_wrapped_full(
                       MemoryFlags.GST_MEMORY_FLAG_READONLY | MemoryFlags.GST_MEMORY_FLAG_NO_SHARE,
                       data, size, 0, size, GPointer.Zero, GPointer.Zero));
        }
Пример #2
0
        /// <summary>
        /// Changes state of a GStreamer element
        /// </summary>
        /// <param name="element">element which its state needs to be changed</param>
        /// <param name="state">new state the element should transition into</param>
        /// <returns></returns>
        public static StateChangeReturn ElementSetState(GstEelement element, State state)
        {
            if (element == GstEelement.Zero)
            {
                return(StateChangeReturn.GST_STATE_CHANGE_FAILURE);
            }

            return(GstNativeMethods.gst_element_set_state(element, state));
        }
Пример #3
0
        /// <summary>
        /// Pushes a buffer into AppSrc when it "needs data"
        /// </summary>
        /// <param name="appsrc">AppSrc requesting a buffer</param>
        /// <param name="buffer">buffer to be pushed into AppSrc</param>
        /// <returns>status of the buffer push (FLOW_OK on success)</returns>
        public static FlowReturn AppSrcPushBuffer(AppSrc appsrc, GstBuffer buffer)
        {
            if (appsrc == AppSrc.Zero || buffer == GstBuffer.Zero)
            {
                return(FlowReturn.GST_FLOW_ERROR);
            }

            return(GstNativeMethods.gst_app_src_push_buffer(appsrc, buffer));
        }
Пример #4
0
        /// <summary>
        /// Looks up a child element in a GstBin by name
        /// </summary>
        /// <param name="bin">parent bin</param>
        /// <param name="name">child element</param>
        /// <returns>child element on success. Use ObjectUnref when you are done.</returns>
        public static GstEelement BinGetByName(GstEelement bin, string name)
        {
            if (bin == GstEelement.Zero)
            {
                return(GstEelement.Zero);
            }

            return(GstNativeMethods.gst_bin_get_by_name(bin, name));
        }
Пример #5
0
        /// <summary>
        /// Decreases ref count of a GStreamer object
        /// </summary>
        /// <param name="element">GStreamer object</param>
        public static void ObjectUnref(GstEelement element)
        {
            if (element == GstEelement.Zero)
            {
                return;
            }

            GstNativeMethods.gst_object_unref(element);
        }
Пример #6
0
        /// <summary>
        /// Returns the version of GStreamer being used.
        /// Throws if DLL is not present.
        /// </summary>
        /// <returns>Version of the GStreamer library</returns>
        public static Version GetVersion()
        {
            Version version = new Version();

            GstNativeMethods.gst_version(
                ref version.Major,
                ref version.Minor,
                ref version.Patch,
                ref version.Nano);

            return(version);
        }
Пример #7
0
 /// <summary>
 /// wrapper for gst_parse_launch
 /// </summary>
 /// <param name="pipeline">pipeline desription (in GstLaunch in syntax)</param>
 /// <returns>a pointer to the pipeline if successful</returns>
 public static GstEelement ParseLaunch(string pipeline)
 {
     return(GstNativeMethods.gst_parse_launch(pipeline, GPointer.Zero));
 }
Пример #8
0
 /// <summary>
 /// Attempts to initialize GStreamer. Safe to call when DLL is not present.
 /// </summary>
 /// <returns>true if initialized or false if (not initialized or DLL is not found)</returns>
 public static bool Initialize()
 {
     try { return(GstNativeMethods.gst_init_check(GPointer.Zero, GPointer.Zero, GPointer.Zero)); }
     catch (DllNotFoundException) { return(false); }
 }