• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C) 2004 Wim Taymans <wim@fluendo.com>
3  * Copyright (c) 2012 Collabora Ltd.
4  *	Author : Edward Hervey <edward@collabora.com>
5  *      Author : Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef __GST_THEORAENC_H__
24 #define __GST_THEORAENC_H__
25 
26 #include <gst/gst.h>
27 #include <gst/base/gstadapter.h>
28 #include <gst/video/gstvideoencoder.h>
29 #include <theora/theoraenc.h>
30 
31 G_BEGIN_DECLS
32 
33 #define GST_TYPE_THEORA_ENC \
34   (gst_theora_enc_get_type())
35 #define GST_THEORA_ENC(obj) \
36   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_THEORA_ENC,GstTheoraEnc))
37 #define GST_THEORA_ENC_CLASS(klass) \
38   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_THEORA_ENC,GstTheoraEncClass))
39 #define GST_IS_THEORA_ENC(obj) \
40   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_THEORA_ENC))
41 #define GST_IS_THEORA_ENC_CLASS(klass) \
42   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_THEORA_ENC))
43 
44 typedef struct _GstTheoraEnc GstTheoraEnc;
45 typedef struct _GstTheoraEncClass GstTheoraEncClass;
46 
47 /**
48  * GstTheoraEncMultipassMode:
49  * @MULTIPASS_MODE_SINGLE_PASS: Single pass encoding
50  * @MULTIPASS_MODE_FIRST_PASS: First pass of two pass encoding
51  * @MULTIPASS_MODE_SECOND_PASS: Second pass of two pass encoding
52  *
53  */
54 typedef enum
55 {
56   MULTIPASS_MODE_SINGLE_PASS,
57   MULTIPASS_MODE_FIRST_PASS,
58   MULTIPASS_MODE_SECOND_PASS
59 } GstTheoraEncMultipassMode;
60 
61 /**
62  * GstTheoraEnc:
63  *
64  * Opaque data structure.
65  */
66 struct _GstTheoraEnc
67 {
68   GstVideoEncoder element;
69 
70   ogg_stream_state to;
71 
72   th_enc_ctx *encoder;
73   th_info info;
74   th_comment comment;
75   gboolean initialised;
76 
77   gint video_bitrate;           /* bitrate target for Theora video */
78   gboolean bitrate_changed;
79   gint video_quality;           /* Theora quality selector 0 = low, 63 = high */
80   gboolean quality_changed;
81   gboolean keyframe_auto;
82   gint keyframe_freq;
83   gint keyframe_force;
84 
85   GstVideoCodecState *input_state;
86 
87   gint width, height;
88   gint fps_n, fps_d;
89 
90   guint packetno;
91   guint64 bytes_out;
92   guint64 granulepos_offset;
93   guint64 timestamp_offset;
94   guint64 pfn_offset;
95 
96   gint speed_level;
97   gboolean vp3_compatible;
98   gboolean drop_frames;
99   gboolean cap_overflow;
100   gboolean cap_underflow;
101   int rate_buffer;
102 
103   GstTheoraEncMultipassMode multipass_mode;
104   GIOChannel *multipass_cache_fd;
105   GstAdapter *multipass_cache_adapter;
106   gchar *multipass_cache_file;
107 };
108 
109 struct _GstTheoraEncClass
110 {
111   GstVideoEncoderClass parent_class;
112 };
113 
114 GType gst_theora_enc_get_type (void);
115 
116 GST_ELEMENT_REGISTER_DECLARE (theoraenc);
117 
118 G_END_DECLS
119 
120 #endif /* __GST_THEORAENC_H__ */
121 
122