1 /*****************************************************************************
2 * desc_5f.h: ETSI EN 300 468 Descriptor 0x5f: Private data specifier
3 *****************************************************************************
4 * Copyright (C) 2009-2010 VideoLAN
5 *
6 * Authors: Christophe Massiot <massiot@via.ecp.fr>
7 * Georgi Chorbadzhiyski <georgi@unixsol.org>
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining
10 * a copy of this software and associated documentation files (the
11 * "Software"), to deal in the Software without restriction, including
12 * without limitation the rights to use, copy, modify, merge, publish,
13 * distribute, sublicense, and/or sell copies of the Software, and to
14 * permit persons to whom the Software is furnished to do so, subject
15 * to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be
18 * included in all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 *****************************************************************************/
28
29 /*
30 * Normative references:
31 * - ETSI EN 300 468 V1.11.1 (2010-04) (SI in DVB systems)
32 */
33
34 #ifndef __BITSTREAM_DVB_DESC_5F_H__
35 #define __BITSTREAM_DVB_DESC_5F_H__
36
37 #include <bitstream/common.h>
38 #include <bitstream/mpeg/psi/descriptors.h>
39
40 #ifdef __cplusplus
41 extern "C"
42 {
43 #endif
44
45 /*****************************************************************************
46 * Descriptor 0x5f: Private data specifier descriptor
47 *****************************************************************************/
48 #define DESC5F_HEADER_SIZE (DESC_HEADER_SIZE + 4)
49
desc5f_init(uint8_t * p_desc)50 static inline void desc5f_init(uint8_t *p_desc)
51 {
52 desc_set_tag(p_desc, 0x5f);
53 desc_set_length(p_desc, DESC5F_HEADER_SIZE - DESC_HEADER_SIZE);
54 }
55
desc5f_get_specifier(const uint8_t * p_desc)56 static inline uint32_t desc5f_get_specifier(const uint8_t *p_desc)
57 {
58 return (p_desc[2] << 24) | (p_desc[3] << 16) |
59 (p_desc[4] << 8) | p_desc[5];
60 }
61
desc5f_set_specifier(uint8_t * p_desc,uint32_t i_specifier)62 static inline void desc5f_set_specifier(uint8_t *p_desc, uint32_t i_specifier)
63 {
64 p_desc[2] = (i_specifier >> 24) & 0xff;
65 p_desc[3] = (i_specifier >> 16) & 0xff;
66 p_desc[4] = (i_specifier >> 8) & 0xff;
67 p_desc[5] = i_specifier & 0xff;
68 }
69
desc5f_validate(const uint8_t * p_desc)70 static inline bool desc5f_validate(const uint8_t *p_desc)
71 {
72 return desc_get_length(p_desc) >= DESC5F_HEADER_SIZE - DESC_HEADER_SIZE;
73 }
74
desc5f_print(const uint8_t * p_desc,f_print pf_print,void * opaque,print_type_t i_print_type)75 static inline void desc5f_print(const uint8_t *p_desc, f_print pf_print,
76 void *opaque, print_type_t i_print_type)
77 {
78 switch (i_print_type) {
79 case PRINT_XML:
80 pf_print(opaque, "<PRIVATE_DATA_SPECIFIER_DESC specifier=\"0x%08x\" />",
81 desc5f_get_specifier(p_desc));
82 break;
83 default:
84 pf_print(opaque, " - desc 5f private_data specifier=0x%08x",
85 desc5f_get_specifier(p_desc));
86 }
87 }
88
89 #ifdef __cplusplus
90 }
91 #endif
92
93 #endif
94