JMFAPI中文指导.docx

上传人:b****4 文档编号:5310408 上传时间:2023-05-08 格式:DOCX 页数:20 大小:22.78KB
下载 相关 举报
JMFAPI中文指导.docx_第1页
第1页 / 共20页
JMFAPI中文指导.docx_第2页
第2页 / 共20页
JMFAPI中文指导.docx_第3页
第3页 / 共20页
JMFAPI中文指导.docx_第4页
第4页 / 共20页
JMFAPI中文指导.docx_第5页
第5页 / 共20页
JMFAPI中文指导.docx_第6页
第6页 / 共20页
JMFAPI中文指导.docx_第7页
第7页 / 共20页
JMFAPI中文指导.docx_第8页
第8页 / 共20页
JMFAPI中文指导.docx_第9页
第9页 / 共20页
JMFAPI中文指导.docx_第10页
第10页 / 共20页
JMFAPI中文指导.docx_第11页
第11页 / 共20页
JMFAPI中文指导.docx_第12页
第12页 / 共20页
JMFAPI中文指导.docx_第13页
第13页 / 共20页
JMFAPI中文指导.docx_第14页
第14页 / 共20页
JMFAPI中文指导.docx_第15页
第15页 / 共20页
JMFAPI中文指导.docx_第16页
第16页 / 共20页
JMFAPI中文指导.docx_第17页
第17页 / 共20页
JMFAPI中文指导.docx_第18页
第18页 / 共20页
JMFAPI中文指导.docx_第19页
第19页 / 共20页
JMFAPI中文指导.docx_第20页
第20页 / 共20页
亲,该文档总共20页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

JMFAPI中文指导.docx

《JMFAPI中文指导.docx》由会员分享,可在线阅读,更多相关《JMFAPI中文指导.docx(20页珍藏版)》请在冰点文库上搜索。

JMFAPI中文指导.docx

JMFAPI中文指导

JMFAPI中文指导

TimeModel

Managers

EventModel

DataModel

Controls

UserInterfaceComponents

Extensibility

 

Presentation

Players

Processors

PresentationControls

ControllerEvents

 

Processing

ProcessingControls

DataOutput

 

Capture

 

MediaDataStorageandTransmission

StorageControls

 

Extensibility

ImplementingPlug-Ins

ImplementingMediaHandlersandDataSources

GoTop

--------------------------------------------------------------------------------

TimeModel

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

ClockInterface:

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

DurationInterface:

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

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

以time來記錄

以position來記錄

以playbackrate:

rate=張數/秒數*時間

公式:

MediaTime=MediaStartTime+Rate(TimeBaseTime-TimeBaseStartTime)

                                         位置                       絕對時間

JMFtimemodel 

--------------------------------------------------------------------------------

Managers

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

JMF所使用的4個managers:

1.         Manager--包含Players,Processors,DataSources和DataSink四種classes,object都是用此四種去建構成的。

2.         PackageManager--可自定classes,如:

自定的Players、Processors、DataSources、DataSinks

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

4.         PlugInManager--當我們要處理資料的performance時(如:

編碼),可以使用plug-in的處理元件,如Multiplexers,Demultiplexers,Codecs,Effects、Renderers.

在JMF的程式中,我們將使用到這些Manager去createmethods去建構Players、Processors、DataSources、DataSinks。

--------------------------------------------------------------------------------

EventModel

MediaEvent是定義許多JMF事件的子集合。

如:

我們要implement一個listener的interface,我們就需呼叫事件:

addListener;我們要去controllerobjects(像Players和Processors)和creatainControlobjects就需呼叫事件:

GainControl。

--------------------------------------------------------------------------------

DataModel

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

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

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

(但在Java中,只有在系統上安裝符合的protocolhandler時才可被create)

DataSource管理一或多個SourceStreamobjects。

一個標準的datasource是使用byte為傳送單位;一個bufferdatasource是使用buffer為傳送單位。

JMF定義了幾種DataSourceobjects的型態:

根據資料傳送方式分類:

PullDataSource:

client端開始傳送資料,並控制pulldata-sources的資料流,使用的protocols型態為HTTP、FILE。

JMF定義二種pulldatasources型態:

PullDataSource、PullBufferDataSouce。

PushDataSource:

server端開始傳送資料,並控制pushdata-sources的資料流。

使用的protocols型態包括RTP、multicastmedia、VOD。

JMF定義二種pushdatasources型態:

PushDataSource、PushBufferDataSouce

client端程式可依使用者自訂,並將其以dataSource型態播出。

例如:

MPEG:

使用者可自行改變播放位置、重播。

