Debian Codegraph @

lib/include/libdvbv5/desc_ca.h

raw
1 /*
2 * Copyright (c) 2013 - Andre Roth <[email protected]>
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 at ETSI EN 300 468 V1.11.1 (2010-04)
19 */
20
21 /**
22 * @file desc_ca.h
23 * @ingroup descriptors
24 * @brief Provides the descriptors for Conditional Access
25 * @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
26 * @author Andre Roth
27 *
28 * @par Relevant specs
29 * The descriptor described herein is defined at:
30 * - ETSI EN 300 468 V1.11.1 (2010-04)
31 *
32 * @see http://www.etherguidesystems.com/help/sdos/mpeg/semantics/mpeg-2/descriptors/CA_descriptor.aspx
33 *
34 * @par Bug Report
35 * Please submit bug reports and patches to [email protected]
36 */
37
38 #ifndef _CA_H
39 #define _CA_H
40
41 #include <libdvbv5/descriptors.h>
42
43 /**
44 * @struct dvb_desc_ca
45 * @ingroup descriptors
46 * @brief Contains the private data for Conditional Access
47 *
48 * @param type descriptor tag
49 * @param length descriptor length
50 * @param next pointer to struct dvb_desc
51 * @param ca_id Conditional Access ID
52 * @param ca_pid Conditional Access ID
53 * @param privdata pointer to private data buffer
54 * @param privdata_len length of the private data
55 */
56 struct dvb_desc_ca {
57 uint8_t type;
58 uint8_t length;
59 struct dvb_desc *next;
60
61 uint16_t ca_id;
62 union {
63 uint16_t bitfield1;
64 struct {
65 uint16_t ca_pid:13;
66 uint16_t reserved:3;
67 } __attribute__((packed));
68 } __attribute__((packed));
69
70 uint8_t *privdata;
71 uint8_t privdata_len;
72 } __attribute__((packed));
73
74 struct dvb_v5_fe_parms;
75
76 /** @brief initial descriptor field at dvb_desc_ca struct */
77 #define dvb_desc_ca_field_first ca_id
78 /** @brief last descriptor field at dvb_desc_ca struct */
79 #define dvb_desc_ca_field_last privdata
80
81 #ifdef __cplusplus
82 extern "C" {
83 #endif
84
85 /**
86 * @brief Initializes and parses the CA descriptor
87 * @ingroup descriptors
88 *
89 * @param parms struct dvb_v5_fe_parms pointer to the opened device
90 * @param buf buffer containing the descriptor's raw data
91 * @param desc pointer to struct dvb_desc to be allocated and filled
92 *
93 * This function allocates a the descriptor and fills the fields inside
94 * the struct. It also makes sure that all fields will follow the CPU
95 * endianness. Due to that, the content of the buffer may change.
96 *
97 * @return On success, it returns the size of the allocated struct.
98 * A negative value indicates an error.
99 */
100 int dvb_desc_ca_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
101 struct dvb_desc *desc);
102
103 /**
104 * @brief Prints the content of the CA descriptor
105 * @ingroup descriptors
106 *
107 * @param parms struct dvb_v5_fe_parms pointer to the opened device
108 * @param desc pointer to struct dvb_desc
109 */
110 void dvb_desc_ca_print(struct dvb_v5_fe_parms *parms,
111 const struct dvb_desc *desc);
112
113 /**
114 * @brief Frees all data allocated by the CA descriptor
115 * @ingroup descriptors
116 *
117 * @param desc pointer to struct dvb_desc to be freed
118 */
119 void dvb_desc_ca_free(struct dvb_desc *desc);
120
121 #ifdef __cplusplus
122 }
123 #endif
124
125 #endif