コード例 #1
0
 /**
  * Add native media options.
  *
  * @param mediaInstance native media instance
  * @param options options to add
  * @return <code>true</code> if the options were added; <code>false</code> if they were not
  */
 private bool AddMediaOptions(IntPtr mediaInstance, params string[] options)
 {
     Logger.Debug("AddMediaOptions(options={})", options);
     if (options != null)
     {
         IntPtr optionPtr = IntPtr.Zero;
         foreach (string option in options)
         {
             Logger.Debug("option={}", option);
             optionPtr = NativeString.StringPointer(option);
             if (optionPtr != IntPtr.Zero)
             {
                 try {
                     LibVlc.libvlc_media_add_option(mediaInstance, optionPtr);
                 }
                 finally {
                     NativeString.Release(optionPtr);
                 }
             }
             else
             {
                 return(false);
             }
         }
     }
     return(true);
 }
コード例 #2
0
        /**
         * Create a new native media instance.
         *
         * @param media media resource locator
         * @param mediaOptions zero or more media options
         * @return native media instance
         */
        private IntPtr newMediaDescriptor(string media, params string[] mediaOptions)
        {
            Logger.Debug("newMediaDescriptor(media={},mediaOptions={})", media, mediaOptions);
            IntPtr mediaPointer  = NativeString.StringPointer(media);
            IntPtr mediaInstance = IntPtr.Zero;

            if (mediaPointer != IntPtr.Zero)
            {
                try {
                    mediaInstance = LibVlc.libvlc_media_new_path(instance, mediaPointer);
                    Logger.Debug("mediaDescriptor={}", mediaInstance);
                    if (mediaListInstance != IntPtr.Zero)
                    {
                        // Set the standard media options (if any)...
                        AddMediaOptions(mediaInstance, standardMediaOptions); // FIXME handle return false?
                        // Set the particular media options (if any)...
                        AddMediaOptions(mediaInstance, mediaOptions);         // FIXME handle return false?
                    }
                }
                finally {
                    NativeString.Release(mediaPointer);
                }
            }
            return(mediaInstance);
        }
コード例 #3
0
        /**
         * Set a local meta data value for a media instance.
         * <p>
         * Setting meta does not affect the underlying media file until {@link #save()} is called.
         *
         * @param metaType type of meta data
         * @param media media instance
         * @param value meta data value
         */
        private void SetMeta(libvlc_meta_e metaType, string metaValue)
        {
            Logger.Trace("SetMeta(metaType={},media={},value={})", metaType, media, metaValue);
            IntPtr metaValuePtr = NativeString.StringPointer(metaValue);

            try {
                LibVlc.libvlc_media_set_meta(media, (int)metaType, metaValuePtr);
            }
            finally {
                NativeString.Release(metaValuePtr);
            }
        }
コード例 #4
0
        /**
         * Get the devices associated with an audio output.
         *
         * @param outputName output
         * @return collection of audio output devices
         */
        private List <AudioDevice> GetAudioOutputDevices(string outputName)
        {
            Logger.Debug("GetAudioOutputDevices(outputName={})", outputName);
            IntPtr outputNamePtr = NativeString.StringPointer(outputName);
            int    deviceCount   = LibVlc.libvlc_audio_output_device_count(instance, outputNamePtr);

            Logger.Debug("deviceCount={}", deviceCount);
            List <AudioDevice> result = new List <AudioDevice>(deviceCount);

            for (int i = 0; i < deviceCount; i++)
            {
                string deviceId = NativeString.GetNativeString(LibVlc.libvlc_audio_output_device_id(instance, outputNamePtr, i));
                string longName = NativeString.GetNativeString(LibVlc.libvlc_audio_output_device_longname(instance, outputNamePtr, i));
                result.Add(new AudioDevice(deviceId, longName));
            }
            return(result);
        }
コード例 #5
0
        /**
         * Set the application name.
         *
         * @param userAgent application name
         * @param httpUserAgent application name for HTTP
         */
        public void SetUserAgent(string userAgent, string httpUserAgent)
        {
            Logger.Debug("SetUserAgent(userAgent={},httpUserAgent)", userAgent, httpUserAgent);
            IntPtr userAgentPtr     = IntPtr.Zero;
            IntPtr httpUserAgentPtr = IntPtr.Zero;

            try {
                userAgentPtr = NativeString.StringPointer(userAgent);
                if (httpUserAgent != null)
                {
                    httpUserAgentPtr = NativeString.StringPointer(httpUserAgent);
                }
                LibVlc.libvlc_set_user_agent(instance, userAgentPtr, httpUserAgentPtr);
            }
            finally {
                NativeString.Release(httpUserAgentPtr);
                NativeString.Release(userAgentPtr);
            }
        }