1 /*
2  * Copyright (c) 2013-2014 - Mauro Carvalho Chehab <mchehab@kernel.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation version 2.1 of the License.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
17  *
18  * Described on ARIB STD-B10 as TS information descriptor
19  */
20 
21 /**
22  * @file desc_ts_info.h
23  * @ingroup descriptors
24  * @brief Provides the descriptors for the ISDB TS information descriptor.
25  * The TS information descriptor specifies the remote control key
26  * identifier assigned to the applicable TS and indicates the relationship
27  * between the service identifier and the transmission layer during
28  * hierarchical transmission.
29  *
30  * @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
31  * @author Mauro Carvalho Chehab
32  *
33  * @par Relevant specs
34  * The descriptor described herein is defined at:
35  * - ARIB STD-B10
36  *
37  * @par Bug Report
38  * Please submit bug reports and patches to linux-media@vger.kernel.org
39  */
40 
41 #ifndef _TS_INFO_H
42 #define _TS_INFO_H
43 
44 #include <libdvbv5/descriptors.h>
45 
46 /**
47  * @struct dvb_desc_ts_info_transmission_type
48  * @ingroup descriptors
49  * @brief ISDB TS information transmission type
50  *
51  * @param transmission_type_info	transmission type info
52  * @param num_of_service	num of service
53  */
54 struct dvb_desc_ts_info_transmission_type {
55 	uint8_t transmission_type_info;
56 	uint8_t num_of_service;
57 } __attribute__((packed));
58 
59 /**
60  * @struct dvb_desc_ts_info
61  * @ingroup descriptors
62  * @brief Structure describing the ISDB TS information descriptor.
63  *
64  * @param type			descriptor tag
65  * @param length		descriptor length
66  * @param next			pointer to struct dvb_desc
67  * @param remote_control_key_id	remote control key id
68  * @param length_of_ts_name	length of ts name
69  * @param transmission_type_count	transmission type count
70  *
71  * @param ts_name		ts name string
72  * @param ts_name_emph		ts name emphasis string
73  * @param transmission_type	struct dvb_desc_ts_info_transmission_type content
74  * @param service_id		service id vector
75  */
76 struct dvb_desc_ts_info {
77 	uint8_t type;
78 	uint8_t length;
79 	struct dvb_desc *next;
80 
81 	char *ts_name, *ts_name_emph;
82 	struct dvb_desc_ts_info_transmission_type transmission_type;
83 	uint16_t *service_id;
84 
85 	union {
86 		uint16_t bitfield;
87 		struct {
88 			uint8_t transmission_type_count:2;
89 			uint8_t length_of_ts_name:6;
90 			uint8_t remote_control_key_id:8;
91 		} __attribute__((packed));
92 	};
93 } __attribute__((packed));
94 
95 struct dvb_v5_fe_parms;
96 
97 #ifdef __cplusplus
98 extern "C" {
99 #endif
100 
101 /**
102  * @brief Initializes and parses the ISDB TS information descriptor.
103  * 	  descriptor
104  * @ingroup descriptors
105  *
106  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
107  * @param buf	buffer containing the descriptor's raw data
108  * @param desc	pointer to struct dvb_desc to be allocated and filled
109  *
110  * This function allocates a the descriptor and fills the fields inside
111  * the struct. It also makes sure that all fields will follow the CPU
112  * endianness. Due to that, the content of the buffer may change.
113  *
114  * @return On success, it returns the size of the allocated struct.
115  *	   A negative value indicates an error.
116  */
117 int dvb_desc_ts_info_init(struct dvb_v5_fe_parms *parms,
118 			  const uint8_t *buf, struct dvb_desc *desc);
119 
120 /**
121  * @brief Prints the content of the ISDB TS information descriptor.
122  *	  descriptor
123  * @ingroup descriptors
124  *
125  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
126  * @param desc	pointer to struct dvb_desc
127  */
128 void dvb_desc_ts_info_print(struct dvb_v5_fe_parms *parms,
129 			    const struct dvb_desc *desc);
130 
131 /**
132  * @brief Frees all data allocated by the ISDB TS information descriptor.
133  *	  descriptor
134  * @ingroup descriptors
135  *
136  * @param desc pointer to struct dvb_desc to be freed
137  */
138 void dvb_desc_ts_info_free(struct dvb_desc *desc);
139 
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif
145