Creating Interactive TV Applications With the Tru2way Platform and OCAP

 
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.

Contents
 
Introducing the Tru2way Platform
Comparing OCAP and BD-J API
Understanding the Concepts of Interactive TV
Creating Your First Tru2way Application: Selecting a Service
How to Get Started
Summary
 
If you're reading about Tru2way for the first time, you might be asking yourself, "Is there a JVM in my TV?"

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.

Panasonic VIERA HDTV With Tru2way Technology
Figure 1: Panasonic VIERA HDTV With Tru2way Technology
 

Introducing the Tru2way Platform

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:

  • ADB (Advanced Digital Broadcast)
  • Alticast
  • AMD
  • Broadcom
  • Cisco
  • Digeo
  • EchoStar
  • Funai
  • Intel
  • LG Electronics
  • Motorola
  • Pace
  • Panasonic
  • Samsung
  • Sony
  • Texas Instruments
  • Thomson
  • Toshiba

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:

  • Brighthouse Networks
  • Cablevision
  • Charter
  • Comcast
  • Cox Communications
  • Time Warner Cable
The Really Serious News (RSN) TV Network Displays a Menu to Allow the User to See Additional Content
Figure 2: The Really Serious News (RSN) TV Network Displays a Menu to Allow the User to See Additional Content

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:

  • Basic Gaming: Are you waiting for your favorite show, and have a few minutes to kill? Tru2way technology allows you to play a basic game with your TV remote control. Games such as this don't need to be incorporated into a particular show (think of the term "unbound"), and are available from a simple menu selection. The OCAP Java APIs are fully featured, so you have everything you need to receive input commands from the remote, handle your algorithms for your game's logic, and render images, graphics, and video on the screen.

  • Live TV Gaming: Have you ever watched a live broadcast of a game show and wanted to play along? Tru2way technology allows the cable operator to not only broadcast the audio and video content of your desired TV show, but additionally enable an interactive application that is tied (or "bound") to the audio and video content. This allows home viewers to use their remote to play along with the show.

  • Voting Applications: Although it might be a while before you're able to cast votes in a presidential election from your TV, Tru2way technology is already in place to allow you to vote for your favorite singer on the popular reality TV series, American Idol. Interactive voting applications also have significance beyond reality TV programs. Content providers can use voting applications to gauge consumers' reaction to changes in the story or plot in a TV drama. This way, you can decide who shot J.R. (or whatever the equivalent plot point is in your part of the world).

  • Custom Program Guide: The electronic program guide (EPG) is a wonderful invention. It allows you to see every channel in your subscription, as well as some metadata about the upcoming shows that will air in the future. However if you have a lot of channels in your subscription, the EPG can be cumbersome to use. An EPG application provided by Tru2way technology can be customized for each member of the family. So, for instance, a customized EPG can filter your guide on a channel-by-channel basis. This way, I can see the Science Channel and the NASA Channel together without having to navigate through all 30 channels that are between them. Additionally, the Java APIs in the Tru2way platform can also allow you to create an EPG that's even more robust. Imagine a program guide that leverages the metadata provided for each show so that you can specify a subject that you're interested in (such as sports, politics, finance, comedy, and so on) or by the program rating (such as TV-Y, TV-Y7, TV-PG), or by the starring actors (such as Eddie Murphy, Angelina Jolie, or Bruce Willis). The possibilities are endless!

  • Interactive News: If you're a busy person, you might not have time to sit through an entire one-hour news broadcast. However, the Tru2way platform provides the capability for an interactive news program. This means that, for instance, you can see all the news headlines that are covered in the program. In fact, Figures 2 and 3 show a modified example from the Enable TV Vision Workbench SDK with a hypothetical interactive news channel named "RSN."
RSN TV Network Now Displays a List of Topics Covered During the News Broadcast
Figure 3: RSN TV Network Now Displays a List of Topics Covered During the News Broadcast

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.

