tizen 2.0 init
[framework/multimedia/gst-plugins-base0.10.git] / ext / ogg / gstoggstream.h
1 /* GStreamer
2  * Copyright (C) 2009 David Schleef <ds@schleef.org>
3  *
4  * gstoggstream.h: header for GstOggStream
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21
22 #ifndef __GST_OGG_STREAM_H__
23 #define __GST_OGG_STREAM_H__
24
25 #include <ogg/ogg.h>
26
27 #include <gst/gst.h>
28 #include <gst/tag/tag.h>
29
30 G_BEGIN_DECLS
31
32 typedef enum {
33   GST_OGG_SKELETON_FISBONE,
34   GST_OGG_SKELETON_INDEX,
35 } GstOggSkeleton;
36
37 typedef struct {
38   guint64 offset;
39   guint64 timestamp;
40 } GstOggIndex;
41
42 typedef struct _GstOggStream GstOggStream;
43
44 struct _GstOggStream
45 {
46   ogg_stream_state stream;
47
48   guint32 serialno;
49   GList *headers;
50   gboolean have_headers;
51   GList *queued;
52
53   /* for oggparse */
54   gboolean in_headers;
55   GList *unknown_pages;
56   GList *stored_buffers;
57
58   gint map;
59   gboolean is_skeleton;
60   gboolean have_fisbone;
61   gint granulerate_n;
62   gint granulerate_d;
63   gint64 granule_offset;
64   guint32 preroll;
65   guint granuleshift;
66   gint n_header_packets;
67   gint n_header_packets_seen;
68   gint64 accumulated_granule;
69   gint frame_size;
70   gint bitrate;
71   guint64 total_time;
72   gboolean is_sparse;
73
74   GstCaps *caps;
75
76   gboolean is_video;
77   gboolean always_flush_page;
78
79   /* vorbis stuff */
80   int nln_increments[4];
81   int nsn_increment;
82   int short_size;
83   int long_size;
84   int vorbis_log2_num_modes;
85   int vorbis_mode_sizes[256];
86   int last_size;
87   int version;
88   gint bitrate_upper;
89   gint bitrate_nominal;
90   gint bitrate_lower;
91   GstTagList *taglist;
92   /* theora stuff */
93   gboolean theora_has_zero_keyoffset;
94   /* VP8 stuff */
95   gboolean is_vp8;
96   /* OGM stuff */
97   gboolean is_ogm;
98   gboolean is_ogm_text;
99   /* fishead stuff */
100   guint16 skeleton_major, skeleton_minor;
101   gint64 prestime;
102   gint64 basetime;
103   /* index */
104   guint n_index;
105   GstOggIndex *index;
106   guint64 kp_denom;
107   guint64 idx_bitrate;
108 };
109
110
111 gboolean gst_ogg_stream_setup_map (GstOggStream * pad, ogg_packet *packet);
112 gboolean gst_ogg_stream_setup_map_from_caps_headers (GstOggStream * pad,
113     const GstCaps * caps);
114 GstClockTime gst_ogg_stream_get_end_time_for_granulepos (GstOggStream *pad,
115     gint64 granulepos);
116 GstClockTime gst_ogg_stream_get_start_time_for_granulepos (GstOggStream *pad,
117     gint64 granulepos);
118 GstClockTime gst_ogg_stream_granule_to_time (GstOggStream *pad, gint64 granule);
119 gint64 gst_ogg_stream_granulepos_to_granule (GstOggStream * pad, gint64 granulepos);
120 gint64 gst_ogg_stream_granulepos_to_key_granule (GstOggStream * pad, gint64 granulepos);
121 gint64 gst_ogg_stream_granule_to_granulepos (GstOggStream * pad, gint64 granule, gint64 keyframe_granule);
122 GstClockTime gst_ogg_stream_get_packet_start_time (GstOggStream *pad,
123     ogg_packet *packet);
124 gboolean gst_ogg_stream_granulepos_is_key_frame (GstOggStream *pad,
125     gint64 granulepos);
126 gboolean gst_ogg_stream_packet_is_header (GstOggStream *pad, ogg_packet *packet);
127 gboolean gst_ogg_stream_packet_is_key_frame (GstOggStream *pad, ogg_packet *packet);
128 gint64 gst_ogg_stream_get_packet_duration (GstOggStream * pad, ogg_packet *packet);
129 void gst_ogg_stream_extract_tags (GstOggStream * pad, ogg_packet * packet);
130 const char *gst_ogg_stream_get_media_type (GstOggStream * pad);
131
132 gboolean gst_ogg_map_parse_fisbone (GstOggStream * pad, const guint8 * data, guint size,
133     guint32 * serialno, GstOggSkeleton *type);
134 gboolean gst_ogg_map_add_fisbone (GstOggStream * pad, GstOggStream * skel_pad, const guint8 * data, guint size,
135     GstClockTime * p_start_time);
136 gboolean gst_ogg_map_add_index (GstOggStream * pad, GstOggStream * skel_pad, const guint8 * data, guint size);
137 gboolean gst_ogg_map_search_index (GstOggStream * pad, gboolean before, guint64 *timestamp, guint64 *offset);
138
139
140
141
142 G_END_DECLS
143
144 #endif /* __GST_OGG_STREAM_H__ */