Wasabi ExpressPlay SDK for Embedded Systems  1.10
Ts2Descriptors.h
Go to the documentation of this file.
1 /*****************************************************************
2 |
3 | MPEG2 Transport Stream - Descriptors
4 |
5 | $Id: Ts2Descriptors.h 296 2014-06-25 11:20:09Z jebaseelir $
6 | Original author: Julien Boeuf
7 |
8 | This software is provided to you pursuant to your agreement
9 | with Intertrust Technologies Corporation ("Intertrust").
10 | This software may be used only in accordance with the terms
11 | of the agreement.
12 |
13 | Copyright (c) 2010-2014 by Intertrust. All rights reserved.
14 |
15 ****************************************************************/
16 
17 #ifndef _TS2_DESCRIPTORS_H_
18 #define _TS2_DESCRIPTORS_H_
19 
20 /*----------------------------------------------------------------------
21 | includes
22 +---------------------------------------------------------------------*/
23 #include "Atomix.h"
24 
25 /*----------------------------------------------------------------------
26 | constants
27 +---------------------------------------------------------------------*/
28 #define TS2_DESCRIPTOR_HEADER_SIZE 2
29 
30 #define TS2_VIDEO_STREAM_DESCRIPTOR_TAG 2
31 #define TS2_AUDIO_STREAM_DESCRIPTOR_TAG 3
32 #define TS2_CA_DESCRIPTOR_TAG 9
33 
34 /*----------------------------------------------------------------------
35 | types
36 +---------------------------------------------------------------------*/
37 typedef struct TS2_Descriptor TS2_Descriptor; /* forward declaration */
38 
40  /* public */
41  ATX_UInt8 tag;
42  ATX_UInt8 length; /* length of the fields */
43  ATX_Boolean is_generic;
44 
45  /* internal */
46  void (*Destroy)(TS2_Descriptor* self);
47  ATX_Result (*SerializeFields)(TS2_Descriptor* self,
48  ATX_Byte* buffer);
49 };
50 
51 typedef struct {
53  ATX_UInt8 flags;
55 
56 typedef struct {
58  ATX_UInt8 flags;
59  /* following are optional, see flags */
61  ATX_UInt8 optional_info;
63 
64 typedef struct {
66  ATX_UInt16 system_id; /* CA_system_ID 16 bit */
67  ATX_UInt16 pid; /* CA_PID 13 bit */
68  ATX_Byte* private_data; /* size is TS2_CADescriptor_GetPrivateDataSize */
70 
71 typedef struct {
73  ATX_Byte* data; /* size is TS2_GenericDescriptor_GetDataSize */
75 
76 
77 typedef enum {
78  AS_GENERIC = -1,
85 
86 /*----------------------------------------------------------------------
87 | functions
88 +---------------------------------------------------------------------*/
89 #ifdef __cplusplus
90 extern "C" {
91 #endif
92 
93 ATX_Result
94 TS2_Descriptor_Parse(const ATX_Byte* data,
95  ATX_Size* data_size, /* in/out */
96  TS2_DescriptorType desc_type, /* what is the descriptor type / context for parsing */
97  ATX_Boolean as_generic, /* whether to short-circuit regular parsing and force parsing as generic descriptor */
98  TS2_Descriptor** desc);
99 
107 ATX_Result
109  ATX_Byte* buffer);
110 
111 ATX_Size
112 TS2_DescriptorList_GetSize(ATX_List* descs);
113 
114 ATX_Result
115 TS2_DescriptorList_Serialize(ATX_List* descs, ATX_Byte* buffer);
116 
117 void
118 TS2_DescriptorList_Destroy(ATX_List* descs);
119 
120 ATX_Result
121 TS2_CADescriptor_Create(ATX_UInt16 system_id,
122  ATX_UInt16 pid,
123  const ATX_Byte* private_data,
124  ATX_Size private_data_size,
125  TS2_CADescriptor** ca_desc);
126 
127 #ifdef __cplusplus
128 }
129 #endif
130 
131 /*----------------------------------------------------------------------
132 | helpers
133 +---------------------------------------------------------------------*/
138 #define TS2_Descriptor_Destroy(self) (self)->Destroy(self)
139 
144 #define TS2_Descriptor_GetSize(self) ((self)->length + 2)
145 
146 #define TS2_CADescriptor_GetPrivateDataSize(self) \
147  (ATX_Size)((self->base.length-4))
148 
149 #define TS2_VideoStreamDescriptor_Mpeg1OnlyFlag(vdesc) ((vdesc)->flags & 0x04)
150 
151 #endif /* _TS2_DESCRIPTORS_H_ */