Transmitting Audio and Video using RTP
来源:互联网 发布:开淘宝店进什么货 编辑:程序博客网 时间:2024/05/02 20:03
http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/AVTransmit.html
Problem
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.
Solution
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, "129.130.131.132" can be used for a point to point transmission and "129.130.131.255" 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.
* AJ = All Java, WPP = Windows Performance Pack, SPP = Solaris Performance Pack Related Classes
- javax.media.Manager
- javax.media.Processor
- javax.media.protocol.DataSource
- javax.media.rtp.SessionManager
- Download and compile the source file.
- Run AVTransmit2 with the required 3 command line parameters
For example,
java AVTransmit2 file:/avmedia.mov 129.144.251.182 42050
- 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:
rtp://<sourceIP>:<port>/media
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.
SourceCode:
- Transmitting Audio and Video using RTP
- RTP/AVP audio and video payload types
- RTP/AVP audio and video payload types
- RTP/AVP audio and video payload types
- RTP audio video profile
- 读《RTP.Audio.And.Video.For.The.Internet》笔记
- 学习RTP.Audio.And.Video.For.The.Internet的单词
- Audio and Video
- Transmitting RTP Media Streams
- H264 video RTP payload and SDP
- Streaming Video with RTSP and RTP
- VideoIO Flash-based audio and video communication
- VideoIO Flash-based audio and video communication
- VideoIO Flash-based audio and video communication
- VideoIO Flash-based audio and video communication
- HTML5-video and audio 音视频
- Audio and Video Synchronization (Amazon Fire TV)
- 关于RTP/MPEG TRANSPORT STREAM和RTP Audio/Video profile的比较
- 回调函数、模板和Ioc
- symbian图像显示
- 哈佛大学图书馆馆训
- 京港海鲜
- 一个用ssh来远程登录多台机器并执行命令的脚本
- Transmitting Audio and Video using RTP
- compile mysql from source code
- Java线程:线程的调度-守护线程
- Java线程:线程的同步-同步方法
- Configure Subversion Server
- Java线程:线程的同步-同步块
- 23种设计模式 UML 类图及对应示例代码 (一)
- Java线程:并发协作-生产者消费者模型
- CClientDC 和CPaintDC (转载于:http://www.cnblogs.com/cutepig/archive/2009/01/19/1378550.html)