Ejemplo n.º 1
0
        private void RestoreLinkedCamera()
        {
            // List the selected cameras
            foreach (FilterInfo fi in VideoCapability.SelectedCameras())
            {
                cboLinkedCamera.Items.Add(fi);
            }

            // Read from registry and select camera, if in list
            string[] linkedCamera = AVReg.ValueNames(AVReg.LinkedCamera);
            if (linkedCamera != null && linkedCamera.Length > 0)
            {
                Debug.Assert(linkedCamera.Length == 1);

                for (int i = 0; i < cboLinkedCamera.Items.Count; i++)
                {
                    FilterInfo fi = (FilterInfo)cboLinkedCamera.Items[i];
                    if (fi.Moniker == linkedCamera[0])
                    {
                        cboLinkedCamera.SelectedItem = fi;
                    }
                }
            }

            if (cboLinkedCamera.SelectedIndex == -1 && cboLinkedCamera.Items.Count > 0)
            {
                cboLinkedCamera.SelectedIndex = 0;
            }

            cboLinkedCamera.Enabled = cboLinkedCamera.Items.Count > 1;
        }
        /// <summary>
        /// Check the registry and compare to the current list of speakers on
        /// the machine (in case there is a mismatch).  Or return the default
        /// system speaker if none were selected.
        /// </summary>
        /// <returns>
        /// The FilterInfo of the speaker that was selected and still exists
        /// </returns>
        public static FilterInfo SelectedSpeaker()
        {
            FilterInfo selectedSpeaker = AudioRenderer.DefaultFilterInfo();

            string[] regSelectedSpeaker = AVReg.ValueNames(AVReg.SelectedSpeaker);
            if (regSelectedSpeaker != null)
            {
                FilterInfo[] spkrs = AudioRenderer.Renderers();

                for (int i = 0; i < spkrs.Length; i++)
                {
                    for (int j = 0; j < regSelectedSpeaker.Length; j++)
                    {
                        if (spkrs[i].Moniker == regSelectedSpeaker[j])
                        {
                            selectedSpeaker = spkrs[i];
                            break;
                        }
                    }
                }
            }
            else
            {
                selectedSpeaker = AudioRenderer.DefaultFilterInfo();
            }

            return(selectedSpeaker);
        }
Ejemplo n.º 3
0
        public void SaveLinkedCamera(FilterInfo fi)
        {
            // Delete previous link value
            string[] linkedCamera = AVReg.ValueNames(AVReg.LinkedCamera);
            if (linkedCamera != null && linkedCamera.Length > 0)
            {
                Debug.Assert(linkedCamera.Length == 1);
                AVReg.DeleteValue(AVReg.LinkedCamera, linkedCamera[0]);
            }

            // Set the new value
            AVReg.WriteValue(AVReg.LinkedCamera, fi.Moniker, fi.Name);
        }
Ejemplo n.º 4
0
        private void frmAVDevices_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            SaveSettings();

            if (ac != null)
            {
                // If a camera hasn't been linked, link the first one
                if (clbCameras.CheckedItems.Count > 0)
                {
                    bool goodLink = false;

                    // Read from registry and select camera, if in list
                    string[] linkedCamera = AVReg.ValueNames(AVReg.LinkedCamera);
                    if (linkedCamera != null && linkedCamera.Length > 0)
                    {
                        Debug.Assert(linkedCamera.Length == 1);

                        for (int i = 0; i < clbCameras.CheckedItems.Count; i++)
                        {
                            FilterInfo fi = (FilterInfo)clbCameras.CheckedItems[i];
                            if (fi.Moniker == linkedCamera[0])
                            {
                                goodLink = true;
                                break;
                            }
                        }
                    }

                    if (!goodLink)
                    {
                        SaveLinkedCamera((FilterInfo)clbCameras.CheckedItems[0]);
                    }
                }

                ac.Dispose();
            }

            foreach (VideoCapability vc in vcs.Values)
            {
                vc.Dispose();
            }

            if (ckPlayVideo.Checked)
            {
                // To clean up any video windows
                GC.Collect();
            }

            tmrPerf.Stop();
            trouble.Close();
        }
Ejemplo n.º 5
0
        private void cboSpeakers_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            // Delete previous value
            string[] selectedSpeaker = AVReg.ValueNames(AVReg.SelectedSpeaker);
            if (selectedSpeaker != null)
            {
                Debug.Assert(selectedSpeaker.Length == 1);
                AVReg.DeleteValue(AVReg.SelectedSpeaker, selectedSpeaker[0]);
            }

            // Store current value
            FilterInfo fi = (FilterInfo)cboSpeakers.SelectedItem;

            AVReg.WriteValue(AVReg.SelectedSpeaker, fi.Moniker, fi.Name);

            if (acg != null)
            {
                RenderAndRunAudio(acg, false);
                RenderAndRunAudio(acg);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Check the registry and compare to the current list of cameras on
        /// the machine (in case there is a mismatch).
        /// </summary>
        /// <returns>
        /// Return the FilterInfo for cameras that were selected and still exist
        /// </returns>
        public static FilterInfo[] SelectedCameras()
        {
            ArrayList selectedCameras = new ArrayList();

            string[] regSelectedCameras = AVReg.ValueNames(AVReg.SelectedCameras);
            if (regSelectedCameras != null)
            {
                FilterInfo[] cameras = VideoSource.Sources();

                for (int i = 0; i < cameras.Length; i++)
                {
                    for (int j = 0; j < regSelectedCameras.Length; j++)
                    {
                        if (cameras[i].Moniker == regSelectedCameras[j])
                        {
                            selectedCameras.Add(cameras[i]);
                            break;
                        }
                    }
                }
            }

            return((FilterInfo[])selectedCameras.ToArray(typeof(FilterInfo)));
        }
        /// <summary>
        /// Check the registry and compare to the current list of microphones on
        /// the machine (in case there is a mismatch).
        /// </summary>
        /// <returns>
        /// The FilterInfo for the mics that were selected and still exist
        /// </returns>
        public static FilterInfo[] SelectedMicrophones()
        {
            ArrayList selectedMics = new ArrayList();

            string[] regSelectedMics = AVReg.ValueNames(AVReg.SelectedMicrophone);
            if (regSelectedMics != null)
            {
                FilterInfo[] mics = AudioSource.Sources();

                for (int i = 0; i < mics.Length; i++)
                {
                    for (int j = 0; j < regSelectedMics.Length; j++)
                    {
                        if (mics[i].Moniker == regSelectedMics[j])
                        {
                            selectedMics.Add(mics[i]);
                            break;
                        }
                    }
                }
            }

            return((FilterInfo[])selectedMics.ToArray(typeof(FilterInfo)));
        }