Monday, May 29, 2017

STB Software


  • Why PCR – Program Clock Reference is required?
    • Already, we know that STC channel is connected to the PCR pid channel. The STC – System Time Clock runs at 27MHz. It is the speed at which the encoding is done at the transmitting side. However, the receiver – STB cannot run at 27MHz to decode the stream because the oscillator is prone to errors (+/- tolerance level). In order to generate the accurate timings, a PCR is feed to STC – System Time Clock. Thus, with the aid of PCR, we can reduce the jitter and macro-blocks at the receiver side.
  • How does System Time Clock – STC is used for decoding?
    • If the frame – DTS – Decoding Time Stamp is equal to the System Time Clock, then only the frame is decoded.
    • If the frame – PTS – Presentation Time Stamp is equal to the System Time Clock, then only the frame is presented.
  • How is “Time Stamp Management” done in STB?
    • For live feed, the PCR is feed to the STC for playing the Stream – Audio and Video.
    • For PVR, the STC is free running. It means that the STC is locked to the system clock. In this scenario, the STB will ignore the DTS and PTS.
  • What problems can occur due to PCR errors?
    • A lip-sync i.e. mismatch between the video frame and the audio may occur.
    • A jitter or macro-blocks may occur due to the lack of PCR. When there is an error/noise in the transmission, we will see a frequent PTS errors i.e. the Presentation Time Stamp (PTS) is not in sync with the STC – PCR.
  • How do we troubleshoot a macro-block/jitter/jerk issue in STB?
    • Check for the Signal/Noise ratio. If found issues over there, then try to rectify the tuner locking process.
    • If the issue cannot be fixed at the tuner side due to the transmission error, then try to fix in the STC sourcing.
      • For the live mode, you can configure the STC in the following mode. If the PCR has high jitters, then the STC will decouple from the PCR source. In such a case, the STC will use the internal crystal clock. Later, once the jitter is low, the STC will be feed with the PCR.
      • For the PVR mode, the STC is configured to a free running mode. In this case, the STC will be feed with the system clock. Also, the decoder will ignore the DTS and PTS. It’s up to decoder to correctly decode the frames. It is same like playing a MPEG stream with a player – like VLC media player.
    • Also, sometimes the jitter/macro-block is due to the reason that Video RAM is full. In such a case, we can re-configure the Video RAM to decode the frames successfully.
      • [note] – For pull-vod, the mode is RTP – real time protocol. With the help of RTP, we can do trick modes on the IP stream.
      • Some typical steps to troubleshoot Macro-blocking issues –
        • List down the services where the problem is seen. Please note down the frequencies of those problematic services.
        • Now, check the SNR and Inband power level. Look at the STB specifications –
                   QAM256 (InBand)
                   min -12dBmV
                   max +15dBmV
                   Min SNR 33dB

        • Check for the Video decoder errors
          • Sometimes, the issue is due to the video memory buffer overflow. Also, it could be due to the PTS errors.
  • What is a PES – Packetised Elementary Streams?
    • A PES is a audio, video, and data packets.
  • What is the size of a PES?
    • The size of a PES is variable. However, the ‘ts’ is of a fixed sized to maintain a constant bit rate. When the TS packets are received, the demodulator demodulates the QPSK ( Quadrature Phase Shift Keying – for Satellite) or QAM ( Quadrature Amplitude Modulation for Cable). Afterwards, the demux separates out the packet size of 204 bytes. The demux discards those packets, whose ‘transport error indicator’ bit field is set to 1.


  • Here is the block diagram of STB —





  • Here is the block diagram depicting the DEMUX-CA System (Descrambling_Module).
  • What is the structure of a PES Packet?
    • Packet Start code Prefix
    • Stream-id
    • PES Packet Length
    • Optional PES Header
    • Data – Payload
  • What is inside ‘Optional PES Header’?
    • PES Scrambling Control
    • PTS
    • DTS
    • ESCR – Elementary Stream Clock Reference
    • ES Rate.
    • [note] – You can see that the PTS and DTS information is present in the PES packet.
  • What is the video packet structure?
    • Sequence Header – aspect ratio( proportion between width and height) info and frame rate.
    • Extension and user data – Closed Caption – CC
    • Group Header
    • Picture Header
    • Picture Data
    • [note] – Once the video decoder ( STB AV drivers) will decode the mpeg frames, it will have the above information.
  • What are the video frames in MPEG Systems?
    • MPEG is a lossy compression technique. There are three major video frame types in MPEG Systems.
      • I (Intra coded) frame – It is a least compressible video frame, and it doesn’t require P or B frame to uncompress/reform the video frame.
      • P ( Predictive)frame – It needs a data from the previous video frame to get compressed, and it requires the previous video frame to uncompress/reform the video frame. Thus, this frame is more compressible compare to I-frame.
      • B ( Bi-Predictive) frame – It needs both previous and future frame to uncompress/reform the video frame. Thus, this frame is highly compressible.
      • In summary, the I frame is a fully specified image. On the other hand, the P and B frames hold the part of the image.
  • A peek inside MPEG frame
    • A frame is segmented into the macro-blocks. A macro-block is created using DCT – Discrete Cosine Transformation. This fundamental is used in JPEG also.
  • How does PTS and DTS information is send out in the DVB transmission?
    • A multiplexer has a System Time Clock – STC. With STC, the DTS and PTS is derived. Later, the DTS and PTS information is embedded in the encoded audio and video PES packets.
    • [note] – Remember, the TS is send out a constant bit rate from the DVB transmission system.
  • What is the band for the terrestrial Services?
    • The band is from 41 to 960 MHz.
    • VHF – Very High Frequency – It is used by FM broadcasting typically.
    • UHF – Ultra High Frequency
  • What is meant by the term ‘source coding’ in DVB transmission?
    • It is a term that refers to the MPEG compression of the video/audio data packets.
  • What is meant by the term ‘channel coding’ in DVB transmission?
    • It is a term that refers to the modulation of the stream and the Service delivery system – like Terrestrial, Satellite, and Cable.
  • What is the frequency range for Satellite transmission?
    • The satellite services are transmitted above 10 GHz frequency.
  • How to setup a local broadcasting for the Set-top box software development purpose?
    • Generally, a decktec card is installed on any PC. Many times, you can use an external usb based DECKTEC. Next, you install a DekTec Stream express for your specific hardware. Once it is installed, play a desired “.ts” file through the stream express. Here is a USB -DECKTEC.
  • DekTecCard_USB
    • Dektec Card

    • Here is the ‘StreamXpress’ application screen shot.



  • Types of DekTec Streamer
    • Terrestrial and Cable – This type of streamer can fulfil the terrestrial as well as cable type of local stream broadcasting requirement. This is possible because the cable and terrestrial have a common range of frequencies.
    • Satellite DekTec
  • How do we set/calculate the DeckTec frequency for the given TS – only for DVB-S?
    • This calculation is required for satellite only because we use LNB ( low noise blocker) for satellite systems.
      • Open the ts file in the DekTec Stream Xpress – you will see the NIT – symbol rate. In this example, the NIT SYMBOL rate is 19,352,941 bps. If the symbol rate is more than 11700 MHz, then DEKtec frequency is equal to
        • Dektec Freq = NIT frequency (MHz) - 10700 ( MHz)
  • How to see the NIT frequency and other tuning parameters? 
    • Download TS Reader-lite
    • Open the TS file via. TS reader lite.
    • Here, you will see the Code Rate, which is the FEC in the modulation parameters feed into the DekTec Stream Xpress. In this example, the FEC is 2/3. Next modulation parameter is the bandwidth. This information can be seen through TS reader lite – Bandwidth. In this example, the bandwidth is 7MHz. Afterwards, we need the modulation type. By looking at the TS reader-lite – NIT section, we will see that the modulation type is 64-QAM. Similarly, we can find out other modulation parameters – DVB-T or others. In this example, it is DVB-T. Also, Guard time – ‘G’. In this example, the guard time is 1/8.


    • If the symbol rate is less than 11700 MHz, then the DEKtec frequency is equal to
      • Dektec Freq = NIT frequency (MHz) - 9750 (MHz)
    • [note] – For terrestrial and cable, the DekTec frequency is same as what is seen in the NIT. There is no need for these calculations in the terrestrial and cable systems.
  • Splitters for the Cable/Terrestrial and Satellite Systems
    • Generally, the splitters are used in the local setup to share the signal. For satellite systems, the splitter should be used in the range of
      • 5 - 2200 MHz.
    • For Cable/Terrestrial systems, the splitter should be used in the range of 
      • 5 - 1000 MHz.
  • How does a IP-Set-top box works?
    • When a IP STB is connected to the network, the IP STB gets the address from the DHCP Server.
      • Next, the IP STB DHCP client will request for the option 43 by passing the vendor Id in the option – 60.
      • Afterwards, the DHCP server will verify the vendor Id. Once the Vendor-ID is verified, the DHCP server will send the information in the option 43 – vendor specific information.
      • The DHCP Client – (Connman – for example) will write that information in the file
