JMF 学习笔记

来源:互联网 发布:科尔宾 知乎 编辑:程序博客网 时间:2024/04/29 02:52
 
JMF 简述
 
JMF,Java Media Framework.
 
JMF是Java中处理多媒体资源(audio,video,etc.)的一套API。
 
这个扩展包提供多媒体资源播放、传输、编码解码等功能。
 
JMF的框架结构:
 
 
JMF Architecture
 
Time Model
Time 对象表示一个时间点,精确道十亿分之一妙(nanosecond)。
Clock接口定义了基本的定时和同步操作,用来控制多媒体数据表现。
TimeBase类似手表的石英振荡器。
Clock的MediaTime记录媒体数据当前的时间指针。
 
Clock接口
Controller,Player,Processor实现了这个接口。
每个Clock包含一个TimeBase,作为一个时间源,很想一个石英振荡器。
 
 
Manager
By using intermediary Objects called managers, JMF makes it easy to integrate new implements of key interface that can be used seamlessly with existing classes.
JMF使用Manager作为媒介,整合关键接口的新实现和现有的JMF 类。
 
JMF有4个Manager:Manager,PackageManager,CaptureDeviceManager,PlugInManager.
 
Manager,用来生成Player,Processor,DataSource,DataSink。这样的工厂方法有利于新实现的无缝整合到JMF中,使用统一的方式生成同样接口的对象。
 
PackageManager,维护JMF类的登记。
 
CaptureDeviceManager,维护可用音频输入设备的登记。
 
PlugInManager,维护JMF中可用的音频处理组件的登记。例如,Multiplexer,Demultiplexer,Codec,Effect,Renderer
 
Event Mode
无论什么时候,JMF object 报告当前情形,都会传递出一个MediaEvent。不同特定的事件类型都是MeidaEvent的子类。
Controller objects(such as Player,Processor)和某些Control对象(such as GainControl)发出MediaEvent。
 
 
Data Mode
DataSource管理媒体数据的传输,它封装了媒体的定位信息、传输协议和传输软件。
一旦DataSource创建后,不能够再用来传输其他媒体数据。
 
使用JMF MediaLocator 或者URL 标识DataSource。
MediaLocator和URL相似,但是,即使对应的protocol handle没装到系统里,
MediaLocator还是能被创建的,而URL不行。
 
一个DataSource可以管理一组SourceStream对象。
 
标准的DataSource使用一个byte数组作为传输的单位。
Buffer DataSource使用一个buffer对象作为传输单位。
 
JMF中有很多种DataSource。
 
 
DataSource按传输控制方式分为Pull,Push 2种。
 
JMF定义了2种特殊的DataSource:cloneable DataSource,merging DataSource。
Cloneable DataSource通过Manager.createCloneableDataSource(DataSource source)创建。
Cloneable DataSource和它的source,克隆体使用时都是有关联的。
Merging DataSource通过Manager.createMergingDataSource(DataSource[])创建。
用来合成多个DataSource中的SourceStream。
它的Content-Type:application/mixed-media。
 
Data Formats
Format描述媒体数据的格式。
 
Controls
JMF类通过实现Controls接口,提供Control objects,来修改和查询它们的属性。
很多JMF类提供操作它们的Control,such as Controller,DataSource,DataSink,plug-ins。
 
 
 
 
UI Componets
 
Control还能够提供可视化组件来控制JMF对象。
例如:Control.getControlComponent(),
Player.getVisualComponent(),
Player.getControlPaneComponent()
 
Extensibility
可扩展性。
参看:JMF GUIDE / Understanding JMF, jmf2_0-guide-html/JMFArchitecture.html
 
Presentation
媒体表现。
JMF Controller定义了媒体的表现机制和主要阶段。
Controller在状态转换时,发出MediaEvent 通知ControllerListener。
 
JMF API定义了2中Controller:Player,Processor。
它们都创建自某个data source, 并且不能够被其他媒体资源再次利用。
 
 
 
Player
Player读入媒体数据流,并渲染出来。
一个DataSource要被用来传输输入媒体流。
渲染结果的输出目标取决于媒体流的格式。
Player的6种状态
 
Player的获得
使用工厂方法Manager.createPlayer(),
Manager.createRealizedPlayer()
获得对应媒体资源的Player。
 
Player的相关事件
TransitionEvent, 进入Realizing或Prefetching状态
RealizeCompleteEvent, 退出Realizing状态
PrefetchCompleteEvent, 退出Prefetching 状态。
StartEvent, 进入Stated状态。
EndOfMediaEvent, 播放完毕
StopByRequestEvent, 调用stop(),媒体停止播放
DeallocateEvent, 调用deallocate()后,释放资源完毕
ControllerCloseEvent, 调用close()后
 
Processor
extends Player
 
 
 
 
ControllerEvent
Change notification Events,such as RateChangeEvent, DurationUpdateEvent, FormatChangeEvent
TransitionEvents
ControllerCloseEvent,ControllerErrorEvent
 
 
 
JMF资源:
l         JMF home page,http://www.javasoft.com/jmf
l         JMF spec,http://java.sun.com/products/java-media/jmf/2.1.1/specdownload.html
l         JMF-supported file format, http://java.sun.com/products/java-media/jmf/2.1.1/formats.html
l         JMF 2.1.1 Solutions(Code Sample and Apps),
http://java.sun.com/products/java-media/jmf/2.1.1/solutions/
l         Sun Developer Forums/JMF 论坛专区,http://forum.java.sun.com/forum.jspa?forumID=28
l         Exporing temporal media and JMF,http://lipas.uwasa.fi/~ksa/mm/mediatem.htm
 
VOD
Video-On-Demand,视频点播
 
Pull protocol
数据转换器在客户端初始化和控制, e.g., HTTP, FILE
 
Push protocol
服务端初始化数据转换器,控制数据流的传输, e.g., RTP, SGI MediaBase
 
 
 
 
 
 
 
原创粉丝点击