Comparing OCAP and BD-J API

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:

  • Both are based on the Java ME CDC JVM platform.

  • They both leverage multiple Java ME specifications:

    • Foundation Profile
    • Personal Basis Profile
    • Java TV API
    • Multimedia Home Platform (MHP)
    • Globally Executable MHP (GEM)

  • The primary user input device is a remote control.

  • The primary output device is a TV screen.

  • Both are capable of playing pre-recorded and live video content.

  • Both share the same application lifecycle. See Figure 4 for more information on the application lifecycle for OCAP applications.
Various States of OCAP Xlet Applications
Figure 4: Various States of OCAP Xlet Applications
 

Understanding the Concepts of Interactive TV

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:

  • Bound application: An application that is tied to a service in order to operate. When the user selects another service, then (in most cases) the application is terminated.

  • MPEG-2 transport stream: The binary stream of data that delivers the audio, video, and interactive content to Tru2way-enabled devices (TVs, set-top boxes, and so on). The transport stream originates from the cable operator and terminates at the cable installation.

  • Return channel: A separate bidirectional data connection between the Tru2way-enabled device and the cable operator. All Tru2way-enabled devices include a cable modem that enables the device to have a high-bandwidth connection back to the cable operator.

  • Service: Conceptually, a service is a TV channel. However, a service is actually an integrated collection of audio, video, and program data that's presented together.

  • Unbound application: An application that is not tied to a specific channel and can run independent of any service. Unlike bound applications, an unbound application continues to run after the user navigates to other services.

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!

Creating Your First Tru2way Application: Selecting a Service

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.

How to Get Started

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.

  • Java TV SDK: If you're looking into writing some basic applications for the TV, try out the freely available Java TV SDK. This SDK is compatible with the NetBeans 6 IDE and provides an additional emulator platform that allows you to develop CDC applications. This SDK includes an implementation of the following APIs:

    • Connected Device Configuration (CDC) 1.1
    • Foundation Profile 1.1
    • Lightweight UI Toolkit (LWUIT) for CDC 1.0

  • Enable TV VISION Workbench: The Enable TV VISION Workbench includes an OCAP Project wizard that enables you to quickly create or import an OCAP project. The wizard defines your application template, sets up your build environment, and generates the OCAP properties configuration file for launching applications in the simulator. The VISION Workbench includes sample OCAP application projects and source code that show you how to use the OCAP APIs to accomplish various tasks such as loading applications, tuning, processing user input, and scaling video.

  • Osmosys SDK: The Osmosys SDK 2.2 allows developers to create both OCAP and MHP applications. If you have a PC/SC smart card reader attached to your PC, the Osmosys SDK can leverage your card reader to allow you to use the Security and Trust Services APIs (SATSA) to process certificate data from a smart card. The SDK has support for DVR applications and has the ability to process MPEG-2 transport streams stored on the hard drive. Finally, the Osmosys SDK has ability test your application using its built-in emulator, or you can provision and test your application on an ADB set-top box.

  • Motorola DEVPlatform for OCAP: Motorola's DEVPlatform for OCAP is a unique product offering for Tru2way developers that includes both software and hardware to aid in application development and testing. The hardware component of the SDK is a Tru2way-enabled set-top box, which gives the developer the ability to load, test, and debug their applications on an actual set-top box in real time. The software components of the SDK include an IDE that contains the OCAP libraries as well as multiple simulators. One of the simulators is a set-top simulator that allows developers to run and test their applications on a PC. The other simulator is a head-end simulator that delivers MPEG-2 transport streams to the set-top simulator and set-top hardware. The SDK also includes the ability to perform code profiling and advanced debugging of your application. Figure 5 shows a screenshot of the Motorola DEVPlatform for OCAP.
 
Screenshot of the Motorola DEVPlatform for OCAP
Figure 5: Screenshot of the Motorola DEVPlatform for OCAP
 

Summary

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).

 
Rate This Article
 
Discussion

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 replies—your information is not used for any other purpose. By submitting a comment, you agree to these Terms of Use.