The experienced developer's guide to JMF!
Core Java Media Framework is the most sophisticated, practical guide to integrating multimedia in your Java applications. Written for experienced developers by one of the world's top multimedia programmers, this book contains extensive source code, plus never-before published JMF programming secrets that will save you hours of coding and debugging!
Start by understanding the JMF architecture in depth, including data source objects, players, events, controllers, and player states. Compare the leading JMF runtimes, including Sun's JMF implementation as well as Intel Media for Java. Master the Java Media Player and crucial concepts such as start-and-stop semantics, playback rates, tracking download times, and synchronization.
Next, move on to advanced topics, including creating new classes of players for devices such as CD, and closed caption text; creating MediaProxies to dynamically alter multimedia content; real-time streaming over the Internet; and JMF Web applications. Finally, preview the latest JMF advances, including Web server support, the Java Sound API, special effects routines, and the JMF 2.0 Plug-in API.
Media Framework delivers:
Includes JMF runtimes and applications that exploit them; key Java and JMF development tools; JMF versions of RealPlayer and RealAudio, and much more!
1. Multimedia Evolution.
Why JMF Anyway? Digital Audio Primer. Time to Squeeze the Charming? Audio Woes. Sneaking Through the Audio Backdoor. Streaming Through the Backdoor. Don't Leave the Backdoor Open. JMF to the Rescue! Is JMF Worth the Risk? Summary.
Growing Pains. Little Guys to the Rescue? Examination of JMF Ports. DirectShow. Intel Versus Sun. Quicktime. Solaris. Runtime Summary. You Are Only as Good as Your Tools. Symantec Visual Cafe Setup. Installation Woes. Summary.
Time Is Unrecoverable. Better than a Timex? Summary.
Break with Tradition. Equilibrium. Are You Listening to Me? Evolution of a Controller. Swimming Downstream. Are You a Good Citizen? A Closer Examination of Events. Finicky Controller. The Dangers of a Used Car Lot. How Long Does This Last Anyway? Summary.
Why a MediaHandler? Being Pushy Isn't All Bad. Return of the Manager. Summary.
Benefits of Object-Orientation. Applets 101. Juicing Up the Applet. Summary.
Getting a Driver's License. Sticks and Stones May Break My Bones, but Names Will Never Hurt Me. Gaining Control Over Your Player. Even a Broken Clock Is Right Twice a Day. Summary.
The Pain of Configuration. Building Blocks. Filtering Out the Riff-Raff. Customizing the View. Audio Sampler. Gravity Always Wins. Monitoring Progress. Souping Up AudioPreview. Summary.
Battle for World Dominance. Trespassing onto a Bean's Property. Conflict Between Theory and Reality. Flexibility Is Key. Outpatient Surgery for Multimedia Preview. Information Booth. The Joys of Testing. Summary.
Preparing the Natives. Summary.
Cross-Stream. Clearing Up Time. Delving into Synchronization Details. Excedrin for Synchronization Woes. Smooth Event Handling. Summary.
Sticking Your Nose into a Player's Business. Mysterious Lists. Installation Black MagicLooking Under the Covers of a DataSource. Speaking with a Forked Tongue. Sibling Rivalry. Trouble in Paradise? Summary.
Yet Another Markup Language? Multipurpose Tool. Putting MCML to Use. The Origination of Streams. Navigating the Streams. Summary.
What's the Big Secret Anyway? Bark Worse Than its Bite. Head of State. Hitting the Breaks. The Player's Achilles Heel. Cleaning Up the Mess. Summary.
ControlPanelComponent Should Listen! Text Never Looked So Good. It's All in the Threads! Events Are the Spice of Life. A Whole New Class of Events. Compilation and Debugging Help. Summary.
The Emperor Has No Clothes. The Natives Are Returning. The Joys of Win32 Multimedia Programming. MCI Details. Decisions, Decisions. When Is a Thread Truly Necessary? It's All Downhill from Here. Summary.
All of These Chapters for This Little Code? A Player's Work Is More Complicated. Ordering the Slaves Around. The Starting Block. What Could Have Been? Summary.
MediaProxy Overview. Single Stream Approach. MediaProxy Responsibilities. Installation Details. MediaProxy Management. Summary.
IP Primer. RTP. Class Is in Session. RTP Is a Chameleon. RTSP. Are You for Real? Additions. Summary.
Yet Another Manager? Peering Inside a DePacketizer. The Easy Route. Dumping Out RTP Statistics. Find an RTP Server to Test on. The Hard Way. Summary.
JMF 1.1 Provides Immediate Relief. Pure Java, Speed Demon? Will We See a Shipping Version of JavaSound in Our Lifetimes? Will JMF 2.0 Lead Us to the Holy Grail? Summary.
The Java Media Framework (JMF) is the most exciting addition to the Java Family of APIs since the introduction of Swing. No longer are you restricted to passive dialogs and silent windows. Now you can use JMF to spice up your applications with audio and visual effects.
JMF is divided into three phases: media playback, media capture and conferencing. This book concentrates on the media playback portion of JMF, the Java Media Player API, and how you can use it in real-world scenarios.
Multimedia has transitioned from an exotic feature used by few applications to a core feature of Web sites, databases, games and virtually all business applications. As a result, anyone who programs in Java needs to read Core JMF.
Core JMF is targeted at serious programmers who don't want a warmed-over version of Sun's JMF's documentation. It not only clarifies the confusing areas in Sun's documentation, but it also provides unique insights to the inner working of the JMF classes and interfaces. Throughout the text, you'll find honest evaluations of JMF's strengths and weaknesses and advice on how to work around bugs.
Core JMF does not assume that the entire world revolves around Microsoft and its Win32 API. You'll discover how to leverage JMF's cross-platform capabilities on Microsoft Windows 95, Windows 98, Windows NT, Sun Solaris and other flavors of UNIX. You'll see comparisons of how JMF runs on each platform and how to avoid platform specific issues so that your applications are portable.
Core JMF does not contain fluffy example programs that show you how to make noise or play video in a window. Rather, you'll encounter example programs that solve real-world multimedia problems. Some of sample programs will show you how to:
This book assumes you have a solid knowledge of Java programming concepts. However, you do not have to be a multimedia expert to read it. You'll find thorough explanations of each multimedia acronym or term.
If you already are a multimedia aficionado and are familiar with environments such as QuickTime, MCI, or DirectShow, this book will show you how each component of JMF compares to the API you already know, so you can rapidly transition to JMF programming.
Core JMF covers the core JMF classes and interfaces that you will use in your programs. If you are looking for an exhaustive overview of every JMF API, you should read Rob Gordon and Stephen Talley's Essential JMF. After you've finished reading Core JMF, you'll have thorough knowledge of the following JMF topics:
The book is not a disjointed set of unrelated example programs. Rather, it is a cohesive unit. Each chapter builds on the lessons learned in previous chapters. As a result, you'll be able to create sophisticated Java applications and objects without being overwhelmed with details.
Chapter 1: Multimedia Evolution. Chapter 1 explains why the Java Media Framework (JMF) was created and why you'll want to use it in your programs. It starts with a digital audio primer that defines how analog audio waveforms are captured and stored in the digital realm. Readers who are familiar with digital audio and Video can jump directly to the "Audio Woes" section of the chapter.
The chapter then explores the primitive audio features found in JDK 1.0.2 and explains why they are inadequate for non-trivial programs. We then uncover an undocumented audio interface present in JDK 1.x and explain how to use it.
You'll be introduced into Sun's Java Media and Communication APIs, the most exciting of which is JMF. Finally, you'll discover three key reasons why you should incorporate JMF into your Java programs.
Chapter 2: JMF's Growing Pains. This chapter examines how JMF operates on platforms such as Solaris, Microsoft Windows 95 and 98, Windows NT and the Apple Macintosh. We reveal the companies that have been involved in developing JMF runtimes and uncover why JMF was a crucial component of the United States Justice Department's lawsuit against Microsoft.
Chapter 3: Everything Revolves Around Time. This chapter introduces you to the two core components of JMF: the Player interface and the Manager . You'll learn about the variety of media formats used by a Player and how to differentiate between a TimeBase and MediaTime . You'll also discover a clock's states (or phases) and how clocks affect synchronization.
Chapter 4: Taking Control of the Situation. Chapter 4 examines Controllers and their impact on the utilization of multimedia resources in your programs. You'll learn what a Controller is, its modes of operation and why this model is superior to the older multimedia architectures.
Chapter 5: Origins. This chapter explores DataSources and how they are used by the Manager and the Player . You'll learn why a DataSource removes all input/output responsibilities from a Player and how this makes the Player more flexible.
We'll discover the differences between a Push and Pull DataSource and explain why the Pushed multimedia content will play a larger role in the future. Finally, we'll introduce you to MediaLocators and show you how they can be used to connect a DataSource to a Player.
Chapter 6: AlohaJMF: A JMF Applet. In this chapter, you'll leverage all the information learned in Chapters 1 through 5 to write your first JMF Applet. We'll explain the similarities between the Applet interface and the JMF's Player interface and explain how to use Player methods in your applets. We'll also give you tips to make your JMF enhanced applets more user-friendly.
Chapter 7: Getting Control Over Your Applications. Chapter 7 will show you why Controls are a crucial part of the Player and why every application must use them. You'll learn the three types of controls that a Player can surface and the most efficient means to obtain these controls. Finally, we'll show you how to incorporate the most popular controls in your applications and squeeze the best performance from them.
Chapter 8: Multimedia Swing Set. Swing and JMF can be a dangerous combination and Chapter 8 teaches you how to safely mix JMF in Swing-based applications. First, you'll find out how to enhance Swing's JFileChooser class with multimedia previewing capabilities. Then, you'll discover how to simultaneously handle JMF and Swing events. Finally, we'll explain the problems you'll encounter in Swing multimedia development and show you how to avoid these pitfalls.
Chapter 9: The Next Generation: JavaBeans and JMF. Chapter 9 introduces you to the JavaBeans object model and how it can be used to create multimedia objects. You'll learn what an object model is and how JavaBeans compares to other object models. We'll then take the multimedia chooser created in Chapter 8 and create a JavaBean from it.
While we're creating this multimedia object, we'll reveal guidelines for converting a general purpose multimedia class into a multimedia bean and give you specific examples of how to use these guidelines.
Chapter 10: Going Native. Chapter 10 teaches you how to reuse JMF objects in your C or C++ programs with the Java Native Interface (JNI). You'll discover how to start the Java virtual machine in C++ and learn how to avoid serious performance bottlenecks present in JNI.
You'll then find out how to launch and use the JavaBean from Chapter 9 in a C++ program. We'll show you the most efficient means to access Java constants, member variables and methods and how to optimize your JNI code.
Chapter 11: The Art of Synchronization. In Chapter 11 you'll learn what synchronization is and why it is a vital feature of all multimedia platforms. We'll use the timing concepts you learned in Chapter 3 to explain how JMF synchronizes multiple Player s. You'll learn about the complexities involved with manually synchronizing two or more Player s and find out about Controller methods which make synchronizing Players simple and fun.
We'll also teach you the things you shouldn't try with synchronized Player s and the catastrophic results if you ignore these warnings. Finally, you'll learn how synchronization affects event reporting and how to respond intelligently to events from a synchronized Player .
Chapter 12: Journey to the Center of the Player. Chapter 12 introduces you to the mysteries of Player creation. We shatter the myth that Player development is an arduous task and explain why you'll want to create your own Player s. You'll learn how to install a JMF Player and discover how the JMF Manager locates installed Players and associates them with DataSource s.
We'll show you how to find out what kind of content a DataSource is transporting and whether the DataSource is cramming the content into one stream or separating its output into multiple streams. We then explain how Players retrieve media from the DataSource 's streams and play this content.
Finally, in order to illustrate synchronization, we create a real world synchronization example program. Over the next five chapters, we create a Caption Player and CD Audio Player and an application that shows you how to synchronize text to the music on a CD.
Chapter 13: The Multimedia Caption DataSource. In Chapter 13 you'll learn how to create a DataSource that processes multimedia captions. You'll find out about the Multimedia Caption Markup Language (MCML) and why it is ideal for synchronizing text to audio/visual content.
Chapter 14: MediaHandler Primer. Chapter 14 provides the infrastructure necessary to create robust Player s. You'll be provided with a Player shell that you can use to build your Player s. Then, we'll tell you why certain methods must be performed on threads and explain the side-effects of improper thread usage.
You'll learn how to properly divide the Player 's workload so that client applications are responsive to user input. Finally, you'll discover when to clean up multimedia resources so your Player can gracefully shut down.
You'll learn how to create a ControlPanel component to start, pause, stop and search within a caption stream. You'll find out how to use a VisualControl within a Player . We'll also explain how threads improve the interactivity of the Player .
We'll discuss the techniques Player s should use to report events and the dangers of reporting events on worker threads. You'll also find out how to create custom events that let you enhance applications that use your Player . Throughout the chapter, you'll receive valuable debugging tips that will save you hours of development and debugging.
Chapter 16: Grapling with the CD. This chapter uncovers a gaping hole in the JMF architecture and shows how you can work around it. Since JMF prevents you from writing non-streaming Player s, we'll show you a secret technique to work around the problem. You'll also learn how to leverage this technology to create a CD Player that doesn't use JMF's streaming model.
This chapter advises you when you should enhance a Player with native code. It also guides you through the minefield of Windows multimedia development and shows you how to safely integrate a JMF Player with native Windows' multimedia calls.
Chapter 17: The Ultimate Synchronization: The Marriage of Players. This is the concluding chapter in the synchronization series. You'll discover how to combine and synchronize the CD Player created in Chapter 16, with the MCML Player and DataSource created in Chapters 13 through 15. In addition, we'll review the responsibilities a Player must assume in order to synchronize with other Players and point out problem areas in synchronized Player development.
Chapter 18: Meddling in a Player's Business With a MediaProxy. Chapter 18 introduces you to the MediaProxy interface. You'll learn how a MediaProxy modifies content after it leaves a DataSource but before it reaches the Player . We'll also provide realistic examples of when you want to use a MediaProxy .
We'll show you how to create a MediaProxy by modifying the MCML DataSource to transmit a single stream of caption content. Then, we'll use a MediaProxy to transform the single caption stream into the multi-stream format expected by the Player we created in Chapter 15.
Chapter 19: Real-time Streaming. This chapter provides a thorough explanation of real-time streaming on the Internet and shows you how they are used in JMF. You'll learn about technologies such as RTP and RTSP and how they are superior to HTTP or FTP for transporting multimedia content over the Internet Protocol.
Chapter 20: A Real-Time Hybrid. Chapter 20 will examine Sun's mysterious RTP architecture and show you how to use RTP in your applets and applications. You'll discover how Sun uses a MediaProxy to bridge the chasm between their RTP-specific DataSource and generic MediaHandlers . We'll also show you how the RTP Depacketizer provides data type independence and enables you to stream custom media types.
Chapter 21: Where Is JMF Headed? We conclude the book by examining the current strengths and weaknesses in JMF and preview how future JMF releases will address these weaknesses. You'll learn about Pure JMF 1.1, the first version of JMF that runs on all Java platforms. We'll also examine the web server version of JMF that dramatically simplifies the installation and usage of JMF applets.
Then we'll review JavaSound: the API that gives you finer control over audio and MIDI hardware. Finally, we'll take a peek at JMF 2.0. This release promises to provide evolutionary new functions such as the Plug-in API. The Plug-in API will let you create and dynamically insert special effect routines into Players.
All books will contain unforeseen errors in the text and bugs in the example programs, and this book is no exception. If you'd like to report a bug, e-mail comments and other feedback at ftp.prenhall.com/pub/ptr/unix_