Articles
Java Platform, Micro Edition
|
| By Bruce Hopkins, April 2009 |
|
| |
This article introduces the concept of interactive TV, provides an overview of Tru2way technology, and shows you how to get started with Tru2way application development.
If you're reading about the Tru2way platform for the first time, you might be asking yourself the question, "Is it really possible to have a Java-enabled TV?" Or, better yet, "Is it possible to put a JVM machine inside my cable set-top box?" The answer to both questions is yes, and you don't have to wait 5 or 10 years for this technology to come to fruition because it's already available today in millions of homes throughout the United States. Tru2way is the brand name for interactive digital cable services delivered over the cable video network, and OCAP (Open Cable Application Platform) is the Java standard for Tru2way devices. This article introduces the concept of interactive TV, provides an overview of Tru2way technology, and shows you how to get started with Tru2way application development. Figure 1 shows a photo of Panasonic's VIERA HDTV integrated with Tru2way technology.
So what exactly is the Tru2way platform? Tru2way is a digital media platform that facilitates the delivery of interactive digital content over the cable video network. Tru2way is joint effort between cable operators and consumer electronics device manufacturers, including set-top box and TV manufacturers. The following is a list of companies that have licensed Tru2way technology:
So what does it mean to have a Tru2way-enabled CE (consumer electronic) device? First, a Tru2way-enabled TV is able to receive interactive content from a cable operator without the use of a set-top box. Additionally, a Tru2way-enabled set-top box allows consumers without a Tru2way-enabled TV to experience interactive TV. Finally, a Tru2way-enabled portable DVR allows consumers to experience interactive TV content while on the go.
The following list of cable operators are implementing Tru2way technology:
So what does it mean for your cable operator to support Tru2way technology? Simply stated, the cable operator is providing an interactive TV experience that can be consumed by Tru2way-enabled devices. If you're still unsure about what interactive TV is, and how to use it, here are a few examples:
Now that you have a basic understanding of the capabilities of the Tru2way platform, let's take a deeper look at the OCAP Java APIs that enable the content on the Tru2way platform to be truly interactive.
As you might have guessed, the Tru2way platform and the OCAP Java APIs share several attributes with the Blu-ray platform and the BD-J (Blu-ray Disc for Java) APIs; namely:
To create interactive TV applications for the Tru2way platform, you first need to understand some of the underlying components and concepts. To start things off, we first need to review some of the terminology that's commonly used for Interactive TV applications:
Now that we've covered the concepts and terminology used for OCAP applications on the Tru2way platform, let's dive right into our first application!
In Code Example 1, you'll notice a recap of the concepts and features that are either presented above or are outlined in the Blu-ray series of articles, Blu-ray Disc Application Development with Java ME, Part 1: Creating Your First Application and Part 2: Responding to User Input.
Code Example 1:
ServiceSelectionXlet.java
import java.awt.event.KeyEvent;
import javax.tv.service.SIManager;
import javax.tv.service.Service;
import javax.tv.service.selection.ServiceContext;
import javax.tv.service.selection.ServiceContextException;
import javax.tv.service.selection.ServiceContextFactory;
import org.davic.net.InvalidLocatorException;
import org.dvb.event.EventManager;
import org.dvb.event.UserEvent;
import org.dvb.event.UserEventListener;
import org.dvb.event.UserEventRepository;
import org.havi.ui.HScene;
import org.havi.ui.HSceneFactory;
import org.ocap.net.OcapLocator;
import org.ocap.ui.event.OCRcEvent;
public class ServiceSelectionXlet implements javax.tv.xlet.Xlet, MenuListener, UserEventListener{
private javax.tv.xlet.XletContext xletContext;
HScene scene;
Menu m;
ServiceContext sc;
public void initXlet(javax.tv.xlet.XletContext ctx)
throws javax.tv.xlet.XletStateChangeException {
this.xletContext = ctx;
scene = HSceneFactory.getInstance().getDefaultHScene();
scene.setSize(600,440);
scene.setLocation(40, 40);
m = new Menu(this, ctx);
ServiceList services = SIManager.createInstance().filterServices(null);
ServiceIterator iterator = services.createServiceIterator();
while (iterator.hasNext()) {
Service s = iterator.nextService();
m.addItem(s.getName(), s.getLocator());
}
scene.add(m);
UserEventRepository uer = new UserEventRepository("menu");
uer.addUserEvent(new UserEvent("", UserEvent.UEF_KEY_EVENT,
KeyEvent.KEY_PRESSED,
OCRcEvent.VK_GUIDE,
0, 0L));
EventManager em = EventManager.getInstance();
em.addUserEventListener(this, uer);
try {
sc = ServiceContextFactory.getInstance().createServiceContext();
} catch (SecurityException e) {
e.printStackTrace();
} catch (ServiceContextException e) {
e.printStackTrace();
}
}
public void startXlet()
throws javax.tv.xlet.XletStateChangeException {
scene.validate();
scene.show();
m.getFocus(0);
}
public void pauseXlet() {
}
public void destroyXlet(boolean forced)
throws javax.tv.xlet.XletStateChangeException {
}
public void menuItemSelected(Object payload) {
Locator loc = (Locator)payload;
m.setVisible(false);
this.selectService(loc);
}
public void userEventReceived(UserEvent arg0) {
if (m.isVisible()) {
m.setVisible(false);
}
else {
m.setVisible(true);
m.getFocus(0);
}
}
public void selectService(Locator loc) {
SIManager siManager = SIManager.createInstance();
if (siManager != null) {
try {
Service service = siManager.getService(loc);
sc.select(service);
} catch (SecurityException e1) {
e1.printStackTrace();
} catch (javax.tv.locator.InvalidLocatorException e1) {
e1.printStackTrace();
}
}
}
}
After examining the import statements in the preceding code example, you can see all the various libraries and APIs that are required to create a basic OCAP application: the Foundation Profile, Personal Basis Profile, Java TV, and GEM/MHP APIs. The purpose of this application is to accept input from the user and select a service.
Did you notice that this class implements the
UserEventListener interface? This means that when a user event is received, the
userEventReceived() callback method is called by the JVM, which gives you the opportunity to handle that event, namely when the user presses a key on the remote control. As you might recall from Figure 3, it is possible for the
startXlet() method to get called multiple times in the normal lifecycle of an OCAP application. So as you can see, I performed all my initialization work in the
initXlet() method.
If you have prior experience with the BD-J APIs (and as you examine the code in Code Example 1), then you can see that the code is strikingly similar for screen rendering, service selection, and responding to user input from the remote control. This is no coincidence; the OCAP and BD-J API were designed from the same underlying framework, so that basic operations are the same, no matter which API you use.
What's the best way to get started with Tru2way technology and OCAP development? First of all, the easiest thing to do is to join the OpenCable Project on Java.net, because it's a major source of news and information for OCAP developers. The next step is to get your hands on a software developer kit, and most of them require license fees. See the following list of OCAP tools and SDKs to help you get started, and be sure to note that all of these development tools require a Windows-based PC.
The Tru2way initiative will continue to grow and evolve over the coming years. If you want to become involved as a developer, CableLabs.com and the OpenCable Project located on Java.net are great places to get up to speed on the latest information on the Tru2way platform. The OpenCable Project is also helpful for obtaining developer tools, asking questions, and learning about CableLabs events such as developer conferences and interoperability events.
Acknowledgments
I'd like to thank all the helpful folks around the interactive TV industry who helped me improve this article, namely Phil Bender (Cable Labs), Anne Dirkse (Enable TV), Frank Goddard and Charles Samuelson (Motorola), Jenni Moyer (Comcast), Andy Abendschein (Vidiom), and Albert Cañigueral (Osmosys).
| |
| |
We welcome your participation in our community. Please keep your comments civil and on point. You can optionally provide your email address to be notified of repliesyour information is not used for any other purpose. By submitting a comment, you agree to these Terms of Use.