Java™ Media Framework API Guide
Total Page:16
File Type:pdf, Size:1020Kb
i Javaª Media Framework API Guide November 19,1999 JMF 2.0 FCS ii JMF API Guide iii 1998-99 Sun Microsystems, Inc. 2550 Garcia Avenue, Mountain View, California 94043-1100 U.S.A. All rights reserved. The images of the video camera, video tape, VCR, television, and speakers on page 12 copyright www.arttoday.com. RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the U.S. Government is subject to restrictions of FAR 52.227-14(g)(2)(6/87) and FAR 52.227-19(6/87), or DFAR 252.227-7015(b)(6/95) and DFAR 227.7202-1(a). The release described in this document may be protected by one or more U.S. patents, foreign patents, or pending applications. Sun, the Sun logo, Sun Microsystems, JDK, Java, and the Java Coffee Cup logo are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. THIS PUBLICATION IS PROVIDED ÒAS ISÓ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THIS PUBLICATION COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION HEREIN; THESE CHANGES WILL BE INCORPORATED IN NEW EDITIONS OF THE PUBLICATION. SUN MICROSYSTEMS, INC. MAY MAKE IMPROVEMENTS AND/OR CHANGES IN THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN THIS PUBLICATION AT ANY TIME. iv JMF API Guide Contents Preface . .xiii About JMF. xiii Design Goals for the JMF API . xiv About the JMF RTP APIs . xv Design Goals for the JMF RTP APIs. xvi Partners in the Development of the JMF API . .xvii Contact Information . .xvii About this Document . .xvii Guide to Contents . .xvii Change History . xix Comments . xx Part 1: Javaª Media Framework . .1 Working with Time-Based Media . .3 Streaming Media . 4 Content Type . 4 Media Streams . 4 Common Media Formats . 5 Media Presentation . 7 Presentation Controls . 7 Latency . 7 Presentation Quality. 7 v vi JMF API Guide Media Processing . .8 Demultiplexers and Multiplexers . .9 Codecs . .9 Effect Filters . .9 Renderers . .9 Compositing . .9 Media Capture . .10 Capture Devices. .10 Capture Controls . .10 Understanding JMF . 11 High-Level Architecture . .11 Time Model. .13 Managers. .14 Event Model . .15 Data Model . .16 Push and Pull Data Sources . .17 Specialty DataSources . .18 Data Formats . .19 Controls. .20 Standard Controls . .20 User Interface Components . .23 Extensibility . .23 Presentation . .24 Players . .25 Player States . .26 Methods Available in Each Player State. .28 Processors . .29 Presentation Controls . .29 Standard User Interface Components . .30 Controller Events. .30 Processing . .32 Processor States . .33 Methods Available in Each Processor State. .35 Processing Controls. .36 Data Output . .36 vii Capture . 37 Media Data Storage and Transmission. 37 Storage Controls . 37 Extensibility . 38 Implementing Plug-Ins . 38 Implementing MediaHandlers and DataSources. 39 MediaHandler Construction . 39 DataSource Construction . 42 Presenting Time-Based Media with JMF . .43 Controlling a Player. 43 Creating a Player. 44 Blocking Until a Player is Realized. 44 Using a ProcessorModel to Create a Processor . 44 Displaying Media Interface Components . 45 Displaying a Visual Component. 45 Displaying a Control Panel Component . 45 Displaying a Gain-Control Component. 46 Displaying Custom Control Components. 46 Displaying a Download-Progress Component. 47 Setting the Playback Rate. 47 Setting the Start Position . 48 Frame Positioning . 48 Preparing to Start . 49 Realizing and Prefetching a Player. 49 Determining the Start Latency . 50 Starting and Stopping the Presentation. 50 Starting the Presentation . 50 Stopping the Presentation . 50 Stopping the Presentation at a Specified Time . 51 Releasing Player Resources . 52 Querying a Player . 53 Getting the Playback Rate . 53 Getting the Media Time . 53 Getting the Time-Base Time . 54 Getting the Duration of the Media Stream . 54 viii JMF API Guide Responding to Media Events . .54 Implementing the ControllerListener Interface . .54 Using ControllerAdapter . .55 Synchronizing Multiple Media Streams . .56 Using a Player to Synchronize Controllers . .57 Adding a Controller . .58 Controlling Managed Controllers . .58 Removing a Controller . .59 Synchronizing Players Directly . .60 Example: Playing an MPEG Movie in an Applet. .61 Overview of PlayerApplet . .62 Initializing the Applet. .64 Controlling the Player. .65 Responding to Media Events . .66 Presenting Media with the MediaPlayer Bean . .66 Presenting RTP Media Streams . ..