← Back to team overview

sltv team mailing list archive

[Branch ~sltv/sltv/trunk] Rev 3: experimentos com captura por webcam e informacoes do projeto (mapa mental)

 

------------------------------------------------------------
revno: 3
committer: Lucas Alberto lucasa@xxxxxxxxx
branch nick: SLTV
timestamp: Fri 2009-09-11 00:20:29 -0300
message:
  experimentos com captura por webcam e informacoes do projeto (mapa mental)
added:
  lib/sltv.jar
  project/sltv architecture mindmap.vym
  src/br/org/softwarelivre/sltv/Capture.java
modified:
  src/br/org/softwarelivre/sltv/SLTVPlayerMain.java
  src/br/org/softwarelivre/sltv/VideoPipeline.java


--
lp:sltv
https://code.launchpad.net/~sltv/sltv/trunk

Your team sltv is subscribed to branch lp:sltv.
To unsubscribe from this branch go to https://code.launchpad.net/~sltv/sltv/trunk/+edit-subscription.
=== added file 'lib/sltv.jar'
Binary files lib/sltv.jar	1970-01-01 00:00:00 +0000 and lib/sltv.jar	2009-09-11 03:20:29 +0000 differ
=== added file 'project/sltv architecture mindmap.vym'
Binary files project/sltv architecture mindmap.vym	1970-01-01 00:00:00 +0000 and project/sltv architecture mindmap.vym	2009-09-11 03:20:29 +0000 differ
=== added file 'src/br/org/softwarelivre/sltv/Capture.java'
--- src/br/org/softwarelivre/sltv/Capture.java	1970-01-01 00:00:00 +0000
+++ src/br/org/softwarelivre/sltv/Capture.java	2009-09-11 03:20:29 +0000
@@ -0,0 +1,42 @@
+package br.org.softwarelivre.sltv;
+
+import org.gstreamer.Caps;
+import org.gstreamer.Element;
+import org.gstreamer.ElementFactory;
+
+public class Capture extends VideoPipeline {
+
+	private String hostIP = "localhost";
+	private String hostPort = "8001";
+
+	public static void main(String[] args) {
+		Capture capture = new Capture();
+	}
+	
+	
+	public Capture() {
+		super();
+		
+		Element v4l2src = ElementFactory.make("v4l2src", "v4l2src");
+		v4l2src.set("device", "/dev/video0");
+//		Element videoscale = ElementFactory.make("videoscale", "videoscale");
+//		Element videorate = ElementFactory.make("videorate", "videorate");
+//		
+//		Element videoFilterSize = ElementFactory.make("capsfilter", null);
+//		videoFilterSize.setCaps(Caps.fromString("video/x-raw-yuv, width=320, height=200"+ ", bpp=32, depth=16"));		
+//		Element videoFilterRate = ElementFactory.make("capsfilter", null);
+//		videoFilterRate.setCaps(Caps.fromString("video/x-raw-yuv, framerate=15/1"));
+//		
+		Element tcpclientsink = ElementFactory.make("tcpclientsink", "tcpclientsink");
+		tcpclientsink.set("host", hostIP);
+		tcpclientsink.set("port", hostPort);
+		tcpclientsink.set("protocol", 1);
+		
+		getPipeline().addMany(v4l2src, tcpclientsink);
+		//getPipeline().addMany(v4l2src, videorate, videoscale, videoFilterRate, videoFilterSize, tcpclientsink);
+		//boolean linked = getPipeline().linkMany(v4l2src, videorate, videoscale, videoFilterRate, videoFilterSize, tcpclientsink);
+		boolean linked = getPipeline().linkMany(v4l2src,  tcpclientsink);
+		if (DEBUG) System.out.println("Pipeline capture linked: " + linked);		
+	}
+
+}

=== modified file 'src/br/org/softwarelivre/sltv/SLTVPlayerMain.java'
--- src/br/org/softwarelivre/sltv/SLTVPlayerMain.java	2009-09-09 01:57:27 +0000
+++ src/br/org/softwarelivre/sltv/SLTVPlayerMain.java	2009-09-11 03:20:29 +0000
@@ -12,6 +12,7 @@
 import javax.swing.JMenu;
 import javax.swing.JMenuBar;
 import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 
 import org.gstreamer.Gst;