/mnt/ffs/networking/lib/connman/dhcp # ls -l
-rw------- 1 root root 135 Feb 11 12:11 dhcp_options
-rwx------ 1 root root 47 Feb 11 12:11 vendor_id
/mnt/ffs/networking/lib/connman/dhcp #

      • Here is the content of DHCP options
        • [dhcp_options]
        • DHCPLease_seconds=1800
        • DHCPOption43_1=224.2.2.201:22222
        • DHCPOption43_2=224.2.2.201:22222
        • DHCPOption42_0=136.170.192.10
        • ~
      • Here is the vendor class identifier. Generally, it is a hardcoded value provided by the vendor.
        • [vendor_id]
        • vendor_class_identifier=DMI7000LAL
      • Once you get a update on the file, you can install the Inotify() to monitor any change in the file.
        • Create the inotify instance by inotify_init().
        • inotify_add_watch()
        • read on the file - this will be blocked until the inotify unblocks it.
        • read the event flags
        • IN_ACCESS – File was accessed
        • IN_ATTRIB – Metadata changed (permissions, timestamps, extended attributes, etc.)
        • IN_CLOSE_WRITE – File opened for writing was closed
        • IN_CLOSE_NOWRITE – File not opened for writing was closed
        • IN_CREATE – File/directory created in watched directory
        • IN_DELETE – File/directory deleted from watched directory
        • IN_DELETE_SELF – Watched file/directory was itself deleted
        • IN_MODIFY – File was modified
        • IN_MOVE_SELF – Watched file/directory was itself moved
        • IN_MOVED_FROM – File moved out of watched directory
        • IN_MOVED_TO – File moved into watched directory
        • IN_OPEN – File was opened
      • You can check the inotify() examples in the internet.
  • How to get the service list in IP Set-top box?
    • After reading the dhcp options – 43 – for example – DHCPOption43_1=224.2.2.201:22222, it will request the service list from this url.
  • What does service list contains in the IP Set-top box scenario?
    • The service list is a table that contains the following list.
      • Service Name ----------#####-------- Service Multicast IP Address.
  • What happens when you do a zapping in ‘IP Set-top box’?
    • Each service is a udp multicast url. When you zap a channel, you will un-join the currently tuned multicast udp address then you will join the desired multicast udp address.
    • Example of IP -Set-top box – Altibox – For Denmark and Norway.
      • http://en.wikipedia.org/wiki/Altibox
    • For example, here is the service list
