Introduction to the DVB Multimedia Home Platform (MHP)

Download Report

Transcript Introduction to the DVB Multimedia Home Platform (MHP)

Developing DVB-Java Applications
Richard Houldsworth
Philips Research
[email protected]
lmtb
TRAD
Overview
 This presentation is an introduction to
programming for DVB-Java.
 How to get started.
 Technical details of key DVB-J concepts
 Hints on how to use the APIs for typical Xlets
and EPGs.
lmtb
TRAD
Infrastructure for App. Development
 You can start Java development on your favourite
computer using JDK or whatever.
 Need some minimal MHP APIs (e.g. JavaTV ref. impl).
 Does not easily allow testing of UIs on a TV
 Access to developer version of an MHP STB
 A much better simulation of the target environment
 For optimising your application's start-up time...
 DSMCC object carousel builders
 MPEG multiplexer / modulator to interface to STB
lmtb
TRAD
Application Environment
 Standard Java VM.
 MHP services can include multiple applications
 Your application may need to execute at the same time
as other applications in that service context (e.g. an
EPG).
 The application manager controls:
 STB resources - you need to negotiate for resources.
 Application lifecycle - the application can be terminated
at any time on service selection.
 Your application needs to work reliably in these
constraints
lmtb
TRAD
Entry Point: Xlet
 Applications must define a class which implements the
javax.tv.xlet.Xlet interface.
 Like java.applet.Applet but simpler & without historical
browser 'baggage'.
 Methods are normally called in this sequence
 initXlet(), startXlet(), {later} destroyXlet()
 initXlet() is where most initialisation should be done
 startXlet() is where scarce resources should be acquired
 Called by the MHP "application manager”, which sets up
an XletContext for the Xlet.
lmtb
TRAD
Context Hierarchy
Service Context 1
Java
Media
Player
Service Context 2
Xlet Context
Xlet Context
Xlet Context
Xlet A
Xlet B
Xlet C
Application Manager
lmtb
TRAD
Application Delivery
 Think about how much bandwidth will be available in the
network for your application.
 Very simple example
 256 Kbits/second bandwidth available for app.
 App. has 4 x 100KByte images and 120KBytes of Java
class files.
 520KBytes @ 256 Kbits/second = 16 seconds
 How long will people wait for this application to start?
 Somebody often needs to restrain the designers!
lmtb
TRAD
Broadcast Data: java.io
 DSMCC object carousels appear as a (read-only) file
system.
 Classloader search path is initialised based on broadcast
signalling before an application is started.
 Normal File classes from java.io work fine.
 e.g. new java.io.FileInputStream("my_data.dat")
 Classes building on java.io.File work fine.
 e.g. Toolkit.getImage(“background.jpg”)
 Overall behaviour very like a standalone Java application
- it is not very similar to Applet (it doesn’t use URLs)
lmtb
TRAD
Broadcast Data: org.dvb.dsmcc
 The org.dvb.dsmcc package extends java.io . It supports
asynchronous functions for broadcast file systems.
 DSMCCObject.asynchronousLoad()
DSMCCObject.addObjectChangeEvent()
 DSMCCStreamEvent.subscribe()
 Use ServiceDomain.attach() to attach to another object
carousel
 For early development, treat DSMCC as a normal file
system. Use extended API when you need fine control
over your broadcast data.
lmtb
TRAD
Other data sources
 MPEG-2 section filter API: org.davic.mpeg.sections
 Useful for non-MHP data broadcast protocols,
 e.g. sharing images between MHP and existing
boxes. Even accessing Data Carousels.
 IP interface: java.net
 Used for both return (bidirectional) and broadcast
channels (multicast)
 org.dvb.net.DatagramSocketBufferControl provides
some extensions to give better control over multicast.
 For control of the return channel: org.dvb.net.rc
lmtb
TRAD
User interface: TV display
 There are differences between TV and computer displays:
 picture aspect ratio (4:3, 14:9, 16:9)
 overscan - assume 5% loss around the edge.
 pixel aspect ration (non 1:1) - prescale bitmaps or use
java.awt.Graphics.stretchImage()
 colour space - the AWT surface is sRGB, but the internal
display format may be YUV, with limited colour resolution,
or palettized.
 interlacing - avoid using single pixel lines, avoid high
contrast between adjacent pixels. Pre-filter bitmaps.
 Graphics possibly not accurately aligned with video.
 Possibly a limited number of alpha levels
lmtb
TRAD
User Interface: java.awt
 MHP uses the standard java.awt package
 Lightweight components
 JDK 1.1.x event model
 No "classical" UI widgets - too computery for TV
 No requirement for a windowing system
 Support for overlapping windows not required
lmtb
TRAD
User Interface: org.dvb.ui
 DVB Extensions to AWT : org.dvb.ui.DVBColor provides alpha (i.e. transparency
through graphics to video)
 org.dvb.ui.DVBGraphics - supports alpha composition.
 org.dvb.ui.DVBBufferedImage - a writeable buffer of
image data - good for double buffering and effects.
 org.dvb.ui.DVBTextLayoutManager allows simple
display of formatted text
 These extensions are similar to parts of Java 2 AWT - you
can prototype on JDK 1.3, but be aware of the
differences. Also consider the performance cost of alpha.
lmtb
TRAD
User Interface : org.havi.ui
 Widget set more graphically oriented than java.awt (e.g.
icons, animations)
 HLook interface allows pluggable look&feel.
 HNavigable.setFocusTraversal() allows applications to
