예제 #1
0
        private void CreateEncoderAppWithUI()
        {
            WMEncoderApp EncoderApp = new WMEncoderApp();
            IWMEncoder   Encoder    = EncoderApp.Encoder;

            // Display the predefined Encoder UI.
            EncoderApp.Visible = true;
        }
예제 #2
0
        private static IWMEncProfile SelectProfile(IWMEncoder enc, string name)
        {
            IWMEncProfile result = null;

            foreach (IWMEncProfile profile in enc.ProfileCollection)
            {
                if (profile.Name.StartsWith(name))
                {
                    result = profile;
                    break;
                }
            }
            return(result);
        }
예제 #3
0
 //To Stop & Save the Recording.
 private void stopRecordingToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (DesktopEncoder != null)
         {
             DesktopEncoder.Stop();
             SaveFileDialog dialog = new SaveFileDialog();
             dialog.Filter     = "Video Files (*.wmv)|*.wmv";
             dialog.DefaultExt = "wmv";
             DialogResult res = dialog.ShowDialog();
             if (res != DialogResult.Cancel)
             {
                 if (File.Exists("C:\\TempRecording.wmv"))
                 {
                     recentRecordingsToolStripMenuItem1.DropDownItems.Add(dialog.FileName, null, recentRecordings_Click);
                     recentRecordingsToolStripMenuItem.DropDownItems.Add(dialog.FileName, null, recentRecordings_Click);
                     File.Copy("C:\\TempRecording.wmv", dialog.FileName);
                     File.Delete("C:\\TempRecording.wmv");
                 }
             }
             tmrRcCounter.Enabled   = false;
             tsRecDuration.Text     = "";
             tmrViewerCount.Enabled = false;
             if (this.Visible)
             {
                 notifyRecorder.Text = "Recorder is in Visible Mode.";
             }
             else
             {
                 notifyRecorder.Text = "Recorder is in Invisible Mode.";
             }
             //Windows Media Encoder EXE.
             Process[] ps = Process.GetProcessesByName("wmenc");
             if (ps.Length != 0)
             {
                 ps[0].Kill();
             }
             DesktopEncoder       = null;
             tmrRcCounter.Enabled = false;
         }
     }
     catch
     {
         MessageBox.Show("Can't Stop it.Please,Save Current Recording and Restart Application.");
     }
 }
예제 #4
0
		//To Stop & Save the Recording.
		private void stopRecordingToolStripMenuItem_Click(object sender, EventArgs e)
		{
			try
			{
				if (DesktopEncoder != null)
				{
					DesktopEncoder.Stop();
					SaveFileDialog dialog = new SaveFileDialog();
					dialog.Filter = "Video Files (*.wmv)|*.wmv";
					dialog.DefaultExt = "wmv";
					DialogResult res = dialog.ShowDialog();
					if (res != DialogResult.Cancel)
					{
						if (File.Exists("C:\\TempRecording.wmv"))
						{
							recentRecordingsToolStripMenuItem1.DropDownItems.Add(dialog.FileName, null, recentRecordings_Click);
							recentRecordingsToolStripMenuItem.DropDownItems.Add(dialog.FileName, null, recentRecordings_Click);
							File.Copy("C:\\TempRecording.wmv", dialog.FileName);
							File.Delete("C:\\TempRecording.wmv");
						}
					}
					tmrRcCounter.Enabled = false;
					tsRecDuration.Text = "";
					tmrViewerCount.Enabled = false;
					if (this.Visible)
					{
						notifyRecorder.Text = "Recorder is in Visible Mode.";
					}
					else
					{
						notifyRecorder.Text = "Recorder is in Invisible Mode.";
					}
					//Windows Media Encoder EXE.
					Process[] ps = Process.GetProcessesByName("wmenc");
					if (ps.Length != 0)
					{
						ps[0].Kill();
					}
					DesktopEncoder = null;
					tmrRcCounter.Enabled = false;
				}
			}
			catch
			{
				MessageBox.Show("Can't Stop it.Please,Save Current Recording and Restart Application.");
			}

		}
