JMF之API 初识...及JMF 2.0 api与JMF1.0 api的修改注意要点

 (注:本贴只为方便自己快速温故所用,不是文章的全部翻译,只做部份摘要解译,方便自己快速浏览)

About JMF

               JMF1.0只供程序员把实时媒体加到应用中,而JMF2.0则增加了捕获设备多媒体、储存多媒体文件、和播放媒体时的控制功能组件、

               另外,JMF2.0还有plug-in 插件API ,它让高级的JMF开发员可以扩展这些jmf框架api

The JMF 1.0 API (the Java Media Player API) enabled programmers to
develop Java programs that presented time-based media. The JMF 2.0 API
extends the framework to provide support for capturing and storing
media data, controlling the type of processing that is performed during
playback, and performing custom processing on media data streams. In
addition, JMF 2.0 deÞnes a plug-in API that enables advanced developers
and technology providers to more easily customize and extend JMF functionality.

以下是JMF 2.0中新增类和接口:

AudioFormat                                  BitRateControl                                            Buffer

BufferControl                                 BufferToImage                                             BufferTransferHandler

CaptureDevice                              CaptureDeviceInfo                                       CaptureDeviceManager
CloneableDataSource                     Codec                                                           ConfigureCompleteEvent
ConnnectionErrorEvent               DataSink                                                     DataSinkErrorEvent
DataSinkEvent                            DataSinkListener                                        Demultiplexer

Effect                                          EndOfStreamEvent                                     FileTypeDescriptor
Format                                      FormatChangeEvent                                     FormatControl
FrameGrabbingControl               FramePositioningControl                                 FrameProcessingControl
FrameRateControl                     H261Control                                                    H261Format
H263Control                            H263Format                                                 ImageToBuffer
IndexedColorFormat                      InputSourceStream                                KeyFrameControl
MonitorControl                               MpegAudioControl                                   Multiplexer
NoStorageSpaceErrorEvent          PacketSizeControl                                    PlugIn
PlugInManager                             PortControl                                        Processor
ProcessorModel                        PullBufferDataSource                            PullBufferStream
PushBufferDataSource         PushBufferStream                                      QualityControl
Renderer                                 RGBFormat                                        SilenceSuppressionControl
StreamWriterControl                   Track                                                  TrackControl
VideoFormat                           VideoRenderer                                     YUVFormat

 

另外MediaPlayer 这个java bean 已经被加到 javax.media.bean.playerbean包中了。

MediaPlayer 可以被直接实例化对象,用它来展示一个或多个media streams。

(原文)In addition, the "MediaPlayer"  Java Bean has been included with the JMF
API in
javax.media.bean.playerbean.
MediaPlayer  can be instantiated  directly and used to present one or more media streams.

 

Design Goals for the JMF API 2.0

JMF API的设计目标:

          1、更容易编程

           2、支持媒体数据的捕获

           3、让多媒体技术和会议应用技术在java中成为可能

           4、让高级开发者与技术专家可以基于现有的api实现更加客户化的解决方案,以及更加方便集成一些新的技术特点到现有技术框架中。(扩展性)

          5、可以访问媒体原数据

          6、可以开发可以用客户化、可下载、复用、分路、编码、效果处理、与展示、插件等
JMF 2.0 supports media capture and addresses the needs of application
developers who want additional control over media processing and rendering.
It also provides a plug-in architecture that provides direct access
to media data and enables JMF to be more easily customized and
extended. JMF 2.0 is designed to:

¥ Be easy to program
¥ Support capturing media data
¥ Enable the development of media streaming and conferencing
applications in Java

¥ Enable advanced developers and technology providers to implement
custom solutions based on the existing API and easily integrate new
features with the existing framework
¥ Provide access to raw media data
¥ Enable the development of custom, downloadable demultiplexers,
codecs, effects processors, multiplexers, and renderers (JMF
plug-ins
)
¥ Maintain compatibility with JMF 1.0

 

About the JMF RTP APIs

 

在javax.media.rtp javax.media.rtp.event javax.media.rtp.rtcp三个包中包的类和接口就提供了对RTP的支持。

rtp的支持使得多媒体流可以在网络上传输。
The classes in
javax.media.rtp, javax.media.rtp.event
, and
javax.media.rtp.rtcp
provide support for RTP (Real-Time Transport Protocol).
RTP enables the transmission and reception of real-time media
streams across the network. RTP can be used for media-on-demand applications
as well as interactive services such as Internet telephony.

 