相對的,廣播則是由server端控制,則無法改變播放位置,有些VOD支援使用者控制─例如:

client端程式允許使用者能尋找到新的位置,但無法快轉或倒帶。

SpecialtyDataSources

JMF定義了二個特殊的DataSources型態:

CloneabledataSources、MergingdataSource

必須注意的是合併時DataSource須都皆為同一型態,例如:

PullDataSource與PushDataSource不可合併。

而合併後的ContentType為application/mixed-media。

Data Formats

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

JMF繼承Format去定義audio和video的格式:

AudioFormat:

記載audio格式的屬性,例如:

頻率、bits數、和channel數量

VideoFormat:

包含video相關的資料訊息。

VideoFormate包含以下數個共同的格式:

IndexedColorFormat、RGBFormat、YUVFormat、JPEGFormat、H261Format、H263Format

--------------------------------------------------------------------------------

Controls

提供設定、查詢物件屬性,通常提供存取符合的使用者介面元件,可讓使用者控制物件的屬性。

許多JMF objects有接觸到Controls,包括:

Controllerobjects、DataSourceobjects、DataSinkobjects、JMFplut-ins。

上圖為JMFcontrols

JMF定義的StandardControls:

CachingControl:

監控下載進度和播放,假如,Player或Processor可以記載downloadprogress,CachingControl就可以implementsinterface,讓progressbar可以display出來。

GainControl:

能夠調整audio音量,例如:

對於player或processor輸出的聲音做調整或消音,它同時支援音量改變的mechanism。

上圖為Gaincontrol

l           StreamWriterControl:

可使用DataSink或Multiplexer等objects從DataSource讀入媒體,並寫至目的地(如:

file),可實作StreamWriterControl介面,且這個Control可限制stream產生的大小。

l           FramePositioningControl:

可在Player或Processor物件的mediastream中正確地取得Frame的位置。

l           FrameGrabbingControl:

可以從videostream中攫取videoframe,且此Control也支援Render。

l           FromatControl:

提供查詢與設定格式的method。

l           TrackControl:

是屬於FormatControl的一種型態,用在個別的tracks處理processorobjectperforms上(如:

Effect、Codec、Renderplug-ins)

l           PortControl、MonitorControl:

可以用來控制captureprocess。

PortControl定義了用來控制屬於capture輸出設備的method。

MonitorControl可以預覽capture完、encode完後的mediadata。

l           BufferControl:

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

l           Codeccontrol:

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

Ø           BitRateControl

Ø           FrameProcessingControl

Ø           FrameRateControl

Ø           H261Control

Ø           H263Control

Ø           KeyFrameControl

Ø           MpegAudioControl

Ø           QualityControl

Ø           SilenceSuppressionControl

--------------------------------------------------------------------------------

UeserInterfaceComponents

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

Ø           getControlComponent:

這個method是繼承AWTComponent下來的,可以讓我們增加applet’spresentationspace或applicationwindow。

Ø           getVisualComponent、getControlPanelComponent:

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

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

--------------------------------------------------------------------------------

Extensibility

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

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

2、透過實作theController,Player,Processor,DataSource,或DataSink

   介面

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

--------------------------------------------------------------------------------

Presentation

在JMF中,播放的處理都是由Controllerinterface來完成。

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

〞Controller〞:

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

JMFAPI定義二種型態的Controllers:

PlayersandProcessors。

PlayerorProcessor產生於特定資料來源時,且不再被重複使用去播放其他的媒體

上圖為JMFcontrollers

--------------------------------------------------------------------------------

Players

Player:

繼承自Controllerinterface,用於傳送和控制時間性的媒體資料,對於AWT元件的取得、媒體的處理控制,Player都有提供methods處理傳入的媒體流,並精確地傳送出去。

DataSource:

通常傳入的media-stream傳送給Player,至輸出裝置再依其型態將之播出

上圖為JMFplayermodel

Player在處理上不提供任何的控制機制,但支援標準化的使用者控制,透過Clock和Controller的操作達成。

Player可分成六個狀態,Clock介面定義二種基本的的狀態:

Stopped和Started。

為了易於資料來源的管理,Controller再將其中的Stopped階段細分成五個狀態:

 Unrealized、Realizing、Realized、Prefetching和Prefetched.

上圖為playerstates

一般情況下,Player,必須經過每一階段直到Started的狀態下:

Ø         Unrealized:

當mediaPlayer被產生,但仍未知媒體資料時,稱之。

Ø         Realizing:

player決定資料來源需求時,稱之。

Realizing通常用於從網路上下載媒體資料。

Ø         Realized:

