public LiveForm(IMDevice pDevice)
        {
            try
            {
                InitializeComponent();
                m_objLive = (IMDevice)pDevice;

                //Fill Video Device List
                FillCombo("video", comboBoxVideo);

                FillCombo("ext_audio", comboBoxExtAudio);

                //Initialize preview
                ((IMPreview)m_objLive).PreviewEnable("", 0, 0);
                ((IMPreview)m_objLive).PreviewWindowSet("", panelPreview.Handle.ToInt32());
                ((IMPreview)m_objLive).PreviewEnable("", checkBoxAudio.Checked ? 1 : 0, checkBoxVideo.Checked ? 1 : 0);

                //Fill output formats
                FillOutputVideoFormats();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Live source object isn't valid: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
        /// <summary>
        /// Fill combo boxes (Audio / Video format)
        /// </summary>
        /// <param name="pDevice"></param>
        /// <param name="strType"></param>
        /// <param name="cbxTarget"></param>
        private void FillComboFomat(IMDevice pDevice, string strType, ComboBox cbxTarget)
        {
            if (strType == "video")
            {
                int         nCount = 0;
                int         nIndex;
                string      strFormat;
                M_VID_PROPS vidProps;
                cbxTarget.Items.Clear();
                //Get video format count
                ((IMFormat)m_objLive).FormatVideoGetCount(eMFormatType.eMFT_Input, out nCount);
                cbxTarget.Enabled = nCount > 0;
                if (nCount > 0)
                {
                    for (int i = 0; i < nCount; i++)
                    {
                        //Get format by index
                        ((IMFormat)m_objLive).FormatVideoGetByIndex(eMFormatType.eMFT_Input, i, out vidProps, out strFormat);
//                        cbxTarget.Items.Add(vidProps.eVideoFormat);
                        cbxTarget.Items.Add(strFormat);
                    }
                    //Check if there is selected format
                    ((IMFormat)m_objLive).FormatVideoGet(eMFormatType.eMFT_Input, out vidProps, out nIndex, out strFormat);
                    if (nIndex > 0)
                    {
                        cbxTarget.SelectedIndex = nIndex;
                    }
                    else
                    {
                        cbxTarget.SelectedIndex = 0;
                    }
                }
            }
            else if (strType == "ext_audio")
            {
                int         nCount = 0;
                int         nIndex;
                string      strFormat;
                M_AUD_PROPS audProps;
                cbxTarget.Items.Clear();
                //Get video format count
                ((IMFormat)m_objLive).FormatAudioGetCount(eMFormatType.eMFT_Input, out nCount);
                cbxTarget.Enabled = nCount > 0;
                if (nCount > 0)
                {
                    for (int i = 0; i < nCount; i++)
                    {
                        //Get audio format
                        ((IMFormat)m_objLive).FormatAudioGetByIndex(eMFormatType.eMFT_Input, i, out audProps, out strFormat);
                        cbxTarget.Items.Add(strFormat);
                    }
                    //Check if there is selected format
                    ((IMFormat)m_objLive).FormatAudioGet(eMFormatType.eMFT_Input, out audProps, out nIndex, out strFormat);
                    if (nIndex > 0)
                    {
                        cbxTarget.SelectedIndex = nIndex;
                    }
                    else
                    {
                        cbxTarget.SelectedIndex = 0;
                    }
                }
            }
            cbxTarget.Tag = strType;
        }
 private void OnMDeviceChanged(IMDevice oldValue, IMDevice newValue)
 {
     this.InitDownStream();
     UpdateItems();
 }