HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML
 

"Web Conferencing Using The JAVA Media Framework"
Vol. 9, Issue 8, p. 24

	



Listing 1: JMF Capture Applet

Step-1
videoDataSource = javax.media.Manager.createDataSource(videoMediaLocator);
Step-2
videoOutputFormat[0] = new VideoFormat(VideoFormat.H263, new Dimension(160,120),
Format.NOT_SPECIFIED, null, 15);
outputType = new FileTypeDescriptor(FileTypeDescriptor.QUICKTIME);
ProcessorModel processorModel = new ProcessorModel(videoDataSource, videoOutputFormat, outputType);
Step-3
videoProcessor = Manager.createRealizedProcessor(processorModel);
if (videoProcessor != null) videoDataSource = videoProcessor.getDataOutput();
Step-4
MediaLocator dest = new MediaLocator("file://" + file);
DataSink filewriter = Manager.createDataSink(videoDataSource, dest);
filewriter.open();
Step-5
filewriter.start();
videoProcessor.start();


Listing 2: File Upload Thread

Step-1
URL url = new URL(“http://localhost:80/jmf/parserUpload.jsp");
Socket sock = new Socket(url.getHost(), (-1 == url.getPort()) ? 80 : url.getPort());
Step-2
header.append("POST ");
header.append(url.getPath());
header.append(" HTTP/1.0\r\n");
header.append("Content-type: multipart/form-data; boundary=");
header.append(boundary.substring(2, boundary.length()) + "\r\n");
header.append("Content-length: ");
header.append(contentLength);
header.append("\r\n");
header.append("\r\n");
Step-3
dataout = new DataOutputStream(new BufferedOutputStream(sock.getOutputStream()));
datain = new BufferedReader(new InputStreamReader(sock.getInputStream()));
Step-4
dataout.writeBytes(header.toString());
uploadFileStream(files, dataout);
dataout.writeBytes(tail.toString());


Listing 3: JMF Player Applet

Step-1
URL mediaURL1 = new URL(videoDir + mediaFile + counter + ".mov");
counter++;
URL mediaURL2 = new URL(videoDir + mediaFile + counter + ".mov");
Player player1 = Manager.createPlayer(mediaURL1);
Player player2 = Manager.createPlayer(mediaURL2);
Step-2
player1.start();
player2.fetch();
Step-3
player2.start();
add(player2.getVisualComponent());
if(visualComp!=null) remove(visualComp);
visualComp = player2.getVisualComponent();
counter++;
URL mediaURL = new URL(videoDir + mediaFile + counter + ".mov");
player = Manager.createRealizedPlayer(mediaURL);
player.addControllerListener(this);
player.prefetch();


Listing 4: Sender HTML code

<html> <head>
<body>
      <applet code=SaveVideoApplet.class width=320 height=280>
	   <param name=archive value="jmf.jar">
      <param name=counter value="0">
      <param name=uploadurl value="http:/localhost/jmf/upload.jsp">
        <!-- URL of the Upload Servlet -->
      <param name=sender value="test"> 
         <!-- sender id -->
      </applet> 
</body></html>


Listing 5: Receiver HTML code

<html> <body>
      <applet code=PlayerApplet.class width=320 height=280>
      <param name=archive value="jmf.jar">
      <param name=counter value="0"> <!-- counter at the time of request -->
      <param name=sender value="test"> <!-- sender id -->
      <param name=rate value="1.0"> <!-- rate at which player sees the video
	  --> 
      <param name=videodir value="http://localhost/jmf/videos/"> <!-- server
	  directory; all clips from sender will be at http://localhost/jmf/videos/ -->
      </applet> 
</body></html>
  
 

All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: [email protected]

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.