~ubuntu-branches/ubuntu/quantal/gst-plugins-bad-multiverse0.10/quantal

« back to all changes in this revision

Viewing changes to gst/mpegtsmux/tsmux/tsmuxstream.h

  • Committer: Bazaar Package Importer
  • Author(s): Onkar Shinde
  • Date: 2009-02-23 02:23:58 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20090223022358-9yhx5izc7dz60yc8
Tags: 0.10.10-0ubuntu1
* New upstream release.
* debian/rules
  - Disable some plugins which get built by default but we do not ship in 
    multiverse package.
  - Do not build docs as there is no multiverse-doc package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * Copyright 2006 BBC and Fluendo S.A. 
 
3
 *
 
4
 * This library is licensed under 4 different licenses and you
 
5
 * can choose to use it under the terms of any one of them. The
 
6
 * four licenses are the MPL 1.1, the LGPL, the GPL and the MIT
 
7
 * license.
 
8
 *
 
9
 * MPL:
 
10
 * 
 
11
 * The contents of this file are subject to the Mozilla Public License
 
12
 * Version 1.1 (the "License"); you may not use this file except in
 
13
 * compliance with the License. You may obtain a copy of the License at
 
14
 * http://www.mozilla.org/MPL/.
 
15
 *
 
16
 * Software distributed under the License is distributed on an "AS IS"
 
17
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 
18
 * License for the specific language governing rights and limitations
 
19
 * under the License.
 
20
 *
 
21
 * LGPL:
 
22
 *
 
23
 * This library is free software; you can redistribute it and/or
 
24
 * modify it under the terms of the GNU Library General Public
 
25
 * License as published by the Free Software Foundation; either
 
26
 * version 2 of the License, or (at your option) any later version.
 
27
 *
 
28
 * This library is distributed in the hope that it will be useful,
 
29
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
30
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
31
 * Library General Public License for more details.
 
32
 *
 
33
 * You should have received a copy of the GNU Library General Public
 
34
 * License along with this library; if not, write to the
 
35
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
36
 * Boston, MA 02111-1307, USA.
 
37
 *
 
38
 * GPL:
 
39
 *
 
40
 * This program is free software; you can redistribute it and/or modify
 
41
 * it under the terms of the GNU General Public License as published by
 
42
 * the Free Software Foundation; either version 2 of the License, or
 
43
 * (at your option) any later version.
 
44
 *
 
45
 * This program is distributed in the hope that it will be useful,
 
46
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
47
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
48
 * GNU General Public License for more details.
 
49
 *
 
50
 * You should have received a copy of the GNU General Public License
 
51
 * along with this program; if not, write to the Free Software
 
52
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
53
 *
 
54
 * MIT:
 
55
 *
 
56
 * Unless otherwise indicated, Source Code is licensed under MIT license.
 
57
 * See further explanation attached in License Statement (distributed in the file
 
58
 * LICENSE).
 
59
 * 
 
60
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 
61
 * this software and associated documentation files (the "Software"), to deal in
 
62
 * the Software without restriction, including without limitation the rights to
 
63
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 
64
 * of the Software, and to permit persons to whom the Software is furnished to do
 
65
 * so, subject to the following conditions:
 
66
 * 
 
67
 * The above copyright notice and this permission notice shall be included in all
 
68
 * copies or substantial portions of the Software.
 
69
 * 
 
70
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
71
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
72
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
73
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
74
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
75
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 
76
 * SOFTWARE.
 
77
 *
 
78
 */
 
79
 
 
80
#ifndef __TSMUXSTREAM_H__
 
81
#define __TSMUXSTREAM_H__
 
82
 
 
83
#include <glib.h>
 
84
 
 
85
#include "tsmuxcommon.h"
 
86
 
 
87
G_BEGIN_DECLS
 
88
 
 
89
typedef enum TsMuxStreamType TsMuxStreamType;
 
90
typedef enum TsMuxStreamState TsMuxStreamState;
 
91
typedef struct TsMuxStreamBuffer TsMuxStreamBuffer;
 
92
 
 
93
typedef void (*TsMuxStreamBufferReleaseFunc) (guint8 *data, void *user_data);
 
94
 
 
95
/* Stream type assignments
 
96
 *
 
97
 *   0x00    ITU-T | ISO/IEC Reserved
 
98
 *   0x01    ISO/IEC 11172 Video
 
99
 *   0x02    ITU-T Rec. H.262 | ISO/IEC 13818-2 Video or
 
100
 *           ISO/IEC 11172-2 constrained parameter video
 
101
 *           stream
 
102
 *   0x03    ISO/IEC 11172 Audio
 
103
 *   0x04    ISO/IEC 13818-3 Audio
 
104
 *   0x05    ITU-T Rec. H.222.0 | ISO/IEC 13818-1
 
105
 *           private_sections
 
106
 *   0x06    ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES
 
107
 *           packets containing private data
 
108
 *   0x07    ISO/IEC 13522 MHEG
 
109
 *   0x08    ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A
 
110
 *           DSM CC
 
111
 *   0x09    ITU-T Rec. H.222.1
 
112
 *   0x0A    ISO/IEC 13818-6 type A
 
113
 *   0x0B    ISO/IEC 13818-6 type B
 
114
 *   0x0C    ISO/IEC 13818-6 type C
 
115
 *   0x0D    ISO/IEC 13818-6 type D
 
116
 *   0x0E    ISO/IEC 13818-1 auxiliary
 
117
 * 0x0F-0x7F ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Reserved
 
118
 * 0x80-0xFF User Private
 
119
 */
 
