<JSTORM> JSTORM http://wwwjstormpekr
Issued by: < > Revision: <10> <2000/8/23> Document Information Document title: Document file name: Revision number: <10> Issued by: 1_ doc Issue Date: <2000/8/25 > Status: < > raica@nownurinet : < > junoyoon@orgionet final Content Information Audience Abstract (JFC) - Media Media Converter Reference Benchmark information JSTORM <2/35>
Issued by: < > Revision: <10> <2000/8/23> Document Approvals Signature date Signature date Revision History Revision Date Author Description of change JSTORM <3/35>
Issued by: < > Revision: <10> <2000/8/23> Table of Contents 6 6 7 8 ( )9 10 Clock, Duration, TimeBase 11 DataSource12 Format 12 Player,Controller13 1 : MediaPlayer14 DataSource 19 Player 20 20 20 Processor23 plug-in 23 TrackControl24 Data & 24 2 :MP3 25 JSTORM <4/35>
Issued by: < > Revision: <10> <2000/8/23> JSTORM <5/35>
Issued by: < > Revision: <10> <2000/8/23> 1998 SGI(Sillicon Graphics) 10 SGI, 1998 IBM IBM Jikes IBM JDK, RMI for IE,, 199811 11 20 FCS 20 - & - ( ) - Player Pluggable Codec 3, Solaris Window, Cross- Platform Cross-Platform OS Cross-Platform OS JDK, JSTORM <6/35>
Issued by: < > Revision: <10> <2000/8/23> http://javasuncom/products/java-media/jmf/20/supportedhtml, RTP API, RTP API RTP API RTP(Real-time Transport Protocol) API, 3 JSTORM <7/35>
Issued by: < > Revision: <10> <2000/8/23> // Player URL MediaLocator player; mediaurl = new URL("file:/c:/dearmpg"); mrl = null; // if ((mrl = new MediaLocator(mediaURL)) == null){ // else{ DataSource src = null; try{ src = ManagercreateDataSource(mrl); player = ManagercreatePlayer(src); // playerrealize Realized playerrealize(); while(!(processorgetstate() == ProcessorRealized)){ // Realized // 2 playersetrate(20); // playerprefetch Prefetched playerprefetch(); while(!(processorgetstate() == ProcessorPrefetch)){ // Prefetch // TimBase playersyncstart(); JSTORM <8/35>
Issued by: < > Revision: <10> <2000/8/23> catch(ioexception e){ catch(javaxmedianodatasourceexception e){ catch(noplayerexception e){,,,? ( ) RTP 90% [ 2] (MediaSource) (Player), Play, Stop [ 2] JSTORM <9/35>
Issued by: < > Revision: <10> <2000/8/23> [ 3], [ 3] JSTORM <10/35>
Issued by: < > Revision: <10> <2000/8/23> Clock, Duration, TimeBase TimeBaseClock Clock (Media Time), TimeBase (Time-Base Time), ClockTimeBase (, Media Stream ) Time, Clock, [ 4] TimeBase (getnanosecond(), gettime()), Time-base, [ 4] 0, Duration?, Clock setrate() getrate(),, setrate(),, setrate() JSTORM <11/35>
Issued by: < > Revision: <10> <2000/8/23> DataSource,,, DataSource DataSource SourceStream, data source Buffer DataSource Data DataSource PullDataSourcePushDataSource, PullDataSource HTTP FILEPull Data, PushDataSource, VOD, RTP(Real-time Transport Protocol) DataSource cloneable DataSourcemerging DataSource DataSource cloneable DataSource SourceCloneable Implement createclone(), DataSource DataSourceclonable DataSource merging Datasource DataSource DataSource DataSourceDuration () Duration, mergingdatasource PullDataSourcePushDataSource merging Format Format MP3WAVE decoding Format JSTORM <12/35>
Issued by: < > Revision: <10> <2000/8/23> Player,Controller [ 3] Player Controller, State Controller 6 Controllerint getstate(), Controller static UnRealized Prefetched 5 Stopped, Clock Player 6? 1, 2,, Controller6 Unrealized Realizing Realized Player Unrealized realize Unrealized realize Realized realize (E xclusive-use resource),, Pl ayer Hardware prefetching realizing getcontrolpanelcomponent (), getvisualcomponen11t() Prefetching Realized prefetch, (Exclusive) ( ), Prefetched JSTORM <13/35>
Issued by: < > Revision: <10> <2000/8/23> Started Prefetching 1 : MediaPlayer import javaxswing*; import javaawt*; import javaawtevent*; import javaxmedia*; import javaxmediaprotocol*; import javanet*; import javaio*; [ 1] public class MediaPlayer extends JFrame implements ControllerListener, ActionListener{ public static final String OPEN_MENU_ACTION_COMMAND public static final String EXIT_MENU_ACTION_COMMAND public static final String RATE_1_ACTION_COMMAND public static final String RATE_2_ACTION_COMMAND public JFileChooser filedlg = new JFileChooser(); = "Open"; = "Exit"; = "1 "; = "2 "; // Player player = null; // URL String float mediaurlstring = null; playrate = (float)10; // Component visualcomponent = null; // (,) Component controlcomponent = null; // visualcomponent JFrame displayframe; public MediaPlayer(){ super("media Player"); JSTORM <14/35>
Issued by: < > Revision: <10> <2000/8/23> // Swing // LightWeight Renderer ManagersetHint(ManagerLIGHTWEIGHT_RENDERER, new Boolean(true)); initcomponent(); thispack(); thisshow(); public void initcomponent(){ JMenuBar mainmenubar = new JMenuBar(); JMenu filemenu = new JMenu("File"); filemenuadd(makemenuitem(open_menu_action_command)); filemenuaddseparator(); filemenuadd(makemenuitem(exit_menu_action_command)); mainmenubaradd(filemenu); JMenu ratemenu = new JMenu("Rate"); ratemenuadd(makemenuitem(rate_1_action_command)); ratemenuadd(makemenuitem(rate_2_action_command)); mainmenubaradd(ratemenu); thissetjmenubar(mainmenubar); addwindowlistener(new WindowAdapter() { public void windowclosing(windowevent e) { exit(); ); // ------------------------------------------------------------------------ private JMenuItem makemenuitem(string commandstring) { JMenuItem item = new JMenuItem(commandString); itemaddactionlistener(this); return item; ////////////////////////////////////////////////////////////////////////////// // ActionListener // ------------------------------------------------------------------------ JSTORM <15/35>
Issued by: < > Revision: <10> <2000/8/23> public void actionperformed(actionevent e){ String actioncommand = egetactioncommand(); if (actioncommandequals(open_menu_action_command)) { openmediafile(); else if(actioncommandequals(exit_menu_action_command)) { exit(); else if(actioncommandequals(rate_1_action_command)) { setplayrate(1); else if(actioncommandequals(rate_2_action_command)) { setplayrate(2); // ------------------------------------------------------------------------ private void openmediafile(){ if(filedlgshowopendialog(this) == JFileChooserAPPROVE_OPTION){ try{ startmedia(filedlggetselectedfile()tourl()); catch(exception e){ // ------------------------------------------------------------------------ private void exit(){ Systemexit(-1); // ------------------------------------------------------------------------ private void setplayrate(float rate){ thisplayrate = rate; if(player!= null){ if(!(playergetstate() == ControllerUnrealized playergetstate() == ControllerRealizing)) playersetrate(playrate); ////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------------ private void startmedia(url mediaurl){ if(player!= null){ playerstop(); JSTORM <16/35>
Issued by: < > Revision: <10> <2000/8/23> try { playerdeallocate(); playerclose(); player = null; // (mediaurl) Player try { player = ManagercreatePlayer(getDataSource(mediaURL)); catch (NoPlayerException e) { fatal(" "); // Add ourselves as a listener for a player's events Systemoutprintln(" "); playeraddcontrollerlistener(this); playerstart(); catch (MalformedURLException e) { fatal("invalid media file URL!"); catch (IOException e) { ////////////////////////////////////////////////////////////////////////////// // ControllerListener public synchronized void controllerupdate(controllerevent e) { Systemoutprintln(" "); if (player == null) return; if (e instanceof RealizeCompleteEvent) { Systemoutprintln("RealizeCompleteEvet - "); float real = playersetrate(playrate); JPanel pane = new JPanel(); panesetlayout(new BorderLayout()); if (( controlcomponent = playergetcontrolpanelcomponent())!= null) { paneadd(controlcomponent, BorderLayoutSOUTH); if (( visualcomponent = playergetvisualcomponent())!= null) { paneadd(visualcomponent, BorderLayoutCENTER); JSTORM <17/35>
Issued by: < > Revision: <10> <2000/8/23> if (controlcomponent!= null) { controlcomponentinvalidate(); if(displayframe == null) displayframe = new JFrame(); displayframesettitle(mediaurlstring); displayframesetcontentpane(pane); displayframedolayout(); displayframepack(); displayframeshow(); else if (e instanceof EndOfMediaEvent) { Systemoutprintln("EndOfMediaEvent"); playersetmediatime(new Time(0)); playerstart(); else if (e instanceof CachingControlEvent) { Systemoutprintln("CachingControlEvent"); playersetmediatime(new Time(0)); playerstart(); else if (e instanceof ControllerErrorEvent) { Systemoutprintln("ControllerErrorEvent"); player = null; fatal(((controllererrorevent)e)getmessage()); else if (e instanceof ControllerClosedEvent) { Systemoutprintln("ControllerClosedEvent"); private DataSource getdatasource(url mediaurl){ mediaurlstring = mediaurltostring(); MediaLocator mrl = null; if ((mrl = new MediaLocator(mediaURL)) == null){ fatal(" "); return null; else{ DataSource src = null; try{ src= ManagercreateDataSource(mrl); catch(ioexception e){ JSTORM <18/35>
Issued by: < > Revision: <10> <2000/8/23> catch(javaxmedianodatasourceexception e){ return src; void fatal (String s) { Systemerrprintln("FATAL ERROR: " + s); throw new Error(s); public static void main(string args[]){ new MediaPlayer(); 200, ( ),, ( ), DataSource DataSource DataSource MediaLocator, MediaLocator MediaLocatorsURL MediaLocator URL URL URLStreamHandler MediaLocator MediaLocator mrl = new MediaLocator(mediaURL); DataSource mediasource = new DataSource(mrl); JSTORM <19/35>
Issued by: < > Revision: <10> <2000/8/23> Player Player Manager static Player ManagercreatePlayer(javanetURL sourceurl) static Player ManagercreatePlayer(MediaLocator sourcelocator) static Player ManagercreatePlayer(DataSource source) URL MediLo cator Player Player Unrealized Player Started, Playerstart(), realize(), prefetch() Controller ControllerEvent ( [ 6] ) Playerstart(), ControllerEvent ControllerListenerPlayer ControllerListener(ControllerUpdate ) instanceof if (e instanceof RealizeCompleteEvent) { else if (e instanceof PrefetchCompleteEvent){ else if (e instanceof ControllerClosedEvent) { Realized Player GUI, Started JSTORM <20/35>
Issued by: < > Revision: <10> <2000/8/23> playergetcontrolpanelcomponent() playergetvisualcomponent() JSTORM <21/35>
Issued by: < > Revision: <10> <2000/8/23> 2> Player NRE NotRealizedError NPE - NotPrefetchedError JSTORM <22/35>
Issued by: < > Revision: <10> <2000/8/23> Processor [ 3]Processor ProcessorPlayer [ 3] Player, Processor [ 5] ProcessorPlayer DataSourceOutput Processor ( DataSource), Processor Processor ProcessorModel Processor TrackControl setformat format ProcessorsetOutputContentDescriptor Multiplex TrackControlSetCodecChain Processor Effect Codec Plug-in TrackControlsetRender Processor Render Processor Effect plug-in 5 Plug-in (Plug In) PlugInManager addplugin, Player Processor,,, JSTORM <23/35>
Issued by: < > Revision: <10> <2000/8/23> Demultiplexer -, mpegdemultiplexing Demultiplexer Multiplexer - Demultiplexing Effect - Codec (TrackControl ) Codec - Buffer Buffer (TrackControl ) Renderer - TrackControl ProcessorgetTrackControl EffectCodec TrackControl TrackControl FormatControl, FormatControl setformat() DataSource, ProcessorModel ProcessorModel Processor ProcessorModel ManagercreateRealizedProcessor() Processor Realized Processor, Realized ProcessorModel Processor Data & DataSink, RTP DataSink,? Manager Manager DataSink Manager JSTORM <24/35>
Issued by: < > Revision: <10> <2000/8/23>, Manager 2 :MP3, mpg, mp3, mpg mp3 Processor Processor Player MediaLocator Manager createprocessor URL, URLMediaLocator Manager createprocessor(medialocator ml) Processor // URL Player processor = ManagercreateProcessor(mrl); StateHelper, ControllerPlayer, Processor State Processor [ 2] Processor Unrealized ([ 6] configure realize prefetch ) StateHelper if (!shconfigure(10000)){ Systemexit(-1); JSTORM <25/35>
Issued by: < > Revision: <10> <2000/8/23> StateHelper processorconfigure(); // configure while(!(processorgetstate() == ProcessorConfigured)){ & mpg (Configured ) Processor TrackControl gettrackcontrols TrackControl TrackControl[] trackcontrols = processorgettrackcontrols(); TrackControl Mpeg setenable else if(trackcontrols[i]getformat() instanceof VideoFormat){ trackcontrols[i]setenabled(false); mp3 trackcontrols[audiotrackindex]setformat (new AudioFormat(AudioFormatMPEGLAYER3)); (Multiplex ) processorsetcontentdescriptor (new FileTypeDescriptor(FileTypeDescriptorMPEG_AUDIO)); Processor Processor mp3 DataSink Manager,, sink = ManagercreateDataSink(processorgetDataOutput(), dest); JSTORM <26/35>
Issued by: < > Revision: <10> <2000/8/23> sinkopen(); sinkstart(); Processor shplaytoendofmedia((int)(processorgetduration()getseconds()) * 1000); shclose(); sinkclose();, Processor mp3, DataSinkProcessor DataSink JSTORM <27/35>
Issued by: < > Revision: <10> <2000/8/23> import javaxmedia*; import javanet*; import javaio*; import javaxmediacontrol*; import javaxmediaformat*; import javaxmediaprotocol*; public class testconvert{ public static void main(string args[]){ if(argslength < 2 ){ Systemoutprintln("Usage: java testconvert <URL> <Destination>"); Systemoutprintln("ex) java testconvert file:/c:/music/lovempg lovemp3"); Systemexit(-1); URL mediaurl = null; URL desturl = null; try{ mediaurl = new URL(args[0]); desturl = new URL(mediaURLgetProtocol(), mediaurlgethost(), args[1]); catch(malformedurlexception e){ eprintstacktrace(); Processor processor; StateHelper sh = null; try { MediaLocator mrl = null; if ((mrl = new MediaLocator(mediaURL)) == null){ return; // URL Player processor = ManagercreateProcessor(mrl); sh = new StateHelper(processor); if (!shconfigure(10000)){ Systemexit(-1); JSTORM <28/35>
Issued by: < > Revision: <10> <2000/8/23> TrackControl[] trackcontrols = processorgettrackcontrols(); int audiotrackindex = 0; for(int i=0; i<trackcontrolslength; i++){ if(trackcontrols[i]getformat() instanceof AudioFormat){ audiotrackindex = i; else if(trackcontrols[i]getformat() instanceof VideoFormat){ trackcontrols[i]setenabled(false); trackcontrols[audiotrackindex]setenabled(true); trackcontrols[audiotrackindex]setformat(new AudioFormat(AudioFormatMPEGLAYER3)); processorsetcontentdescriptor(new if (!shrealize(10000)){ Systemexit(-1); DataSink sink = null; FileTypeDescriptor(FileTypeDescriptorMPEG_AUDIO)); MediaLocator dest = new MediaLocator(destURL); try{ sink = ManagercreateDataSink(processorgetDataOutput(), dest); sinkopen(); sinkstart(); catch(exception e){ eprintstacktrace(); // shplaytoendofmedia((int)(processorgetduration()getseconds()) * 1000); shclose(); sinkclose(); Systemexit(-1); catch (NoProcessorException e){ catch (MalformedURLException e) { catch (IOException e) { JSTORM <29/35>
Issued by: < > Revision: <10> <2000/8/23> import javaxmedia*; public class StateHelper implements javaxmediacontrollerlistener { Player player = null; boolean configured = false; boolean realized = false; boolean prefetched = false; boolean eom = false; boolean failed = false; boolean closed = false; public StateHelper(Player p) { player = p; paddcontrollerlistener(this); public boolean configure(int timeoutmillis) { long starttime = SystemcurrentTimeMillis(); synchronized (this) { if (player instanceof Processor) ((Processor)player)configure(); else return false; while (!configured &&!failed) { try { wait(timeoutmillis); catch (InterruptedException ie) { if (SystemcurrentTimeMillis() - starttime > timeoutmillis) break; return configured; public boolean realize(int timeoutmillis) { JSTORM <30/35>
Issued by: < > Revision: <10> <2000/8/23> long starttime = SystemcurrentTimeMillis(); synchronized (this) { playerrealize(); while (!realized &&!failed) { try { wait(timeoutmillis); catch (InterruptedException ie) { if (SystemcurrentTimeMillis() - starttime > timeoutmillis) break; return realized; public boolean prefetch(int timeoutmillis) { long starttime = SystemcurrentTimeMillis(); synchronized (this) { playerprefetch(); while (!prefetched &&!failed) { try { wait(timeoutmillis); catch (InterruptedException ie) { if (SystemcurrentTimeMillis() - starttime > timeoutmillis) break; return prefetched &&!failed; public boolean playtoendofmedia(int timeoutmillis) { long starttime = SystemcurrentTimeMillis(); eom = false; synchronized (this) { playerstart(); JSTORM <31/35>
Issued by: < > Revision: <10> <2000/8/23> while (!eom &&!failed) { try { wait(timeoutmillis); catch (InterruptedException ie) { if (SystemcurrentTimeMillis() - starttime > timeoutmillis) break; return eom &&!failed; public void close() { synchronized (this) { playerclose(); while (!closed) { try { wait(100); catch (InterruptedException ie) { playerremovecontrollerlistener(this); public synchronized void controllerupdate(controllerevent ce) { if (ce instanceof RealizeCompleteEvent) { realized = true; else if (ce instanceof ConfigureCompleteEvent) { configured = true; else if (ce instanceof PrefetchCompleteEvent) { prefetched = true; else if (ce instanceof EndOfMediaEvent) { eom = true; else if (ce instanceof ControllerErrorEvent) { failed = true; else if (ce instanceof ControllerClosedEvent) { closed = true; else { return; JSTORM <32/35>
Issued by: < > Revision: <10> <2000/8/23> notifyall(); SUN, ('Know How') ('Know Where'), 'Know Where, CaptureRTP JSTORM <33/35>
Issued by: < > Revision: <10> <2000/8/23> JSTORM <34/35>
Issued by: < > Revision: <10> <2000/8/23> JSTORM <35/35>