JMF 的实现不是必须包括RTP的支持

(原文)JMF-compliant implementations are not required to support the RTP
APIs in
javax.media.rtp
,
javax.media.rtp.event
, and
javax.media.rtp.rtcp
.

sun 和IBM提供了一些JMF api接口的参考实现

如:RTPSessionMgr等
The reference implementations of JMF provided
by Sun Microsystems, Inc. and IBM Corporation fully support these APIs.

第一个版本中只支持rtp streams的接收和播放,第二版api就增加了rtp streams 的发送。
(原文)The Þrst version of the JMF RTP APIs (referred to as the RTP Session Manager
API) enabled developers to receive RTP streams and play them using
JMF. In JMF 2.0, the RTP APIs also support the transmission of RTP
streams.

以下是RTP的类和接口在2.0中是新增的:

SendStream                                       SendStreamListener                      InactiveSendStreamEvent
ActiveSendStreamEvent                 SendPayloadChangeEvent                    NewSendStreamEvent
GlobalTransmissionStats                TransmissionStats 

RTP包中的一些类和接口已经被重新组织过了,一些方法也被重新命名过。

 The RTP packages have been reorganized and some classes, interfaces,
and methods have been renamed to make the API easier to use.

以下是包重新组织发生的改变

The package reorganization consists of the following changes:

1、The RTP event classes that were in javax.media.rtp.session are now in  javax.media.rtp.event


2、The RTCP-related classes that were in javax.media.rtp.session are now in javax.media.rtp.rtcp
.

3、The rest of the classes in javax.media.rtp.session are now in javax.media.rtp and the javax.media.rtp.session package has been removed.

以下是方法重新命名的规则

1、去了方法的rtp、rtcp前缀

The name changes consist primarily of the removal of the RTP and RTCP
preÞxes from class and interface names and the elimination of non-standard
abbreviations. For example,
RTPRecvStreamListener
has been
renamed to
ReceiveStreamListener
. For a complete list of the changes
made to the RTP packages, see the JMF 2.0 Beta release notes.

另外还会做一些修改以兼容jmf2.0对其它方面api的修改

 In addition, changes were made to the RTP APIs to make them compatible
with other changes in JMF 2.0:

 

1、javax.media.rtp.session.io 和javax.media.rtp.session.depacketizer 已经删除,客户化的rtp packetzers 和depacketizers现在通过JMF2.0的plug-in插件体系结构来提供支持。

     原来已存在的depacketizer会被放到现在的插件体系结构中去。
javax.media.rtp.session.io
and
javax.media.rtp.session.depacketizer
have been removed. Custom
RTP packetizers and depacketizers are now supported through the
JMF 2.0 plug-in architecture. Existing depacketizers will need to be
ported to the new plug-in architecture.
2、Buffer 对象实例是SessionManager传送的基本单元,代替来原来 的DePacketizedUnit 和DePacketizedObject传送单元。

     Buffer有自己的数据和头信息格式。
Buffer
is now the basic unit of transfer between the
SessionManager
and other JMF objects, in place of
DePacketizedUnit
and
DePacketizedObject.
RTP-formatted
Buffers
have a specific format
for their data and header objects.

3、 BaseEndcoingInfo已经被JMF的Format对像所代替了。一个rtp特定的Format通过一个特定的encoding字符串标志的。

       编码标志字符串都是“***_RTP格式的” 。如:RAW_RTP 。

        通过在Format中绑定一个动态加载数字来实现动态加载格式信息。

BaseEncodingInfo
has been replaced by the generic JMF
Format
object.
An RTP-specific
Format
is differentiated from other formats by its
encoding string. Encoding strings for RTP-specific
Formats
end in
_RTP
. Dynamic payload information can be provided by associating a
dynamic payload number with a
Format
object.

 

Design Goals for the JMF RTP APIs

// JMF RTP APIs的设计目标:为实现多媒体会议应用。


The RTP APIs in JMF 2.0 support the reception and transmission of RTP
streams and address the needs of application developers who want to use
RTP to implement media streaming and conferencing applications. These
APIs are designed to:
¥ Enable the development of media streaming and conferencing
applications in Java
¥ Support media data reception and transmission using RTP and RTCP
¥ Support custom packetizer and depacketizer plug-ins through the
JMF 2.0 plug-in architecture.
¥ Be easy to program

 

