示例#1
0
	private void CameraScanWin()
	{

		Gst.Element e = Gst.ElementFactory.Make ("dshowvideosrc");
		Gst.Interfaces.PropertyProbeAdapter ppa = new Gst.Interfaces.PropertyProbeAdapter (e.Handle);

		object[] devices = ppa.ProbeAndGetValues ("device-name");

		FillCombo (cbxCamera);

		foreach (String dev in devices) {
			Gst.Caps caps = e.GetStaticPad ("src").Caps;

			foreach (Gst.Structure cap in caps) {
				if (cap.HasField ("width") && cap.HasField ("height")) {
					Gst.GLib.Value s;
					int height = 0, width = 0;

					s = cap.GetValue ("width");
					if (s.Val is int) {
						width = (int)s.Val;
					}
					s = cap.GetValue ("height");
					if (s.Val is int) {
						height = (int)s.Val;
					}

					if (width == 320 && height == 240) {
						s = cap.GetValue ("framerate");

						Gst.Fraction f;
						if (s.Val is Gst.FractionRange) {
							f = new Gst.FractionRange (s).Max;  // ? Min
						} else if (s.Val is Gst.Fraction) {
							f = new Gst.Fraction (s);
						} else if (s.Val is int) {
							f = new Gst.Fraction ((int)s.Val, 1);
						} else
							continue;

						cameras [dev] = new GstCapture.cameraDevice (dev, f, width, height);

						cbxCamera.AppendText (dev);	


					}
				}
			}
		}
	}
示例#2
0
	private void CameraScanUnix ()
	{

		Gst.Element e = Gst.ElementFactory.Make ("v4l2src");
		Gst.Interfaces.PropertyProbeAdapter ppa = new Gst.Interfaces.PropertyProbeAdapter (e.Handle);

		object[] devices = ppa.ProbeAndGetValues ("device");

		FillCombo (cbxCamera);

		foreach (String dev in devices) {

			Gst.Fraction f = new Gst.Fraction(30,1);

			cameras [dev] = new GstCapture.cameraDevice (dev, f , 320 , 240);

			cbxCamera.AppendText (dev);	


		}
	}
示例#3
0
	public void StartRecordingUnix()
	{
		if (txtFolderOut.Text != String.Empty && Directory.Exists(txtFolderOut.Text.Trim()))
		{
			GstCapture.cameraDevice cDev = cameras[cbxCamera.ActiveText];
			//String sDev = "yes";
			String aDev = cbxMic.ActiveText;
			String _path = txtFolderOut.Text.Trim();

			DateTime dt = DateTime.Now;

			//Encoding w = Encoding.GetEncoding("windows-1251"); // HACK

			String aargs = null,
			cargs = null,
			sargs = null;


			if ((aDev != null) && ckbxMic.Active)
			{


				//aargs = String.Format(" dshowaudiosrc device-name=\"{0}\"", w.GetString(Encoding.UTF8.GetBytes(aDev)));
				aargs = String.Format(" pulsesrc");
				//aargs += " ! audio/x-raw-int, rate = 44100, channels = 1, depth = 16 ! queue ! faac ! tee name = audio";
				aargs += " ! audio/x-raw-int, rate = 44100, channels = 1, depth = 16 ! queue ! ffenc_adpcm_swf ! tee name = audio";

			}

			dir = String.Format("{0:yyyy-MM-dd_HH-mm-ss}", dt);
			path = Directory.CreateDirectory(
				System.IO.Path.Combine(_path, dir)
				).FullName;

			Directory.SetCurrentDirectory(path);
			Environment.SetEnvironmentVariable("GST_DEBUG", "3");

			if (cDev != null && ckbxCamera.Active)
			{
				int gop = 450;

				cargs = " flvmux name=camera ! filesink location=\"camera.flv\"";

				cargs += String.Format(" v4l2src device =\"{0}\"", cDev.device.ToString());
				cargs += String.Format(" ! video/x-raw-yuv, framerate = {0}/{1}, width={2}, height={3}" +
				                       " ! videorate ! video/x-raw-yuv, framerate = {4}/1" +
				                       " ! queue ! ffenc_flv name = cv gop-size = {5} ! camera.",
				                       cDev.framerate.Numerator, cDev.framerate.Denominator, cDev.width, cDev.height,
				                       30, gop);
				if (aargs != null)
				{
					//cargs += " audio. ! queue ! audio/mpeg ! camera.";
					cargs += " audio. ! queue ! audio/x-adpcm ! camera.";
				}

			}

			if (ckbxDisplay.Active)//sDev != null)
			{
				int gop = 150;
				sargs = " flvmux name=\"screen\" ! filesink location=\"screen.flv\"";

				sargs += " ximagesrc use-damage=false";
				sargs += String.Format(" ! video/x-raw-rgb, framerate = {0}/1" +
				                       " ! ffmpegcolorspace ! queue " +
				                       " ! ffenc_flashsv name=sv gop-size = {1} ! screen.",
				                       5, gop);


				if (aargs != null)
				{
					// sargs += " audio. ! queue ! audio/mpeg ! screen.";
					sargs += " audio. ! queue ! audio/x-adpcm ! screen.";
				}

			}

			try
			{
				String final =  cargs + sargs + aargs;
				gstRecording = (Gst.Pipeline)Gst.Parse.Launch(final);

				lblStatus.Text = "Recording";

			}
			catch (Exception error)
			{
				GstCapture.MessageBox.Show(String.Format("{0}: {1}", error.Message, cargs + sargs + aargs));
			}

			if (gstRecording != null)
			{
				gstRecording.SetState(Gst.State.Playing);

				Gst.State s;
				gstRecording.GetState(out s, timeout);

				isRecording = true;

			}

			Directory.SetCurrentDirectory(_path);
		}
	}