Пример #1
0
        private void frmStartStop_Load(object sender, System.EventArgs e)
        {
            m_wrap = new CarverLab.Utility.Win32Wrapper();
            disco.Start();
            cboCaptureQuality.DisplayMember = "Name";
            cboCaptureQuality.ValueMember = "Identifier";
            cboCaptureQuality.DataSource = m_PerformanceList;

            gbAutomatic.Enabled = false;
            gbManual.Enabled = false;
            timer1.Enabled = true;
            //tabControl1.TabPages.RemoveAt(1);
            RestoreOptions();
        }
Пример #2
0
        public frmRecordOptions()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            string FakeUDN = "DBF54A20-3C3F-477c-A15D-84673C1DDF3B";
            NoDevice = Intel.UPNP.UPnPDevice.CreateEmbeddedDevice((double)1,FakeUDN);
            NoDevice.FriendlyName = "No Device Selected";
            NoDevice.SerialNumber = "N/A";
            cboOysterDevice.DisplayMember = "FriendlyName";
            cboOysterDevice.ValueMember = "SerialNumber";
            cboOysterDevice.Items.Add(NoDevice);
            disco = new OysterDeviceDiscovery();
            disco.OnAddedDevice += new OysterDeviceDiscovery.DiscoveryHandler(AddSink);
            disco.OnRemovedDevice += new OysterDeviceDiscovery.DiscoveryHandler(RemoveSink);

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            //			log = new CarverLab.Utility.Logger("DesktopRecorder");
            m_RecordOptions = new RecordOptions(RecordOptions.SaveType.ToRegistry);
            //tabControl1.SelectedIndex = 0;
            m_wrap = new CarverLab.Utility.Win32Wrapper();
            //disco.Start();
            cboCaptureQuality.DisplayMember = "Name";
            cboCaptureQuality.ValueMember = "Identifier";
            cboCaptureQuality.DataSource = m_PerformanceList;
        }
Пример #3
0
 public CarverLab.Utility.Window[] GetWindows()
 {
     alWindowArray = new System.Collections.ArrayList();
     CarverLab.Utility.Win32Wrapper myWrap = new CarverLab.Utility.Win32Wrapper();
     myWrap.EnumWindowsExReceived += new EnumWindowsExProc(GetWindows_EnumWindowsExReceived);
     myWrap.EnumWindowsEx(null);
     if (alWindowArray.Count > 0)
     {
         WindowArray = new CarverLab.Utility.Window[alWindowArray.Count];
         alWindowArray.CopyTo(WindowArray);
     }
     return WindowArray;
 }
Пример #4
0
 public InternalCallbackParams(CarverLab.Utility.Win32Wrapper This, System.Object obj)
 {
     m_This = This;
     m_obj = obj;
 }
