Lecture13 Java Media Framework II - Java Media Framework II - Processing and Controlling Media with JMF.

Slides:



Advertisements
Similar presentations
Chapter 17 Failures and exceptions. This chapter discusses n Failure. n The meaning of system failure. n Causes of failure. n Handling failure. n Exception.
Advertisements

Java Media Framework. Inhalt Java Media APIs Architektur Zeitmodell Manager Ereignismodell Datenmodell Control Controller Player Processor Plug-Ins Aufnahme.
It provides a framework for embedded multimedia facilities in java enabled mobile devices.
Data Dependencies Describes the normal situation that the data that instructions use depend upon the data created by other instructions, or data is stored.
Lecture 11: Operating System Services. What is an Operating System? An operating system is an event driven program which acts as an interface between.
Java Media Framework The Java Media Framework (JMF) is an application programming interface (API) for incorporating time- based media into Java applications.
Module 20 Troubleshooting Common SQL Server 2008 R2 Administrative Issues.
Exception Handling.  What are errors?  What does exception handling allow us to do?  Where are exceptions handled?  What does exception handling facilitate?
400 Gb/s Programmable Packet Parsing on a Single FPGA Authors : Michael Attig 、 Gordon Brebner Publisher: 2011 Seventh ACM/IEEE Symposium on Architectures.
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
Java Threads Part II. Lecture Objectives To understand the concepts of multithreading in Java To be able to develop simple multithreaded applications.
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
1 Java - Threads A thread is an individual flow of control within a larger program. A program which is running more than one thread is said to be multithreaded.
Lecture12 Java Media Framework I. Streaming Media Steaming media simply means we have a stream of media coming through some kind of a media channel. Some.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
1 Chapter 6 Inheritance, Interfaces, and Abstract Classes.
1 Introduction of JMF Student : 朱浩廷 Advisor : 杭學鳴 教授.
Marakas: Decision Support Systems, 2nd Edition © 2003, Prentice-Hall Chapter Chapter 1: Introduction to Decision Support Systems Decision Support.
Java ThreadsGraphics Programming Graphics Programming: Java Threads.
Lecture14 Java Media Framework III – Some JMF Applications.
1 Java Media Framework Multimedia Systems: Module 3 Lesson 1 Summary: r JMF Core Model m Architecture m Models: time, event, data r JMF Core Functionality.
CONTENTS:-  What is Event Log Service ?  Types of event logs and their purpose.  How and when the Event Log is useful?  What is Event Viewer?  Briefing.
Lecture 2 - Struts ENTERPRISE JAVA. 2 Contents  Servlet Deployment  Servlet Filters  Model View Controllers  Struts  Dependency Injection.
June 14, 2001Exception Handling in Java1 Richard S. Huntrods June 14, 2001 University of Calgary.
Video Conferencing-introduction --- IT Acumens. COM --- IT Acumens. COMIT Acumens. COMIT Acumens. COM.
Chapter 11 Inheritance and Composition. Chapter Objectives Learn about inheritance Learn about subclasses and superclasses Explore how to override the.
Java Programming: Advanced Topics
CMSC 202 Exceptions. Aug 7, Error Handling In the ideal world, all errors would occur when your code is compiled. That won’t happen. Errors which.
The Java Media Framework: javax.media
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
Copyright, 1996 © Dale Carnegie & Associates, Inc. Presented by Hsiuling Hsieh Christine Liu.
Event Management & ITIL V3
Minor Project By: Pasang Gurung Pramod Nepal Rajendra Bdr. Thapa.
Data Structures and Java CS 105. L7: Java Slide 2 Data structure Data structure defined: A systematic way of organizing and accessing data Examples Dictionary:
Exceptions. Exception Abnormal event occurring during program execution Examples –Manipulate nonexistent files FileReader in = new FileReader("mumbers.txt“);
1 Java Media Framework RTP 를 이용한 데이터 송 / 수신. 2.2 Java Media Framework  Live media broadcast 또는 video conference 를 인 터넷이나 인트라넷에서 수행하기위해서 Real-time 으로.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
Database System Development Lifecycle 1.  Main components of the Infn System  What is Database System Development Life Cycle (DSDLC)  Phases of the.
Java Threads. What is a Thread? A thread can be loosely defined as a separate stream of execution that takes place simultaneously with and independently.
Slide 1 Extending Tuscany Raymond Feng Apache Tuscany committer.
JMF Introduction Yuqiang Liao Content What can JMF do What can JMF do Handling Time-Based Media Handling Time-Based Media JMF Architecture.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
CSC 205 – Java Programming II Applet. Types of Java Programs Applets Applications Console applications Graphics applications Applications are stand-alone.
Li Tak Sing COMPS311F. Case study: consumers and producers A fixed size buffer which can hold at most certain integers. A number of producers which generate.
Vinay Paul. CONTENTS:- What is Event Log Service ? Types of event logs and their purpose. How and when the Event Log is useful? What is Event Viewer?
Chapter 2 Collections. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Chapter Objectives Define the concept and terminology related.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 11 Handling Exceptions and Events.
Slide 1 Extending Tuscany Raymond Feng Apache Tuscany committer.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Exception Handling in Java Topics: Introduction Errors and Error handling Exceptions Types of Exceptions Coding Exceptions Summary.
Interfaces F What is an Interface? F Creating an Interface F Implementing an Interface F What is Marker Interface?
CS 116 OBJECT ORIENTED PROGRAMMING II LECTURE 12 GEORGE KOUTSOGIANNAKIS Copyright: 2015 Illinois Institute of Technology/ George Koutsogiannakis 1.
Exceptions. Exception  Abnormal event occurring during program execution  Examples Manipulate nonexistent files FileReader in = new FileReader("mumbers.txt“);
بسم الله الرحمن الرحيم MEMORY AND I/O.
Multithreading. Multitasking The multitasking is the ability of single processor to perform more than one operation at the same time Once systems allowed.
Lecture10 Exception Handling Jaeki Song. Introduction Categories of errors –Compilation error The rules of language have not been followed –Runtime error.
1 Lecture 19: Unix signals and Terminal management n what is a signal n signal handling u kernel u user n signal generation n signal example usage n terminal.
Eighth Lecture Exception Handling in Java
Modern Programming Tools And Techniques-I
Multithreaded Programming in Java
Multithreading in Java
Video Conferencing-introduction
Inheritance, Polymorphism, and Interfaces. Oh My
Multithreading.
Multithreaded Programming
Threads and Multithreading
Exceptions.
Exceptions.
Presentation transcript:

Lecture13 Java Media Framework II - Java Media Framework II - Processing and Controlling Media with JMF

JMF Timing Model JMF employs a layered approach to its representation of time. At the low-level end of the time model are classes for representing time to nanosecond accuracy. At the high-level end of the model, JMF sees controllers as being in one of a number of states that are transitioned between under program control.

Low-Level Time The Time class specifies a single instant in time. The following are the two constructors of Time class. Time(double seconds) // Time in seconds Time (long nanoseconds) // Time in nanoseconds While Time objects cannot tick, classes that implement TimeBase interface provide a constantly ticking, unalterable source of time. In particular SystemTimeBase class implement the TimeBase interface.

The Clock interface A Clock contains a TimeBase that provides a source of time. The interfaces Controller, Player, and Processor are all sub interfaces of Clock. The time a Clock object keeps is known as the media time.

Media Time The time a Clock object keeps is known as the media time which can be determined as follows: mediaTime = mediaStartT ime + rate*(timeBaseTime − timeBaseStartTime) mediaTime : The media’s own position in time. For instance, if an audio clip was one minute in length, its media time would range between 0 and 60 seconds. mediaStartTime : The offset within the media from which play is started. rate : The rate of time passage for media. A rate of 1 represents normal forward passage, whereas a value of -5 would represent fast rewind. timeBaseTime : The time of the TimeBase object that Clock incorporates. timeBaseStartTime : The time of the TimeBase object at which the Clock is started and synchronized with TimeBase. For instance, the Clock might be started 3.2 seconds after the Clock was created.

The Clock interface The Clock interface could be used to do things such as Being able to start or stop the media at arbitrary locations. Control its rate (for example, fast forward or rewind). The Clock is in one of two possible states: Started or Stoped. The usual steps in starting a clock are: Stop the clock if it is currently started. Set the media (start) time of the clock. Set the rate of the clock. syncStart() the clock.

High Level Time The Controller interface extends the Clock interface. The Controller interface directly extends Clock in three areas: Extends the concept of Stopped into number of states concerning resource allocation, so that time-consuming process can be better tracked and controlled. Provides a event mechanism by which the states can be tracked. Provides a mechanism by which objects providing further control over the controller can be obtained.

States - States - The Controller interface The Controller interface subdivides the Stopped category of Clock interface into five states: Unrealized : A controller that has been created but hasn’t undertaken any resource gathering. At the end of this state, TransitionEvent is generated. Realizing : A transition state reflecting the fact that the Controller is gathering information about the resources needed for its task, as well as gathering resources themselves. At the end of this state, RealizeCompleteEvent is generated. Realized : A steady state reflecting a Controller that has gathered all the nonexclusive resources needed for the task. At the end of this state, TransitionEvent is generated. Prefetching : A transition state reflecting the fact that the Controller is gathering all resources needed for its task that weren’t obtained in the realizing state. Typically this means acquiring exclusive usage resources such as hardware. At the end of this state, PrefetchCompleteEvent is generated. Prefetched : The Controller has acquired all necessary resources, performed all pre-start-up processing, and is ready to be started.

Methods - Methods - The Controller The Controller provides realize(), and prefetch() asynchronous methods in addition to syncStart() from the Clock interface in order to bring the Controller to the respective states.

Player interface While Player interface extends the Controller interface, it adds more power and at the same time retain the same states as that of the Controller. Player relaxes some restrictions that a Controller imposes on what methods can be called on a Started Controller. As a convenience, Player provides a start() method that can be invoked before a Player is Prefetched. This method attempts to transition the Player to the Started state from whatever state it’s currently in. For example, if the Player is Unrealized, start implicitly calls realize(), and prefetch(), (of Controller interface) and syncStart() (of Clock interface). The appropriate TransitionEvents are posted as the Player moves through each state on its way to Started.

The Processor interface The Processor interface extends the Player interface. It is the most central class in many processing tasks. Processor extends the state transition cycle of a Controller by adding the Configuring and Configured states. A ConfigureCompleteEvent is posted when the Processor reaches Configured state. The purpose of these additional states is to further refine the realizing process. The realizing step is essentially split into two phases: Source information gathering - the input DataSource is queried and the input media stream is parsed to get the format information for the tracks in the stream. Construction - the internals of the Processor are constructed to handle the input media stream. Between these two steps, you can program the Processor to perform specific processing on its media stream. The states of a Processor are: Unrealized, Configuring, Configured, Realizing, Realized, Prefetching, Prefetched, and Started.

Methods - Processor interface The Processor has the configure() method to bring it to the Configured state in addition to realize(), prefetch(), syncStart() and start() methods inherited from the Controller, Clock, and Player interfaces. The objects that implement ControllerListener interface can receive events generated by a Controller object (or a Player object or a Processor object). The classes which implement ControllerListener interface must implement the following method: public synchronized void controllerUpdate(ControllerEvent e)

Processing Just like we created imaging chains we can create processing chains using the DataSource class, Processor and Datasink interfaces. These are central to most processing tasks. The following classes are useful in sourcing the media: MediaLocator : Specifies the location and protocol for the media. Closely related to the URL class. Needed to create a DataSource. DataSource : A manager for media transfer. Required to create Players, Processors, or DataSinks. A DataSource can be obtained from a Processor using getOutput() method. This enables chaining the processing tasks. The DataSink interface enable us to write the media into a file.

Playing media using a Processor Since Processor works at a lower level we have to do more than what we did using a Player thus having more added control. Before we start a processor we need to bring it to configured state.

Bringing a Processor to Configured State // … URL url = new URL(getCodeBase(),videoFile); MediaLocator mediaLocator = new MediaLocator(url); try { processor = Manager.createProcessor(mediaLocator); } catch (NoProcessorException npe) { System.out.println("No Processor Exception"); } catch (IOException ioe) { System.out.println("IO error creating player"); } processor.addControllerListener(new VideoControlListener()); processor.configure(); // …

Playing media using a Processor public class VideoControlListener implements ControllerListener { private Processor processor; public void controllerUpdate(ControllerEvent event) { processor = (Processor) event.getSourceController(); if (event instanceof ConfigureCompleteEvent) { // Refer next slide } else if (event instanceof RealizeCompleteEvent){ SwingUtilities.invokeLater(new AddComponentsThread()); } else if (event instanceof EndOfMediaEvent) { processor.setMediaTime(new Time(0)); processor.start(); }

Processing Processing ConfigureCompleteEvent processor.setContentDescriptor(null); TrackControl[] controls = processor.getTrackControls(); for (int i = 0; i < controls.length; i++) { if (controls[i].getFormat() instanceof VideoFormat) controls[i].setFormat(new VideoFormat(VideoFormat.CINEPAK)); else controls[i].setFormat(new AudioFormat(AudioFormat.LINEAR)); } processor.start();

class AddComponentsThread class AddComponentsThread implements Runnable { private Component controlPanel,visualComponent; public void run() { controlPanel = processor.getControlPanelComponent(); if (controlPanel != null) panel.add(controlPanel, BorderLayout.SOUTH); else System.out.println("Unable to create Control Panel"); visualComponent = processor.getVisualComponent(); if (visualComponent != null) panel.add(visualComponent,BorderLayout.CENTER); else System.out.println(" Unable to create Visual Component "); panel.validate(); }

Programming the Processor 1. Create a Processor through the Manager class 2. Bring the Processor to the Configured state using configure(). 3. Set the required ContentDescriptor on the Processor which specifies the content type of the media that will be produced. 4. Obtain the TrackControls of the Processor 5. For each TrackControl Set the required output Format If codecs/effects are to be used for the track Set the TrackControl’s codec chain If the track is to be rendered Set the TrackControl’s renderer 6. Start the Processor

Programming the Processor If the Processor is to render the media to the screen rather than outputting it, Processor’s setContentDescriptor() method should be passed null. A rather restricted form of a realized Processor can be created using the ProcessorModel class. But This method can cause run time failures in certain situations, in partucular when the the Processor output is to be casted as a PushBufferDataSource. We will talk about PushBufferDataSource soon.

using the ProcessorModel class //... URL url = new URL(getCodeBase(),videoFile); MediaLocator mediaLocator = new MediaLocator(url); Format[] formats = new Format[1]; formats[0] = new VideoFormat(VideoFormat.CINEPAK); ContentDescriptor outputType = null; ProcessorModel processorModel = new ProcessorModel(mediaLocator,formats,outputType); try { processor = Manager.createRealizedProcessor(processorModel); } catch (CannotRealizeException cre) { System.out.println("Cannot Realize Processor"); } catch (NoProcessorException npe) { System.out.println("No Processor Exception"); } //...