Broadcast Tutorial

Getting Started

The first concept to learn is the Headend. The Headend will contain all the data to be handled and broadcasted by the system.

So first thing to do is to create a new headend:
// Init the dvb library (descriptors, tables, etc. are properly registered)

// Create or open the Headend
String uri = "file:///home/user/myheadend.jbc"
DVBHeadend headend = new DVBHeadend(uri, new Properties());

Notice that opening an already existing Headend can be done by exactly the same code.

In order to work with a Headend you'll need to create a new session:

// Create a new session
DVBSIBroadcastManager datamgr = (DVBSIBroadcastManager) headend.getDataBroadcastManager("mysession");

Each session holds its own copy of the SI data from the Headend.
The benefit of using session based mangament of the data is that it allows you to perform several changes on the data, and apply them all at once, so that the changes are broadcasted in one atomic operation.

Now will get a "service" session:

DVBServiceBroadcastManager servicemgr = datamgr.getServiceManager();

So what's that? In JBroadcast you've got two types of session managers:
  • DataManagers allow you to directly handle the underlying tables, descriptors, streams, etc. Use this when requiring to manipulate low level details of the SI (such as descriptors, distribution of the tables, etc.).
  • ServiceManagers allow you to manipulate the data on top of a higher level abstraction layer. When operating on a service Manager (i.e: creating a new service) it will take care of all the underlying actions that are needed (i.e: creating the PMT, the entry inside the PAT, the SDT actual&other, etc.)
All changes are done in real time, so both the DataManager and the associated ServiceManager remain in sync.

So let's start with the real stuff
// Create two transports
DVBSITransportStreamLocator locator0 = new DVBSITransportStreamLocator("dvb://10.20");
Transport transport0 = servicemgr.createTransport(locator0);
DVBSITransportStreamLocator locator1 = new DVBSITransportStreamLocator("dvb://10.21");
Transport transport1 = servicemgr.createTransport(locator1);

// Create a network
ArrayList<Transport> transportList = new ArrayList<Transport>();
DVBNetwork network = sm.createNetwork(new DVBNetworkLocator(0x07), transportList);

// And a service in transport 1
Service service = sm.createService(new DVBServiceLocator(locator0, 0xa7));

So what have we done so far? We've created two Transports and a Service. Transports carry out all the information. This is managed internally as a Transport Stream by the DataManager.
Both Transport Streams are populated with their PAT, default NIT (using the original network id), SDT elementary stream, etc.

Then we've created a network, with the two transports. Internally this is translated to the creation of a NIT table in each of the transport streams. 

Later on we have created a new service with id 0xa7, which produces the following actions:
  • A PMT with program id 0xa7 is created.
  • An entry in the PAT is created
  • SDT actual with service id 0xa7 in the Transport Stream associated with transport0
  • SDT other with service id 0xa7 in the Transport Stream associated with transport1