00001 /* 00002 * Copyright (C) David C.J. Matthews 2005, 2006 00003 * Derived from libdsmcc by Richard Palmer 00004 */ 00005 #ifndef LIBDSMCC_H 00006 #define LIBDSMCC_H 00007 00008 #include <QLinkedList> 00009 #include <QStringList> 00010 00011 #include "dsmccreceiver.h" 00012 #include "dsmccobjcarousel.h" 00013 00014 /* 00015 Overview. 00016 This is brief, perhaps simplistic, overview of the DSMCC object carousel. 00017 00018 The purpose of the carousel is to make available to the MHEG or MHP application 00019 a small, Unix-like, filing system. The notion of a carousel comes from the idea 00020 that the files and directories of the filing system are constantly retransmitted 00021 so that whenever a receiver tunes in it will eventually see all the components. 00022 00023 The input to this code is in the form of MPEG tables which have been constructed 00024 out of MPEG TS packets. There are three kinds of tables that are processed: DSI, 00025 DII and DDB. 00026 00027 DSI tables contain the address (IOR) of the root directory of the filing system. 00028 Why this is needed and how it works is described below. 00029 00030 DII tables describe "modules". A module is collection of one or more files 00031 or directories. Because a module may be larger than the maximum allowed table 00032 size (4k) the entries in the DII say how many blocks, contained in DDB tables, 00033 are needed to make the module and also whether, when all the blocks have been 00034 found, the module needs to be decompressed. 00035 00036 Each DDB contains data forming part of a module as well as information saying 00037 which module it belongs to and which block within the module it is. Once all 00038 the blocks of a module have been found and, if necessary, the module 00039 decompressed, the data is ready for the next stage. 00040 00041 A module comprises one of more directory, service gateway or file objects. 00042 A service gateway is exactly the same as a directory except that it is a 00043 root directory. Directories and service gateways are tables with a text 00044 name, whether the entry is a file or sub-directory, and the address (IOR) 00045 of the file or sub-directory. File objects contain the data for the file 00046 itself. Note that this arrangement allows for the directory structure to 00047 be an arbitrary directed graph. 00048 00049 There may be multiple service gateways in the carousel and this is the 00050 reason for the DSI message. The DSI message identifies one service 00051 gateway as the root to be used. Working from this it is possible to 00052 construct a tree of sub-directories and files to make the filing system. 00053 00054 The reason for having multiple service gateways and DSI messages rather 00055 than just transmitting a single service gateway is that it allows for 00056 the same carousel to be used for several services on a DVB multiplex 00057 and so reduce the overall bandwidth requirements on the multiplex. For 00058 example, several BBC radio programmes are transmitted on the same multiplex. 00059 The PMT for each programme identifies an initial PID stream containing 00060 DSMCC packets and a secondary stream. The initial stream is different 00061 for each programme and sends only DSI messages. Everything else is 00062 transmitted on the common stream with a service gateway and a few extra 00063 files, such as the programme logo, specific to that programme, but with 00064 everything else shared. 00065 00066 The MHEG or MHP library makes requests for files by passing in a 00067 Unix-like path name. The organisation of the carousel allows a 00068 receiver to pick out the file by building the data structures needed 00069 to satisfy only the request. That minimises the memory requirements 00070 but provides a slow response since every file request requires the 00071 application to wait until the file appears on the carousel. Instead 00072 this code builds the filing system as the information appears. 00073 */ 00074 00075 class Dsmcc 00076 { 00077 public: 00078 Dsmcc(); 00079 ~Dsmcc(); 00080 // Reset the object carousel and clear the caches. 00081 void Reset(); 00082 // Process an incoming DSMCC carousel table 00083 void ProcessSection(const unsigned char *data, int length, 00084 int componentTag, unsigned carouselId, 00085 int dataBroadcastId); 00086 // Request for a carousel object. 00087 int GetDSMCCObject(QStringList &objectPath, QByteArray &result); 00088 00089 // Add a tap. This indicates the component tag of the stream that is to 00090 // be used to receive subsequent messages for this carousel. 00091 // Creates a new carousel object if there isn't one for this ID. 00092 ObjCarousel *AddTap(unsigned short componentTag, unsigned carouselId); 00093 00094 protected: 00095 void ProcessSectionIndication(const unsigned char *data, int Lstartength, 00096 unsigned short streamTag); 00097 void ProcessSectionData(const unsigned char *data, int length); 00098 void ProcessSectionDesc(const unsigned char *data, int length); 00099 00100 bool ProcessSectionHeader(DsmccSectionHeader *pSection, 00101 const unsigned char *data, int length); 00102 00103 void ProcessDownloadServerInitiate(const unsigned char *data, int length); 00104 void ProcessDownloadInfoIndication(const unsigned char *data, 00105 unsigned short streamTag); 00106 00107 // Return a carousel with the given ID. 00108 ObjCarousel *GetCarouselById(unsigned int carId); 00109 00110 // Known carousels. 00111 QLinkedList<ObjCarousel*> carousels; 00112 00113 // Initial stream 00114 unsigned short m_startTag; 00115 }; 00116 00117 #endif
1.6.3