Friday, 15 April 2016

How section binary view in DVBStreamExplorer helped locating a bug

A little known feature in DVBStreamExplorer is the ability to view raw section content in main window. This feature recently helped me out locating a bug in DVBStreamExplorer.
Some time time ago I had done some DVB-S scanning of several satellites. SI and SVC XML files had been saved. Recently I tried to open SVC XML file in DVBStreamExplorer Service View which I was running from Visual Studio. I got this error during load.



I opened SVC XML file in wxHexEditor. I was able to locate the 0x07 character.



The problem was related to a service name. I was able to figure which service had the problem. I loaded the SI XML file in DVBStreamExplorer and navigated to that service and got this view.



There appears to be some kind of control character before service name. That's suspicious since control characters are supposed to be filtered out before being displayed. To view raw section content select section on tree view. And select 'value' tab in bottom view.
The first byte in highlighted area is 15 which is hexadecimal for 21 decimal which again is the length of the string. Then there is a sequence of 10 00 07 which constitutes character set selector. From ETSI EN 300 468 table A.4 it can be seen this is Latin/Greek. After this sequence there is the actual service name string. Considering that issue is about an unexpected 0x07 character it's obvious to suspect that 0x07 is considered part of the service name string.
After a code review such a bug was indeed found. This has been fixed in DVBStreamExplorer 4.0.20 just released. SI XML was loaded in new version. Service name was now displayed correctly as seen below.


A new SVC XML file was exported. And this time it could be loaded from DVBStreamExplorer Service View without any issues.


Sunday, 6 March 2016

Integrating user defined Python scripts with DVBStreamExplorer

NOTE: this post describes a feature that is not yet included in DVBStreamExplorer public release.

A new feature is planned for a future DVBStreamExplorer release. This feature will allow a user defined Python script to be invoked at certain points during 'Multiple DVB-x MUX scanning'. User script will be called on events like:
  • Starting a new scan session.
  • Starting scan of new satellite. This is only applicable for DVB-S scanning.
  • Starting scan of new MUX. Tuner parameters. 
  • Scanning of MUX completed.
  • Scanning of satellite completed. This is only applicable for DVB-S scanning.
  • Scan session completed.
Depending on event context user script can typically request DVBStreamExplorer to continue scanning, skip scanning of current satellite/MUX or abort the entire scanning session. Events handlers are methods in a class user script must implement. Using a class allows script to maintain state between calls to methods.
In example below user script is handling the start scanning of new DVB-S MUX event.

    def StartScanMuxDvbS(self,frequency, symbolrate, polarisation, fec):
        print(self.count,frequency, symbolrate, polarisation, fec)
        self.count=self.count+1
        if polarisation == "H":
            return 0
        else:
            return 1

This code causes scanning of horisontal transponders only. Scanning of vertical transponders will be skipped.While this might not represent an interesting case for a real production system, it does demonstrate the possibilities. Note that 'self.count=self.count+1' statement is to keep track of the number of times script was called. This is for debugging purposes only.

A more realistic case for a real production system: If you are scanning multiple satellites on a regular basis, you might have certain expectations about hove many transponders should be scanned and how many services should be found. If scan result differs too much from your expectations you could send a notification, i.e. email, to a user to alert about this.

The work on this is still in progress. I now have a working prototype. But there is still some way before it's ready for public release.
Please feel free to provide feedback on this, i.e. if you have any suggestion about information that should be passed on to user script. You can provide feedback either by commenting on this post or send to info@dvbstreamexplorer.com.

Wednesday, 10 February 2016

PCR, OPCR,PTS and DTS reports in TS File Demux

In TS File Demux v2.3.17 new feature has been added to generate CSV reports containing details about PCR, OPCR, PTS and DTS timestamps.

To create PCR, OPCR CSV report add 'Single PID one file' filter for a PID stream containing such timestamps. That will typically be the PID marked as PCR in program tree. I.e. for PID 0x1001 the binary file ts_pid_0x1001.bin will be created in output folder together with ts_pid_0x1001.bin.csv file.
See embedded sheet below for an example of such CSV file.


To create PTS, DTS report add PES filter for a PES stream containing such timestamps. That would typically be video and audio streams. Note that not all stream types recognized as PES streams may contain timestamps. Refer to ISO 13818-1 for details.  I.e. for PID 0x0fa1 the binary file pes_0x0fa1.bin will be created in output folder together with pes_0x0fa1.bin.csv file.
See embedded sheet below for an example of such CSV file.



Wednesday, 7 October 2015

Extracting DSM-CC data and object carousel content with TS File Demux

TS File Demux now includes a feature to extract DSM-CC data and object carousel content. This feature is meant to be a lighter alternative to a similar feature in DVBSTreamExplorer which might be overkill in some situations. If you need decoding of DSM-CC sections and BIOP messages, DVBStreamExplorer is the still way to go.
Below is a screenshot of a TS file that contains  DSM-CC data.
 
TS File Demux main window

The DSM-CC filters have been added automatically after applying 'Add all'. Streams of type 0x0b, ISO/IEC 13818-6 type B, are considered as DSM-CC carousel streams. You can add DSM-CC filter for arbitrary PID if it wasn't recognized as DSM-CC carousel and you believe that it is.
Below is screenshot of some extracted object carousel files. The files are part of a MHP application.

Extracted files
The files can now be studied offline.
Follow this link to download TS File Demux here.