@@ -25,8 +26,9 @@
 	private JDesktopPane jDesktopPane = null;
 	private JMenuBar jJMenuBar;
 	private JMenu jMenu;
-	private JMenuItem jMenuItem;
+	private JMenuItem jMenuItemPlay;
 	private JMenuItem jMenuItem1;
+	private JMenuItem jMenuItemCapture;
 	
 	/**
 	 * This method initializes jDesktopPane	
@@ -78,6 +80,7 @@
 			public void windowClosing(WindowEvent arg0) {
 				/* clean before get out */
 				Gst.deinit();	
+				System.exit(0);
 			}
 			public void windowClosed(WindowEvent arg0) {
 				
@@ -112,7 +115,8 @@
 		if (jMenu == null) {
 			jMenu = new JMenu();
 			jMenu.setText("File");
-			jMenu.add(getJMenuItem());
+			jMenu.add(getJMenuItemPlay());
+			jMenu.add(getJMenuItemCapture());
 			jMenu.add(getJMenuItem1());
 		}
 		return jMenu;
@@ -123,11 +127,11 @@
 	 * 
 	 * @return javax.swing.JMenuItem
 	 */
-	private JMenuItem getJMenuItem() {
-		if (jMenuItem == null) {
-			jMenuItem = new JMenuItem();
-			jMenuItem.setText("Play Video");
-			jMenuItem.addActionListener(new java.awt.event.ActionListener() {
+	private JMenuItem getJMenuItemPlay() {
+		if (jMenuItemPlay == null) {
+			jMenuItemPlay = new JMenuItem();
+			jMenuItemPlay.setText("Play Video");
+			jMenuItemPlay.addActionListener(new java.awt.event.ActionListener() {
 				public void actionPerformed(java.awt.event.ActionEvent e) {
 
 //					playVideo("/home/lucasa/temp/SpiritOfUbuntu.ogv");
@@ -152,7 +156,33 @@
 				}
 			});
 		}
-		return jMenuItem;
+		return jMenuItemPlay;
+	}
+	
+	/**
+	 * This method initializes jMenuItem
+	 * 
+	 * @return javax.swing.JMenuItem
+	 */
+	private JMenuItem getJMenuItemCapture() {
+		if (jMenuItemCapture == null) {
+			jMenuItemCapture = new JMenuItem();
+			jMenuItemCapture.setText("Capture Webcam Video");
+			jMenuItemCapture.addActionListener(new java.awt.event.ActionListener() {
+				public void actionPerformed(java.awt.event.ActionEvent e) {
+					Thread thread = new Thread(new Runnable() {
+						public void run() {
+							Capture capture = new Capture();
+							capture.getPipeline().play();
+							String message = "Capture Webcam started...";
+							JOptionPane.showMessageDialog(SLTVPlayerMain.this, message);
+						}
+					});
+					thread.start();
+				}
+			});
+		}
+		return jMenuItemCapture;
 	}
 
 	/**

=== modified file 'src/br/org/softwarelivre/sltv/VideoPipeline.java'
--- src/br/org/softwarelivre/sltv/VideoPipeline.java	2009-09-09 02:59:06 +0000
+++ src/br/org/softwarelivre/sltv/VideoPipeline.java	2009-09-11 03:20:29 +0000
@@ -30,8 +30,11 @@
 
 	String lastEffect = "";
 	private Element streamBin;
+	final Element queueBegin = ElementFactory.make("queue", "queue1");
 	private int AUTO_INDEX = 0;
 	protected boolean DEBUG = true;
+	private String hostPort = "8001";
+	private String hostIP = "localhost";
 
 	public enum SLTVEffects {
 		noeffect("identity"), quarktv, revtv, vertigotv, shagadelictv, warptv, dicetv, agingtv, edgetv;
@@ -52,7 +55,7 @@
 		}
 	};
 
-	public VideoPipeline(String filepath, Element videoOutput) {
+	public VideoPipeline() {
 		pipe = new Pipeline("SLTV video pipeline");
 		pipe.getBus().connect(new Bus.ERROR() {
 			public void errorMessage(GstObject source, int code, String message) {
@@ -60,19 +63,22 @@
 					System.out.println("Error occurred: " + message);
 			}
 		});
+	}
+	
+	public VideoPipeline(String filepath, Element videoOutput) {
 
+		this();
+		
 		Element gnlcomposition = ElementFactory.make("gnlcomposition",
 				"gnlcomposition");
 
 		Element videosrc = null;
 		videosrc = ElementFactory.make("videotestsrc", "source");
 
-		final Element queue1 = ElementFactory.make("queue", "queue1");
-
 		/* listen for newly created pads */
 		gnlcomposition.connect(new Element.PAD_ADDED() {
 			public void padAdded(Element element, Pad pad) {
-				Pad sinkPad = queue1.getPad("sink");
+				Pad sinkPad = queueBegin.getPad("sink");
 				pad.link(sinkPad);
 				if (DEBUG)
 					System.out.println("New Pad [" + sinkPad.getName()
@@ -104,26 +110,27 @@
 		
 		Element timeoverlay = ElementFactory.make("timeoverlay", null);
 		//pipe.addMany(gnlcomposition, queue1, queue2, tee, queue3, videoOutput);
-		pipe.addMany(queue1, queue2, timeoverlay, videoscale, videoFilterSize, videorate, videoFilterRate, tee, queue3, videoOutput);
+		pipe.addMany(queueBegin, queue2, timeoverlay, videoscale, videoFilterSize, videorate, videoFilterRate, tee, queue3, videoOutput);
 
-		pipe.addMany(videosrc);
-		pipe.linkMany(videosrc, queue1);
-		//createReadNetworkBin(getPipeline());
+		//pipe.addMany(videosrc);
+		//pipe.linkMany(videosrc, queue1);
+		createReadNetworkBin(getPipeline());
 		
 		lastEffect = "filterBin";
 		filterBin = createSimpleBin(lastEffect, "ffmpegcolorspace ! quarktv ! ffmpegcolorspace");
 		//filterBin = createSimpleBin(lastEffect, "identity");
 		pipe.add(filterBin);
 
-		boolean linkedLocal = pipe.linkMany(queue1, filterBin,
+		
+		boolean linkedLocal = pipe.linkMany(queueBegin, filterBin,
 				queue2, timeoverlay, videoscale, videoFilterSize, videorate,
 				videoFilterRate, tee, queue3, videoOutput);
 		if (DEBUG) System.out.println("Pipeline local linked: " + linkedLocal);
 
-//		streamBin = createStreamBin();
-//		pipe.addMany(queue4, streamBin);
-//		boolean linkedStream = pipe.linkMany(tee, queue4, streamBin);
-//		if (DEBUG)System.out.println("Pipeline stream linked: " + linkedStream);
+		//streamBin = createStreamBin();
+		//pipe.addMany(queue4, streamBin);
+		//boolean linkedStream = pipe.linkMany(tee, queue4, streamBin);
+		//if (DEBUG)System.out.println("Pipeline stream linked: " + linkedStream);
 
 		bus = pipe.getBus();
 		bus.connect(new Bus.ERROR() {
@@ -211,7 +218,7 @@
 		Element queue2 = ElementFactory.make("queue", "queue2s");
 		Element shout2send = ElementFactory.make("shout2send", "shout2send");
 		shout2send.set("ip", "estudiolivre.org");
-		shout2send.set("password", "******");
+		shout2send.set("password", "lucasa");
 		shout2send.set("mount", "lucasa");
 		Element filesink = ElementFactory.make("filesink", "filesink");
 		filesink.set("location", "/tmp/output.ogg");
@@ -263,15 +270,15 @@
 		
 		Element source = null;
 		source = ElementFactory.make("tcpserversrc", "tcpserversrc");
-		source.set("host", "localhost");
-		source.set("port", "1234");
-		//source = ElementFactory.make("filesrc", "source");
-		//decodebin = ElementFactory.make("identity", null);
-		bin.addMany(source, decodebin);
+		source.set("host", hostIP);
+		source.set("port", hostPort );
+		source.set("protocol", 1);
+		bin.add(source);
+		//bin.add(decodebin);
 		
-		boolean linked = bin.linkMany(source, decodebin);		
+		boolean linked = bin.linkMany(source, this.queueBegin);
+		//boolean linked = bin.linkMany(source, decodebin);
 		if (DEBUG) System.out.println("Pipeline read from network linked: " + linked);
-		//bin.addPad(new GhostPad("src", decodebin.getPad("src")));
 		return bin;
 	}