120
enum TsMuxStreamType {
 
121
  TSMUX_ST_RESERVED                   = 0x00,
 
122
  TSMUX_ST_VIDEO_MPEG1                = 0x01,
 
123
  TSMUX_ST_VIDEO_MPEG2                = 0x02,
 
124
  TSMUX_ST_AUDIO_MPEG1                = 0x03,
 
125
  TSMUX_ST_AUDIO_MPEG2                = 0x04,
 
126
  TSMUX_ST_PRIVATE_SECTIONS           = 0x05,
 
127
  TSMUX_ST_PRIVATE_DATA               = 0x06,
 
128
  TSMUX_ST_MHEG                       = 0x07,
 
129
  TSMUX_ST_DSMCC                      = 0x08,
 
130
  TSMUX_ST_H222_1                     = 0x09,
 
131
 
 
132
  /* later extensions */
 
133
  TSMUX_ST_AUDIO_AAC                  = 0x0f,
 
134
  TSMUX_ST_VIDEO_MPEG4                = 0x10,
 
135
  TSMUX_ST_VIDEO_H264                 = 0x1b,
 
136
 
 
137
  /* private stream types */
 
138
  TSMUX_ST_PS_AUDIO_AC3               = 0x81,
 
139
  TSMUX_ST_PS_AUDIO_DTS               = 0x8a,
 
140
  TSMUX_ST_PS_AUDIO_LPCM              = 0x8b,
 
141
  TSMUX_ST_PS_DVD_SUBPICTURE          = 0xff,
 
142
 
 
143
  /* Non-standard definitions */
 
144
  TSMUX_ST_VIDEO_DIRAC                = 0xD1
 
145
};
 
146
 
 
147
enum TsMuxStreamState {
 
148
    TSMUX_STREAM_STATE_HEADER,
 
149
    TSMUX_STREAM_STATE_PACKET
 
150
};
 
151
 
 
152
/* TsMuxStream receives elementary streams for parsing.
 
153
 * Via the write_bytes() method, it can output a PES stream piecemeal */
 
154
struct TsMuxStream {
 
155
  TsMuxStreamState state;
 
156
  TsMuxPacketInfo pi;
 
157
  TsMuxStreamType stream_type;
 
158
  guint8 id; /* stream id */
 
159
  guint8 id_extended; /* extended stream id (13818-1 Amdt 2) */
 
160
 
 
161
  gboolean is_video_stream;
 
162
 
 
163
  /* List of data buffers available for writing out */
 
164
  GList *buffers;
 
165
  guint32 bytes_avail;
 
166
 
 
167
  /* Current data buffer being consumed */
 
168
  TsMuxStreamBuffer *cur_buffer;
 
169
  guint32 cur_buffer_consumed;
 
170
 
 
171
  TsMuxStreamBufferReleaseFunc buffer_release;
 
172
 
 
173
  guint16 pes_payload_size;
 
174
  guint16 cur_pes_payload_size;
 
175
  guint16 pes_bytes_written;
 
176
 
 
177
  /* PTS/DTS to write if the flags in the packet info are set */
 
178
  gint64 pts;
 
179
  gint64 dts;
 
180
 
 
181
  gint64 last_pts;
 
182
  gint64 last_dts;
 
183
 
 
184
  gint   pcr_ref;
 
185
  gint64 last_pcr;
 
186
 
 
187
  gint audio_sampling;
 
188
  gint audio_channels;
 
189
  gint audio_bitrate;
 
190
};
 
191
 
 
192
/* stream management */
 
193
TsMuxStream *   tsmux_stream_new                (guint16 pid, TsMuxStreamType stream_type);
 
194
void            tsmux_stream_free               (TsMuxStream *stream);
 
195
 
 
196
guint16         tsmux_stream_get_pid            (TsMuxStream *stream);
 
197
 
 
198
void            tsmux_stream_set_buffer_release_func    (TsMuxStream *stream, 
 
199
                                                         TsMuxStreamBufferReleaseFunc func);
 
200
 
 
201
/* Add a new buffer to the pool of available bytes. If pts or dts are not -1, they
 
202
 * indicate the PTS or DTS of the first access unit within this packet */
 
203
void            tsmux_stream_add_data           (TsMuxStream *stream, guint8 *data, guint len, 
 
204
                                                 void *user_data, gint64 pts, gint64 dts);
 
205
 
 
206
void            tsmux_stream_pcr_ref            (TsMuxStream *stream);
 
207
void            tsmux_stream_pcr_unref          (TsMuxStream *stream);
 
208
gboolean        tsmux_stream_is_pcr             (TsMuxStream *stream);
 
209
 
 
210
gboolean        tsmux_stream_at_pes_start       (TsMuxStream *stream);
 
211
void            tsmux_stream_get_es_descrs      (TsMuxStream *stream, guint8 *buf, guint16 *len);
 
212
 
 
213
gint            tsmux_stream_bytes_in_buffer    (TsMuxStream *stream);
 
214
gint            tsmux_stream_bytes_avail        (TsMuxStream *stream);
 
215
gboolean        tsmux_stream_get_data           (TsMuxStream *stream, guint8 *buf, guint len);
 
216
 
 
217
guint64         tsmux_stream_get_pts            (TsMuxStream *stream);
 
218
 
 
219
G_END_DECLS
 
220
 
 
221
#endif