Пример #5
0
        void StartRecording()
        {
            frmRecordOptions frm = new frmRecordOptions();

            if(!System.IO.Directory.Exists(frm.CurrentRecordOptions.WMVDirectory))
            {
                try
                {
                    System.IO.Directory.CreateDirectory(frm.CurrentRecordOptions.WMVDirectory);
                }
                catch(Exception Err)
                {
                    MessageBox.Show("Error details:" + Err.Message,"Temporary storage directory does not exist. Creation attempt failed.",MessageBoxButtons.OK,MessageBoxIcon.Error);
                    return;
                }
            }
            frmStatusWindow StatusWindow = new frmStatusWindow("Desktop Recorder: Preparing Session Capture","Please wait...");

            bDontClick = true;
            StatusWindow.Owner = this;
            StatusWindow.Show();
            bool bRecordCamera = true, bRecordScreen = true; // bError = false;
            int NumCams = 0;
            string sErrorBody = "";
            string sErrorCaption = "";

            //btnStartStop.Text = "Preparing...";

            //btnStartStop.Update();
            Application.DoEvents();

            //			clock.DigitalDisplayColor = SriClocks.DigitalColor.GreenColor;
            //			clock.ClockDisplayType = SriClocks.ClockType.StopWatch;
            //			clock.Reset();
            //			btnStartStop.Text = "STOP";

            // startup the oyster encoder

            RecordOptions ro = frm.CurrentRecordOptions;
            bool bIsSession = false;

            System.Diagnostics.Debug.Assert(m_oec == null,"OEC should be null when starting a recording.");
            #region SCREEN SELECTION

            object oparams = null;
            ScreenEncoder.CapturePerformance cp = ScreenEncoder.CapturePerformance.VeryLow;
            ScreenEncoder.CaptureType ct = ScreenEncoder.CaptureType.FullScreen;
            switch (frm.CurrentRecordOptions.RecordType)
            {
                case RecordOptions.ScreenRecordType.ScreenRecordNone:
                    bRecordScreen = false;
                    break;
                case RecordOptions.ScreenRecordType.ScreenRecordFullScreen:

                    //					oparams = "N/A";
                    /*Changed By Kevin Gray 5-6-05 due to errors in typecasting "N/A" to an object[]*/
                    oparams = new object[1];
                    cp = frm.CurrentRecordOptions.ScreenCapturePerformance;
                    ct = ScreenEncoder.CaptureType.FullScreen;
                    bRecordScreen = true;
                    break;
                case RecordOptions.ScreenRecordType.ScreenRecordWindow:
                    CarverLab.Utility.Win32Wrapper w32 = new CarverLab.Utility.Win32Wrapper();
                    CarverLab.Utility.Window CapWin = w32[frm.CurrentRecordOptions.WindowTitleToRecord];

                    cp = frm.CurrentRecordOptions.ScreenCapturePerformance;
                    if (frm.CurrentRecordOptions.WindowTitleToRecord == string.Empty ||
                        CapWin == null)
                    {
                        if (System.Windows.Forms.MessageBox.Show(this,"Could not find the specified window entitled: " + frm.CurrentRecordOptions.WindowTitleToRecord + ". Continue and record the full screen instead?",
                            "Record the Entire Screen?",System.Windows.Forms.MessageBoxButtons.YesNo,
                            System.Windows.Forms.MessageBoxIcon.Question,System.Windows.Forms.MessageBoxDefaultButton.Button1)
                            == System.Windows.Forms.DialogResult.Yes)
                        {
                            ct = ScreenEncoder.CaptureType.FullScreen;
                            oparams = "N/A";
                        }
                        else
                        {
                            if(bRecordCamera)
                            {

                                if (System.Windows.Forms.MessageBox.Show(this,"Would you like to continue recording camera(s)?",
                                    "Record Cameras without Screen Capture?",System.Windows.Forms.MessageBoxButtons.YesNo,
                                    System.Windows.Forms.MessageBoxIcon.Question,System.Windows.Forms.MessageBoxDefaultButton.Button1)
                                    != System.Windows.Forms.DialogResult.Yes)
                                {
                                    bRecordScreen = false;
                                }
                            }
                        }
                    }
                    else
                    {
                        System.Diagnostics.Debug.Assert(CapWin != null,"CapWin should not be null!");
                        ct = ScreenEncoder.CaptureType.WindowByHandle;
                        oparams = CapWin;
                    }
                    break;
                default:
                    System.Diagnostics.Debug.Assert(false,"Invalid recording type selected for screen recording.");
                    break;
            }

            #endregion

            #region SET UP FOR SCREEN RECORD

            if (bRecordScreen)
            {
                if (!m_encoder.Execute(ScreenEncoder.Command.SetupEncoder,cp,ct,oparams))
                {
                    sErrorBody = "Could not start the screen recording process. This is a serious error. Contact your system administrator.";
                    sErrorCaption = "Screen Recording Failure...";
                    goto Label_Screen_Error;
                }
                Application.DoEvents();
                System.Threading.Thread.Sleep(1500);
                Application.DoEvents();
            }
            #endregion

            #region CAMERA SELECTION

            switch (ro.SelectedCamera)
            {
                case RecordOptions.CameraSelection.CameraNone:
                    bRecordCamera = false;
                    NumCams = 0;
                    break;
                case RecordOptions.CameraSelection.CameraOne:
                    NumCams = 1;

                    m_sCameraRecordingName = new string[1];
                    m_oec = new OysterEncoderController.Control[1];
                    m_oec[0] = new OysterEncoderController.Control(ro.DefaultOysterDeviceAddress,OysterEncoderController.Control.CameraDefaultPort(1),ref mLogger);

                    if (!m_oec[0].Open())
                    {
                        sErrorBody = "Could not start the camera one recording process. Camera may be in use or this could be a serious error. Contact your system administrator.";
                        sErrorCaption = "Camera Recording Failure...";
                        //bRecordCamera = false;
                        //bError = true;
                        //Reset();
                        goto Label_Camera_Error;
                    }
                    break;
                case RecordOptions.CameraSelection.CameraTwo:
                    NumCams = 1;
                    m_sCameraRecordingName = new string[1];
                    m_oec = new OysterEncoderController.Control[1];
                    m_oec[0] = new OysterEncoderController.Control(ro.DefaultOysterDeviceAddress,OysterEncoderController.Control.CameraDefaultPort(2),ref mLogger);
                    if (!m_oec[0].Open())
                    {
                        sErrorBody = "Could not start the camera two recording process. Camera may be in use or this could be a serious error. Contact your system administrator.";
                        sErrorCaption = "Camera Recording Failure...";
                        goto Label_Camera_Error;
                    }
                    break;
                case RecordOptions.CameraSelection.CameraOneAndTwo:
                    NumCams = 2;
                    bIsSession = true;
                    m_sCameraRecordingName = new string[2];
                    m_oec = new OysterEncoderController.Control[2];
                    m_oec[0] = new OysterEncoderController.Control(ro.DefaultOysterDeviceAddress,OysterEncoderController.Control.CameraDefaultPort(1),ref mLogger);
                    if (!m_oec[0].Open())
                    {
                        sErrorBody = "Could not start the camera one recording process. Camera may be in use or this could be a serious error. Contact your system administrator.";
                        sErrorCaption = "Camera Recording Failure...";
                        goto Label_Camera_Error;
                    }
                    m_oec[1] = new OysterEncoderController.Control(ro.DefaultOysterDeviceAddress,OysterEncoderController.Control.CameraDefaultPort(2),ref mLogger);
                    if (!m_oec[1].Open())
                    {
                        sErrorBody = "Could not start the camera two recording process. Camera may be in use or this could be a serious error. Contact your system administrator.";
                        sErrorCaption = "Camera Recording Failure...";
                        goto Label_Camera_Error;
                    }
                    break;
                default:
                    System.Diagnostics.Debug.Assert(false,"Invalid SelectedCamera enum");

                    sErrorBody = "A programmer error detected.  Please try reselected the desired camera in the options menu. If problem persist please contact your Administrator.";
                    sErrorCaption = "Programmer Error: Invalid SelectedCamera enum";
                    //bRecordCamera = false;
                    //bError = true;
                    goto Label_Camera_Error;
            }

            #endregion

            #region Require Oyster Objects
            //OCL.Oyster oyster = new OCL.Oyster();
            OCL.Oyster oyster = new OCL.Oyster(frm.CurrentRecordOptions.DefaultOysterAddress,frm.CurrentRecordOptions.DefaultOysterConnectionPort);
            OCL.User me = oyster.GetUserById(m_me.ID);
            OCL.VideoStorageServer vss;// = (OCL.VideoStorageServer)oyster.GetUnassignedObject(OCL.OysterUnassignedObjects.VideoStorageServer);

            OCL.Scene sce;// = (OCL.Scene)oyster.GetUnassignedObject(OCL.OysterUnassignedObjects.Scene);
            OCL.Source src = null;// = (OCL.Source)oyster.GetUnassignedObject(OCL.OysterUnassignedObjects.Source);
            foreach (OCL.Source srcx in oyster.AllVisibleSources(me))
            {
                string shostname = System.Net.Dns.GetHostByAddress(System.Net.IPAddress.Parse(frm.CurrentRecordOptions.DefaultOysterDeviceAddress)).HostName;
                //strip off domain info
                if (shostname.IndexOf(".") != -1)
                {
                    shostname = shostname.Substring(0,shostname.IndexOf("."));
                }
                if (srcx.ControlAddress.ToLower() == shostname.ToLower() ||
                    srcx.ControlAddress.ToLower() == frm.CurrentRecordOptions.DefaultOysterDeviceAddress.ToLower())
                {
                    src = srcx;
                    break;
                }
            }
            if (src == null)
            {

                sErrorBody = "The data for the Oyster Device that was selected for this recording is not configured correctly. Contact the system administrator.";
                sErrorCaption = "Camera Recording Failure";
                //bRecordCamera = false;
                //bError = true;
                goto Label_Camera_Error;
            }
            sce = src.CurrentScene;
            vss = sce.AssignedVideoStorageServer;
            #endregion

            #region START RECORDING

            if (bRecordScreen)
            {
                if (bRecordCamera)
                {
                    bIsSession = true;
                }
                m_sScreenRecordingName = System.Guid.NewGuid().ToString();
                Application.DoEvents();
                System.Threading.Thread T = new System.Threading.Thread(new System.Threading.ThreadStart(StartScreenCapture));
                T.Start();
                //m_encoder.Execute(ScreenEncoder.Command.StartRecording,m_sScreenRecordingName);

            }

            if (bRecordCamera)
            {
                for (int i = 0; i < m_oec.GetLength(0); i++)
                {
                    m_sCameraRecordingName[i] = System.Guid.NewGuid().ToString();
                    m_oec[i].FilePath = vss.OysterRootDirectory;
                    if (m_oec[i].LastError.Length > 0)
                    {
                        sErrorBody = m_oec[i].LastError;
                        sErrorCaption = "Recording Startup Error...";
                        goto Label_Camera_Error;
                    }
                    m_oec[i].StartRecording(m_sCameraRecordingName[i]);
                    m_oec[i].OnConnectionError +=new OysterEncoderController.Control.OnConnectionErrorHandler(frmDisplay_OnConnectionError);

                }
            }
            #endregion

            if (bIsSession)
            {
                m_sRecordingSessionId = System.Guid.NewGuid().ToString();
            }
            else
                m_sRecordingSessionId = null;

            #region Create Database Entries

            bool bIsPresentation = false;
            if(bRecordScreen && bRecordCamera)
            {
                bIsPresentation = true;
            }
            int NumRecordings = NumCams;
            if(bRecordScreen)
                NumRecordings++;

            CurrentRecordingSession = me.CreateASession(DateTime.Now.ToString(),bIsPresentation);
            CurrentRecordings = new OCL.Recording[NumRecordings];
            int iRecIndex = 0;

            /// Create Camera Recording Entries
            if(bRecordCamera)
            {
                for (int i = 0; i < NumCams; i++)
                {
                    bool bIsPrimaryCamera;

                    if (i == System.Convert.ToInt32(frm.CurrentRecordOptions.CameraPrimary))
                        bIsPrimaryCamera = true;
                    else
                        bIsPrimaryCamera = false;

                    CurrentRecordings[iRecIndex] = CurrentRecordingSession.CreateRecording(m_sCameraRecordingName[i] + ".wmv",
                        "Camera " + (i+1),me,sce,src,false,bIsPrimaryCamera);
                    //CurrentRecordings[iRecIndex].UpdateFileSizeOnDisk();
                    //CurrentRecordings[iRecIndex].Update(TotalTime.ToString());
                    iRecIndex++;
                }
            }
            /// Create Desktop Recording Entry
            if(bRecordScreen)
            {

                string sRawFileName = m_sScreenRecordingName;
                string sRName = sRawFileName + ".wmv";

                string sFileLocation = frm.CurrentRecordOptions.WMVDirectory + @"\" + sRName;

                System.IO.FileInfo FID = new System.IO.FileInfo(sFileLocation);
                m_DesktopRecordingSize = FID.Length;
                CurrentRecordings[iRecIndex] = CurrentRecordingSession.CreateRecording(sRName,"Presentation",
                    me,sce,src,true,false);
                //CurrentRecordings[iRecIndex].Update(m_DesktopRecordingSize);
                //CurrentRecordings[iRecIndex].Update(TotalTime.ToString());
                DataRow R = null;
                string SourceFile = frm.CurrentRecordOptions.WMVDirectory + @"\" + sRName;
                try
                {
                    R = dsFileTransfer.Tables["File"].NewRow();
                    R["ObjectID"] = CurrentRecordings[iRecIndex].ID;
                    R["OysterObjectTypeID"]= 2; //Recording Type
                    R["RecordingSessionID"] = CurrentRecordings[iRecIndex].SessionID;
                    R["UserID"] = m_me.ID;
                    R["UserDescription"]= m_me.Description;
                    R["VideoStorageServerID"]= vss.ID;
                    R["OysterServerAddress"] = frm.CurrentRecordOptions.DefaultOysterAddress;
                    R["SourceFile"] = frm.CurrentRecordOptions.WMVDirectory + @"\" + sRName;
                    R["DestinationFileName"] = sRName;
                    R["DeleteAfterTransfer"] = true;
                    dsFileTransfer.Tables["File"].Rows.Add(R);
                    dsFileTransfer.Tables["File"].AcceptChanges();
                    dsFileTransfer.WriteXml(frm.CurrentRecordOptions.WMVDirectory + @"\" + sRawFileName + ".xml");
                }
                catch(Exception Err)
                {
                    MessageBox.Show(Err.Message,"Programmer Error during writing xml");
                }
            }
            #endregion

            clock.DigitalDisplayColor = SriClocks.DigitalColor.GreenColor;
            clock.ClockDisplayType = SriClocks.ClockType.StopWatch;
            clock.Reset();
            btnStartStop.Text = "STOP";
            btnStartStop.Enabled = true;
            clock.StartTimer();
            StartRecordingTime = DateTime.Now;
            m_bRecording = true;
            m_ScreenIsCaptured = bRecordScreen;
            m_CameraIsCaptured = bRecordCamera;
            this.TopMost = false;
            bDontClick = false;
            StatusWindow.Hide();
            StatusWindow.Dispose();
            return;

            Label_Camera_Error:
            {
                bDontClick = false;
                StatusWindow.Hide();
                StatusWindow.Dispose();
                System.Windows.Forms.MessageBox.Show(this,sErrorBody,
                    sErrorCaption,System.Windows.Forms.MessageBoxButtons.OK,
                    System.Windows.Forms.MessageBoxIcon.Error);
                if(m_oec != null)
                {
                    for(int i=0; i< m_oec.Length;i++)
                    {
                        m_oec[i] = null;
                    }
                    m_oec = null;
                }
                Reset();
                m_CameraIsCaptured = false;
                m_ScreenIsCaptured = false;
                this.TopMost = true;
                return;
            }
            Label_Screen_Error:
            {
                bDontClick = false;
                StatusWindow.Hide();
                StatusWindow.Dispose();
                System.Windows.Forms.MessageBox.Show(this,sErrorBody,
                    sErrorCaption,System.Windows.Forms.MessageBoxButtons.OK,
                    System.Windows.Forms.MessageBoxIcon.Error);
                if(m_oec != null)
                {
                    for(int i=0; i< m_oec.Length;i++)
                    {
                        m_oec[i].StopRecording();
                        m_oec[i].Close();
                        m_oec[i] = null;
                    }
                    m_oec = null;
                }
                m_CameraIsCaptured = false;
                m_ScreenIsCaptured = false;
                Reset();
                this.TopMost = true;
                return;
            }
        }