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., 51 Franklin St, Fifth Floor, 19 * Boston, MA 02110-1301, 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 gboolean audio_clipping; 74 75 GstCaps *caps; 76 77 gboolean is_video; 78 gboolean always_flush_page; 79 80 /* vorbis stuff */ 81 int nln_increments[4]; 82 int nsn_increment; 83 int short_size; 84 int long_size; 85 int vorbis_log2_num_modes; 86 int vorbis_mode_sizes[256]; 87 int last_size; 88 int version; 89 gint bitrate_upper; 90 gint bitrate_nominal; 91 gint bitrate_lower; 92 GstTagList *taglist; 93 /* theora stuff */ 94 gboolean theora_has_zero_keyoffset; 95 /* VP8 stuff */ 96 gboolean is_vp8; 97 gint64 invisible_count; 98 /* opus stuff */ 99 gint64 first_granpos; 100 /* OGM stuff */ 101 gboolean is_ogm; 102 gboolean is_ogm_text; 103 /* CMML */ 104 gboolean is_cmml; 105 /* fishead stuff */ 106 guint16 skeleton_major, skeleton_minor; 107 gint64 prestime; 108 gint64 basetime; 109 /* index */ 110 guint n_index; 111 GstOggIndex *index; 112 guint64 kp_denom; 113 guint64 idx_bitrate; 114 }; 115 116 117 gboolean gst_ogg_stream_setup_map (GstOggStream * pad, ogg_packet *packet); 118 gboolean gst_ogg_stream_setup_map_from_caps_headers (GstOggStream * pad, 119 const GstCaps * caps); 120 gboolean gst_ogg_stream_setup_map_from_caps (GstOggStream * pad, 121 const GstCaps * caps); 122 GstClockTime gst_ogg_stream_get_end_time_for_granulepos (GstOggStream *pad, 123 gint64 granulepos); 124 GstClockTime gst_ogg_stream_get_start_time_for_granulepos (GstOggStream *pad, 125 gint64 granulepos); 126 GstClockTime gst_ogg_stream_granule_to_time (GstOggStream *pad, gint64 granule); 127 gint64 gst_ogg_stream_granulepos_to_granule (GstOggStream * pad, gint64 granulepos); 128 gint64 gst_ogg_stream_granulepos_to_key_granule (GstOggStream * pad, gint64 granulepos); 129 gint64 gst_ogg_stream_granule_to_granulepos (GstOggStream * pad, gint64 granule, gint64 keyframe_granule); 130 GstClockTime gst_ogg_stream_get_packet_start_time (GstOggStream *pad, 131 ogg_packet *packet); 132 gboolean gst_ogg_stream_granulepos_is_key_frame (GstOggStream *pad, 133 gint64 granulepos); 134 gboolean gst_ogg_stream_packet_is_header (GstOggStream *pad, ogg_packet *packet); 135 gboolean gst_ogg_stream_packet_is_key_frame (GstOggStream *pad, ogg_packet *packet); 136 gint64 gst_ogg_stream_get_packet_duration (GstOggStream * pad, ogg_packet *packet); 137 void gst_ogg_stream_extract_tags (GstOggStream * pad, ogg_packet * packet); 138 const char *gst_ogg_stream_get_media_type (GstOggStream * pad); 139 GstBuffer *gst_ogg_stream_get_headers (GstOggStream *pad); 140 void gst_ogg_stream_update_stats (GstOggStream * pad, ogg_packet * packet); 141 142 gboolean gst_ogg_map_parse_fisbone (GstOggStream * pad, const guint8 * data, guint size, 143 guint32 * serialno, GstOggSkeleton *type); 144 gboolean gst_ogg_map_add_fisbone (GstOggStream * pad, GstOggStream * skel_pad, const guint8 * data, guint size, 145 GstClockTime * p_start_time); 146 gboolean gst_ogg_map_add_index (GstOggStream * pad, GstOggStream * skel_pad, const guint8 * data, guint size); 147 gboolean gst_ogg_map_search_index (GstOggStream * pad, gboolean before, guint64 *timestamp, guint64 *offset); 148 149 150 151 152 G_END_DECLS 153 154 #endif /* __GST_OGG_STREAM_H__ */ 155