Homework #4: Java Media Framework
Goal:
- Learn to create multimedia applications using JMF API and NetBean IDE
- Learn to set up video multicast with JMF and RTP using JMStudio.
Assignment Date: 4/17/2006 Due 4/26/2006
Related Reference:
Description:
Part 1: Setup NetBean IDE with JMF Jar files and Compile a Simple JMF Player Applet.
- Create a directory with your login name in c:\student\; for example c:\student\chow if your login is chow. In the following I assume the chow is your login.
- Click on the NetBean4.1 icon on the desktop and select File | New Project ... to start a new project.
- In New Project dialog box, select "Web" as categories and "Web Application" as Projects; Hit "Next >"

- In New Web Application dialog box, enter "SimplePlayerApplet" as Project Name and "C:\student\chow" as Project Location. Choose the default for other settings.Click "Finish" button.

- Click My Computer, enter C:\student\<login>, you should see a folder with SimplePlayerApplet created with nbproject, src, web, test directories and bulid.xml file. These are typical java web application project directories set up.
- cd web. It shows META-INF, WEB-INF directories and the default index.jsp web page.
- copy the jmftest.html and orion_1.mpg in http://cs.uccs.edu/~cs525/jmf/ to C:\student\chow\SimplePlayerApplet\web directory.
- From the web browser, type http://cs.uccs.edu/~cs525/jmf/ to access the jmf directory and right click on jmftest.html and select "save target as" to save it in C:\student\chow\SimplePlayerApplet\web
- You can also use SSH Secure File Transfer to copy files.
- remove index.jsp file in C:\student\chow\SimplePlayerApplet\web
- copy the SimplePlayerApplet.java in http://cs.uccs.edu/~cs525/jmf/ directory to C:\student\chow\SimplePlayerApplet\src\java directory.
- On NetBean, click + Source Packages and then <default package> You should see the SimplePlayerApplet.java there.

- Double click SimplePlayerApplet.java to open it on the source editor to the right of project window.
- If you are the first to run this exercise in those five PCs, you mayl see the error x mark in front of "import javax.media.*;" statement and we need to add jmf2.1.1e library to this project.
- In NetBean 5, it automatically searches for the JMF media library if you already add them in with libary manager. In NetBean 4.1 you need to manually add it in.
- To add a library to a project, right click SimplePlayerApplet in the top of the Project window. and select properties. Then select the add library menuitem.
- Select Build | Build Main Project (hit F11) to build your web applications.
- Select Run | Run Main Project (hit F6) to start the Tomcat server, deploy the web application, and to start a web browser access the SimplePlayerApplet web site on tomcat server, typically it shows port 8084. Just click on jmftest.html to play the movie.
- Take a snapshot of the browser. Save it in your cs525/hw4part directory.
- Try to add your movie files to the web directory of your project and create a web page similar to the jmftest.html. Rerun your project.
- Note that dist contain the war file, you can copy to a tomcat server for deploying your web application.
Part2: Video Transmission over RTP
In this exercise we will create a JMF-based Video Transmit application that multicast video using RTP.
- Creaet a Java application project called VideoTransmit using NetBean. Follow the procedure in part 1 but instead of choosing web application, choose java application.
- Enter c:\student\<login> as the project location.
- Copy VideoTransmit.java from http://cs.uccs.edu/~cs525/jmf/ to c:\student\<login>\VideoTransmit\src directory. Remove the VideoTransmit directory there under src.
- Select Build | Build Main Project.
- Set argument for running VideoTransit application, by right click on VideoTransmit project and select properties menuitem and enter file:/c:/student/<login>/SimplePlayerApplet/web/orion_1.mpg 239.0.0.1 3000 as Arguments. Click OK. This specifies the video file orion_1.mpeg as data source and data sink will be an RTP session with 239.0.0.1 multicast address and port 3000.
- Then Run | Run Main Project.
- In output window, you will see
init:
deps-jar:
compile:
run:
streams is [Lcom.sun.media.multiplexer.RawBufferMux$RawBufferSourceStream;@1a28362 : 1
sink: setOutputLocator rtp://239.0.0.1:3000/video
Video transmitted as:
JPEG/RTP, 320x240, FrameRate=29.9
- Setting quality to 0.5 on com.sun.media.codec.video.jpeg.NativeEncoder$1$QCA@30d82d
Start transmission for 600 seconds...
- Click on JMStudio on any of the five PC.
or select start | programs | Java Media Framework 2.1.1.e | JMStudio
- Click File | Open RTP session.

- Enter 239.0.0.1 as IP address and 3000 as port number.
- You can login to another PC and set up JMStudio to watch the same vido.
- You should see the movie multicast by the VideoTransmit java application.
- Try use AVTransmit to transmit both auido and video or darkcity.mov. You need to open up two JMStudio windows, one for audio and one for video. http://java.sun.com/products/java-media/jmf/2.1.1/solutions/AVTransmit.html
- Take a snapshot of the JMStudio and the output window of your NetBean IDE running AVTransmit2.