clib/dvb_ts_lib/descriptors/parse_desc_component.c

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 33 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« clib/dvb_ts_lib/descriptors/parse_desc_cell_frequency_link.c ↑ Summary clib/dvb_ts_lib/descriptors/parse_desc_content.c »
1 /*
2 * parse_desc_component.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_desc_component.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 // component_descriptor(){
43 // descriptor_tag 8 uimsbf
44 // descriptor_length 8 uimsbf
45 // reserved_future_use 4 bslbf
46 // stream_content 4 uimsbf
47 // component_type 8 uimsbf
48 // component_tag 8 uimsbf
49 // ISO_639_language_code 24 bslbf
50 // for (i=0;i<N;i++){
51 // text_char 8 uimsbf
52 // }
53 // }
54
55
56 /* ----------------------------------------------------------------------- */
57 0 void print_component(struct Descriptor_component *cd, int level)
58 {
59 struct list_head *item, *safe;
60
61 0 printf(" Descriptor: component [0x%02x]\n", cd->descriptor_tag) ;
62 0 printf(" Length: %d\n", cd->descriptor_length) ;
63
64 0 printf(" stream_content = %d\n", cd->stream_content) ;
65 0 printf(" component_type = %d\n", cd->component_type) ;
66 0 printf(" component_tag = %d\n", cd->component_tag) ;
67 0 printf(" ISO_639_language_code = %d\n", cd->ISO_639_language_code) ;
68 0 printf(" text = \"%s\"\n", cd->text) ;
69 0 }
70
71 /* ----------------------------------------------------------------------- */
72 0 struct Descriptor *parse_component(struct TS_bits *bits, unsigned tag, unsigned len)
73 {
74 struct Descriptor_component *cd ;
75 unsigned byte ;
76 int end_buff_len ;
77
78 0 cd = (struct Descriptor_component *)malloc( sizeof(*cd) ) ;
79 0 memset(cd,0,sizeof(*cd));
80
81 //== Parse data ==
82 0 INIT_LIST_HEAD(&cd->next);
83 0 cd->descriptor_tag = tag ; // already extracted by parse_desc()
84 0 cd->descriptor_length = len ; // already extracted by parse_desc()
85 0 bits_skip(bits, 4) ;
86 0 cd->stream_content = bits_get(bits, 4) ;
87 0 cd->component_type = bits_get(bits, 8) ;
88 0 cd->component_tag = bits_get(bits, 8) ;
89 0 cd->ISO_639_language_code = bits_get(bits, 24) ;
90
91 0 end_buff_len = bits_len_calc(bits, -(cd->descriptor_length - 6)) ;
92 0 cd->text[0] = 0 ;
93 0 ▶ for (byte=0; (bits->buff_len > end_buff_len) && (byte < MAX_TEXT_LEN); ++byte)
Branch: 2 branches
BranchTrueFalseTotal
for (byte=0; (bits->buff_len > end_buff_len) && (byte < MAX_TEXT_LEN); ++byte) 0 0 0
for (byte=0; (bits->buff_len > end_buff_len) && (byte < MAX_TEXT_LEN); ++byte) 0 0 0
94 {
95 0 cd->text[byte] = bits_get(bits, 8) ;
96 0 cd->text[byte+1] = 0 ;
97 }
98
99
100 0 return (struct Descriptor *)cd ;
101 }
102
103 /* ----------------------------------------------------------------------- */
104 0 void free_component(struct Descriptor_component *cd)
105 {
106 struct list_head *item, *safe;
107
108 0 free(cd) ;
109 0 }
« clib/dvb_ts_lib/descriptors/parse_desc_cell_frequency_link.c ↑ Summary clib/dvb_ts_lib/descriptors/parse_desc_content.c »