| 1 |
|
| /*
|
| 2 |
|
| * parse_si_tdt.c
|
| 3 |
|
| *
|
| 4 |
|
| * Created by: si_desc.pl
|
| 5 |
|
| * Created on: 20-May-2011
|
| 6 |
|
| * Author: sdprice1
|
| 7 |
|
| */
|
| 8 |
|
|
|
| 9 |
|
|
|
| 10 |
|
| // VERSION = 1.00
|
| 11 |
|
|
|
| 12 |
|
| /*=============================================================================================*/
|
| 13 |
|
| // USES
|
| 14 |
|
| /*=============================================================================================*/
|
| 15 |
|
|
|
| 16 |
|
| #include <stdio.h>
|
| 17 |
|
| #include <stdlib.h>
|
| 18 |
|
| #include <unistd.h>
|
| 19 |
|
| #include <string.h>
|
| 20 |
|
| #include <errno.h>
|
| 21 |
|
| #include <ctype.h>
|
| 22 |
|
| #include <fcntl.h>
|
| 23 |
|
| #include <inttypes.h>
|
| 24 |
|
|
|
| 25 |
|
| #include "parse_si_tdt.h"
|
| 26 |
|
| #include "descriptors/parse_desc.h"
|
| 27 |
|
|
|
| 28 |
|
| /*=============================================================================================*/
|
| 29 |
|
| // CONSTANTS
|
| 30 |
|
| /*=============================================================================================*/
|
| 31 |
|
|
|
| 32 |
|
| /*=============================================================================================*/
|
| 33 |
|
| // MACROS
|
| 34 |
|
| /*=============================================================================================*/
|
| 35 |
|
|
|
| 36 |
|
| /*=============================================================================================*/
|
| 37 |
|
| // FUNCTIONS
|
| 38 |
|
| /*=============================================================================================*/
|
| 39 |
|
|
|
| 40 |
|
| /* ----------------------------------------------------------------------- */
|
| 41 |
|
| //
|
| 42 |
|
| // time_date_section(){
|
| 43 |
|
| // table_id 8 uimsbf
|
| 44 |
|
| // section_syntax_indicator 1 bslbf
|
| 45 |
|
| // reserved_future_use 1 bslbf
|
| 46 |
|
| // reserved 2 bslbf
|
| 47 |
|
| // section_length 12 uimsbf
|
| 48 |
|
| // UTC_time 40 bslbf
|
| 49 |
|
| // }
|
| 50 |
|
|
|
| 51 |
|
|
|
| 52 |
|
| /* ----------------------------------------------------------------------- */
|
| 53 |
0 |
| void print_tdt(struct Section_time_date *tdt)
|
| 54 |
|
| {
|
| 55 |
|
| struct list_head *item, *safe;
|
| 56 |
|
| int end_buff_len ;
|
| 57 |
|
|
|
| 58 |
0 |
| printf("Table: time_date [0x%02x]\n", tdt->table_id) ;
|
| 59 |
0 |
| printf("Length: %d\n", tdt->section_length) ;
|
| 60 |
|
|
|
| 61 |
|
| //== data ==
|
| 62 |
0 |
| printf("section_syntax_indicator = %d\n", tdt->section_syntax_indicator) ;
|
| 63 |
0 |
| printf("UTC_time = %02d-%02d-%04d %02d:%02d:%02d\n",
|
| 64 |
|
| tdt->UTC_time.tm_mday, tdt->UTC_time.tm_mon, tdt->UTC_time.tm_year,
|
| 65 |
|
| tdt->UTC_time.tm_hour, tdt->UTC_time.tm_min, tdt->UTC_time.tm_sec
|
| 66 |
|
| ) ;
|
| 67 |
0 |
| }
|
| 68 |
|
|
|
| 69 |
|
| /* ----------------------------------------------------------------------- */
|
| 70 |
0 |
| void parse_tdt(struct TS_reader *tsreader, struct TS_state *tsstate, struct TS_bits *bits,
|
| 71 |
|
| Section_handler handler, struct Section_decode_flags *flags)
|
| 72 |
|
| {
|
| 73 |
|
| struct Section_time_date tdt ;
|
| 74 |
|
| struct list_head *item, *safe;
|
| 75 |
|
| unsigned byte ;
|
| 76 |
|
| int end_buff_len ;
|
| 77 |
|
|
|
| 78 |
|
| //== Parse data ==
|
| 79 |
|
|
|
| 80 |
0 |
| tdt.table_id = bits_get(bits, 8) ;
|
| 81 |
0 |
| tdt.section_syntax_indicator = bits_get(bits, 1) ;
|
| 82 |
0 |
| bits_skip(bits, 1) ;
|
| 83 |
0 |
| bits_skip(bits, 2) ;
|
| 84 |
0 |
| tdt.section_length = bits_get(bits, 12) ;
|
| 85 |
0 |
| tdt.UTC_time = bits_get_mjd_time(bits) ;
|
| 86 |
|
|
|
| 87 |
|
| //== Call handler ==
|
| 88 |
0 |
▶ | if (handler)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (handler)
|
0 |
0 |
0 |
|
| 89 |
0 |
| handler(tsreader, tsstate, (struct Section *)&tdt, tsreader->user_data) ;
|
| 90 |
|
|
|
| 91 |
|
| //== Tidy up ==
|
| 92 |
0 |
| }
|