Пример #1
0
        /// <summary>
        /// Create a media from a MediaInput
        /// requires libvlc 3.0 or higher
        /// </summary>
        /// <param name="libVLC">the libvlc instance</param>
        /// <param name="input">the media to be used by libvlc. LibVLCSharp will NOT dispose or close it.
        /// Use <see cref="StreamMediaInput"/> or implement your own.</param>
        /// <param name="options">the libvlc options</param>
        public Media(LibVLC libVLC, MediaInput input, params string[] options)
            : base(() => CtorFromInput(libVLC, input), Native.LibVLCMediaRelease)
        {
            foreach (var option in options)
            {
                var optionUtf8 = option.ToUtf8();

                MarshalUtils.PerformInteropAndFree(() => Native.LibVLCMediaAddOption(NativeReference, optionUtf8), optionUtf8);
            }
        }
Пример #2
0
        static IntPtr CtorFromInput(LibVLC libVLC, MediaInput input)
        {
            if (libVLC == null)
            {
                throw new ArgumentNullException(nameof(libVLC));
            }
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            return(Native.LibVLCMediaNewCallbacks(libVLC.NativeReference,
                                                  OpenMediaCallbackHandle,
                                                  ReadMediaCallbackHandle,
                                                  SeekMediaCallbackHandle,
                                                  CloseMediaCallbackHandle,
                                                  GCHandle.ToIntPtr(input.GcHandle)));
        }
Пример #3
0
 /// <summary>
 /// Create a media from a MediaInput
 /// requires libvlc 3.0 or higher
 /// </summary>
 /// <param name="libVLC">the libvlc instance</param>
 /// <param name="input">the media to be used by libvlc. LibVLCSharp will NOT dispose or close it.
 /// Use <see cref="StreamMediaInput"/> or implement your own.</param>
 /// <param name="options">the libvlc options</param>
 public Media(LibVLC libVLC, MediaInput input, params string[] options)
     : this(() => CtorFromInput(libVLC, input), Native.LibVLCMediaRelease, options)
 {
 }