describe a focus navigation map (up/down/left/right)
 Device framework
 HScreenDevice & sub-classes allow applications to
access a model of the graphics, video & background
devices in a system, and request a configuration.
 Extra key codes for remote controls
 org.havi.ui.event.HRcEvent
lmtb
TRAD
User Interface: Getting the root container
 Your application can get its top level UI container in 2
ways.
 javax.tv.graphics.TVContainer.getRootContainer()
 Returns an invisible {0,0} size container
 Size & position the container by hand
 Methods on org.havi.ui.HSceneFactory
 Allow applications to be more expressive about what
they really want. Returns an HScene object.
lmtb
TRAD
User Interface: Configuring the scene
 Each Xlet has an HScene representing a region of the TV
display.
 Create from the HSceneFactory using an
HSceneTemplate with the desired properties
Application
creates
HSceneTemplate
getBestScene(template)
HScene
creates
HSceneFactory
 Similar model used for HScreenDevice
lmtb
TRAD
User Interface: Drawing your components
 Several different ways of approaching this in your
applications.
 Draw everything using java.awt.Graphics primitives
 Define your own lightweight components extending
java.awt.Component.
 Can implement org.havi.ui.HNavigable for
extended navigation
 Use the HAVi widget set
 Can define your own appearance if you need.
 Consider code size and impact on performance.
lmtb
TRAD
User Interface: User input
 There is no mouse input, and only a few key codes.
 Only one AWT component has input focus at any time
 No other components receive input events
 The org.dvb.event API traps input events before they
enter AWT
 Allows applications to register an interest in a subset of
the input events - its UserEventRepository
 it can register exclusive access to these
 Consider this early in your design process
 Test it on TVs & with TV remote controls very early
lmtb
TRAD
Controlling Media: javax.media
 Applications can have basic control of video and audio
with the Java Media Framework.
 Based on JMF 1.0
 Use org.davic.net.dvb.DVBLocator to select what to
show:
dvb://<original network ID>.<transport stream ID>.<service id>[.<event ID>]
[;<component tag>]
 Applications can obtain running JMF players.
 Needed for applications running as part of a TV service
to get access to already running A/V.
 See javax.tv.service.selection.ServiceMediaHandler
lmtb
TRAD
Controlling Media: javax.tv.media
 MHP provides a number of extra JMF controls
 For video scaling...
 javax.tv.media.AWTVideoSizeControl (simple)
 org.dvb.media.BackgroundVideoPresentationCo
ntrol (flexible)
 Platforms aren't required to support unlimited video
scaling
 Control and monitoring of subtitles, service components
 Fine control over audio playback from memory
 org.davic.media.MediaTimePositionControl
 Notification of changes in incoming TV signals
 video size, aspect ratio, ...
lmtb
TRAD
Synchronising with Media
 DSMCC stream events
 org.dvb.dsmcc.DSMCCStreamEvent.subscribe()
 org.davic.media.StreamEventControl.subscribeStrea
mEvent()
 Use media time (NPT)
 org.davic.media.MediaTimeEventControl
 Use a private section
 org.davic.mpeg.sections
 Choice really determined by the broadcaster - the data
needs to be injected at the right time in the right format.
lmtb
TRAD
EPGs: Service Information
 There are some APIs that are only useful for non-service
bound applications (e.g. Electronic Program Guides)
 i.e. the application is signalled on all services.
 Access to broadcast service information
 DVB-SI API - org.dvb.si
 Gives access to all the low level detail of DVB-SI for
those who know how to use that.
 JavaTV SI API - javax.tv.service, javax.tv.service.guide
 A high level abstract view
 Beware: many broadcast networks don't follow the DVBSI specification very well or very completely.
lmtb
TRAD
EPGs: Service Selection
 Previewing a TV service
 Get ServiceContentHandler objects to access JMF.
 Using JMF, an EPG can preview a TV service without
starting any associated applications.
 Really selecting a TV service (incl. applications)
 Get ServiceContext from ServiceContextFactory
 Use javax.tv.service.selection.ServiceContext.select()
 This kills locally signalled Xlets. Don’t use unless you
really ‘own’ the service context.
lmtb
TRAD
Hints: Speed
 Optimising application launch time




Consumers are impatient - they won't wait for TV.
Get user interaction working quickly.
Make use of asynchronous asset loading (e.g. images)
Look at the files needed by your application to get the
initial display - fine tune your broadcast so those are
loaded together & quickly.
 Image decode time is significant - e.g. fullscreen JPEGs
 Analyse major transitions between different parts of your
application.
 Think about pre-loading assets you are likely to need
lmtb
TRAD
Hints: Cleanup
 Check your application cleans up after itself
 cause any threads you created to exit voluntarily.
 stop(),deallocate() and close() any JMF players you
created.
 stop() and destroy() any ServiceContext objects you
created.
 flush any images using the Image.flush() method.
 have no unnecessary delays in your Xlet.destroyXlet()
method.
 Doing this is a matter of being considerate to other
applications running in the box.
lmtb
TRAD
General Hints
 An STB is not a high-end platform
 don’t expect PC performance
 Reliability and robustness are vital
 people will not tolerate unreliable applications in the
consumer environment
 unreliable applications make the STB look unreliable
 Remember that your application may be paused and
resumed at any time
 Resources are very scarce, and you may lose them at
any time
 but you may also get them back at any time
lmtb
TRAD