JAVA多媒体开发手册,Java多媒体框架(JMF)中包含了许多用于处理多媒体的API。它是一个相当复杂的系统,完全了解这个系统可能需要花上几周的时间,但是这篇文章将主要介绍JMF的几个核心接口和类,然后通过一个简单的例子向你展示如何利用该接口进行编程。 JMF目前的最新版本是2.1,Sun通过它向Java中引入处理多媒体的能力。下面是JMF所支持的功能的一个概述: ● 可以在Java Applet和应用程序中播放各种媒体文件,例如AU、AVI、MIDI、MPEG、QuickTime和WAV等文件。 ● 可以播放从互联网上下载的媒体流。 ● 可以利用麦克风和摄像机一类的设备截取音频和视频,并保存成多媒体文件。 ● 处理多媒体文件,转换文件格式。 ● 向互联网上传音频和视频数据流。 ● 在互联网上广播音频和视频数据。 JMF的结构 为了更好地说明JMF的结构,让我们用立体声音响做一个简单的比喻。当你CD机播放CD唱片的时候,CD唱片向系统提供音乐信号。这些数据是在录音棚中用麦克风和其他类似的设备记录下来的。CD播放机将音乐信号传送到系统的音箱上。在这个例子中,麦克风就是一个音频截取设备,CD唱片是数据源,而音箱是输出设备。 JMF的结构和立体声音响系统非常相似,在后面的文章中,你会遇到下面的这些术语: ● 数据源(Data source) ● 截取设备(Capture Device,包括视频和音频截取设备) ● 播放器(Player) ● 处理器(Processor) ● 数据格式(Format) ● 管理器(Manager) 下面让我们来看一看这些术语到底代表什么意思。 1.数据源 就像CD中保存了歌曲一样,数据源中包含了媒体数据流。在JMF中,DataSource对象就是数据源,它可以是一个多媒体文件,也可以是从互联网上下载的数据流。对于DataSource对象,一旦你确定了它的位置和类型,对象中就包含了多媒体的位置信息和能够播放该多媒体的软件信息。当创建了DataSource对象后,可以将它送入Player对象中,而Player对象不需要关心DataSource中的多媒体是如何获得的,以及格式是什么。 在某些情况下,你需要将多个数据源合并成一个数据源。例如当你在制作一段录像时,你需要将音频数据源和视频数据源合并在一起。JMF支持数据源合并,在后面的例子中我们将提到这一点。 2.截取设备 截取设备指的是可以截取到音频或视频数据的硬件,如麦克风、摄像机等。截取到的数据可以被送入Player对象中进行处理。 3.播放器 在JMF中对应播放器的接口是Player。Player对象将音频/视频数据流作为输入,然后将数据流输出到音箱或屏幕上,就像CD播放机读取CD唱片中的歌曲,然后将信号送到音箱上一样。Player对象有多种状态,JMF中定义了JMF的六种状态,在正常情况下Player对象需要经历每个状态,然后才能播放多媒体。下面是对这些状态的说明。 ● Unrealized:在这种状态下,Player对象已经被实例化,但是并不知道它需要播放的多媒体的任何信息。 ● Realizing:当调用realize()方法时,Player对象的状态从Unrealized转变为Realizing。在这种状态下,Player对象正在确定它需要占用哪些资源。 ● Realized:在这种状态下Player对象已经确定了它需要哪些资源,并且也知道需要播放的多媒体的类型。 ● Prefetching:当调用prefectch()方法时,Player对象的状态从Realized变为Prefetching。在该状态下的Player对象正在为播放多媒体做一些准备工作,其中包括加载多媒体数据,获得需要独占的资源等。这个过程被称为预取(Prefetch)。 ● Prefetched:当Player对象完成了预取操作后就到达了该状态。 ● Started:当调用start()方法后,Player对象就进入了该状态并播放多媒体。 4.处理器 处理器对应的接口是Processor,它一种播放器。在JMF API中,Processor接口继承了Player接口。 Processor对象除了支持支持Player对象支持的所有功能,还可以控制对于输入的多媒体数据流进行何种处理以及通过数据源向其他的Player对象或Processor对象输出数据。 除了在播放器中提到了六种状态外,Processor 对象还包括两种新的状态,这两种状态是在Unrealized状态之后,但是在Realizing状态之前。 ● Configuring:当调用configure()方法后,Processor对象进入该状态。在该状态下
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值