tizen 2.3 release
[framework/multimedia/gst-plugins-base0.10.git] / gst / playback / gstplaybasebin.h
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *               <2007> Wim Taymans <wim.taymans@gmail.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
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  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #ifndef __GST_PLAYBASEBIN_H__
22 #define __GST_PLAYBASEBIN_H__
23
24 #include <gst/gst.h>
25 #include "gststreaminfo.h"
26
27 G_BEGIN_DECLS
28
29 #define GST_TYPE_PLAY_BASE_BIN            (gst_play_base_bin_get_type())
30 #define GST_PLAY_BASE_BIN(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PLAY_BASE_BIN,GstPlayBaseBin))
31 #define GST_PLAY_BASE_BIN_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PLAY_BASE_BIN,GstPlayBaseBinClass))
32 #define GST_IS_PLAY_BASE_BIN(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PLAY_BASE_BIN))
33 #define GST_IS_PLAY_BASE_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PLAY_BASE_BIN))
34 #define GST_PLAY_BASE_BIN_GET_CLASS(obj) \
35   (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLAY_BASE_BIN, \
36                               GstPlayBaseBinClass))
37
38 typedef struct _GstPlayBaseBin GstPlayBaseBin;
39 typedef struct _GstPlayBaseBinClass GstPlayBaseBinClass;
40
41 /* a GstPlayBaseGroup is a group of pads and streaminfo that together 
42  * make up a playable stream. A new group is created from the current 
43  * set of pads that are alive when the preroll elements are filled or 
44  * when the no-more-pads signal is fired.
45  *
46  * We have to queue the groups as they can be created while the preroll
47  * queues are still playing the old group. We monitor the EOS signals
48  * on the preroll queues and when all the streams in the current group
49  * have EOSed, we switch to the next queued group.
50  */
51 typedef struct
52 {
53   GstPlayBaseBin *bin;  /* ref to the owner */
54
55   gint           nstreams;
56   GList         *streaminfo;
57   GValueArray   *streaminfo_value_array;
58
59   /* contained decoded elementary streams */
60   struct {
61     gint         npads;
62     GstBin      *bin;
63     GstElement  *preroll;
64     GstElement  *selector;
65     gboolean     done;
66 #define NUM_TYPES 4
67   } type[NUM_TYPES]; /* AUDIO, VIDEO, TEXT, SUBPIC */
68 } GstPlayBaseGroup;
69
70 struct _GstPlayBaseBin {
71   GstPipeline    pipeline;
72         
73   /* properties */
74   guint64        queue_size;
75   guint64        queue_threshold;
76   guint64        queue_min_threshold;
77   /* connection speed in bits/sec (0 = unknown) */
78   guint          connection_speed;
79   
80
81   /* currently loaded media */
82   gint           current[NUM_TYPES];
83   gchar         *uri, *suburi;
84   gboolean       is_stream;
85   GstElement    *source;
86   GSList        *decoders;
87   GstElement    *subtitle;              /* additional filesrc ! subparse bin */
88   gboolean       subtitle_done;
89   gboolean       need_rebuild;
90   gboolean       raw_decoding_mode;     /* Use smaller queues when source outputs raw data */
91
92   GSList        *subtitle_elements;     /* subtitle elements that have 'subtitle-encoding' property */
93   gchar         *subencoding;           /* encoding to propagate to the above subtitle elements     */
94   GMutex        *sub_lock;              /* protecting subtitle_elements and subencoding members     */
95
96   /* group management - using own lock */
97   GMutex        *group_lock;            /* lock and mutex to signal availability of new group */
98   GCond         *group_cond;
99   GstPlayBaseGroup *building_group;     /* the group that we are constructing */
100   GList         *queued_groups;         /* the constructed groups, head is the active one */
101
102   /* for dynamic sources */
103   guint          src_np_sig_id;         /* new-pad signal id */
104   guint          src_nmp_sig_id;        /* no-more-pads signal id */
105   gint           pending;
106 };
107
108 struct _GstPlayBaseBinClass {
109   GstPipelineClass parent_class;
110
111   /* virtual functions */
112   gboolean (*setup_output_pads) (GstPlayBaseBin *play_base_bin,
113                                  GstPlayBaseGroup *group);
114
115   void     (*set_subtitles_visible) (GstPlayBaseBin *play_base_bin,
116                                      gboolean visible);
117   void     (*set_audio_mute)        (GstPlayBaseBin *play_base_bin,
118                                      gboolean mute);
119 };
120
121 GType gst_play_base_bin_get_type (void);
122
123 G_END_DECLS
124
125 #endif /* __GST_PLAYBASEBIN_H__ */
126