basescope: allow subclasses telling how many sample they need per frame
[platform/upstream/gstreamer.git] / gst / scopes / gstbasescope.h
1 /* GStreamer
2  * Copyright (C) <2011> Stefan Kost <ensonic@users.sf.net>
3  *
4  * gstbasescope.c: base class for audio visualisation elements
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program 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
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  */
20
21 #ifndef __GST_BASE_SCOPE_H__
22 #define __GST_BASE_SCOPE_H__
23
24 #include <gst/gst.h>
25 #include <gst/base/gstbasetransform.h>
26
27 #include <gst/video/video.h>
28 #include <gst/audio/audio.h>
29 #include <gst/base/gstadapter.h>
30
31 G_BEGIN_DECLS
32 #define GST_TYPE_BASE_SCOPE            (gst_base_scope_get_type())
33 #define GST_BASE_SCOPE(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_SCOPE,GstBaseScope))
34 #define GST_BASE_SCOPE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_SCOPE,GstBaseScopeClass))
35 #define GST_IS_SYNAESTHESIA(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_SCOPE))
36 #define GST_IS_SYNAESTHESIA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_SCOPE))
37 typedef struct _GstBaseScope GstBaseScope;
38 typedef struct _GstBaseScopeClass GstBaseScopeClass;
39
40 struct _GstBaseScope
41 {
42   GstElement parent;
43
44   /* pads */
45   GstPad *srcpad, *sinkpad;
46
47   GstAdapter *adapter;
48   GstBuffer *inbuf;
49
50   guint64 next_ts;              /* the timestamp of the next frame */
51   guint64 frame_duration;
52   guint bps;                    /* bytes per sample        */
53   guint spf;                    /* samples per video frame */
54   guint req_spf;                /* min samples per frame wanted by the subclass */
55
56   /* video state */
57   GstVideoFormat video_format;
58   gint fps_n, fps_d;
59   gint width;
60   gint height;
61   gint channels;
62
63   /* audio state */
64   gint sample_rate;
65   gint rate;
66 };
67
68 struct _GstBaseScopeClass
69 {
70   GstElementClass parent_class;
71
72   /* virtual function, called whenever the format changes */
73   gboolean (*setup) (GstBaseScope * scope);
74
75   /* virtual function for rendering a frame */
76   gboolean (*render) (GstBaseScope * scope, GstBuffer * audio, GstBuffer * video);
77 };
78
79 GType gst_base_scope_get_type (void);
80
81 G_END_DECLS
82 #endif /* __GST_BASE_SCOPE_H__ */