source: svn/trunk/newcon3bcm2_21bu/BSEAV/lib/mpeg2_ts_parse/test/main.c

Last change on this file was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 23.9 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2007, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: main.c $
11 * $brcm_Revision: 6 $
12 * $brcm_Date: 5/9/07 4:49p $
13 *
14 * [File Description:]
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /BSEAV/lib/mpeg2_ts_parse/test/main.c $
19 *
20 * 6   5/9/07 4:49p marcusk
21 * PR 28094: Added another failing test case for compressed text.
22 *
23 * 3   2/23/07 5:37p marcusk
24 * PR 28094: Added test for huffman decoding.
25 * 
26 * 2   3/3/05 4:45p erickson
27 * PR14332: adapted to api changes
28 *
29 * 1   2/7/05 11:28p dlwin
30 * Merge down for release 2005_REFSW_MERGETOMAIN:
31 *
32 * Irvine_BSEAVSW_Devel/2   9/10/03 5:38p marcusk
33 * Updated with number of programs and streams.
34 *
35 * Irvine_BSEAVSW_Devel/1   8/29/03 5:07p marcusk
36 * Initial version.
37 *
38 ***************************************************************************/
39#include <stdio.h>
40#include <memory.h>
41
42#include "bstd.h"
43#include "ts_priv.h"
44#include "ts_packet.h"
45
46#include "ts_psi.h"
47#include "ts_pat.h"
48#include "ts_pmt.h"
49#include "psip_mgt.h"
50#include "psip_vct.h"
51#include "psip_eit.h"
52#include "psip_mss.h"
53#include "psip_ett.h"
54#include "psip_stt.h"
55#include "psip_rrt.h"
56
57
58#define MAX_MESSAGE_SIZE        4096
59#define MAX_PIDS                        64
60#define MAX_STRING_SIZE         (8*1024)
61
62struct pid_info_t
63{
64        bool            inUse;
65        uint16_t        PID;
66        uint8_t         contCount;
67        bool            foundFirstPusi;
68        uint8_t         messageBuf[MAX_MESSAGE_SIZE];
69        int                     messageSize;
70};
71
72static struct pid_info_t        gPidArray[MAX_PIDS];
73
74static void printString( PSIP_MSS_string mss, char * pre, char * post )
75{
76        int j;
77        static char string[MAX_STRING_SIZE];
78        static int stringSize = MAX_STRING_SIZE;
79        char *pLangCode;
80
81        for(j=0; PSIP_MSS_getString(mss, j, &stringSize, string)==BERR_SUCCESS; stringSize = MAX_STRING_SIZE, j++ )
82        {
83                PSIP_MSS_getCode( mss, j, &pLangCode );
84                if( stringSize != 0 )
85                {
86                        printf("%s(%c%c%c): %s%s", pre, pLangCode[0], pLangCode[1], pLangCode[2], string, post);
87                }
88        }
89}
90
91void processDescriptor( TS_PSI_descriptor descriptor )
92{
93        switch( descriptor[0] )
94        {
95        case 2:
96                printf("video_stream_descriptor\n");
97                break;
98        case 3:
99                printf("audio_stream_descriptor\n");
100                break;
101        case 4:
102                printf("hierarchy_descriptor\n");
103                break;
104        case 5:
105                printf("registration_descriptor\n");
106                break;
107        case 6:
108                printf("data_stream_alignment_descriptor\n");
109                break;
110        case 7:
111                printf("target_background_grid_descriptor\n");
112                break;
113        case 8:
114                printf("Video_window_descriptor\n");
115                break;
116        case 9:
117                printf("CA_descriptor\n");
118                break;
119        case 10:
120                printf("ISO_639_language_descriptor\n");
121                break;
122        case 11:
123                printf("System_clock_descriptor\n");
124                break;
125        case 12:
126                printf("Multiplex_buffer_utilization_descriptor\n");
127                break;
128        case 13:
129                printf("Copyright_descriptor\n");
130                break;
131        case 14:
132                printf("Maximum_bitrate_descriptor\n");
133                break;
134        case 15:
135                printf("Private_data_indicator_descriptor\n");
136                break;
137        case 16:
138                printf("Smoothing_buffer_descriptor\n");
139                break;
140        case 17:
141                printf("STD_descriptor\n");
142                break;
143        case 18:
144                printf("IBP_descriptor\n");
145                break;
146        case 27:
147                printf("MPEG-4_video_descriptor\n");
148                break;
149        case 28:
150                printf("MPEG-4_audio_descriptor\n");
151                break;
152        case 29:
153                printf("IOD_descriptor\n");
154                break;
155        case 30:
156                printf("SL_descriptor\n");
157                break;
158        case 31:
159                printf("FMC_descriptor\n");
160                break;
161        case 32:
162                printf("External_ES_ID_descriptor\n");
163                break;
164        case 33:
165                printf("MuxCode_descriptor\n");
166                break;
167        case 34:
168                printf("FmxBufferSize_descriptor\n");
169                break;
170        case 35:
171                printf("MultiplexBuffer_descriptor\n");
172                break;
173        case 0x80:
174                printf("PSIP stuffing descriptor\n");
175                break;
176        case 0x81:
177                printf("PSIP AC-3 audio descriptor\n");
178                break;
179        case 0x86:
180                printf("PSIP caption service descriptor\n");
181                break;
182        case 0x87:
183                printf("PSIP content advisory descriptor\n");
184                break;
185        case 0xA0:
186                printf("PSIP extended channel name descriptor\n");
187                break;
188        case 0xA1:
189                printf("PSIP service location descriptor\n");
190                break;
191        case 0xA2:
192                printf("PSIP time-shifted service descriptor\n");
193                break;
194        case 0xA3:
195                printf("PSIP component name descriptor\n");
196                break;
197        case 0xA8:
198                printf("PSIP DCC departing request descriptor\n");
199                break;
200        case 0xA9:
201                printf("PSIP arriving request descriptor\n");
202                break;
203        case 0xAA:
204                printf("PSIP redistribution control descriptor\n");
205                break;
206        default:
207                printf("Unknown descriptor id %d\n", descriptor[0] );
208                break;
209        }
210}
211
212void processMessages( const uint8_t *buf, int messageSize )
213{
214        int i, j;
215        TS_PSI_header header;
216
217        TS_PSI_getSectionHeader( buf, &header );
218        printf("id: 0x%02X, ssi: %d, pi: %d, len: %d, ext: %d, ver: %d, cni: %d, #: %d, l#: %d\n", header.table_id, header.section_syntax_indicator, header.private_indicator, header.section_length, header.table_id_extension, header.version_number, header.current_next_indicator, header.section_number, header.last_section_number );
219
220        switch( buf[0] )
221        {
222        case 0x00:      /* PAT */
223                {
224                        TS_PAT_program program;
225                        printf("\tPAT - %d Programs\n", TS_PAT_getNumPrograms(buf));
226                        for(i=0; TS_PAT_getProgram(buf,messageSize,i,&program)==BERR_SUCCESS; i++ )
227                        {
228                                printf("\tprogram_number: %d, PID: 0x%04X\n", program.program_number, program.PID);
229                        }
230                }
231                break;
232        case 0x01:      /* CAT */
233                printf("\tCAT\n");
234                break;
235        case 0x02:      /* PMT */
236                {
237                        TS_PMT_stream stream;
238                        TS_PSI_descriptor descriptor;
239
240                        printf("\tPMT - PCR PID: 0x%04X - Num Streams: %d\n", 
241                                TS_PMT_getPcrPid(buf,messageSize), TS_PMT_getNumStreams(buf,messageSize) );
242                        for(j=0; (descriptor=TS_PMT_getDescriptor(buf,messageSize,j))!=NULL; j++ )
243                        {
244                                printf("\t\t");
245                                processDescriptor( descriptor );
246                        }
247                       
248                        for(i=0; TS_PMT_getStream(buf, messageSize, i, &stream)==BERR_SUCCESS; i++ )
249                        {
250                                printf("\tstream_type: 0x%02X, PID: 0x%04X\n", stream.stream_type, stream.elementary_PID);
251                                for(j=0; (descriptor=TS_PMT_getStreamDescriptor(buf,messageSize,i,j))!=NULL; j++ )
252                                {
253                                        printf("\t\t");
254                                        processDescriptor( descriptor );
255                                }
256                        }
257                }
258                break;
259        case 0xC7:      /* MGT */
260                {
261                        PSIP_MGT_table table;
262                        TS_PSI_descriptor descriptor;
263
264                        printf("\tMGT\n");
265                        for(j=0; (descriptor=PSIP_MGT_getAdditionalDescriptor(buf,j))!=NULL; j++ )
266                        {
267                                printf("\t\t");
268                                processDescriptor( descriptor );
269                        }
270                        for(i=0; PSIP_MGT_getTable(buf, i, &table)==BERR_SUCCESS; i++ )
271                        {
272
273typedef struct
274{
275        const char * name;
276        uint16_t        typeStart;
277        uint16_t        typeEnd;
278        uint16_t        subValue;
279} MGT_Table_Types;                     
280
281const MGT_Table_Types mgtTypes[] = {
282
283        {"VCT CNI=1", 0x0,    0x0,    0},
284        {"VCT CNI=0", 0x1,    0x1,    1},
285        {"VCT CNI=1", 0x2,    0x2,    2},
286        {"VCT CNI=0", 0x3,        0x3,    3},
287        {"Chan ETT ", 0x4,        0x4,    4},
288        {"DCCSCT   ", 0x5,    0x5,    5},
289        {"EIT      ", 0x100,  0x17F,  0x100},
290        {"Event ETT", 0x200,  0x27F,  0x200},
291        {"RRT      ", 0x301,  0x3FF,  0x300},
292        {"DCCT     ", 0x1400, 0x14FF, 0x1400},
293        {"Reserved ", 0,      0xFFFF, 0}
294};
295
296                                for(j=0; !(table.table_type >= mgtTypes[j].typeStart && table.table_type <= mgtTypes[j].typeEnd); j++ ) {}
297
298                                printf("\t%s (%d), PID: 0x%04X, ver: %d, bytes: %ld\n", mgtTypes[j].name, table.table_type-mgtTypes[j].subValue, table.table_type_PID, table.table_type_version_number, table.number_bytes );
299                                for(j=0; (descriptor=PSIP_MGT_getTableDescriptor(buf,i,j))!=NULL; j++ )
300                                {
301                                        printf("\t\t");
302                                        processDescriptor( descriptor );
303                                }
304                        }
305                }
306                break;
307        case 0xC8:      /* TVCT */
308                /* Fallthrough */
309        case 0xC9:      /* CVCT */
310                {
311                        PSIP_VCT_channel channel;
312                        TS_PSI_descriptor descriptor;
313
314                        printf("\tTVCT / CVCT\n");
315                        for(j=0; (descriptor=PSIP_VCT_getAdditionalDescriptor(buf,j))!=NULL; j++ )
316                        {
317                                printf("\t\t");
318                                processDescriptor( descriptor );
319                        }
320                        for(i=0; PSIP_VCT_getChannel(buf, i, &channel)==BERR_SUCCESS; i++ )
321                        {
322                                wprintf(L"\t%.7s: %d.%d\n", channel.short_name, channel.major_channel_number, channel.minor_channel_number);
323                                for(j=0; (descriptor=PSIP_VCT_getChannelDescriptor(buf,i,j))!=NULL; j++ )
324                                {
325                                        printf("\t\t");
326                                        processDescriptor( descriptor );
327                                }
328                        }
329                }
330                break;
331        case 0xCA:      /* RRT */
332                {
333                        PSIP_RRT_header header;
334                        PSIP_RRT_dimension dimension;
335                        PSIP_RRT_value value;
336
337                        PSIP_RRT_getHeader( buf, &header );
338
339                        printf("\tRRT: %d dimensions\n",header.dimensions_defined);
340                       
341                        printString( header.p_rating_region_name_text, "\t", "\n" );
342                               
343                        for(i=0; PSIP_RRT_getDimension(buf, i, &dimension)==BERR_SUCCESS; i++ )
344                        {
345                                printf("\tDimension %d - graduated_scale: %d, values: %d\n", i, dimension.graduated_scale, dimension.values_defined);
346                                printString( dimension.p_dimension_name_text, "\t\t", "\n" );
347
348                                for(j=0; PSIP_RRT_getValue(buf, i, j, &value)==BERR_SUCCESS; j++ )
349                                {
350                                        printString( value.p_abbrev_rating_value_text, "\t\t\t", ": " );
351                                        printString( value.p_rating_value_text, "", "\n" );
352                                }
353                        }
354                }
355                break;
356        case 0xCB:      /* EIT */
357                {
358                        PSIP_EIT_event event;
359                        TS_PSI_descriptor descriptor;
360
361                        printf("\tEIT\n");
362                        for(i=0; PSIP_EIT_getEvent(buf, i, &event)==BERR_SUCCESS; i++ )
363                        {
364                                printf("\tevent_id: 0x%X, start_time: %u, ETM_loc: %d, sec: %d\n", event.event_id, event.start_time, event.ETM_location, event.length_in_seconds );
365                                printString( event.p_title_text, "\t\t", "\n" );
366                                for(j=0; (descriptor=PSIP_EIT_getEventDescriptor(buf,i,j))!=NULL; j++ )
367                                {
368                                        printf("\t\t\t");
369                                        processDescriptor( descriptor );
370                                }
371                        }
372                }
373                break;
374        case 0xCC:      /* ETT */
375                {
376                        PSIP_ETT_header header;
377
378                        printf("\tETT\n");
379                        PSIP_ETT_getHeader( buf, &header );
380
381                        printf("\ttype: %d, ETM_source_id: 0x%04X, ETM_event_id: 0x%04X\n", header.ETM_id.id_type, header.ETM_id.source_id, header.ETM_id.event_id );
382                        printString( header.p_extended_text_message, "\t\t", "\n" );
383                }
384                break;
385        case 0xCD:      /* STT */
386                {
387                        PSIP_STT_header header;
388                        TS_PSI_descriptor descriptor;
389
390                        printf("\tSTT\n");
391                        PSIP_STT_getHeader( buf, &header );
392
393                        printf("\ttime: %u, offset: %d, DS_status: %d, DS_dom: %d, DS_hour: %d\n", header.system_time, header.GPS_UTC_offset, header.daylight_savings.DS_status, header.daylight_savings.DS_day_of_month, header.daylight_savings.DS_hour );
394                        for(j=0; (descriptor=PSIP_STT_getDescriptor(buf,j))!=NULL; j++ )
395                        {
396                                printf("\t\t");
397                                processDescriptor( descriptor );
398                        }
399                }
400                break;
401        case 0xD3:      /* DCCT */
402                printf("\tDCCT\n");
403                break;
404        case 0xD4:      /* DCCSCT */
405                printf("\tDCCSCT\n");
406                break;
407        default:
408                printf("Unknown Table ID 0x%2X\n", buf[0]);
409                break;
410        }
411}
412
413void processPid( const TS_packet *p_packet )
414{
415        int i;
416
417        for( i=0; i<MAX_PIDS; i++ )
418        {
419                if( !gPidArray[i].inUse )
420                        break;
421
422                if( gPidArray[i].PID == p_packet->PID )
423                        break;
424        }
425
426        if( i == MAX_PIDS )
427        {
428                printf("Too many PIDS found.  Discarding PID 0x%04X\n", p_packet->PID );
429                return;
430        }
431
432        if( !gPidArray[i].inUse )
433        {
434                printf("PID 0x%04X Detected.\n", p_packet->PID );
435                gPidArray[i].inUse = true;
436                gPidArray[i].PID = p_packet->PID;
437                gPidArray[i].contCount = (uint8_t)(p_packet->continuity_counter-1);
438        }
439
440        if( p_packet->continuity_counter != ((gPidArray[i].contCount+1)&0xF) )
441        {
442                printf( "continuity_counter error detected on PID 0x%04X\n", p_packet->PID );
443                gPidArray[i].messageSize = 0;
444                gPidArray[i].foundFirstPusi = false;
445                return;
446        }
447
448        gPidArray[i].contCount = p_packet->continuity_counter;
449
450        if( !gPidArray[i].foundFirstPusi )
451        {
452                if( p_packet->payload_unit_start_indicator )
453                        gPidArray[i].foundFirstPusi = true;
454                else
455                        return;
456        }
457
458        if( p_packet->payload_unit_start_indicator && ((TS_READ_32( p_packet->p_data_byte ) & 0xFFFFFF00) == 0x00000100) )
459        {
460                /* This packet contains PES data (non PSI), so ignore it... */
461                gPidArray[i].foundFirstPusi = false;
462                return;
463        }
464
465        if( gPidArray[i].messageSize != 0 )
466        {
467                /* Continue copying message(s) */
468                if( p_packet->payload_unit_start_indicator )
469                {
470                        /* only copy data until we hit start of next message */
471                        memcpy( &gPidArray[i].messageBuf[gPidArray[i].messageSize], &p_packet->p_data_byte[1], p_packet->p_data_byte[0] );
472                        gPidArray[i].messageSize += p_packet->p_data_byte[0];
473                }
474                else
475                {
476                        memcpy( &gPidArray[i].messageBuf[gPidArray[i].messageSize], p_packet->p_data_byte, p_packet->data_size );
477                        gPidArray[i].messageSize += p_packet->data_size;
478                }
479        }
480
481        if( p_packet->payload_unit_start_indicator )
482        {
483                /* We are starting a new message */
484                if( gPidArray[i].messageSize != 0 )
485                {
486                        processMessages( gPidArray[i].messageBuf, gPidArray[i].messageSize );
487                }
488
489                /* Copy our new message(s) */
490                memcpy( gPidArray[i].messageBuf, &p_packet->p_data_byte[1+p_packet->p_data_byte[0]], p_packet->data_size-(1+p_packet->p_data_byte[0]) );
491                gPidArray[i].messageSize = p_packet->data_size-(1+p_packet->p_data_byte[0]);
492
493                /* Check if we have a complete message */
494                if( (TS_PSI_GET_SECTION_LENGTH(gPidArray[i].messageBuf)+3) <= gPidArray[i].messageSize )
495                {
496                        processMessages( gPidArray[i].messageBuf, gPidArray[i].messageSize );
497                        gPidArray[i].messageSize = 0;
498                        gPidArray[i].foundFirstPusi = false;
499                }
500        }
501}
502
503#include "psip_mss.h"
504/* These are compressed buffers passed to the function
505 *
506 * void PSIP_MSS_P_decompressString( const uint8_t *p_decodeTree,
507 *         const uint8_t *p_compressedString, uint8_t numberBytes, int *p_stringSize, char *p_string )
508 *
509 * p_decodeTree = PSIP_decode_tree_02
510 */
511unsigned char g_compressed_data_0[39] = 
512{
513        0xd1,   0x5b,   0x9d,   0x36,   0x55,   0xa3,   0x3d,   0xfb,   0x2c,   0x71,   0xeb,   0xa9,   0x89,   0xaf,   0x2f,   0x7b, 
514        0xfb,   0xe2,   0x5f,   0xf5,   0x9b,   0xb8,   0x0e,   0xeb,   0xff,   0xdd,   0xf5,   0x55,   0xb4,   0xfa,   0x94,   0x39, 
515        0x5d,   0x8a,   0xdd,   0xdc,   0xb5,   0xbf,   0x24, 
516};
517
518unsigned char g_compressed_data_1[34] =
519{
520        0x5d,   0xc9,   0x88,   0xea,   0x25,   0xb3,   0xa1,   0xcc,   0xb9,   0x34,   0x59,   0x7a,   0xa2,   0x4b,   0xff,   0xa7, 
521        0xc0,   0x61,   0x51,   0x10,   0xb4,   0xff,   0x4e,   0x2f,   0xff,   0x52,   0x0d,   0x43,   0x0c,   0x88,   0x2f,   0xb9, 
522        0x66,   0x20,   
523};
524
525unsigned char g_compressed_data_2[29] = 
526{
527        0x5d,   0xfd,   0x22,   0x5f,   0xfe,   0x4b,   0xaa,   0x2e,   0x17,   0x34,   0x7f,   0xad,   0xef,   0xbc,   0x43,   0x64, 
528        0xea,   0xbd,   0x69,   0xd4,   0xe7,   0x10,   0xf5,   0x8b,   0xea,   0x15,   0x1a,   0xb1,   0x00, 
529};
530
531unsigned char g_compressed_data_3[143] = 
532{
533        0x4c,   0xd7,   0xc4,   0xfa,   0x1c,   0x41,   0x4c,   0x77,   0xee,   0xff,   0xf7,   0x73,   0x72,   0xe6,   0x65,   0xeb, 
534        0xbd,   0xde,   0xb5,   0xcb,   0x3e,   0x9d,   0x77,   0xbd,   0x31,   0x68,   0x7f,   0xb7,   0x75,   0x2a,   0xb1,   0xd5, 
535        0x2a,   0xda,   0x7d,   0x42,   0x57,   0xb2,   0x66,   0xe7,   0x17,   0x33,   0xfc,   0xb1,   0xae,   0x68,   0xc5,   0xcf, 
536        0x53,   0xb6,   0x33,   0xe6,   0x73,   0x6f,   0x0c,   0x5b,   0x9c,   0xcb,   0xd7,   0x7c,   0xed,   0x11,   0xb6,   0xfe, 
537        0xef,   0xcd,   0xdf,   0x30,   0xe2,   0x42,   0xd3,   0x70,   0x56,   0xc2,   0xd1,   0x17,   0x6d,   0x39,   0x0e,   0xd1, 
538        0x54,   0x7f,   0x26,   0xdf,   0xdd,   0xfb,   0xfc,   0xb0,   0x8b,   0x4f,   0xfb,   0x26,   0x6e,   0x7e,   0x90,   0xdb, 
539        0xa7,   0x92,   0x0a,   0xd7,   0xa8,   0x9c,   0xd7,   0xea,   0xe9,   0xf1,   0xe3,   0x1d,   0xca,   0xb2,   0xef,   0xf5, 
540        0x1f,   0x73,   0xfd,   0xb0,   0xb3,   0xd2,   0x86,   0x29,   0x89,   0xd0,   0x33,   0xd0,   0xdc,   0x85,   0xa7,   0xec, 
541        0xe8,   0x11,   0xfe,   0x2d,   0x46,   0x9f,   0xa5,   0xd0,   0x4d,   0xde,   0x9f,   0x34,   0x02,   0x31,   0x00, 
542};
543
544extern void PSIP_MSS_P_decompressString( const uint8_t *p_decodeTree, const uint8_t *p_compressedString, uint8_t numberBytes, int *p_stringSize, char *p_string );
545extern const uint8_t PSIP_decode_tree_01[];
546extern const uint8_t PSIP_decode_tree_02[];
547
548int test_huffman(void)
549{
550        #define TEST_STRING_SIZE (8*1024)
551        uint8_t *str = malloc(TEST_STRING_SIZE);
552        int size;
553       
554        size = TEST_STRING_SIZE;
555        PSIP_MSS_P_decompressString(PSIP_decode_tree_02, g_compressed_data_0, 39, &size, str);
556        if( size != 91 )
557                return 10;
558        printf("%d: %s\n", size, str);
559
560        size = TEST_STRING_SIZE;
561        PSIP_MSS_P_decompressString(PSIP_decode_tree_02, g_compressed_data_1, 34, &size, str);
562        if( size != 68 )
563                return 11;
564        printf("%d: %s\n", size, str);
565
566        size = TEST_STRING_SIZE;
567        PSIP_MSS_P_decompressString(PSIP_decode_tree_02, g_compressed_data_2, 29, &size, str);
568        if( size != 58 )
569                return 12;
570        printf("%d: %s\n", size, str);
571
572        size = TEST_STRING_SIZE;
573        PSIP_MSS_P_decompressString(PSIP_decode_tree_02, g_compressed_data_3, 143, &size, str);
574        if( size != 303 )
575                return 13;
576        printf("%d: %s\n", size, str);
577       
578        return 0;
579}
580unsigned char g_message_data_0[75] = {
581
582        0xcb, // EIT   
583  0xf0, 0x4b, // Length = 0x4B
584  0x00, 0x07, // Source         
585  0xdf, // ? 2b0, 5bVersion, 1b1       
586  0x00, // Section #   
587  0x00, // Last section         
588  0x00, // Protocol     
589  0x02, // Num events   
590  // Event 1
591  0xc3, 0xda,   // 2b1 + Event ID       
592  0x33,         0x0e, 0xa7, 0x8d, // Start time         
593  0xc0,         0x70, 0x80, // ? 2b1, 2bETM, 20bSeconds
594  0x0c,         // Title len (12)
595  // compr text
596  0x01,         0x65,   0x6e,   0x67,   0x01,   0x01,   0x00,   0x04,   0x2a,   0xf0,   0x60,   0xba,
597        0xf0,   0x08, // descr len (8) 
598  0x81,         0x06,   0x08,   0xbc,   0x1b,   0x09,   0x1f,   0x00,   
599  // Event 2
600  0xc3,         0xdd, // Event id       
601  0x33,         0x0f,   0x18,   0x0d, // start time
602        0xc0,   0x70,   0x80, // ? 2b1, 2bETM, 20bSeconds
603  0x0c,         // Title len (12)
604  // compr text
605  0x01,         0x65,   0x6e,   0x67,   0x01,   0x01,   0x00,   0x04,   0x2a,   0xf0,   0x60,   0xba, 
606        0xf0,   0x08, // desc len (8)   
607  0x81,         0x06,   0x08,   0xbc,   0x1b,   0x09,   0x1f,   0x00,   
608  0xbe, // missing CRC bytes?
609  };
610unsigned char g_message_data_1[75] = {
611
612        0xcb,   0xf0,   0x4b,   0x00,   0x07,   0xdf,   0x00,   0x00,   0x00,   0x02,   0xc3,   0xda,   0x33,   0x0e,   0xa7,   0x8d, 
613        0xc0,   0x70,   0x80,   0x0c,   0x01,   0x65,   0x6e,   0x67,   0x01,   0x01,   0x00,   0x04,   0x2a,   0xf0,   0x60,   0xba, 
614        0xf0,   0x08,   0x81,   0x06,   0x08,   0xbc,   0x1b,   0x09,   0x1f,   0x00,   0xc3,   0xdd,   0x33,   0x0f,   0x18,   0x0d, 
615        0xc0,   0x70,   0x80,   0x0c,   0x01,   0x65,   0x6e,   0x67,   0x01,   0x01,   0x00,   0x04,   0x2a,   0xf0,   0x60,   0xba, 
616        0xf0,   0x08,   0x81,   0x06,   0x08,   0xbc,   0x1b,   0x09,   0x1f,   0x00,   0xbe, };
617unsigned char g_message_data_2[165] = {
618
619        0xcc, // ETT   
620  0xf0,  0xa5, // len   
621  0x00,         0x00, // 0x00   
622  0xc7, // 2b1, 5bVer, 1b1     
623  0x00, // sec num     
624  0x00, // last sec num         
625  0x00, // protocol ver         
626  0x00,         0x16,   0x65,   0xe6, // etm id
627  // Text start...
628  0x01, // num strings 
629  0x65,         0x6e, 0x67, // iso lang code
630  0x01, // num segs     
631  0x02, // compr type   
632  0x00, // mode         
633  0x8f, // num bytes   
634  0x4c,         0xd7,   0xc4,   0xfa,   0x1c,   0x41,   0x4c,   0x77,   0xee,   0xff,   0xf7, 
635        0x73,   0x72,   0xe6,   0x65,   0xeb,   0xbd,   0xde,   0xb5,   0xcb,   0x3e,   0x9d,   0x77,   0xbd,   0x31,   0x68,   0x7f, 
636        0xb7,   0x75,   0x2a,   0xb1,   0xd5,   0x2a,   0xda,   0x7d,   0x42,   0x57,   0xb2,   0x66,   0xe7,   0x17,   0x33,   0xfc, 
637        0xb1,   0xae,   0x68,   0xc5,   0xcf,   0x53,   0xb6,   0x33,   0xe6,   0x73,   0x6f,   0x0c,   0x5b,   0x9c,   0xcb,   0xd7, 
638        0x7c,   0xed,   0x11,   0xb6,   0xfe,   0xef,   0xcd,   0xdf,   0x30,   0xe2,   0x42,   0xd3,   0x70,   0x56,   0xc2,   0xd1, 
639        0x17,   0x6d,   0x39,   0x0e,   0xd1,   0x54,   0x7f,   0x26,   0xdf,   0xdd,   0xfb,   0xfc,   0xb0,   0x8b,   0x4f,   0xfb, 
640        0x26,   0x6e,   0x7e,   0x90,   0xdb,   0xa7,   0x92,   0x0a,   0xd7,   0xa8,   0x9c,   0xd7,   0xea,   0xe9,   0xf1,   0xe3, 
641        0x1d,   0xca,   0xb2,   0xef,   0xf5,   0x1f,   0x73,   0xfd,   0xb0,   0xb3,   0xd2,   0x86,   0x29,   0x89,   0xd0,   0x33, 
642        0xd0,   0xdc,   0x85,   0xa7,   0xec,   0xe8,   0x11,   0xfe,   0x2d,   0x46,   0x9f,   0xa5,   0xd0,   0x4d,   0xde,   0x9f, 
643        0x34,   
644  0x02,         0x31,   0x00,   0x90, // CRC
645  };
646unsigned char g_message_data_3[43] = {
647
648        0xcb, // EIT   
649  0xf0,         0x2b, // len   
650  0x00,         0x07, // source id     
651  0xcb, // ver 
652  0x00, // sec num
653  0x00, // last sec     
654  0x00, // protocol     
655  0x01, // num events   
656  0xc3,         0xdd, // event id       
657  0x33,         0x0f,   0x18,   0x0d, // start time
658        0xc0,   0x70,   0x80,   0x0c,   0x01,   0x65,   0x6e,   0x67,   0x01,   0x01,   0x00,   0x04,   0x2a,   0xf0,   0x60,   0xba, 
659        0xf0,   0x08,   0x81,   0x06,   0x08,   0xbc,   0x1b,   0x09,   0x1f,   0x00,   0x83, };
660unsigned char g_message_data_4[104] = {
661
662        0xcc,   0xf0,   0x68,   0x00,   0x00,   0xcb,   0x00,   0x00,   0x00,   0x00,   0x15,   0x54,   0x0a,   0x01,   0x65,   0x6e, 
663        0x67,   0x01,   0x02,   0x00,   0x52,   0x67,   0x31,   0x77,   0xd4,   0xc3,   0x67,   0x7b,   0xd3,   0xed,   0xcb,   0xc0, 
664        0x14,   0x33,   0x19,   0xbf,   0x25,   0xc2,   0x44,   0x80,   0xc9,   0x7d,   0x0f,   0x3e,   0x58,   0x7c,   0x06,   0x72, 
665        0x09,   0x70,   0xa3,   0x0a,   0xbe,   0xf2,   0x0e,   0x98,   0xde,   0x51,   0xe9,   0xa1,   0x62,   0xf3,   0x8a,   0x12, 
666        0x8e,   0xdd,   0x38,   0x75,   0xf6,   0xf6,   0x69,   0x8f,   0xfc,   0x07,   0x5e,   0x3f,   0xed,   0x75,   0x3d,   0xa5, 
667        0x21,   0xec,   0x33,   0xaa,   0xc3,   0x28,   0x89,   0xfe,   0x0e,   0x1c,   0xa2,   0xfb,   0x13,   0x6a,   0x8e,   0xa6, 
668        0xbf,   0xa9,   0x15,   0x99,   0xde,   0xeb,   0x00,   0xaf, };
669unsigned char g_message_data_5[75] = {
670
671        0xcb,   0xf0,   0x4b,   0x00,   0x07,   0xcb,   0x00,   0x00,   0x00,   0x02,   0xc3,   0xe0,   0x33,   0x0f,   0x88,   0x8d, 
672        0xc0,   0x70,   0x80,   0x0c,   0x01,   0x65,   0x6e,   0x67,   0x01,   0x01,   0x00,   0x04,   0x2a,   0xf0,   0x60,   0xba, 
673        0xf0,   0x08,   0x81,   0x06,   0x08,   0xbc,   0x1b,   0x09,   0x1f,   0x00,   0xc3,   0xe3,   0x33,   0x0f,   0xf9,   0x0d, 
674        0xc0,   0x70,   0x80,   0x0c,   0x01,   0x65,   0x6e,   0x67,   0x01,   0x01,   0x00,   0x04,   0x2a,   0xf0,   0x60,   0xba, 
675        0xf0,   0x08,   0x81,   0x06,   0x08,   0xbc,   0x1b,   0x09,   0x1f,   0x00,   0x92, };
676unsigned char g_message_data_6[65] = {
677
678        0xcc,   0xf0,   0x41,   0x00,   0x00,   0xcb,   0x00,   0x00,   0x00,   0x00,   0x16,   0x66,   0x7a,   0x01,   0x65,   0x6e, 
679        0x67,   0x01,   0x02,   0x00,   0x2b,   0x9f,   0xda,   0x2f,   0x92,   0x40,   0xc6,   0xe8,   0xdf,   0xe5,   0x88,   0x17, 
680        0xb3,   0xa8,   0x87,   0xde,   0x8f,   0xf8,   0xc5,   0x77,   0x6e,   0xfc,   0x9c,   0x23,   0xef,   0xb9,   0x5c,   0xc3, 
681        0x75,   0x4e,   0x0d,   0xb7,   0x7b,   0x8f,   0x2c,   0x29,   0xce,   0x21,   0xeb,   0x17,   0xd4,   0x2a,   0x35,   0x62, 
682        0xd6, };
683
684unsigned char g_message_data_7[] = {
685/* ###  chan_mgr: ETT: 0x1d01(0) <seg1/8><seg3/8><seg5/8><seg7/8> */
6860xcc, 0xf0, 0x6b, 0x00, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x0e, 
6870x01, 0x65, 0x6e, 0x67, 0x08, 
6880x00, 0x00, 0x08, 0x3c, 0x73, 0x65, 0x67, 0x31, 0x2f, 0x38, 0x3e, 
6890x00, 0x01, 0x08, 0x3c, 0x73, 0x65, 0x67, 0x32, 0x2f, 0x38, 0x3e, 
6900x00, 0x00, 0x08, 0x3c, 0x73, 0x65, 0x67, 0x33, 0x2f, 0x38, 0x3e, 
6910x00, 0x01, 0x08, 0x3c, 0x73, 0x65, 0x67, 0x34, 0x2f, 0x38, 0x3e, 
6920x00, 0x00, 0x08, 0x3c, 0x73, 0x65, 0x67, 0x35, 0x2f, 0x38, 0x3e, 
6930x00, 0x01, 0x08, 0x3c, 0x73, 0x65, 0x67, 0x36, 0x2f, 0x38, 0x3e, 
6940x00, 0x00, 0x08, 0x3c, 0x73, 0x65, 0x67, 0x37, 0x2f, 0x38, 0x3e, 
6950x00, 0x01, 0x08, 0x3c, 0x73, 0x65, 0x67, 0x38, 0x2f, 0x38, 0x3e, 
6960x83, 
697};
698
699unsigned char g_message_data_8[] = {
700/* ###  chan_mgr: ETT: 0x1d01(0) */ 
7010xcc, 0xf0, 0x26, 0x00, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x12, 
7020x01, 0x65, 0x6e, 0x67, 0x01, 
7030x01, 0x00, 0x10, 0xcb, 0x68, 0xe7, 0x3f, 0x7e, 0x5b, 0x6e, 0xc8, 0x5c, 0x81, 0x31, 0x11, 0xbe, 0x26, 0x9c, 0x00, 
7040x72, 
705};
706
707int test_message(void)
708{
709        processMessages( g_message_data_0, sizeof(g_message_data_0) );
710        processMessages( g_message_data_1, sizeof(g_message_data_1) );
711        processMessages( g_message_data_2, sizeof(g_message_data_2) );
712        processMessages( g_message_data_3, sizeof(g_message_data_3) );
713        processMessages( g_message_data_4, sizeof(g_message_data_4) );
714        processMessages( g_message_data_5, sizeof(g_message_data_5) );
715        processMessages( g_message_data_6, sizeof(g_message_data_6) );
716        processMessages( g_message_data_7, sizeof(g_message_data_7) );
717        processMessages( g_message_data_8, sizeof(g_message_data_8) );
718       
719        return 0;
720}
721
722
723int main(int argc, char* argv[])
724{
725        static uint8_t buf[188];
726        FILE    *source;
727
728        /* Stream Statistics */
729        int             nullPacketCount = 0;
730        int             packetCount = 0;
731
732        /* Packet structures */
733        TS_packet ts_packet;
734
735        if( argc != 2 )
736        {
737                printf("USAGE:\n");
738                printf("psip [sourceFile|HUFFMAN|MESSAGE]\n\n");
739                return 1;
740        }
741       
742        if( strcmp(argv[1], "HUFFMAN") == 0)
743        {
744                return test_huffman();
745        }
746
747        if( strcmp(argv[1], "MESSAGE") == 0)
748        {
749                return test_message();
750        }
751
752        if( (source=fopen(argv[1], "rb"))==NULL )
753        {
754                printf("Unable to open source file: %s", argv[1]);
755                return 2;
756        }
757
758        while( fread( buf, 1, 188, source ) )
759        {
760                packetCount++;
761                TS_parseTsPacket( buf, &ts_packet );
762
763                if( ts_packet.PID == 0x1FFF )
764                {
765                        nullPacketCount++;
766                }
767                else
768                {
769                        processPid( &ts_packet );
770                }
771        }
772
773        fclose(source);
774        printf("Packet Count = %d\n", packetCount);
775        printf("Null Packet Count = %d\n", nullPacketCount);
776
777        return 0;
778}
Note: See TracBrowser for help on using the repository browser.