clib/dvb_ts_lib/descriptors/parse_desc_linkage.c

filter: Statementstmt 0.0% 0 / 51 Branchbran 0.0% 0 / 32 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 83 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« clib/dvb_ts_lib/descriptors/parse_desc_frequency_list.c ↑ Summary clib/dvb_ts_lib/descriptors/parse_desc_local_time_offset.c »
1 /*
2 * parse_desc_linkage.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_linkage.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 // linkage_descriptor(){
43 // descriptor_tag 8 uimsbf
44 // descriptor_length 8 uimsbf
45 // transport_stream_id 16 uimsbf
46 // original_network_id 16 uimsbf
47 // service_id 16 uimsbf
48 // linkage_type 8 uimsbf
49 // if (linkage_type !=0x08){
50 // for (i=0;i<N;i++){
51 // private_data_byte 8 bslbf
52 // }
53 // }
54 // if (linkage_type ==0x08){
55 // hand_over_type 4 bslbf
56 // reserved_future_use 3 bslbf
57 // origin_type 1 bslbf
58 // if (hand_over_type ==0x01
59 // network_id 16 uimsbf
60 // }
61 // if (origin_type ==0x00){
62 // initial_service_id 16 uimsbf
63 // }
64 // for (i=0;i<N;i++){
65 // private_data_byte 8 bslbf
66 // }
67 // }
68 // }
69
70
71 /* ----------------------------------------------------------------------- */
72 0 void print_linkage(struct Descriptor_linkage *ld, int level)
73 {
74 struct list_head *item, *safe;
75
76 0 printf(" Descriptor: linkage [0x%02x]\n", ld->descriptor_tag) ;
77 0 printf(" Length: %d\n", ld->descriptor_length) ;
78
79 0 printf(" transport_stream_id = %d\n", ld->transport_stream_id) ;
80 0 printf(" original_network_id = %d\n", ld->original_network_id) ;
81 0 printf(" service_id = %d\n", ld->service_id) ;
82 0 printf(" linkage_type = %d\n", ld->linkage_type) ;
83 0 ▶ if (ld->linkage_type != 0x8 )
Branch: 1 branch
BranchTrueFalseTotal
if (ld->linkage_type != 0x8 ) 0 0 0
84 {
85 0 printf(" private_data = \"%s\"\n", ld->private_data) ;
86 }
87
88 0 ▶ if (ld->linkage_type == 0x8 )
Branch: 1 branch
BranchTrueFalseTotal
if (ld->linkage_type == 0x8 ) 0 0 0
89 {
90 0 printf(" hand_over_type = %d\n", ld->hand_over_type) ;
91 0 printf(" origin_type = %d\n", ld->origin_type) ;
92 0 ▶ if (ld->hand_over_type == 0x1 || ld->hand_over_type == 0x2 || ld->hand_over_type == 0x3 )
Branch: 3 branches
BranchTrueFalseTotal
if (ld->hand_over_type == 0x1 || ld->hand_over_type == 0x2 || ld->hand_over_type == 0x3 ) 0 0 0
if (ld->hand_over_type == 0x1 || ld->hand_over_type == 0x2 || ld->hand_over_type == 0x3 ) 0 0 0
if (ld->hand_over_type == 0x1 || ld->hand_over_type == 0x2 || ld->hand_over_type == 0x3 ) 0 0 0
93 {
94 0 printf(" network_id = %d\n", ld->network_id) ;
95 }
96
97 0 ▶ if (ld->origin_type == 0x0 )
Branch: 1 branch
BranchTrueFalseTotal
if (ld->origin_type == 0x0 ) 0 0 0
98 {
99 0 printf(" initial_service_id = %d\n", ld->initial_service_id) ;
100 }
101
102 0 printf(" private_data1 = \"%s\"\n", ld->private_data1) ;
103 }
104
105 0 }
106
107 /* ----------------------------------------------------------------------- */
108 0 struct Descriptor *parse_linkage(struct TS_bits *bits, unsigned tag, unsigned len)
109 {
110 struct Descriptor_linkage *ld ;
111 unsigned byte ;
112 int end_buff_len ;
113
114 0 ld = (struct Descriptor_linkage *)malloc( sizeof(*ld) ) ;
115 0 memset(ld,0,sizeof(*ld));
116
117 //== Parse data ==
118 0 INIT_LIST_HEAD(&ld->next);
119 0 ld->descriptor_tag = tag ; // already extracted by parse_desc()
120 0 ld->descriptor_length = len ; // already extracted by parse_desc()
121 0 ld->transport_stream_id = bits_get(bits, 16) ;
122 0 ld->original_network_id = bits_get(bits, 16) ;
123 0 ld->service_id = bits_get(bits, 16) ;
124 0 ld->linkage_type = bits_get(bits, 8) ;
125 0 ▶ if (ld->linkage_type != 0x8 )
Branch: 1 branch
BranchTrueFalseTotal
if (ld->linkage_type != 0x8 ) 0 0 0
126 {
127
128 0 end_buff_len = bits_len_calc(bits, -(ld->descriptor_length - 7)) ;
129 0 ld->private_data[0] = 0 ;
130 0 ▶ for (byte=0; (bits->buff_len > end_buff_len) && (byte < MAX_PRIVATE_DATA_LEN); ++byte)
Branch: 2 branches
BranchTrueFalseTotal
for (byte=0; (bits->buff_len > end_buff_len) && (byte < MAX_PRIVATE_DATA_LEN); ++byte) 0 0 0
for (byte=0; (bits->buff_len > end_buff_len) && (byte < MAX_PRIVATE_DATA_LEN); ++byte) 0 0 0
131 {
132 0 ld->private_data[byte] = bits_get(bits, 8) ;
133 0 ld->private_data[byte+1] = 0 ;
134 }
135
136 }
137
138 0 ▶ if (ld->linkage_type == 0x8 )
Branch: 1 branch
BranchTrueFalseTotal
if (ld->linkage_type == 0x8 ) 0 0 0
139 {
140 0 ld->hand_over_type = bits_get(bits, 4) ;
141 0 bits_skip(bits, 3) ;
142 0 ld->origin_type = bits_get(bits, 1) ;
143 0 ▶ if (ld->hand_over_type == 0x1 || ld->hand_over_type == 0x2 || ld->hand_over_type == 0x3 )
Branch: 3 branches
BranchTrueFalseTotal
if (ld->hand_over_type == 0x1 || ld->hand_over_type == 0x2 || ld->hand_over_type == 0x3 ) 0 0 0
if (ld->hand_over_type == 0x1 || ld->hand_over_type == 0x2 || ld->hand_over_type == 0x3 ) 0 0 0
if (ld->hand_over_type == 0x1 || ld->hand_over_type == 0x2 || ld->hand_over_type == 0x3 ) 0 0 0
144 {
145 0 ld->network_id = bits_get(bits, 16) ;
146 }
147
148 0 ▶ if (ld->origin_type == 0x0 )
Branch: 1 branch
BranchTrueFalseTotal
if (ld->origin_type == 0x0 ) 0 0 0
149 {
150 0 ld->initial_service_id = bits_get(bits, 16) ;
151 }
152
153
154 0 end_buff_len = bits_len_calc(bits, -(ld->descriptor_length - 12)) ;
155 0 ld->private_data1[0] = 0 ;
156 0 ▶ for (byte=0; (bits->buff_len > end_buff_len) && (byte < MAX_PRIVATE_DATA1_LEN); ++byte)
Branch: 2 branches
BranchTrueFalseTotal
for (byte=0; (bits->buff_len > end_buff_len) && (byte < MAX_PRIVATE_DATA1_LEN); ++byte) 0 0 0
for (byte=0; (bits->buff_len > end_buff_len) && (byte < MAX_PRIVATE_DATA1_LEN); ++byte) 0 0 0
157 {
158 0 ld->private_data1[byte] = bits_get(bits, 8) ;
159 0 ld->private_data1[byte+1] = 0 ;
160 }
161
162 }
163
164
165 0 return (struct Descriptor *)ld ;
166 }
167
168 /* ----------------------------------------------------------------------- */
169 0 void free_linkage(struct Descriptor_linkage *ld)
170 {
171 struct list_head *item, *safe;
172
173 0 free(ld) ;
174 0 }
« clib/dvb_ts_lib/descriptors/parse_desc_frequency_list.c ↑ Summary clib/dvb_ts_lib/descriptors/parse_desc_local_time_offset.c »