DVBStreamExplorer service XML files

DVBStreamExplorer has the feature to save service information as XML files. This can either be done explicitly from File->Export->XML menu, or it can be saved automatically on completion of a multiple MUX scanning session.
The folder where to save automatically can be set on Options->preferences menu on SI Scan tab.

The XML file contains information about all the services found during SI scan by analysing PAT, PMT, NIT, SDT and NIT tables. Post processing this XML file can have many useful applications.
In this post I will be demonstrate how to read the service XML file and post content to a web service encoded in JSON. For instance this could be used to feed an on-line web application with service data.

Service

Information about one service is stored in one XML element.
An example of a service XML element is shown below.

<service position=”Astra 19.2°E” frequency=”11303″ polarity=”H” symbolrate=”22000″ fec=”2/3″ modulation_system=”1″ modulation_type=”2″ roll_off=”0″ name=”ORF1 HD” provider=”ORF” network_type=”dvbs” network_name=”ASTRA 1″ onid=”1″ nid=”1″ tsid=”1007″ sid=”4911″ pmt=”107″ pcr=”1920″ type=”25″ free_ca_mode=”1″ lcn=”-1″>
<ca_list>
<ca CA_system_ID=”3333″ CA_PID=”220″ private_bytes=””/>
<ca CA_system_ID=”3477″ CA_PID=”270″ private_bytes=””/>
<ca CA_system_ID=”1608″ CA_PID=”120″ private_bytes=””/>
<ca CA_system_ID=”5890″ CA_PID=”320″ private_bytes=””/>
<ca CA_system_ID=”6195″ CA_PID=”420″ private_bytes=””/>
<ca CA_system_ID=”2500″ CA_PID=”480″ private_bytes=””/>
<ca CA_system_ID=”2444″ CA_PID=”490″ private_bytes=””/>
<ca CA_system_ID=”3480″ CA_PID=”272″ private_bytes=””/>
<ca CA_system_ID=”1616″ CA_PID=”122″ private_bytes=””/>
</ca_list>
<streams>
<stream type=”27″ pid=”1920″ type2=”14496-10″>
<ca_list/>
</stream>
<stream type=”4″ pid=”1921″ language=”ger” type2=”13818-3″>
<ca_list/>
</stream>
<stream type=”4″ pid=”1922″ language=”eng” type2=”13818-3″>
<ca_list/>
</stream>
<stream type=”6″ pid=”1923″ language=”ger” type2=”ac3″>
<ca_list/>
</stream>
<stream type=”6″ pid=”1925″ type2=”teletext”>
<ca_list/>
</stream>
<stream type=”5″ pid=”7310″ application_name=”ORF HbbTV – SAT HD” type2=”hbbtv”>
<ca_list/>
</stream>
<stream type=”11″ pid=”7311″ type2=”data”>
<ca_list/>
</stream>
</streams>
</service>

As it can be seen there is quite some information. This includes properties like name, provider, tuner parameters, NID/ONID/TSID/SID and more. It also includes CA information, both from first loop of descriptors and the loop for each stream.
Each stream contains a type field which is simply the stream_type field from PMT. It contains a type2 field. The value is decided after analysing of stream_type field and certain descriptors. Besides benefaction of various audio and video streams this will also identify certain features and applications such as teletext, subtitle, mhp, hbbtv and more.

Client application

The client application is a .NET application written in C#. Source code is available from here https://dvbseserviceproc.codeplex.com/
It will allow you to select service XML file; network type; web service URL and method. After applying ‘Process’ service content will be sent to specified URL encoded in JSON.
You can modify the application for your specific needs if this will not work for you.

Server application

PHP

The server application is a simple PHP script that will consume the JSON data posted by client application. It will validate the presence of  a few expected properties, name and provider. Other than that it won’t do anything with the data. In a real world application one might want to do stuff like saving the service data to a database.
The PHP script can be found below and can me modified for your specific needs. It was tested on a basic Apache running on Linux.

<?php
$fp = fopen(php://input,r);
$data = stream_get_contents($fp);
$decode = json_decode($data);
if($decode == null) {
header(HTTP/1.0 500 Internal Server Error);
header(Content-Type: text/plain);
echo failed to decode JSON\n;
exit;
}
else {
foreach($decode as $value) {
// check a few properties, but not all possible properties.
if(!property_exists($value,name)) {
header(HTTP/1.0 500 Internal Server Error);
header(Content-Type: text/plain);
echo property name not found\n;
exit;
}
if(!property_exists($value,provider)) {
header(HTTP/1.0 500 Internal Server Error);
header(Content-Type: text/plain);
echo property provider not found\n;
exit;
}
}
}
?>
view rawapi.php hosted with ❤ by GitHub

Google App Engine

There is is a live test web-service here http://dvbseserviceapi.appspot.com running on Google App Engine. Source code for web application is available here https://code.google.com/p/appengine-dvbseserviceapi/.

Conclusion

This was just an minimum example to get you started. It doesn’t really do anything useful as is. But it does show the potential of post processing service XML file.

Leave a Reply

Your email address will not be published. Required fields are marked *