source: trunk/third/gstreamer/gst/gstpipeline.c @ 21005

Revision 21005, 4.7 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21004, which included commits to RCS files with non-trunk default branches.
Line 
1/* GStreamer
2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 *                    2000 Wim Taymans <wtay@chello.be>
4 *
5 * gstpipeline.c: Overall pipeline management element
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., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
21 */
22
23#include "gst_private.h"
24
25#include "gstpipeline.h"
26#include "gstinfo.h"
27#include "gstscheduler.h"
28
29static GstElementDetails gst_pipeline_details =
30GST_ELEMENT_DETAILS ("Pipeline object",
31    "Generic/Bin",
32    "Complete pipeline object",
33    "Erik Walthinsen <omega@cse.ogi.edu>");
34
35/* Pipeline signals and args */
36enum
37{
38  /* FILL ME */
39  LAST_SIGNAL
40};
41
42enum
43{
44  ARG_0
45      /* FILL ME */
46};
47
48
49static void gst_pipeline_base_init (gpointer g_class);
50static void gst_pipeline_class_init (gpointer g_class, gpointer class_data);
51static void gst_pipeline_init (GTypeInstance * instance, gpointer g_class);
52
53static void gst_pipeline_dispose (GObject * object);
54
55static GstElementStateReturn gst_pipeline_change_state (GstElement * element);
56
57static GstBinClass *parent_class = NULL;
58
59/* static guint gst_pipeline_signals[LAST_SIGNAL] = { 0 }; */
60
61GType
62gst_pipeline_get_type (void)
63{
64  static GType pipeline_type = 0;
65
66  if (!pipeline_type) {
67    static const GTypeInfo pipeline_info = {
68      sizeof (GstPipelineClass),
69      gst_pipeline_base_init,
70      NULL,
71      (GClassInitFunc) gst_pipeline_class_init,
72      NULL,
73      NULL,
74      sizeof (GstPipeline),
75      0,
76      gst_pipeline_init,
77      NULL
78    };
79
80    pipeline_type =
81        g_type_register_static (GST_TYPE_BIN, "GstPipeline", &pipeline_info, 0);
82  }
83  return pipeline_type;
84}
85
86static void
87gst_pipeline_base_init (gpointer g_class)
88{
89  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
90
91  gst_element_class_set_details (gstelement_class, &gst_pipeline_details);
92}
93
94static void
95gst_pipeline_class_init (gpointer g_class, gpointer class_data)
96{
97  GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
98  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
99  GstPipelineClass *klass = GST_PIPELINE_CLASS (g_class);
100
101  parent_class = g_type_class_peek_parent (klass);
102
103  gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_pipeline_dispose);
104
105  gstelement_class->change_state =
106      GST_DEBUG_FUNCPTR (gst_pipeline_change_state);
107}
108
109static void
110gst_pipeline_init (GTypeInstance * instance, gpointer g_class)
111{
112  GstScheduler *scheduler;
113  GstPipeline *pipeline = GST_PIPELINE (instance);
114
115  /* pipelines are managing bins */
116  GST_FLAG_SET (pipeline, GST_BIN_FLAG_MANAGER);
117
118  /* get an instance of the default scheduler */
119  scheduler = gst_scheduler_factory_make (NULL, GST_ELEMENT (pipeline));
120
121  /* FIXME need better error handling */
122  if (scheduler == NULL) {
123    const gchar *name = gst_scheduler_factory_get_default_name ();
124
125    g_error ("Critical error: could not get scheduler \"%s\"\n"
126        "Are you sure you have a registry ?\n"
127        "Run gst-register as root if you haven't done so yet.", name);
128  }
129}
130
131static void
132gst_pipeline_dispose (GObject * object)
133{
134  GstPipeline *pipeline = GST_PIPELINE (object);
135  GstScheduler *sched;
136
137  g_assert (GST_IS_SCHEDULER (GST_ELEMENT_SCHED (pipeline)));
138  sched = GST_ELEMENT_SCHED (pipeline);
139
140  gst_scheduler_reset (sched);
141  G_OBJECT_CLASS (parent_class)->dispose (object);
142}
143
144/**
145 * gst_pipeline_new:
146 * @name: name of new pipeline
147 *
148 * Create a new pipeline with the given name.
149 *
150 * Returns: newly created GstPipeline
151 */
152GstElement *
153gst_pipeline_new (const gchar * name)
154{
155  return gst_element_factory_make ("pipeline", name);
156}
157
158static GstElementStateReturn
159gst_pipeline_change_state (GstElement * element)
160{
161  switch (GST_STATE_TRANSITION (element)) {
162    case GST_STATE_NULL_TO_READY:
163      gst_scheduler_setup (GST_ELEMENT_SCHED (element));
164      break;
165    case GST_STATE_READY_TO_PAUSED:
166    case GST_STATE_PAUSED_TO_PLAYING:
167    case GST_STATE_PLAYING_TO_PAUSED:
168    case GST_STATE_PAUSED_TO_READY:
169    case GST_STATE_READY_TO_NULL:
170      break;
171  }
172
173  if (GST_ELEMENT_CLASS (parent_class)->change_state)
174    return GST_ELEMENT_CLASS (parent_class)->change_state (element);
175
176  return GST_STATE_SUCCESS;
177}
Note: See TracBrowser for help on using the repository browser.