Saturday, 25 April 2015

Decrypting service in DVBStreamExplorer using CI capable hardware

A little known feature in DVBStreamExplorer is the ability to decrypt DVB services using hardware that supports common interface (CI). You will need a TechnoTrend tuner card with CI support. This includes devices such as TT-connect CT 3650 CI and TT-connect S2 3650 CI. TT Budget cards with CI add-on card will also work. Cards with CI option from manufactures other than TechnoTrend will not work. Also this will only work with DVBStreamExplorer x86 version. CI and DiSEqC features are implemented in a proprietary DLL from TechnoTrend, ttBdaDrvApi_Dll.dll. Apparently this DLL is only available in 32 bit version.
You will also need a conditional access module (CAM) and a valid subscription smart-card. See picture below. It shows TT-connect CT 3650 CI, Conax CAM and subscription smart-card.




Insert your CAM and do a SI scan in DVBStreamExplorer. When completed switch to service view and DVBStreamExplorer should look similar to below.


Note that in lower right corner it can be seen that no service is currently selected.
To select a service for decryption locate an encrypted service in service view and double-click on it.
Lower right corner will now show that a service has been successfully selected.



Note this does not necessarily mean that service will be decrypted successfully. It just mean that tuning and selection of service was executed successfully.

You can check the DVBStreamExplorer log file for CI related entries. The log file can be found from options / preferences / logging.

Here is some logging from when CAM was inserted and initialized. The CA ID 0xb00 is for Conax.
 213 - Apr 25 09:25:51.189 - (9.842) - <4> - CI_OnSlotStatus(0,1)
 214 - Apr 25 09:25:51.189 - (9.842) - <4> - CI_SLOT_MODULE_INSERTED
 215 - Apr 25 09:25:57. 63 - (15.716) - <4> - CI_OnSlotStatus(0,2)
 216 - Apr 25 09:25:57. 63 - (15.716) - <4> - CI_SLOT_MODULE_OK
 217 - Apr 25 09:25:57. 63 - (15.716) - <4> - CI_SLOT_CA_OK
 218 - Apr 25 09:25:57. 63 - (15.716) - <4> - CA:  219 - Apr 25 09:25:57. 63 - (15.716) - <4> - supported CA ID[0]: 0x0B00

And here is some logging from when a service was selected for decryption.
1222 - Apr 25 12:10:11.524 - (9870.177) - <4> - Selecting service 'Discovery Channel'
1223 - Apr 25 12:10:11.623 - (9870.276) - <4> - CI_OnCAStatus(255,14,0)
1224 - Apr 25 12:10:11.623 - (9870.276) - <4> - CI_SWITCH_PRG_REPLY
1225 - Apr 25 12:10:11.623 - (9870.276) - <4> - ERR_NONE

Again this does not not necessarily mean that service will be decrypted successfully. It just means that connection to CAM is in good state.

To check that service is actually decrypted open DVB TS Monitor. Make sure that "Options / Parse A/V elementary headers" is enabled. Start the scan. In current service tab, services node locate the service selected for decryption. Verify that it looks something like below.



If you see details about A/V streams as tagged above, it means that service is successfully decrypted. That is unless the service was not encrypted at all to begin with. Note that it can take up to a minute or in rare cases even more for the header details to appear. This is because each stream in TS is scanned one by one for some time looking for header information.

Once decryption is verified you can save TS to disk. You can then view decrypted service in VLC. You can also stream service over UDP. Other clients can then pick up the decrypted service.


Sunday, 15 February 2015

Capture HbbTV data with DVBStreamExplorer

In this post I will demonstrate how you can capture HbbTV data using DVBStreamExplorer. You will need DVBStreamExplorer Professional Edition for this exercise.
You can then study the HbbTV application offline. You can find more information about HbbTV here: https://www.hbbtv.org/.
First we need to find a service that contains HbbTV application. In this example I will find a service on Astra 19E.
You can find such service in this list: http://dtvlist.dvbstreamexplorer.com/dvbs.html. Look for 'hbbtv' in feature field.
Or you can do a complete SI scan of Astra 19E with DVBStreamExplorer. After completing SI scan switch to service view and you should see something similar to below.


Scroll to the far right to see features field and look for 'hbbtv'.


It can be seem that first service in the list, ORF SPORT+, features HbbTV.
Open the tuning window and tune on 11244H where the ORF SPORT+ service can be found.
Open Transport Stream Monitor (DVB) and start scanning. After a few seconds of scanning you should be able to select ORF SPORT+ from service drop-down list.


Now go to the DSM-CC tab. You should see list of DSM-CC streams found in service. For ORF SPORT+ there will only be one on PID 0x1c2b. Enable scanning of the PID in list.


It will now scan for DSM-CC data. This may take a short while. Once all DSM-CC data has been acquired the Object Carousel tab will be populated with file/folder structure. The content of files will also be shown as ASCII/Hex. Below can be seen partly content of a CSS file named min_portal_1_0_6.css which is part of HbbTV application.


And below is shown content of min_config_1_0_6.js which is a JavaScript file also part of HbbTV application.


Finally below shows partial content of index.html which is a HTML file also part of HbbTV application.


You can now stop scanning to enable file menu. From here the entire Object Carousel be saved. Directory structure in OC is preserved when saved to file system. You can now open the files in your favourite text editor for further examination.

Monday, 20 October 2014

DVBStreamExplorer service XML files

Introduction

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.

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.