| 1 |
|
| /*
|
| 2 |
|
| * parse_si_st.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_st.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 |
|
| // stuffing_descriptor(){
|
| 43 |
|
| // descriptor_tag 8 uimsbf
|
| 44 |
|
| // descriptor_length 8 uimsbf
|
| 45 |
|
| // for (i= 0;i<N;i++){
|
| 46 |
|
| // stuffing_byte 8 bslbf
|
| 47 |
|
| // }
|
| 48 |
|
| // }
|
| 49 |
|
| // stuffing_section(){
|
| 50 |
|
| // table_id 8 uimsbf
|
| 51 |
|
| // section_syntax_indicator 1 bslbf
|
| 52 |
|
| // reserved_future_use 1 bslbf
|
| 53 |
|
| // reserved 2 bslbf
|
| 54 |
|
| // section_length 12 uimsbf
|
| 55 |
|
| // for (i=0;i<N;i++){
|
| 56 |
|
| // data_byte 8 uimsbf
|
| 57 |
|
| // }
|
| 58 |
|
| // }
|
| 59 |
|
|
|
| 60 |
|
|
|
| 61 |
|
| /* ----------------------------------------------------------------------- */
|
| 62 |
0 |
| void print_st(struct Section_stuffing *st)
|
| 63 |
|
| {
|
| 64 |
|
| struct list_head *item, *safe;
|
| 65 |
|
| int end_buff_len ;
|
| 66 |
|
|
|
| 67 |
0 |
| printf("Table: stuffing [0x%02x]\n", st->table_id) ;
|
| 68 |
0 |
| printf("Length: %d\n", st->section_length) ;
|
| 69 |
|
|
|
| 70 |
|
| //== data ==
|
| 71 |
0 |
| printf("section_syntax_indicator = %d\n", st->section_syntax_indicator) ;
|
| 72 |
0 |
| printf("section = \"%s\"\n", st->section) ;
|
| 73 |
0 |
| }
|
| 74 |
|
|
|
| 75 |
|
| /* ----------------------------------------------------------------------- */
|
| 76 |
0 |
| void parse_st(struct TS_reader *tsreader, struct TS_state *tsstate, struct TS_bits *bits,
|
| 77 |
|
| Section_handler handler, struct Section_decode_flags *flags)
|
| 78 |
|
| {
|
| 79 |
|
| struct Section_stuffing st ;
|
| 80 |
|
| struct list_head *item, *safe;
|
| 81 |
|
| unsigned byte ;
|
| 82 |
|
| int end_buff_len ;
|
| 83 |
|
|
|
| 84 |
|
| //== Parse data ==
|
| 85 |
|
|
|
| 86 |
0 |
| st.table_id = bits_get(bits, 8) ;
|
| 87 |
0 |
| st.section_syntax_indicator = bits_get(bits, 1) ;
|
| 88 |
0 |
| bits_skip(bits, 1) ;
|
| 89 |
0 |
| bits_skip(bits, 2) ;
|
| 90 |
0 |
| st.section_length = bits_get(bits, 12) ;
|
| 91 |
|
|
|
| 92 |
0 |
| end_buff_len = bits_len_calc(bits, -st.section_length) ;
|
| 93 |
0 |
| st.section[0] = 0 ;
|
| 94 |
0 |
▶ | for (byte=0; (bits->buff_len > end_buff_len) && (byte < MAX_SECTION_LEN); ++byte)
|
Branch: 2 branches
| Branch | True | False | Total |
| for (byte=0; (bits->buff_len > end_buff_len) && (byte < MAX_SECTION_LEN); ++byte)
|
0 |
0 |
0 |
| for (byte=0; (bits->buff_len > end_buff_len) && (byte < MAX_SECTION_LEN); ++byte)
|
0 |
0 |
0 |
|
| 95 |
|
| {
|
| 96 |
0 |
| st.section[byte] = bits_get(bits, 8) ;
|
| 97 |
0 |
| st.section[byte+1] = 0 ;
|
| 98 |
|
| }
|
| 99 |
|
|
|
| 100 |
|
|
|
| 101 |
|
| //== Call handler ==
|
| 102 |
0 |
▶ | if (handler)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (handler)
|
0 |
0 |
0 |
|
| 103 |
0 |
| handler(tsreader, tsstate, (struct Section *)&st, tsreader->user_data) ;
|
| 104 |
|
|
|
| 105 |
|
| //== Tidy up ==
|
| 106 |
0 |
| }
|