0.10.28.3 pre-release
[platform/upstream/gstreamer.git] / gst / quicktime / descriptors.h
1 /* Quicktime muxer plugin for GStreamer
2  * Copyright (C) 2008 Thiago Sousa Santos <thiagoss@embedded.ufcg.edu.br>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 /*
20  * Unless otherwise indicated, Source Code is licensed under MIT license.
21  * See further explanation attached in License Statement (distributed in the file
22  * LICENSE).
23  *
24  * Permission is hereby granted, free of charge, to any person obtaining a copy of
25  * this software and associated documentation files (the "Software"), to deal in
26  * the Software without restriction, including without limitation the rights to
27  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
28  * of the Software, and to permit persons to whom the Software is furnished to do
29  * so, subject to the following conditions:
30  *
31  * The above copyright notice and this permission notice shall be included in all
32  * copies or substantial portions of the Software.
33  *
34  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
40  * SOFTWARE.
41  */
42
43 #ifndef __DESCRIPTORS_H__
44 #define __DESCRIPTORS_H__
45
46 #include <glib.h>
47 #include <string.h>
48 #include "properties.h"
49
50 /*
51  * Tags for descriptor (each kind is represented by a number, instead of fourcc as in atoms)
52  */
53 #define OBJECT_DESC_TAG            0x01
54 #define INIT_OBJECT_DESC_TAG       0x02
55 #define ES_DESCRIPTOR_TAG          0x03
56 #define DECODER_CONFIG_DESC_TAG    0x04
57 #define DECODER_SPECIFIC_INFO_TAG  0x05
58 #define SL_CONFIG_DESC_TAG         0x06
59 #define ES_ID_INC_TAG              0x0E
60 #define MP4_INIT_OBJECT_DESC_TAG   0x10
61
62 #define ESDS_OBJECT_TYPE_MPEG1_P3       0x6B
63 #define ESDS_OBJECT_TYPE_MPEG2_P7_MAIN  0x66
64 #define ESDS_OBJECT_TYPE_MPEG4_P7_LC    0x67
65 #define ESDS_OBJECT_TYPE_MPEG4_P7_SSR   0x68
66 #define ESDS_OBJECT_TYPE_MPEG4_P2       0x20
67 #define ESDS_OBJECT_TYPE_MPEG4_P3       0x40
68
69 #define ESDS_STREAM_TYPE_VISUAL         0x04
70 #define ESDS_STREAM_TYPE_AUDIO          0x05
71
72
73 typedef struct _BaseDescriptor
74 {
75   guint8 tag;
76   /* the first bit of each byte indicates if the next byte should be used */
77   guint8 size[4];
78 } BaseDescriptor;
79
80 typedef struct _SLConfigDescriptor
81 {
82   BaseDescriptor base;
83
84   guint8 predefined;              /* everything is supposed predefined */
85 } SLConfigDescriptor;
86
87 typedef struct _DecoderSpecificInfoDescriptor
88 {
89   BaseDescriptor base;
90   guint32 length;
91   guint8 *data;
92 } DecoderSpecificInfoDescriptor;
93
94 typedef struct _DecoderConfigDescriptor {
95   BaseDescriptor base;
96
97   guint8 object_type;
98
99   /* following are condensed into streamType:
100    * bit(6) streamType;
101    * bit(1) upStream;
102    * const bit(1) reserved=1;
103   */
104   guint8 stream_type;
105
106   guint8 buffer_size_DB[3];
107   guint32 max_bitrate;
108   guint32 avg_bitrate;
109
110   DecoderSpecificInfoDescriptor *dec_specific_info;
111 } DecoderConfigDescriptor;
112
113 typedef struct _ESDescriptor
114 {
115   BaseDescriptor base;
116
117   guint16 id;
118
119   /* flags contains the following:
120    * bit(1) streamDependenceFlag;
121    * bit(1) URL_Flag;
122    * bit(1) OCRstreamFlag;
123    * bit(5) streamPriority;
124    */
125   guint8 flags;
126
127   guint16 depends_on_es_id;
128   guint8 url_length;              /* only if URL_flag is set */
129   guint8 *url_string;             /* size is url_length */
130
131   guint16 ocr_es_id;              /* only if OCRstreamFlag is set */
132
133   DecoderConfigDescriptor dec_conf_desc;
134   SLConfigDescriptor sl_conf_desc;
135
136   /* optional remainder of ESDescriptor is not used */
137 } ESDescriptor;
138
139 /* --- FUNCTIONS --- */
140 void    desc_es_init                               (ESDescriptor *es);
141 ESDescriptor *desc_es_descriptor_new               (void);
142 guint64 desc_es_descriptor_copy_data               (ESDescriptor *es, guint8 **buffer,
143                                                     guint64 *size, guint64 *offset);
144 void    desc_es_descriptor_clear                   (ESDescriptor *es);
145
146 DecoderSpecificInfoDescriptor *desc_dec_specific_info_new(void);
147 void    desc_dec_specific_info_free                (DecoderSpecificInfoDescriptor *dsid);
148 void    desc_dec_specific_info_alloc_data          (DecoderSpecificInfoDescriptor *dsid,
149                                                     guint32 size);
150
151 #endif /* __DESCRIPTORS_H__ */