1 /* 2 * Copyright (C) 2012, Collabora Ltd. 3 * Author: Sebastian Dröge <sebastian.droege@collabora.co.uk> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation 8 * version 2.1 of the License. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 * 19 */ 20 21 #ifndef __GST_AMC_VIDEO_DEC_H__ 22 #define __GST_AMC_VIDEO_DEC_H__ 23 24 #include <gst/gst.h> 25 #include <gst/gl/gl.h> 26 27 #include <gst/video/gstvideodecoder.h> 28 29 #include "gstamc.h" 30 #include "gstamcsurfacetexture.h" 31 32 G_BEGIN_DECLS 33 34 #define GST_TYPE_AMC_VIDEO_DEC \ 35 (gst_amc_video_dec_get_type()) 36 #define GST_AMC_VIDEO_DEC(obj) \ 37 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AMC_VIDEO_DEC,GstAmcVideoDec)) 38 #define GST_AMC_VIDEO_DEC_CLASS(klass) \ 39 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AMC_VIDEO_DEC,GstAmcVideoDecClass)) 40 #define GST_AMC_VIDEO_DEC_GET_CLASS(obj) \ 41 (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_AMC_VIDEO_DEC,GstAmcVideoDecClass)) 42 #define GST_IS_AMC_VIDEO_DEC(obj) \ 43 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AMC_VIDEO_DEC)) 44 #define GST_IS_AMC_VIDEO_DEC_CLASS(obj) \ 45 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AMC_VIDEO_DEC)) 46 47 typedef struct _GstAmcVideoDec GstAmcVideoDec; 48 typedef struct _GstAmcVideoDecClass GstAmcVideoDecClass; 49 typedef enum _GstAmcCodecConfig GstAmcCodecConfig; 50 51 enum _GstAmcCodecConfig 52 { 53 AMC_CODEC_CONFIG_NONE, 54 AMC_CODEC_CONFIG_WITH_SURFACE, 55 AMC_CODEC_CONFIG_WITHOUT_SURFACE, 56 }; 57 58 struct _GstAmcVideoDec 59 { 60 GstVideoDecoder parent; 61 62 /* < private > */ 63 GstAmcCodec *codec; 64 GstAmcCodecConfig codec_config; 65 66 GstVideoCodecState *input_state; 67 gboolean input_state_changed; 68 69 /* Output format of the codec */ 70 GstVideoFormat format; 71 GstAmcColorFormatInfo color_format_info; 72 73 /* Output dimensions */ 74 guint width; 75 guint height; 76 77 guint8 *codec_data; 78 gsize codec_data_size; 79 /* TRUE if the component is configured and saw 80 * the first buffer */ 81 gboolean started; 82 gboolean flushing; 83 84 GstClockTime last_upstream_ts; 85 86 /* Draining state */ 87 GMutex drain_lock; 88 GCond drain_cond; 89 /* TRUE if EOS buffers shouldn't be forwarded */ 90 gboolean draining; 91 /* TRUE if the component is drained currently */ 92 gboolean drained; 93 94 GstAmcSurfaceTexture *surface; 95 96 GstGLDisplay *gl_display; 97 GstGLContext *gl_context; 98 GstGLContext *other_gl_context; 99 100 gboolean downstream_supports_gl; 101 GstFlowReturn downstream_flow_ret; 102 103 gboolean gl_mem_attached; 104 GstGLMemory *oes_mem; 105 GError *gl_error; 106 GMutex gl_lock; 107 GCond gl_cond; 108 guint gl_last_rendered_frame; 109 guint gl_pushed_frame_count; /* n buffers pushed */ 110 guint gl_ready_frame_count; /* n buffers ready for GL access */ 111 guint gl_released_frame_count; /* n buffers released */ 112 GQueue *gl_queue; 113 }; 114 115 struct _GstAmcVideoDecClass 116 { 117 GstVideoDecoderClass parent_class; 118 119 const GstAmcCodecInfo *codec_info; 120 }; 121 122 GType gst_amc_video_dec_get_type (void); 123 124 G_END_DECLS 125 126 #endif /* __GST_AMC_VIDEO_DEC_H__ */ 127