C H A P T E R  10

Streaming API

The Sun Java System Content Delivery Server Streaming API provides an interface between Content Delivery Server and the streaming server of your choice. Use this API to write a streaming adapter to work with your streaming server.

The Streaming API consists of the following classes and interfaces:

The classes and interfaces for the Streaming API are in the com.sun.content.server.streaming package. For additional information on these classes and interfaces, see the HTML output of the Javadoc tool at $CDS_HOME/javadoc/cdsapi/index.html.


10.1 General Process Flow

The streaming adapter, which is your implementation of the StreamingAdapter interface, manages the transfer of data to the streaming server and the delivery of data to the subscriber.

This section describes the following interactions between Content Delivery Server and the streaming server:

10.1.1 Stocking

When on-demand streamed content is stocked by the Vending Manager, Content Delivery Server creates a StreamingContent object that describes the content. The uploadContent method is then called to transfer the content to the streaming server. If an error occurs, the streaming adapter must throw a StreamingException. If the streaming adapter cannot connect to the streaming server, the streaming adapter must throw a StreamingServerConnectionFailedException. When Content Delivery Server sees an exception, the stocking process is stopped and the content is not stocked.

10.1.2 Unstocking

When on-demand streamed content is unstocked by the Vending Manager, Content Delivery Server creates a StreamingContent object that describes the content and calls the deleteContent method to remove the content from the streaming server. If an error occurs, the streaming adapter must throw StreamingException. If the streaming adapter cannot connect to the streaming server, the streaming adapter must throw StreamingServerConnectionFailedException. If Content Delivery Server sees an exception, the content is still marked as unstocked and becomes unavailable to subscribers.

10.1.3 Purchasing

When a subscriber purchases content or requests free content, one of the following actions is taken:


10.2 StreamingAdapter Interface

The StreamingAdapter interface is used to communicate with the streaming server that you are using. Implement this interface to create the streaming adapter for your streaming server.

10.2.1 addInfoToSDPContent Method

public byte[] addInfoToSDPContent(byte[] binary, long categoryItemId, String contentId, String inCodedTicket, String fileExtension, String contentName, long mimeTypeId, String vendingAccountId) throws StreamingServerConnectionFailedException, StreamingException;

The addInfoToSDPContent method is called by Content Delivery Server when a subscriber purchases streamed content that is represented by an SDP. Use this method to add additional encoded information to the SDP file. For example, this method can be used to add additional parameters to the URL that might be needed by Content Delivery Server or the streaming server that you are using, such as coded ticket or subscriber identifier. If an error occurs, make sure that your implementation throws the appropriate exception.

10.2.2 deleteContent Method

public void deleteContent(StreamingContent streamingContent, String vendingAccountId) throws StreamingServerConnectionFailedException, StreamingException;

The deleteContent method is called by Content Delivery Server when streamed content is unstocked by a Vending Manager. Use this method to remove content from the streaming server. Pass in the object that describes the content and the ID of the Vending Manager that stocked the content. If an error occurs, make sure that your implementation throws the appropriate exception.

10.2.3 getSDP Method

public byte[] getSDP(long categoryItemId, String contentId, String inCodedTicket, String fileExtension, String contentName, String vendingAccountId, String liveURL) throws StreamingServerConnectionFailedException, StreamingException;

The getSDP method is called when a subscriber requests access to streaming content that is represented by an SDP file. Use this method to return the SDP for the content identified by contentId. If your streaming server provides access to content through a URL only, you do not need to implement this method. If an error occurs, make sure that your implementation throws the appropriate exception.

10.2.4 getStreamingURL Method

public String getStreamingURL(long categoryItemId, String contentId, String inCodedTicket, String fileExtension, String contentName, long mimeTypeId, String vendingAccountId, String liveURL) throws StreamingServerConnectionFailedException, StreamingException;

The getStreamingURL method is called when a subscriber purchases streamed content. Content Delivery Server provides information that identifies the content and the purchase transaction. Use this method to provide the URL that the subscriber needs to access the item. If your streaming server does not provide access to content through a URL, you do not need to implement this method. If an error occurs, make sure that your implementation throws the appropriate exception.

10.2.5 returnsSDP Method

public boolean returnsSDP();

The returnsSDP method is called by Content Delivery Server to determine whether content on the streaming server is accessed through an SDP file or through a URL. Return true if content is accessed through an SDP file and implement the getSDP method. Return false if content is accessed through a URL and implement the getStreamingURL method.

10.2.6 uploadContent Method

public void uploadContent(StreamingContent streamingContent, String vendingAccountId) throws StreamingServerConnectionFailedException, StreamingException;

The uploadContent method is called by Content Delivery Server when streamed content is stocked by a Vending Manager. Use this method to copy content to the streaming server. Pass in the object that describes the content and the ID of the Vending Manager that stocked the content. If an error occurs, make sure that your implementation throws the appropriate exception.


10.3 Using the Streaming API

The classes for the Streaming API are available in cdsapi.jar, which is found in the $CDS_HOME/deployment/deployment-name/lib/cdslib directory. This file must be in your classpath when you compile your adapter. For convenience, a copy of all Content Delivery Server JAR files are available in the $CDS_HOME/dist/cds/staging/jar directory. Use this staging area in your classpath when compiling the adapter that you create.

Making your adapter available to Content Delivery Server depends on the application server you are using and whether you have already deployed. To make your adapter available, follow these steps:

1. Create a JAR file for your adapter.

2. For all application servers, place the JAR file in the $CDS_HOME/dist/cds/lib/external directory.

The adapter is now included in all future deployments.

3. If you have existing deployments that need to use the adapter, place the JAR file in the $CDS_HOME/deployment/deployment-name/lib/external directory for each deployment.

If you are using WebLogic Server, the classpath is handled for you.

If you are using Sun Java System Application Server, update the classpath for each deployment:

a. Back up the $CDS_HOME/deployment/deployment-name/sun/domains/cdsdomain/config/domain.xml file before editing it so you can recover from any errors that might be introduced during editing.

b. Edit domain.xml and modify the java-config element to add the absolute path for your JAR file to the classpath-suffix attribute.

c. Save your changes.

4. In the streaming.properties file in the $CDS_HOME/deployment/deployment-name/conf directory, set the streaming.adapter.impl.class property to the fully qualified name of your streaming adapter.

5. Restart any existing deployment to make it aware of the new JAR file.