예제 #5
0
		//To Start the Recording.
		private void startRecordingToolStripMenuItem_Click(object sender, EventArgs e)
		{
			IWMEncProfile SelProfile;
			IWMEncSource AudioSrc;
			try
			{
				if (DesktopEncoder != null)
				{
					if (DesktopEncoder.RunState == WMENC_ENCODER_STATE.WMENC_ENCODER_PAUSED)
					{
						DesktopEncoder.Start();
						return;
					}
				}
				DesktopEncoderAppln = new WMEncoderApp();
				DesktopEncoder = DesktopEncoderAppln.Encoder;
				IWMEncSourceGroupCollection SrcGroupCollection = DesktopEncoder.SourceGroupCollection;
				IWMEncSourceGroup SrcGroup = SrcGroupCollection.Add("SG_1");
				IWMEncVideoSource2 VideoSrc = (IWMEncVideoSource2)SrcGroup.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
				//Set Audio Source.
				if (addAudio.Checked)
				{
					AudioSrc = SrcGroup.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
					if (txtAudioFile.Text.Trim() != "")
					{
						if (File.Exists(txtAudioFile.Text.Trim()))
						{
							AudioSrc.SetInput(txtAudioFile.Text.Trim(), "", "");
						}
						else
						{
							AudioSrc.SetInput("Default_Audio_Device", "Device", "");
						}
					}
					else
					{
						AudioSrc.SetInput("Default_Audio_Device", "Device", "");
					}
				}
				//Set Video Source:Desktop.
				VideoSrc.SetInput("ScreenCapture1", "ScreenCap", "");
				IWMEncProfileCollection ProfileCollection = DesktopEncoder.ProfileCollection;
				ProfileCollection = DesktopEncoder.ProfileCollection;
				int lLength = ProfileCollection.Count;
				//Set Profile.
				if (toolstripEnableBroadcast.Checked && txtPortNbr.Text.Trim() != "")
				{
					IWMEncBroadcast broadcast = DesktopEncoder.Broadcast;
					broadcast.set_PortNumber(WMENC_BROADCAST_PROTOCOL.WMENC_PROTOCOL_HTTP, Convert.ToInt32(txtPortNbr.Text.Trim()));
					for (int i = 0; i <= lLength - 1; i++)
					{
						SelProfile = ProfileCollection.Item(i);
						if (SelProfile.Name == "Windows Media Video 8 for Local Area Network (768 Kbps)")
						{
							SrcGroup.set_Profile((IWMEncProfile)SelProfile);
							break;
						}
					}
				}
				else
				{
					for (int i = 0; i <= lLength - 1; i++)
					{
						SelProfile = ProfileCollection.Item(i);
						if (SelProfile.Name == "Screen Video/Audio High (CBR)")
						{
							SrcGroup.set_Profile((IWMEncProfile)SelProfile);
							break;
						}
					}
				}
				//Local File to Store Recording temporarily.
				IWMEncFile inputFile = DesktopEncoder.File;
				inputFile.LocalFileName = "C:\\TempRecording.wmv";
				DesktopEncoder.PrepareToEncode(true);
				DesktopEncoder.Start();
				tmrRcCounter.Enabled = true;
				recordStarttime = DateTime.Now;
				if (toolstripEnableBroadcast.Checked && txtPortNbr.Text.Trim() != "")
				{
					//Start Timer to Count Viewers connected to Broadcast.
					tmrViewerCount.Enabled = true;
				}
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}
예제 #6
0
        //To Start the Recording.
        private void startRecordingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IWMEncProfile SelProfile;
            IWMEncSource  AudioSrc;

            try
            {
                if (DesktopEncoder != null)
                {
                    if (DesktopEncoder.RunState == WMENC_ENCODER_STATE.WMENC_ENCODER_PAUSED)
                    {
                        DesktopEncoder.Start();
                        return;
                    }
                }
                DesktopEncoderAppln = new WMEncoderApp();
                DesktopEncoder      = DesktopEncoderAppln.Encoder;
                IWMEncSourceGroupCollection SrcGroupCollection = DesktopEncoder.SourceGroupCollection;
                IWMEncSourceGroup           SrcGroup           = SrcGroupCollection.Add("SG_1");
                IWMEncVideoSource2          VideoSrc           = (IWMEncVideoSource2)SrcGroup.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
                //Set Audio Source.
                if (addAudio.Checked)
                {
                    AudioSrc = SrcGroup.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
                    if (txtAudioFile.Text.Trim() != "")
                    {
                        if (File.Exists(txtAudioFile.Text.Trim()))
                        {
                            AudioSrc.SetInput(txtAudioFile.Text.Trim(), "", "");
                        }
                        else
                        {
                            AudioSrc.SetInput("Default_Audio_Device", "Device", "");
                        }
                    }
                    else
                    {
                        AudioSrc.SetInput("Default_Audio_Device", "Device", "");
                    }
                }
                //Set Video Source:Desktop.
                VideoSrc.SetInput("ScreenCapture1", "ScreenCap", "");
                IWMEncProfileCollection ProfileCollection = DesktopEncoder.ProfileCollection;
                ProfileCollection = DesktopEncoder.ProfileCollection;
                int lLength = ProfileCollection.Count;
                //Set Profile.
                if (toolstripEnableBroadcast.Checked && txtPortNbr.Text.Trim() != "")
                {
                    IWMEncBroadcast broadcast = DesktopEncoder.Broadcast;
                    broadcast.set_PortNumber(WMENC_BROADCAST_PROTOCOL.WMENC_PROTOCOL_HTTP, Convert.ToInt32(txtPortNbr.Text.Trim()));
                    for (int i = 0; i <= lLength - 1; i++)
                    {
                        SelProfile = ProfileCollection.Item(i);
                        if (SelProfile.Name == "Windows Media Video 8 for Local Area Network (768 Kbps)")
                        {
                            SrcGroup.set_Profile((IWMEncProfile)SelProfile);
                            break;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i <= lLength - 1; i++)
                    {
                        SelProfile = ProfileCollection.Item(i);
                        if (SelProfile.Name == "Screen Video/Audio High (CBR)")
                        {
                            SrcGroup.set_Profile((IWMEncProfile)SelProfile);
                            break;
                        }
                    }
                }
                //Local File to Store Recording temporarily.
                IWMEncFile inputFile = DesktopEncoder.File;
                inputFile.LocalFileName = "C:\\TempRecording.wmv";
                DesktopEncoder.PrepareToEncode(true);
                DesktopEncoder.Start();
                tmrRcCounter.Enabled = true;
                recordStarttime      = DateTime.Now;
                if (toolstripEnableBroadcast.Checked && txtPortNbr.Text.Trim() != "")
                {
                    //Start Timer to Count Viewers connected to Broadcast.
                    tmrViewerCount.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #7
0
        private static IWMEncProfile SelectProfile(IWMEncoder enc, string name)
        {
            IWMEncProfile result = null;

            foreach (IWMEncProfile profile in enc.ProfileCollection)
            {
                if (profile.Name.StartsWith(name))
                {
                    result = profile;
                    break;
                }
            }
            return result;
        }
예제 #8
0
파일: Stream.cs 프로젝트: usmanghani/VTC
 public void InitializeBasic()
 {
     if (EncoderApp == null)
     {
         EncoderApp = new WMEncoderApp();
         Encoder = EncoderApp.Encoder;
         // IMPORTANT: set to false on product release
         EncoderApp.Visible = false; //true;
         //Encoder.OnStateChange += new _IWMEncoderEvents_OnStateChangeEventHandler(OnStateChange);
         InitializeEncoder();
     }
 }