expand tabs
[platform/upstream/gstreamer.git] / gst / playback / gstplaybasebin.h
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __GST_PLAYBASEBIN_H__
21 #define __GST_PLAYBASEBIN_H__
22
23 #include <gst/gst.h>
24 #include "gststreaminfo.h"
25
26 G_BEGIN_DECLS
27
28 #define GST_TYPE_PLAY_BASE_BIN          (gst_play_base_bin_get_type())
29 #define GST_PLAY_BASE_BIN(obj)          (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PLAY_BASE_BIN,GstPlayBaseBin))
30 #define GST_PLAY_BASE_BIN_CLASS(klass)  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PLAY_BASE_BIN,GstPlayBaseBinClass))
31 #define GST_IS_PLAY_BASE_BIN(obj)               (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PLAY_BASE_BIN))
32 #define GST_IS_PLAY_BASE_BIN_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PLAY_BASE_BIN))
33 #define GST_PLAY_BASE_BIN_GET_CLASS(obj) \
34   (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLAY_BASE_BIN, \
35                               GstPlayBaseBinClass))
36
37 typedef struct _GstPlayBaseBin GstPlayBaseBin;
38 typedef struct _GstPlayBaseBinClass GstPlayBaseBinClass;
39
40 /* a GstPlayBaseGroup is a group of pads and streaminfo that together 
41  * make up a playable stream. A new group is created from the current 
42  * set of pads that are alive when the preroll elements are filled or 
43  * when the no-more-pads signal is fired.
44  *
45  * We have to queue the groups as they can be created while the preroll
46  * queues are still playing the old group. We monitor the EOS signals
47  * on the preroll queues and when all the streams in the current group
48  * have EOSed, we switch to the next queued group.
49  */
50 typedef struct
51 {
52   GstPlayBaseBin *bin;  /* ref to the owner */
53
54   gint           nstreams;
55   GList         *streaminfo;
56
57   /* contained decoded elementary streams */
58   struct {
59     gint         npads;
60     GstBin      *bin;
61     GstElement  *preroll;
62     GstElement  *selector;
63     gboolean     done;
64 #define NUM_TYPES 3
65   } type[NUM_TYPES]; /* AUDIO, VIDEO, TEXT */
66 } GstPlayBaseGroup;
67
68 struct _GstPlayBaseBin {
69   GstPipeline    pipeline;
70         
71   /* properties */
72   guint64        queue_size;
73   guint          queue_threshold;
74
75   /* currently loaded media */
76   gint           current[NUM_TYPES];
77   gchar         *uri, *suburi;
78   gboolean       is_stream;
79   GstElement    *source;
80   GstElement    *decoder;
81   GstElement    *subtitle; /* additional filesrc ! subparse bin */
82   gboolean       need_rebuild;
83
84   /* group management - using own lock */
85   GMutex        *group_lock;            /* lock and mutex to signal availability of new group */
86   GCond         *group_cond;
87   GstPlayBaseGroup *building_group;     /* the group that we are constructing */
88   GList         *queued_groups;         /* the constructed groups, head is the active one */
89 };
90
91 struct _GstPlayBaseBinClass {
92   GstPipelineClass parent_class;
93
94   /* virtual fuctions */
95   gboolean (*setup_output_pads) (GstPlayBaseBin *play_base_bin,
96                                  GstPlayBaseGroup *group);
97 };
98
99 GType gst_play_base_bin_get_type (void);
100
101 G_END_DECLS
102
103 #endif /* __GST_PLAYBASEBIN_H__ */
104