现在的位置: 首页 > 综合 > 正文

JMF API 中文指导台湾版(1)

2013年04月19日 ⁄ 综合 ⁄ 共 4917字 ⁄ 字号 评论关闭

JavaTM Media Framework API Guide    NO.2

 

High-Level Architecture

Time Model

Managers

Event Model

Data Model

Controls

User Interface Components

Extensibility

 

Presentation

Players

Processors

Presentation Controls

Controller Events

 

Processing

Processing Controls

Data Output

 

Capture

 

Media Data Storage and Transmission

Storage Controls

 

Extensibility

Implementing Plug-Ins

Implementing MediaHandlers and DataSources

 Go Top



Time Model

關於TIME,可實作二個相關的interface:

Clock Interface:定義了basic timing和同步時所需的資料,clock是使用TimeBase作為track行進的時間(而time-base提供的資訊只有目前的時間,以system clock為主)

Duration Interface:影片的開始到結束的時間(片長時間)

為了維持track目前時間,Clock使用:

以time來記錄

以position來記錄

以play back rate:rate=張數 / 秒數 * 時間

公式:MediaTime=MediaStartTime+Rate(TimeBaseTime-TimeBaseStartTime)

                                          位置                        絕對時間

 

JMF time model 

 

 


Managers

 

對於媒體的擷取、處理和播放時間性的媒體,JMF都有提供相關的API

JMF所使用的 4 managers

1.          Manager--包含Players, Processors, DataSourcesDataSink四種classesobject都是用此四種去建構成的。

2.          PackageManager--可自定classes,如:自定的Players Processors DataSourcesDataSinks

3.          CaptureDeviceManager--當我們要從input devicecapturing媒體資料的話,就需使用CaptureDeviceManager去尋找可以使用、存取的devices

4.          PlugInManager--當我們要處理資料的performance(如:編碼),可以使用 plug-in的處理元件,如Multiplexers,Demultiplexers, Codecs, EffectsRenderers.

 

JMF的程式中,我們將使用到這些Managercreate methods去建構Players Processors DataSourcesDataSinks

 



 

Event Model

 

MediaEvent 是定義許多JMF事件的子集合。如:我們要implement一個 listenerinterface,我們就需呼叫事件:addListener;我們要去controller objects(PlayersProcessors)creatain Control objects就需呼叫事件:GainControl

 

 



 

Data Model

 

JMFmedia players通常使〞DataSources〞管理媒體的傳輸、連結。

DataSource包含了媒體位置、protocol、和使用何種軟體來傳送媒體。

