melunko@47
|
1 |
/* GStreamer
|
melunko@47
|
2 |
* Copyright (C) <2006> Renato Araujo Oliveira Filho <renato.filho@indt.org.br>
|
melunko@47
|
3 |
* Rosfran Borges <rosfran.borges@indt.org.br>
|
melunko@47
|
4 |
*
|
melunko@47
|
5 |
* This library is free software; you can redistribute it and/or
|
melunko@47
|
6 |
* modify it under the terms of the GNU Library General Public
|
melunko@47
|
7 |
* License as published by the Free Software Foundation; either
|
melunko@47
|
8 |
* version 2 of the License, or (at your option) any later version.
|
melunko@47
|
9 |
*
|
melunko@47
|
10 |
* This library is distributed in the hope that it will be useful,
|
melunko@47
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
melunko@47
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
melunko@47
|
13 |
* Library General Public License for more details.
|
melunko@47
|
14 |
*
|
melunko@47
|
15 |
* You should have received a copy of the GNU Library General Public
|
melunko@47
|
16 |
* License along with this library; if not, write to the
|
melunko@47
|
17 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
melunko@47
|
18 |
* Boston, MA 02111-1307, USA.
|
melunko@47
|
19 |
*/
|
melunko@47
|
20 |
|
melunko@47
|
21 |
#ifndef __GST_NUV_DEMUX_H__
|
melunko@47
|
22 |
#define __GST_NUV_DEMUX_H__
|
melunko@47
|
23 |
|
melunko@47
|
24 |
#include <gst/gst.h>
|
melunko@47
|
25 |
|
melunko@47
|
26 |
#include <gst/base/gstadapter.h>
|
melunko@47
|
27 |
|
melunko@47
|
28 |
G_BEGIN_DECLS
|
melunko@47
|
29 |
|
melunko@47
|
30 |
#define GST_TYPE_NUV_DEMUX \
|
melunko@47
|
31 |
(gst_nuv_demux_get_type ())
|
melunko@47
|
32 |
#define GST_NUV_DEMUX(obj) \
|
melunko@47
|
33 |
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_NUV_DEMUX, GstNuvDemux))
|
melunko@47
|
34 |
#define GST_NUV_DEMUX_CLASS(klass) \
|
melunko@47
|
35 |
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_NUV_DEMUX, GstNuvDemuxClass))
|
melunko@47
|
36 |
#define GST_IS_NUV_DEMUX(obj) \
|
melunko@47
|
37 |
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_NUV_DEMUX))
|
melunko@47
|
38 |
#define GST_IS_NUV_DEMUX_CLASS(klass) \
|
melunko@47
|
39 |
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_NUV_DEMUX))
|
melunko@47
|
40 |
|
rosfran@73
|
41 |
#define DEMUX_INDEX_SIZE_MAX (100000)
|
rosfran@73
|
42 |
|
rosfran@56
|
43 |
/* Indexes (timecodes/offsets) conversion structures */
|
rosfran@56
|
44 |
typedef struct
|
rosfran@56
|
45 |
{
|
rosfran@56
|
46 |
gint64 i_time;
|
rosfran@56
|
47 |
gint64 i_offset;
|
rosfran@56
|
48 |
|
rosfran@56
|
49 |
} nuv_demux_index_entry;
|
rosfran@56
|
50 |
|
rosfran@56
|
51 |
typedef struct
|
rosfran@56
|
52 |
{
|
rosfran@56
|
53 |
gint i_idx;
|
rosfran@56
|
54 |
gint i_idx_max;
|
rosfran@56
|
55 |
|
rosfran@73
|
56 |
nuv_demux_index_entry idx[DEMUX_INDEX_SIZE_MAX];
|
rosfran@56
|
57 |
} nuv_demux_index;
|
melunko@47
|
58 |
|
melunko@47
|
59 |
/* */
|
melunko@47
|
60 |
typedef struct
|
melunko@47
|
61 |
{
|
melunko@47
|
62 |
gchar id[12]; /* "NuppelVideo\0" or "MythTVVideo\0" */
|
melunko@47
|
63 |
gchar version[5]; /* "x.xx\0" */
|
melunko@47
|
64 |
|
melunko@47
|
65 |
gint i_width;
|
melunko@47
|
66 |
gint i_height;
|
melunko@47
|
67 |
gint i_width_desired;
|
melunko@47
|
68 |
gint i_height_desired;
|
melunko@47
|
69 |
|
melunko@47
|
70 |
gchar i_mode; /* P progressive, I interlaced */
|
melunko@47
|
71 |
|
melunko@47
|
72 |
gdouble d_aspect; /* 1.0 squared pixel */
|
melunko@47
|
73 |
gdouble d_fps;
|
melunko@47
|
74 |
|
melunko@47
|
75 |
gint i_video_blocks; /* 0 no video, -1 unknown */
|
melunko@47
|
76 |
gint i_audio_blocks;
|
melunko@47
|
77 |
gint i_text_blocks;
|
melunko@47
|
78 |
|
melunko@47
|
79 |
gint i_keyframe_distance;
|
melunko@47
|
80 |
|
melunko@47
|
81 |
} nuv_header;
|
melunko@47
|
82 |
|
melunko@47
|
83 |
typedef struct
|
melunko@47
|
84 |
{
|
melunko@47
|
85 |
gchar i_type; /* A: audio, V: video, S: sync; T: test
|
melunko@47
|
86 |
R: Seekpoint (string:RTjjjjjjjj)
|
melunko@47
|
87 |
D: Extra data for codec */
|
melunko@47
|
88 |
gchar i_compression; /* V: 0 uncompressed
|
melunko@47
|
89 |
1 RTJpeg
|
melunko@47
|
90 |
2 RTJpeg+lzo
|
melunko@47
|
91 |
N black frame
|
melunko@47
|
92 |
L copy last
|
melunko@47
|
93 |
A: 0 uncompressed (44100 1-bits, 2ch)
|
melunko@47
|
94 |
1 lzo
|
melunko@47
|
95 |
2 layer 2
|
melunko@47
|
96 |
3 layer 3
|
melunko@47
|
97 |
F flac
|
melunko@47
|
98 |
S shorten
|
melunko@47
|
99 |
N null frame loudless
|
melunko@47
|
100 |
L copy last
|
melunko@47
|
101 |
S: B audio and vdeo sync point
|
melunko@47
|
102 |
A audio sync info (timecode == effective
|
melunko@47
|
103 |
dsp frequency*100)
|
melunko@47
|
104 |
V next video sync (timecode == next video
|
melunko@47
|
105 |
frame num)
|
melunko@47
|
106 |
S audio,video,text correlation */
|
melunko@47
|
107 |
gchar i_keyframe; /* 0 keyframe, else no no key frame */
|
melunko@47
|
108 |
guint8 i_filters; /* 0x01: gauss 5 pixel (8,2,2,2,2)/16
|
melunko@47
|
109 |
0x02: gauss 5 pixel (8,1,1,1,1)/12
|
melunko@47
|
110 |
0x04: cartoon filter */
|
melunko@47
|
111 |
|
rosfran@73
|
112 |
gint32 i_timecode; /* ms */
|
melunko@47
|
113 |
|
rosfran@56
|
114 |
gint i_length; /* V,A,T: length of following data
|
melunko@47
|
115 |
S: length of packet correl */
|
melunko@47
|
116 |
} nuv_frame_header;
|
melunko@47
|
117 |
|
melunko@47
|
118 |
/* FIXME Not sure of this one */
|
melunko@47
|
119 |
typedef struct
|
melunko@47
|
120 |
{
|
melunko@47
|
121 |
gint i_version;
|
melunko@47
|
122 |
guint32 i_video_fcc;
|
melunko@47
|
123 |
|
melunko@47
|
124 |
guint32 i_audio_fcc;
|
melunko@47
|
125 |
gint i_audio_sample_rate;
|
melunko@47
|
126 |
gint i_audio_bits_per_sample;
|
melunko@47
|
127 |
gint i_audio_channels;
|
melunko@47
|
128 |
gint i_audio_compression_ratio;
|
melunko@47
|
129 |
gint i_audio_quality;
|
melunko@47
|
130 |
gint i_rtjpeg_quality;
|
melunko@47
|
131 |
gint i_rtjpeg_luma_filter;
|
melunko@47
|
132 |
gint i_rtjpeg_chroma_filter;
|
melunko@47
|
133 |
gint i_lavc_bitrate;
|
melunko@47
|
134 |
gint i_lavc_qmin;
|
melunko@47
|
135 |
gint i_lavc_qmax;
|
melunko@47
|
136 |
gint i_lavc_maxqdiff;
|
melunko@47
|
137 |
gint64 i_seekable_offset;
|
melunko@47
|
138 |
gint64 i_keyframe_adjust_offset;
|
melunko@47
|
139 |
|
melunko@47
|
140 |
} nuv_extended_header;
|
melunko@47
|
141 |
|
melunko@47
|
142 |
typedef enum {
|
melunko@47
|
143 |
GST_NUV_DEMUX_START,
|
melunko@47
|
144 |
GST_NUV_DEMUX_HEADER_DATA,
|
melunko@47
|
145 |
GST_NUV_DEMUX_EXTRA_DATA,
|
melunko@47
|
146 |
GST_NUV_DEMUX_MPEG_DATA,
|
melunko@47
|
147 |
GST_NUV_DEMUX_EXTEND_HEADER,
|
melunko@47
|
148 |
GST_NUV_DEMUX_EXTEND_HEADER_DATA,
|
melunko@47
|
149 |
GST_NUV_DEMUX_FRAME_HEADER,
|
melunko@47
|
150 |
GST_NUV_DEMUX_MOVI,
|
melunko@47
|
151 |
GST_NUV_DEMUX_INVALID_DATA
|
melunko@47
|
152 |
} GstNuvDemuxState;
|
melunko@47
|
153 |
|
melunko@47
|
154 |
typedef struct _GstNuvDemux {
|
melunko@47
|
155 |
GstElement parent;
|
melunko@47
|
156 |
|
melunko@47
|
157 |
guint mode;
|
melunko@47
|
158 |
GstAdapter *adapter;
|
melunko@47
|
159 |
|
melunko@47
|
160 |
/* pads */
|
melunko@47
|
161 |
GstPad *sinkpad;
|
melunko@47
|
162 |
GstPad *src_video_pad;
|
melunko@47
|
163 |
GstPad *src_audio_pad;
|
melunko@47
|
164 |
|
melunko@47
|
165 |
/* NUV decoding state */
|
melunko@47
|
166 |
GstNuvDemuxState state;
|
melunko@47
|
167 |
guint64 offset;
|
renatofilho@77
|
168 |
guint last_time;
|
renatofilho@77
|
169 |
|
melunko@47
|
170 |
|
melunko@47
|
171 |
/* Mpeg ExtraData */
|
melunko@47
|
172 |
guint64 mpeg_data_size;
|
melunko@47
|
173 |
GstBuffer *mpeg_buffer;
|
melunko@47
|
174 |
|
melunko@47
|
175 |
nuv_header *h;
|
melunko@47
|
176 |
nuv_extended_header *eh;
|
melunko@47
|
177 |
nuv_frame_header *fh;
|
rosfran@56
|
178 |
|
rosfran@56
|
179 |
/* index */
|
rosfran@56
|
180 |
nuv_demux_index *index_entries;
|
rosfran@56
|
181 |
guint index_size;
|
rosfran@56
|
182 |
guint64 index_offset;
|
rosfran@56
|
183 |
guint current_entry;
|
rosfran@56
|
184 |
|
leo_sobral@80
|
185 |
/* FIXME: change these fields to private struct */
|
leo_sobral@80
|
186 |
/* first data buffer received, should sent new_segment */
|
leo_sobral@80
|
187 |
gboolean new_audio_segment;
|
leo_sobral@80
|
188 |
gboolean new_video_segment;
|
melunko@47
|
189 |
} GstNuvDemux;
|
melunko@47
|
190 |
|
melunko@47
|
191 |
typedef struct _GstNuvDemuxClass {
|
melunko@47
|
192 |
GstElementClass parent_class;
|
melunko@47
|
193 |
} GstNuvDemuxClass;
|
melunko@47
|
194 |
|
melunko@47
|
195 |
GType gst_nuv_demux_get_type (void);
|
melunko@47
|
196 |
|
melunko@47
|
197 |
G_END_DECLS
|
melunko@47
|
198 |
|
melunko@47
|
199 |
#endif /* __GST_NUV_DEMUX_H__ */
|