Beispiel #1
0
Datei: ngw.cs Projekt: 3p3r/ngw
        /// <summary>
        /// Constructor, taking care of registering GC pinned callbacks
        /// properly and turning them into C# events instead. Users of
        /// this class can subscribe to On[event name] events.
        /// </summary>
        public Player()
        {
            mNativePlayer = NativeMethods.ngw_player_make();

            if (mNativePlayer != IntPtr.Zero)
            {
                var error_delegate = new NativeTypes.ErrorDelegate((msg, player) =>
                {
                    if (OnErrorReceived != null)
                    {
                        OnErrorReceived(msg);
                    }
                });

                var state_delegate = new NativeTypes.StateDelegate((old, player) =>
                {
                    if (OnStateChanged != null)
                    {
                        OnStateChanged(old);
                    }
                });

                var stend_delegate = new NativeTypes.StreamEndDelegate((player) =>
                {
                    if (OnStreamEnded != null)
                    {
                        OnStreamEnded();
                    }
                });

                mErrorCallbackHandle  = GCHandle.Alloc(error_delegate, GCHandleType.Pinned);
                mStateCallbackHandle  = GCHandle.Alloc(state_delegate, GCHandleType.Pinned);
                mStEndCallbackHandle  = GCHandle.Alloc(stend_delegate, GCHandleType.Pinned);
                mFrameDirtyFlagHandle = GCHandle.Alloc(mFrameDirty, GCHandleType.Pinned);

                NativeMethods.ngw_player_set_error_callback(mNativePlayer, error_delegate);
                NativeMethods.ngw_player_set_state_callback(mNativePlayer, state_delegate);
                NativeMethods.ngw_player_set_stream_end_callback(mNativePlayer, stend_delegate);
                NativeMethods.ngw_player_set_frame_dirty_flag(mNativePlayer, ref mFrameDirty);
            }
        }
Beispiel #2
0
Datei: ngw.cs Projekt: 3p3r/ngw
 public static extern void ngw_player_set_state_callback(IntPtr player, NativeTypes.StateDelegate cb);