############ #####################
Service_NAME                    Multicast UDP Address
############ #####################
NRK 2                                    239.192.1.6:5501
NRK Rogaland                     239.192.1.7:5501
NRK Super                            239.192.1.89:5501
NRK P1                                  239.192.1.201:5501
NRK P3                                  239.192.1.203:5501
NRK 1 HD                             239.192.1.179:5501
NRK 2 HD                             239.192.1.80:5501
BBC 1 Scot HD                     239.20.61.5:5501
BBC R4 LW                          239.20.46.1:2046
BBC 1 Yrks and Lin            239.20.46.2:2046
BBC 1 East (E)                    239.20.46.3:2046
Aljazeera                              236.1.1.1:1234

  • Video Encoding to be feed into television
    • The job of ‘DENC – digital encoder’ in STB is to encode the video format required/accepted by the television. There are two television display systems.
      • PAL – It has a refreshing rates of 25 frames per second. In PAL, there are 625 lines. This type of encoding is used in Europe, Asia, and Australia.
      • NTSC – It has a refreshing rate of 30 frames per second. In NTSC, there are 525 lines. This type of encoding is used in North-America, South America, and Canada.
      • Finally, a TV decodes the PAL or NTSC video signal.
  • What is a linkage descriptor?
    • This is an optional descriptor available in the NIT. This gives a link to another ‘ts’ or service. A linkage descriptor will contain the linkage type, and it will point to the private data. A private data will be read, and it will point to the address of the private messages.
    • Here are some of the types of linkage descriptor.
