JavaMediaPlayer API学习笔记

1.Format videoFormat = new VideoFormat(VideoFormat.MJPG);

①关于 Format 类的介绍:
A Format abstracts(抽象出) an exact(精确地,严谨的) media format(媒体格式). It carries(携带了)
no encoding-specific(以特定格式编码的) parameters or timing information global
to the presentation.

Comparing different formats(比较不同的格式)
Not all of the attributes(属性) in a Format object(格式对象) have to be specified(限定).
This enables selected attributes to be specified, making it possible
to locate(定位) a supported Format(一种支持的格式) that meets certain requirements(满足特定的需求) without
needing to find an exact match(精确地匹配). Two methods are provided for comparing Formats.
The equals method returns true if two Format objects are exactly the
same(严格的相似) -- they're the same type and all of their attributes are the same.
The matches method relaxes the comparison(放宽比较的限制), comparing only the attributes
that are explicitly(明白地,明确地) specified in the Format you are comparing.

Direct Known Subclasses(直接已知的子类):
AudioFormat(视频格式), ContentDescriptor, VideoFormat(音频格式)

②关于 VideoFormat 类的介绍
Encapsulates(封装) format information for video data(视频数据). The attributes of a VideoFormat
include the encoding type(编码格式), frame size(屏幕大小), frame rate(帧数), and the data type(数据类型).

VideoFormat 类的两个可能被用到的方法:
getSize() 方法:Gets the dimensions of a video frame in this VideoFormat.
getFrameRate() 方法:Gets the frame rate associated with this VideoFormat.

2.Vector<CaptureDeviceInfo> deviceList = CaptureDeviceManager.getDeviceList(videoFormat);

①关于 CaptureDeviceManager 的介绍:
CaptureDeviceManager is a manager class that provides access(访问) to
a list of the capture devices available(可用的捕获设备) on a system. CaptureDeviceManager
uses a registry(注册) and query(查询) mechanisms(机制) to locate(定位) devices and return
CaptureDeviceInfo objects for available devices. The CaptureDeviceManager
is also used to register new capture devices(亦可用于注册新的捕获设备).

②CaptureDeviceManager 类的 getDeviceList(Format format) 方法( 返回值:Vector<CaptureDeviceInfo> )
Gets a list of CaptureDeviceInfo objects that correspond to devices that
can capture data in the specified Format(以一种特定的形式捕获数据).

3.关于 CaptureDeviceInfo 类的介绍:
A CaptureDeviceInfo(捕获设备信息) object contains information(相关信息) about
a particular capture device(一种特定的捕获设备).

Field Summary
①protected Format[] formats
The output formats supported by a device.
②protected MediaLocator locator
A MediaLocator that identifies a device.
③protected java.lang.String name
A String that contains the name of a device.

Method Summary
①equals(java.lang.Object obj) boolean
②getFormats() Format[]
Gets a list of the output formats supported by this device.
获取一份被这个设备所支持的输出格式的列表
③getLocator() MediaLocator
Gets the MediaLocator needed to create a DataSource for this device through the Manager.
④java.lang.String getName()
Gets the name of this device.
获取这个设备的名称

4.关于 Manager 类的介绍:
Manager is the access point for obtaining system dependent resources(获取系统所依赖的资源) such as
Players(播放器), DataSources(数据源), Processors(处理器), DataSinks(数据池), the system TimeBase,
the cloneable and merging utility DataSources.

A DataSource is an object used to deliver time-based(基于时间的) multimedia data(多媒体数据) that
is specific to a delivery protocol.

A Player is an object used to control(控制) and render(渲染) multimedia data(多媒体数据) that is specific
to the content type of the data.

A Processor is an object similar to a Player which is used to process data and
output the processed data(用于处理并输出经过处理后的数据).

A DataSink(数据池) is an object that takes a DataSource as input(把数据源当做输入) and renders the output
to a specified destination(渲染输出到一个特定的目的地).

A DataSource provides a Player, Processor or DataSink with media data(为播放器、处理器和数据池提供多媒体数据);
a Player, Processor or DataSink must have a DataSource(播放器、处理器和数据池必须有一个数据源做支撑).
Manager provides access(访问) to a protocol and media independent mechanism
for constructing DataSources, Players, Processors and DataSinks.

Creating Players and DataSources
Manager will create Players from a URL(UnifiedResourceLocator), a MediaLocator or a DataSource.
Creating a Player requires the following:

①Obtain the connected DataSource for the specified protocol
②Obtain the Player for the content-type specified by the DataSource
③Attach the DataSource to the Player using the setSource method.

A Player is a MediaHandler. A MediaHandler is a an object that reads data from a DataSource.
(媒体处理器是从数据源读取数据的对象)There are three types of supported MediaHandler:
MediaProxy(多媒体代理), Player(播放器) and Processor(处理器).

MediaHandlers are identified by the content type that they support.
(媒体处理器通过他们所支持的内容被鉴别)

Players and Processors process media data asynchronously(异步的) from the main program flow.
This implies(标明) that a Player or Processor must often manage one or more threads.
The threads managed by the Player or Processor are not in the thread group of
the application that calls createPlayer or createProcessor.

All Players need a TimeBase. Many use a system-wide TimeBase, often based
on a time-of-day clock. Manager provides access to the system TimeBase through getSystemTimeBase.

Cloning(克隆,复制) and Merging(混合,融合) DataSources
DataSources can be cloned(克隆) or merged(混合). If a DataSource is cloned,
more than one MediaHandler can use it as input(就可以用超过一个的媒体处理器来把它当做输入而使用它).
Merging more than one DataSources will generate one DataSource
which contains all the SourceStreams of the constituent(1. 构成的,组成的) DataSources
The Manager provides two methods:
createCloneableDataSource() and createMergingDataSource() for such purpose.

5.JMF定义了两类特殊的数据源,克隆数据源(cloneable data sources)和合并数据源(merging data sources)。
一个克隆数据源可以克隆一个pull或push数据源。你可以调用管理器(manager)的createCloneableDataSource
方法并传递相应的数据源对象来克隆一个数据源。
一旦一个数据源被传递到createCloneableDataSource方法,你就只能对这个克隆数据源以及它的克隆体进行处理,
原始数据源对象不能被直接使用。
克隆数据源(cloneable data sources)实现SourceCloneable接口,其中定义了一个方法叫createClone。
通过调用该方法,你可以为你的原始数据源复制出任意数量的克隆体,并由创建它们的克隆数据源(cloneable data sources)对其进行管理。
一个合并数据源(merging data sources)可以将来自于多个数据源的源数据流合并为一个数据源。这样可以对一系列得数据源进行统一管理。
你可以调用管理器(manager)的createMergingDataSource方法并传递相应的数据源来创建一个合并数据源。需要注意的是,
待合并的数据源必须是同一种类型的。例如你不能将一个PullDataSource和一个PushDataSource合并。
该合并源的持续时间为其中最长的数据源的持续时间。它的内容类型(ContentType)为application/mixed-media。

6.关于 MediaLocator 类
MediaLocator describes the location of media content.
MediaLocator is closely related to URL. URLs can be obtained from MediaLocators,
and MediaLocators can be constructed from URL. Unlike a URL, a MediaLocator
can be instanced without a URLStreamHandler installed on the System.

你可能感兴趣的:(mediaplayer)