Пример #1
0
CoglGstVideoSink *
cogl_gst_video_sink_new (CoglContext *ctx)
{
  CoglGstVideoSink *sink = g_object_new (COGL_GST_TYPE_VIDEO_SINK, NULL);
  cogl_gst_video_sink_set_context (sink, ctx);

  return sink;
}
Пример #2
0
static void
cogl_gst_video_sink_finalize (GObject *object)
{
  CoglGstVideoSink *self = COGL_GST_VIDEO_SINK (object);

  cogl_gst_video_sink_set_context (self, NULL);

  G_OBJECT_CLASS (cogl_gst_video_sink_parent_class)->finalize (object);
}
Пример #3
0
static CoglBool
make_pipeline_for_uri (CoglContext *ctx,
                       const char *uri,
                       GstElement **pipeline_out,
                       CoglGstVideoSink **sink_out,
                       GError **error)
{
  GstElement *pipeline;
  GstElement *bin;
  CoglGstVideoSink *sink;
  GError *tmp_error = NULL;

  if (is_uri (uri))
    {
      pipeline = gst_pipeline_new ("gst-player");
      bin = gst_element_factory_make ("playbin", "bin");

      sink = cogl_gst_video_sink_new (ctx);

      g_object_set (G_OBJECT (bin),
                    "video-sink",
                    GST_ELEMENT (sink),
                    NULL);

      gst_bin_add (GST_BIN (pipeline), bin);

      g_object_set (G_OBJECT (bin), "uri", uri, NULL);
    }
  else
    {
      pipeline = gst_parse_launch (uri, &tmp_error);

      if (tmp_error)
        {
          if (pipeline)
            g_object_unref (pipeline);

          g_propagate_error (error, tmp_error);

          return FALSE;
        }

      sink = find_cogl_gst_video_sink (pipeline);

      if (sink == NULL)
        {
          g_set_error (error,
                       GST_STREAM_ERROR,
                       GST_STREAM_ERROR_FAILED,
                       "The pipeline does not contain a CoglGstVideoSink. "
                       "Make sure you add a 'coglsink' element somewhere in "
                       "the pipeline");
          g_object_unref (pipeline);
          return FALSE;
        }

      g_object_ref (sink);

      cogl_gst_video_sink_set_context (sink, ctx);
    }

  *pipeline_out = pipeline;
  *sink_out = sink;

  return TRUE;
}