0x01 - additional info about the network
0x02 - EPG info
0x04 - comprehensive service information
0x08 - if a particular terrestrial service is not available then what service it can tune to.
0x09 - about the TS - carrying the software update image.

What is the practical usage of linkage descriptor?

1. Here is an example to get the custom type message – one way message – owm.


linkage_descriptor ()
{
descriptor_tag
descriptor_length
transport_stream_id
original_network_id
service_id
linkage_type
if linkage_type == 0xF0
{
pid_count
for (i=0; i<N; i++)
{
reserved
pid
reserved
type
}
}
}

2. To locate the primary data carousel.


linkage_descriptor ()
{
descriptor_tag = 0x4A
descriptor_length = 0x14
transport_stream_id = 0x000B (11)
original_network_id = 0x1000 (4096)
service_id = 0xD6DB (55003)
linkage_type = 0x06 (Primary Carousel Linkage Descriptor)
{
private_data_byte = ComcastHDRootData
}

}

DSM-CC – Digital Storage Media – Command and Control

Here the broadcaster will update the filesystem, and the receiver (STB) will wait for the file it wants. Generally, there are DSMCC servers running for this purpose. In DSM-CC system, the data to be transmitted is split in the blocks called modules.

Types of Carousel –

1. Data Carousel – The data is send directly here. It is upto the receiver to parse and understand the data. This type of carousel is used in ATSC systems – US.

2. Object Carousel – It consists of a directory tree, and the directory tree contains a module or a list of modules. These modules can be a file or a directory.

Here is an example of Object Carousel –


index.html 1256 bytes
image1.jpg 4040 bytes
image2.jpg 120346 bytes

audio <directory>
audio/clip1.aiff 26430 bytes

classes <directory>
classes/Main.class 23020 bytes
classes/Big.class 59982 bytes
classes/Other.class 26947 bytes

How to support multiple polarisation and bands in the Satellite Systems?

If we need more services, then we need to setup different LNB’s to receive the services from the different sub-bands of a Ku band. There are four sub-bands in a Ku-band. These are the following –

a. low freq, horizontal polarisation
b. low freq, vertical polarisation
c. high freq, horizontal polarisation
d. high freq, vertical polarisation

We cannot run four cables from the dish antenna to the STB in the house. This will add up a cost. Also, it becomes clumsy to maintain 4 RF cables. The solution is to use the SatCR – Satellite Channel Router. The receiver – STB will send a DiSEQC command to SatCR to receive a particular sub-band. You can request various sub-bands, and the SatCR will combine the various sub-bands to be available in a single co-axial cable. This single co-axial cable is feed to the receiver.

What is the software stack of a typical Set-top box using Broadcom chipset?

1. Low level – minimal driver – board support package (BSP) – CFE ( Common Firmware Environment) – a Broadcom property. It provides an external API for boot-loaders and startup programs. A CFE will initialise the board – cpu, caches, memory controllers, and peripherals. It has a built-in drivers like SPI, etc. It supports a minimal network protocols like – DHCP, IP, ARP, ICMP, and UDP.

2. BootLoader Application – This will be an application that will be launched when there is a need to upgrade the software. The job of this application is to tune to a service where the software update is available. Once the tuning is successful, the boot-loader application will setup a section filter to get the data. Next, the data will be verified – CRC check. If the data is verified, then the software image will be written to the Flash. After writing into the flash – the boot-loader application will reboot the box. This application can be written on the top of a minimal kernel, rootfs image, and minimal Broadcom drivers. This application will take care of the housekeeping also – flash – management. By flash management, we mean where the kernel image, rootfs image, application, and the reserved space will be available in the flash map.

3. STB application – Full Drivers (Broadcom – Nexus or Magnum), OS – Linux, Middleware, and UI ( user interface). This is a complete application that will be launched when there is no software upgrade required. In this condition, the CFE will launch the STB application directly. This application binary is stored in the flash. By reading from the flash, the CFE will launch this STB application.

[note]- When the box is manufactured in the factory, the minimal software will be flashed on to it in the factory. For example, low level – CFE, and the boot-loader application.