Programming with JMF - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

Programming with JMF

Description:

Setting up the Recording Control. Setting up the Volume Control. Testing with Sound Recorder. 14. 2. Programming with JMF. Playing Media File Using JMF ... – PowerPoint PPT presentation

Number of Views:96
Avg rating:3.0/5.0
Slides: 22
Provided by: orc52
Category:

less

Transcript and Presenter's Notes

Title: Programming with JMF


1
Programming with JMF
  • Prepared by Tony K. C. Chan.

2
Learning Objectives
  • Foundation of media communications
  • Setup the voice communication channel with Java
    Media Framework (JMF)
  • Complete the simplified Internet phone system

3
1. Background Knowledge
  • Java Media Framework (JMF) API for time-based
    media in Java.
  • Processing model

4
1. Background Knowledge
  • Some Important Terms in JMF
  • DataSource an object thatencapsulates the media
    stream(e.g., a file, an incoming stream,etc.).
  • Capture device hardware used to capture the
    media data (e.g., microphone).

5
1. Background Knowledge
  • Some Important Terms in JMF, cont.
  • Player
  • a media handler forrendering and
    controllingtime-based media data.
  • Processing model of the Player

6
1. Background Knowledge
  • Some Important Terms in JMF, cont.
  • Player, cont.
  • Six states of the Player

7
1. Background Knowledge
  • Some Important Terms in JMF, cont.
  • Processor
  • It extends the Player interface.
  • Rendering media data
  • Control over the processing of the input output
    media data.
  • Processing model of the Processor

8
1. Background Knowledge
  • Some Important Terms in JMF, cont.
  • Processor, cont.
  • Processing stages of the Processor

9
1. Background Knowledge
  • Some Important Terms in JMF, cont.
  • Processor, cont.
  • Two additional states (Configuring Configured).

10
1. Background Knowledge
  • Some Important Terms in JMF, cont.
  • Format represents the exact format of the media
    (e.g., GSM).
  • Manager
  • used to implement some other interfaces
  • Example
  • Manager ? Player, Processor, and DataSource.
  • CaptureDeviceManager ? access a list of available
    capture devices.
  • RTPManater used to create, maintain and close an
    RTP session.

11
1. Background Knowledge
  • Some Useful Event
  • ConfigureCompleteEvent
  • posed when a Processor finishes Configuring.
  • occurs when a Processor moves from Configuring to
    Configured (i.e., Processor is already
    Configured).
  • RealizeCompleteEvent
  • posted when a Controller finishes Realizing.
  • occurs when a Controller moves from Realizing to
    Realized (i.e., the Controller is already
    Realized).

12
1. Background Knowledge
  • Some Useful Event, cont.
  • EndOfMediaEvent
  • indicates that the Controller has reached the end
    of its media and is stopping.
  • NewReceiveStreamEvent
  • Informs the RTP listener that a new stream of RTP
    data packets has been detected

13
2. Programming with JMF
  • Setting up Your Computer
  • Setting up the Recording Control
  • Setting up the Volume Control
  • Testing with Sound Recorder

14
2. Programming with JMF
  • Playing Media File Using JMF
  • Create MediaLocator that represents the
    mediaMediaLocator mediaLocator new
    MediaLocator(fileName)
  • Create DataSource for the MediaLocatordataSource
    Manager.createDataSource( mediaLocator)
  • Create Player for the DataSourceplayer
    Manager.createPlayer(dataSource)

15
2. Programming with JMF
  • Playing Media File Using JMF, cont.
  • Add ControllerListener to the playerplayer.addCon
    trollerListener(this)
  • Implement the controllerUpdate methodpublic
    synchronized void controllerUpdate(
    ControllerEvent e) ...
  • Realize the Playerplayer.realize()
  • Start the Playerplayer.start()

16
2. Programming with JMF
  • Playing Media File Using JMF, cont.

/ File name RingPlayer.java / import
java.media. import java.media.protocol. publi
c class RingPlayer Player player public
RingPlayer() String fileName
file//C\\java\\ringin.wav ... public
void start() ... public void stop() ...

17
2. Programming with JMF
  • Playing Media File Using JMF, cont.

public class RingPlayer implements
ControllerListener Player player public
RingPlayer() String fileName
file//C\\java\\ringin.wav ...
player.addControllerListener(this) ...
... public synchronized void controllerUpate(
ControllerEvent e) if (e instanceof
EndOfMediaEvent) player.setMediaTime(new
Time(0)) ...
18
3. The ChattingManager for our SIPS
  • Details of ChattingManager
  • ChattingManager(int mediaPort)
  • Creates an instance of ChattingManager.
  • Capture the audio device from your computer and
    prepare all stuff for setting up the voice
    communication channel.
  • ChattingManager(int mediaPort, boolean
    showProgress)
  • Same as ChattingManager(int mediaPort), but with
    debugging output.

19
3. The ChattingManager for our SIPS
  • Details of ChattingManager, cont.
  • void setupConnection(InetAddress targetIP, int
    targetPort) sets up the RTP session with the
    remote host and waiting for receiving audio
    stream.
  • void start() start sending the captured audio
    stream through the connected RTP session.
  • void destroy() stop and destroy the RTP session
    (it will not destroy the ChattingManager).

20
3. The ChattingManager for our SIPS
  • How to use the ChattingManager
  • Save ChattingManager.class and SendProcessor.class
    in the working directory

21
THE END
Write a Comment
User Comments (0)
About PowerShow.com