DataSource不是透過MediaLocator就是透過URL來定義,MediaLocator很類似URL而且可以從URL中去建構,即使系統上沒有安裝符合的protocol handler仍可被create。(但在Java中,只有在系統上安裝符合的protocol handler時才可被create

 

DataSource管理一或多個SourceStream objects。一個標準的data source是使用byte為傳送單位;一個buffer data source是使用buffer為傳送單位。JMF定義了幾種DataSource objects的型態:

 

 

 

 

根據資料傳送方式分類:

  • PullDataSourceclient端開始傳送資料,並控制pull data-sources的資料流,使用的protocols型態為HTTPFILEJMF定義二種pull data sources型態:PullDataSourcePullBufferDataSouce
  • PushDataSourceserver端開始傳送資料,並控制push data-sources的資料流。使用的protocols型態包括RTPmulticast mediaVODJMF定義二種push data sources型態:PushDataSourcePushBufferDataSouce

client端程式可依使用者自訂,並將其以dataSource型態播出。例如:MPEG:使用者可自行改變播放位置、重播。相對的,廣播則是由server端控制,則無法改變播放位置,有些VOD支援使用者控制例如:client端程式允許使用者能尋找到新的位置,但無法快轉或倒帶。

 

 

Specialty DataSources

 

JMF定義了二個特殊的Data Sources型態:Cloneable data SourcesMerging data Source

必須注意的是合併時DataSource須都皆為同一型態,例如:PullDataSourcePushDataSource不可合併。而合併後的Content Typeapplication/mixed-media

 

Data  Formats

 

描述媒體編碼格式名稱,資料格式型態的需求。

JMF繼承Format去定義audiovideo的格式:

 

AudioFormat:記載audio格式的屬性,例如:頻率、bits數、和channel數量

VideoFormat:包含video相關的資料訊息。VideoFormate包含以下數個共同的格式: IndexedColorFormat RGBFormat YUVFormat JPEGFormat H261Format H263Format

 



 

Controls

 

提供設定、查詢物件屬性,通常提供存取符合的使用者介面元件,可讓使用者控制物件的屬性。許多JMF  objects有接觸到Controls,包括:Controller objectsDataSource objectsDataSink objectsJMF plut-ins

 

上圖為JMF controls

 

 

JMF定義的Standard Controls

  • CachingControl:監控下載進度和播放,假如,Player或Processor可以記載download progress,CachingControl就可以implements interface,讓progress bar可以display出來。

  • GainControl:能夠調整audio音量,例如:對於player或processor輸出的聲音做調整或消音,它同時支援音量改變的mechanism。

 

上圖為Gain control

 

 

l            StreamWriterControl:可使用DataSinkMultiplexerobjectsData Source讀入媒體,並寫至目的地(如:file),可實作StreamWriterControl介面,且這個Control可限制stream產生的大小。

l            FramePositioningControl:可在PlayerProcessor物件的media stream中正確地取得Frame的位置。

l            FrameGrabbingControl:可以從video stream中攫取video frame,且此Control也支援Render。

l            FromatControl:提供查詢與設定格式的method

l            TrackControl:是屬於FormatControl的一種型態,用在個別的tracks處理processor object performs(如:EffectCodecRender plug-ins)

l            PortControlMonitorControl:可以用來控制capture processPortControl定義了用來控制屬於capture輸出設備的methodMonitorControl可以預覽capture完、encode完後的media data

l            BufferControl:在特別的objects上控制 buffer的處理。

l            Codec control可以控制軟、硬體的編、解碼器

Ø            BitRateControl

Ø            FrameProcessingControl

Ø            FrameRateControl

Ø            H261Control

Ø            H263Control

Ø            KeyFrameControl

Ø            MpegAudioControl

Ø            QualityControl

Ø            SilenceSuppressionControl

 



 

Ueser Interface Components

 

Control提供可以存取user interface Component(讓使用者可以看得到媒體撥放的狀態)

Ø            getControlComponent:這個method是繼承AWT Component下來的,可以讓我們增加applet’s presentation spaceapplication window

Ø            getVisualComponentgetControlPanelComponent:這二個方法可以得到player執行的畫面和控制狀態畫面。

 

當然,如果你不使用這些內定的control component時,也可以自定自己的component

 


Extensibility

 

可透過二種方式繼承JMF的功能

1、經由實作自訂的處理元件(plug-ins

2、透過實作the Controller, Player, Processor, DataSource, DataSink

    介面

 

這部分屬於plug-in部分,講到p.85時會重新提到

 



 

Presentation

 

JMF中,播放的處理都是由Controller interface來完成。

Controller定義了物件的控制、播放或擷取時間性媒體的控制機制。

Controller〞:為一介面,繼承自Clock,提供來源配置的狀態訊息,事件的產生,並且於獲得物件的機制提供控制。

 JMF API 定義二種型態的Controllers: Players and Processors Player or Processor 產生於特定資料來源時,且不再被重複使用去播放其他的媒體

 


上圖為JMF controllers

 


 

Players

Player:繼承自Controller interface,用於傳送和控制時間性的媒體資料,對於AWT元件的取得、媒體的處理控制,Player都有提供methods 處理傳入的媒體

抱歉!评论已关闭.