26.07.2013 Views

Java How to Program Fourth Edition - DCC

Java How to Program Fourth Edition - DCC

Java How to Program Fourth Edition - DCC

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 22 <strong>Java</strong> Media Framework and <strong>Java</strong> Sound (on CD) 1263<br />

ponent <strong>to</strong> obtain the GUI component that displays the moni<strong>to</strong>red media. Moni<strong>to</strong>rControls<br />

typically have a checkbox <strong>to</strong> enable or disable displaying media. Also, audio<br />

devices have a volume control and video devices have a control for setting the preview<br />

frame rate. Line 301 invokes method showSaveMoni<strong>to</strong>r (lines 245–261) <strong>to</strong> display the<br />

moni<strong>to</strong>ring GUI in a dialog box. To terminate capturing, users can press the OK but<strong>to</strong>n or<br />

close the dialog box (lines 254–261). For some video capture devices, the Processor<br />

needs <strong>to</strong> be in a S<strong>to</strong>pped state <strong>to</strong> enable moni<strong>to</strong>ring of the saving and capturing process.<br />

Thus far, we have discussed JMF’s capabilities <strong>to</strong> access, present and save media content.<br />

Our final JMF example demonstrates how <strong>to</strong> send media between computers using<br />

JMF’s streaming capabilities.<br />

22.4 RTP Streaming<br />

Streaming media refers <strong>to</strong> media that is transferred from a server <strong>to</strong> a client in a continuous<br />

stream of bytes. The client can begin playing the media while still downloading the media<br />

from the server. Audio and video media files are often many megabytes in size. Live events,<br />

such as concerts or football game broadcasts, may have indeterminable sizes. Users could<br />

wait until a recording of a concert or game is posted, then download the entire recording.<br />

<strong>How</strong>ever, at <strong>to</strong>day’s Internet connection speeds, downloading such a broadcast could take<br />

days and typically users prefer <strong>to</strong> listen <strong>to</strong> live broadcasts as they occur. Streaming media<br />

enables client applications <strong>to</strong> play media over the Internet or over a network without downloading<br />

the entire media file at once.<br />

In a streaming media application, the client typically connects <strong>to</strong> a server that sends a<br />

stream of bytes containing the media back <strong>to</strong> the client. The client application buffers (i.e.<br />

s<strong>to</strong>res locally) a portion of the media, which the client begins playing after a certain portion<br />

has been received. The client continually buffers additional media, providing users with an<br />

uninterrupted clip, as long as network traffic does not prevent the client application from<br />

buffering additional bytes. With buffering, users experience the media within seconds of<br />

when the streaming begins, even though all of the material has not been received.<br />

Performance Tip 22.3<br />

Streaming media <strong>to</strong> a client enables the client <strong>to</strong> experience the media faster than if the client<br />

must wait for an entire media file <strong>to</strong> download. 22.3<br />

Demand for real-time, robust multimedia is rising dramatically as the speed of Internet<br />

connections increase. Broadband Internet access, which provides high-speed network connections<br />

<strong>to</strong> the Internet for so many home users, is becoming more popular, though the<br />

number of users remains relatively small compared <strong>to</strong> the <strong>to</strong>tal number of Internet users.<br />

With faster connections, streaming media can provide a better multimedia experience.<br />

Users with slower connections can still experience the multimedia, though with lesser<br />

quality. The wide range of applications that use streaming media is growing. Applications<br />

that stream video clips <strong>to</strong> clients have expanded <strong>to</strong> provide real-time broadcast feeds. Thousands<br />

of radio stations stream music continuously over the Internet. Client applications<br />

such as RealPlayer have focused on streaming media content with live radio broadcasts.<br />

Applications are not limited <strong>to</strong> audio and video server-<strong>to</strong>-client streaming. For example,<br />

teleconferencing and video conferencing applications increase efficiency in everyday business<br />

by reducing the need for business people <strong>to</strong> travel great distances <strong>to</strong> attend meetings.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!