How to transmit media over the network using JMF and JMF/RTP. You may want to transmit media from one computer to another. Or you may want to broadcast a live feed to your company's intranet. The source of the media can be a file, live media using a capture device or any other source supported by JMF.
The AVTransmit2 class is similar to VideoTransmit except that it attempts to transmit each of the tracks within the given input media. To do that, an RTP session is created for each media track. For that purpose, the RTP Session API instead of the DataSink API is used for flexibility. For JMF 2.1.1 users, an alternative sample that uses the new RTPManager API is also provided. The default (first available) RTP format is set for each track. For video, special attention is taken to ensure that the input sizes are usable for RTP transmission. Real-time scaling is applied when necessary.
Note that due to limitations of the JMF 2.1 implementation, audio and video are not in tight synchronization.
The AVTransmit2 class takes three parameters in the constructor - the source locator, the destination IP address and a base destination port number for all the media tracks.
The source locator can be -
a file name such as "file:/C:/media/speech.mov",
an http locator such as "http://mediacentral.com/speech.avi",
or a capture datasource such as "javasound://8000"
The IP address should be the IP address of the computer that should receive your transmission. If you want all the computers on your subnet to receive the transmission, then use 255 as the last number in your IP address. For example, "126.96.36.199" can be used for a point to point transmission and "188.8.131.52" can be used for all computers that are on your subnet. Consult your system administrator if you're not sure what these IP addresses mean. You can also refer to the JMF RTP documentation in the JMF Programmer's Guide for more information on RTP transmission and reception.
The base Port number can be any port number that is not in use by any other service on your computer. For example, you can use "22222". Make sure that it is an even number. Once again, refer to the Programmer's Guide. The first media track will be transmitted from the base port number. The next track will go to base port number plus 2 and so on.
The sample program can be used as a utility class as well as standalone. There is a main method that takes three command line parameters. If all goes well, the media will be sent out for 300 seconds and then the application will exit. This 300 seconds limit is because there is no GUI that allows you to specify when to stop the transmission.
Or write your own little program that uses the AVTransmit2 class to create, start and stop an RTP transmit session.
Since the media tracks are transmitted in multiple sessions, you'll need to use one Player per track on the receive side. Using JMStudio, you can start multiple Players from the "File" menu using the "New Window" item. Then use the "Open URL..." item to open one RTP session per track. The URL to use is:
Where <sourceIP> is the IP address of the RTP session and the port number is the same one that is used on the transmitting side.