當player完成Realizing後,即進入Realized狀態。

至此階段已知媒體的需求及媒體播放型態的資訊。

它也提供視覺化的元件和控制,可以連接到系統的相關物件,但仍沒擁有任何資源,以預防其它的Player啟動。

Ø         Prefetching:

準備開始播放媒體,player若播放位置被改變,則重新配置

Ø         Prefetched:

進入播放狀態

Ø         Started:

呼叫start,將Player放至Startedstate。

當Player物件的time-basetime和媒體時間mapping後,開始播出。

Player提供TransitionEvents,可以從這個狀態移至另一個狀態中。

ControllerListener介面也提供可決定player位在哪個狀態下和適時地提出respond,例如:

在Player或Process中呼叫asynchronous的method,就需ControllerListener提供event來決定operation何時被完成。

MethodsAvailableinEachPlayerState

為了防止race(猛轉,急速)的狀態產生,在Player的每個狀態中並非所有method都可以呼叫,下表為在Player的每個階段中,JMF定義的method使用限制說明,如果是不合法的method,player就會丟出exception。

Method

UnrealizedPlayer

RealizedPlayer

PrefetchedPlayer

StartedPlayer

addController

NotRealizedError

legal

legal

ClockStartedError

deallocate

legal

legal

legal

ClockStartedError

getControlPanelComponent

NotRealizedError

legal

legal

legal

getGainControl

NotRealizedError

legal

legal

legal

getStartLatency

NotRealizedError

legal

legal

legal

getTimeBase

NotRealizedError

legal

legal

legal

getVisualComponent

NotRealizedError

legal

legal

legal

mapToTimeBase

ClockStoppedException

ClockStoppedException

ClockStoppedException

legal

removeController

NotRealizedError

legal

legal

ClockStartedError

setMediaTime

NotRealizedError

legal

legal

legal

setRate

NotRealizedError

legal

legal

legal

setStopTime

NotRealizedError

legal

legal

StopTimeSetError

ifpreviouslyset

setTimeBase

NotRealizedError

legal

legal

ClockStartedError

syncStart

NotPrefetchedError

NotPrefetchedError

legal

ClockStartedError

Table2-1:

Methodrestrictionsforplayers.

--------------------------------------------------------------------------------

Processors

Processors也可以用來撥放mediadata。

除了提供媒體撥放的設備外,Processor也可以透過DataSource輸出mediadata,以便讓其他的Player和Processor來呈現,更進一步地透過其他Processor來操作或傳送到其他的目的地,如檔案中。

PresentationControls

參見Controls

ControllerEvents

ControllerEvents提供三種類的events:

Ø         changenotifications---像RateChangeEvent、DurationUpdateEvent、FormatChangeEvent表示可以改變Controller的一些屬性,例如:

Player提供RateChangeEvent,當rate被改變時就呼叫setRate。

Ø         transitionevents---TransitionEvents允許我們的程式在Controllerobjects’sstate下改變時得到respond,不論是從那個狀態到哪個狀態,player都提供transitionevents。

Ø         closedevents---ControllerClosedEvents由ControllerEvent繼承下來,提供shutsdown功能;ControllerErrorEvent由ControllerClosedEvents繼承下來,當程式發生錯誤時,可以respondController發生的錯誤及將錯誤造成的影響減到最低。

上圖為JMFevents

--------------------------------------------------------------------------------

Processing

Processor:

是一個從DataSource輸入,執行一些使用者自定的媒體資料處理,再將其媒體資料輸出的Player。

可傳送輸出資料至播放設備或DataSource(DataSource可如同再輸入至另一個Player或Processor,或輸入至DataSink)

上圖為JMFprocessors

          

媒體資料的處理可分割成幾個階段:

 

上圖為Processorstages.

1.         Demultiplexing:

剖析inputstream,若stream包含了多個tracks,則將之分離,例如:

QuickTime檔案分成audioandvideotracks。

無論是否有包含多樣的資料,皆會自動執行Demultiplexing。

 

2.         Pre-Processing:

對inputstream中的tracks做特效(effect)的演算處理。

3.         Transcoding:

轉碼;壓縮  = ﹥解壓縮。

4.         Post-Processing:

對decodedtracks做特效(effect)的演算處理

5.         Multiplexing:

將由多個tracks的合併成單一datastream。

例:

將分離的audioandvideotracks合併成單一個MPEG-1datastream,可藉由setOutputContentDescriptor的method定義輸出流的資料型態。

6.         Rendering:

將播放媒體出來。

Processing執行的每個階段,由不同的proces

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 医药卫生 > 基础医学

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2