[507/906] GstGLTestSrc: update for 1.0
authorMatthew Waters <ystreet00@gmail.com>
Tue, 5 Jun 2012 05:40:52 +0000 (15:40 +1000)
committerMatthew Waters <ystreet00@gmail.com>
Sat, 15 Mar 2014 17:36:44 +0000 (18:36 +0100)
gst/gl/gltestsrc.c
gst/gl/gltestsrc.h
gst/gl/gstgltestsrc.c
gst/gl/gstgltestsrc.h

index 3011fa2..594fbe3 100644 (file)
@@ -79,11 +79,11 @@ static const struct vts_color_struct vts_colors[] = {
 };
 
 static void
-gst_gl_test_src_unicolor (GstGLTestSrc * v, GstGLBuffer * buffer, int w,
+gst_gl_test_src_unicolor (GstGLTestSrc * v, GstBuffer * buffer, int w,
     int h, const struct vts_color_struct *color);
 
 void
-gst_gl_test_src_smpte (GstGLTestSrc * v, GstGLBuffer * buffer, int w, int h)
+gst_gl_test_src_smpte (GstGLTestSrc * v, GstBuffer * buffer, int w, int h)
 {
   int i;
 
@@ -186,7 +186,7 @@ gst_gl_test_src_smpte (GstGLTestSrc * v, GstGLBuffer * buffer, int w, int h)
 }
 
 void
-gst_gl_test_src_snow (GstGLTestSrc * v, GstGLBuffer * buffer, int w, int h)
+gst_gl_test_src_snow (GstGLTestSrc * v, GstBuffer * buffer, int w, int h)
 {
   glClearColor (0.0, 0.0, 0.0, 1.0);
   glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -208,7 +208,7 @@ gst_gl_test_src_snow (GstGLTestSrc * v, GstGLBuffer * buffer, int w, int h)
 }
 
 static void
-gst_gl_test_src_unicolor (GstGLTestSrc * v, GstGLBuffer * buffer, int w,
+gst_gl_test_src_unicolor (GstGLTestSrc * v, GstBuffer * buffer, int w,
     int h, const struct vts_color_struct *color)
 {
   glClearColor (color->R * (1 / 255.0f), color->G * (1 / 255.0f),
@@ -217,37 +217,37 @@ gst_gl_test_src_unicolor (GstGLTestSrc * v, GstGLBuffer * buffer, int w,
 }
 
 void
-gst_gl_test_src_black (GstGLTestSrc * v, GstGLBuffer * buffer, int w, int h)
+gst_gl_test_src_black (GstGLTestSrc * v, GstBuffer * buffer, int w, int h)
 {
   gst_gl_test_src_unicolor (v, buffer, w, h, vts_colors + COLOR_BLACK);
 }
 
 void
-gst_gl_test_src_white (GstGLTestSrc * v, GstGLBuffer * buffer, int w, int h)
+gst_gl_test_src_white (GstGLTestSrc * v, GstBuffer * buffer, int w, int h)
 {
   gst_gl_test_src_unicolor (v, buffer, w, h, vts_colors + COLOR_WHITE);
 }
 
 void
-gst_gl_test_src_red (GstGLTestSrc * v, GstGLBuffer * buffer, int w, int h)
+gst_gl_test_src_red (GstGLTestSrc * v, GstBuffer * buffer, int w, int h)
 {
   gst_gl_test_src_unicolor (v, buffer, w, h, vts_colors + COLOR_RED);
 }
 
 void
-gst_gl_test_src_green (GstGLTestSrc * v, GstGLBuffer * buffer, int w, int h)
+gst_gl_test_src_green (GstGLTestSrc * v, GstBuffer * buffer, int w, int h)
 {
   gst_gl_test_src_unicolor (v, buffer, w, h, vts_colors + COLOR_GREEN);
 }
 
 void
-gst_gl_test_src_blue (GstGLTestSrc * v, GstGLBuffer * buffer, int w, int h)
+gst_gl_test_src_blue (GstGLTestSrc * v, GstBuffer * buffer, int w, int h)
 {
   gst_gl_test_src_unicolor (v, buffer, w, h, vts_colors + COLOR_BLUE);
 }
 
 void
-gst_gl_test_src_checkers1 (GstGLTestSrc * v, GstGLBuffer * buffer, int w, int h)
+gst_gl_test_src_checkers1 (GstGLTestSrc * v, GstBuffer * buffer, int w, int h)
 {
 #if 0
   int x, y;
@@ -276,7 +276,7 @@ gst_gl_test_src_checkers1 (GstGLTestSrc * v, GstGLBuffer * buffer, int w, int h)
 }
 
 void
-gst_gl_test_src_checkers2 (GstGLTestSrc * v, GstGLBuffer * buffer, int w, int h)
+gst_gl_test_src_checkers2 (GstGLTestSrc * v, GstBuffer * buffer, int w, int h)
 {
 #if 0
   int x, y;
@@ -313,7 +313,7 @@ gst_gl_test_src_checkers2 (GstGLTestSrc * v, GstGLBuffer * buffer, int w, int h)
 }
 
 void
-gst_gl_test_src_checkers4 (GstGLTestSrc * v, GstGLBuffer * buffer, int w, int h)
+gst_gl_test_src_checkers4 (GstGLTestSrc * v, GstBuffer * buffer, int w, int h)
 {
 #if 0
   int x, y;
@@ -356,7 +356,7 @@ gst_gl_test_src_checkers4 (GstGLTestSrc * v, GstGLBuffer * buffer, int w, int h)
 }
 
 void
-gst_gl_test_src_checkers8 (GstGLTestSrc * v, GstGLBuffer * buffer, int w, int h)
+gst_gl_test_src_checkers8 (GstGLTestSrc * v, GstBuffer * buffer, int w, int h)
 {
 #if 0
   int x, y;
@@ -411,7 +411,7 @@ gst_gl_test_src_checkers8 (GstGLTestSrc * v, GstGLBuffer * buffer, int w, int h)
 }
 
 void
-gst_gl_test_src_circular (GstGLTestSrc * v, GstGLBuffer * buffer, int w, int h)
+gst_gl_test_src_circular (GstGLTestSrc * v, GstBuffer * buffer, int w, int h)
 {
 #if 0
   int i;
index 13b4d6c..86bda92 100644 (file)
@@ -31,28 +31,28 @@ struct vts_color_struct {
 };
 
 void    gst_gl_test_src_smpte        (GstGLTestSrc * v,
-                                         GstGLBuffer *buffer, int w, int h);
+                                         GstBuffer *buffer, int w, int h);
 void    gst_gl_test_src_snow         (GstGLTestSrc * v,
-                                         GstGLBuffer *buffer, int w, int h);
+                                         GstBuffer *buffer, int w, int h);
 void    gst_gl_test_src_black        (GstGLTestSrc * v,
-                                         GstGLBuffer *buffer, int w, int h);
+                                         GstBuffer *buffer, int w, int h);
 void    gst_gl_test_src_white        (GstGLTestSrc * v,
-                                         GstGLBuffer *buffer, int w, int h);
+                                         GstBuffer *buffer, int w, int h);
 void    gst_gl_test_src_red          (GstGLTestSrc * v,
-                                         GstGLBuffer *buffer, int w, int h);
+                                         GstBuffer *buffer, int w, int h);
 void    gst_gl_test_src_green        (GstGLTestSrc * v,
-                                         GstGLBuffer *buffer, int w, int h);
+                                         GstBuffer *buffer, int w, int h);
 void    gst_gl_test_src_blue         (GstGLTestSrc * v,
-                                         GstGLBuffer *buffer, int w, int h);
+                                         GstBuffer *buffer, int w, int h);
 void    gst_gl_test_src_checkers1    (GstGLTestSrc * v,
-                                         GstGLBuffer *buffer, int w, int h);
+                                         GstBuffer *buffer, int w, int h);
 void    gst_gl_test_src_checkers2    (GstGLTestSrc * v,
-                                         GstGLBuffer *buffer, int w, int h);
+                                         GstBuffer *buffer, int w, int h);
 void    gst_gl_test_src_checkers4    (GstGLTestSrc * v,
-                                         GstGLBuffer *buffer, int w, int h);
+                                         GstBuffer *buffer, int w, int h);
 void    gst_gl_test_src_checkers8    (GstGLTestSrc * v,
-                                         GstGLBuffer *buffer, int w, int h);
+                                         GstBuffer *buffer, int w, int h);
 void    gst_gl_test_src_circular     (GstGLTestSrc * v,
-                                         GstGLBuffer *buffer, int w, int h);
+                                         GstBuffer *buffer, int w, int h);
 
 #endif
index aec8bf6..d7139b0 100644 (file)
@@ -61,6 +61,7 @@ enum
       /* FILL ME */
 };
 
+#define gst_gl_test_src_parent_class parent_class
 G_DEFINE_TYPE (GstGLTestSrc, gst_gl_test_src, GST_TYPE_PUSH_SRC);
 
 static void gst_gl_test_src_set_pattern (GstGLTestSrc * gltestsrc,
@@ -70,10 +71,11 @@ static void gst_gl_test_src_set_property (GObject * object, guint prop_id,
 static void gst_gl_test_src_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
 
-static gboolean gst_gl_test_src_src_query (GstPad * pad, GstQuery * query);
+static gboolean gst_gl_test_src_src_query (GstPad * pad, GstObject * object,
+    GstQuery * query);
 
 static gboolean gst_gl_test_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps);
-static void gst_gl_test_src_src_fixate (GstPad * pad, GstCaps * caps);
+static GstCaps *gst_gl_test_src_fixate (GstBaseSrc * bsrc, GstCaps * caps);
 
 static gboolean gst_gl_test_src_is_seekable (GstBaseSrc * psrc);
 static gboolean gst_gl_test_src_do_seek (GstBaseSrc * bsrc,
@@ -87,8 +89,8 @@ static GstFlowReturn gst_gl_test_src_create (GstPushSrc * psrc,
 static gboolean gst_gl_test_src_start (GstBaseSrc * basesrc);
 static gboolean gst_gl_test_src_stop (GstBaseSrc * basesrc);
 
-static void gst_gl_test_src_callback (gint width, gint height, guint texture,
-    gpointer stuff);
+/*static void gst_gl_test_src_callback (gint width, gint height, guint texture,
+    gpointer stuff); */
 
 #define GST_TYPE_GL_TEST_SRC_PATTERN (gst_gl_test_src_pattern_get_type ())
 static GType
@@ -167,6 +169,7 @@ gst_gl_test_src_class_init (GstGLTestSrcClass * klass)
   gstbasesrc_class->get_times = gst_gl_test_src_get_times;
   gstbasesrc_class->start = gst_gl_test_src_start;
   gstbasesrc_class->stop = gst_gl_test_src_stop;
+  gstbasesrc_class->fixate = gst_gl_test_src_fixate;
 
   gstpushsrc_class->create = gst_gl_test_src_create;
 }
@@ -176,8 +179,6 @@ gst_gl_test_src_init (GstGLTestSrc * src)
 {
   GstPad *pad = GST_BASE_SRC_PAD (src);
 
-  gst_pad_set_fixatecaps_function (pad, gst_gl_test_src_src_fixate);
-
   gst_gl_test_src_set_pattern (src, GST_GL_TEST_SRC_SMPTE);
 
   src->timestamp_offset = 0;
@@ -190,18 +191,22 @@ gst_gl_test_src_init (GstGLTestSrc * src)
       GST_DEBUG_FUNCPTR (gst_gl_test_src_src_query));
 }
 
-static void
-gst_gl_test_src_src_fixate (GstPad * pad, GstCaps * caps)
+static GstCaps *
+gst_gl_test_src_fixate (GstBaseSrc * bsrc, GstCaps * caps)
 {
   GstStructure *structure;
 
   GST_DEBUG ("fixate");
 
+  caps = gst_caps_make_writable (caps);
+
   structure = gst_caps_get_structure (caps, 0);
 
   gst_structure_fixate_field_nearest_int (structure, "width", 320);
   gst_structure_fixate_field_nearest_int (structure, "height", 240);
   gst_structure_fixate_field_nearest_fraction (structure, "framerate", 30, 1);
+
+  return caps;
 }
 
 static void
@@ -300,27 +305,24 @@ gst_gl_test_src_get_property (GObject * object, guint prop_id,
 }
 
 static gboolean
-gst_gl_test_src_src_query (GstPad * pad, GstQuery * query)
+gst_gl_test_src_src_query (GstPad * pad, GstObject * object, GstQuery * query)
 {
-  gboolean res = FALSE;
-  GstElement *parent = GST_ELEMENT (gst_pad_get_parent (pad));
+  gboolean res;
 
   switch (GST_QUERY_TYPE (query)) {
     case GST_QUERY_CUSTOM:
     {
-      GstStructure *structure = gst_query_get_structure (query);
+      const GstStructure *structure = gst_query_get_structure (query);
       res =
-          g_strcmp0 (gst_element_get_name (parent),
+          g_strcmp0 (gst_element_get_name (object),
           gst_structure_get_name (structure)) == 0;
       break;
     }
     default:
-      res = gst_pad_query_default (pad, query);
+      res = gst_pad_query_default (pad, object, query);
       break;
   }
 
-  gst_object_unref (parent);
-
   return res;
 }
 
@@ -494,7 +496,7 @@ gst_gl_test_src_do_seek (GstBaseSrc * bsrc, GstSegment * segment)
   src = GST_GL_TEST_SRC (bsrc);
 
   segment->time = segment->start;
-  time = segment->last_stop;
+  time = segment->position;
 
   /* now move to the time indicated */
   if (src->rate_numerator) {
@@ -527,7 +529,6 @@ static GstFlowReturn
 gst_gl_test_src_create (GstPushSrc * psrc, GstBuffer ** buffer)
 {
   GstGLTestSrc *src;
-  GstGLBuffer *outbuf;
 
   //GstFlowReturn res;
   GstClockTime next_time;
@@ -544,16 +545,15 @@ gst_gl_test_src_create (GstPushSrc * psrc, GstBuffer ** buffer)
   GST_LOG_OBJECT (src, "creating buffer %dx%d image for frame %d",
       src->width, src->height, (gint) src->n_frames);
 
-  outbuf = gst_gl_buffer_new (src->display, src->width, src->height);
-
-  if (!outbuf->texture) {
-    gst_buffer_unref (GST_BUFFER_CAST (outbuf));
-    goto eos;
-  }
+  /*outbuf = gst_gl_buffer_new (src->display, src->width, src->height);
 
-  gst_buffer_set_caps (GST_BUFFER (outbuf),
-      GST_PAD_CAPS (GST_BASE_SRC_PAD (psrc)));
+     if (!outbuf->texture) {
+     goto eos;
+     }
 
+     gst_buffer_set_caps (GST_BUFFER (outbuf),
+     gst_pad_get_negotiated_caps (GST_BASE_SRC_PAD (psrc)));
+   */
   if (src->pattern_type == GST_GL_TEST_SRC_BLINK) {
     if (src->n_frames & 0x1)
       src->make_image = gst_gl_test_src_white;
@@ -561,35 +561,31 @@ gst_gl_test_src_create (GstPushSrc * psrc, GstBuffer ** buffer)
       src->make_image = gst_gl_test_src_black;
   }
 
-  src->buffer = outbuf;
-
+  src->buffer = gst_buffer_ref (*buffer);
+/* FIXME: use GstGLMeta
   //blocking call, generate a FBO
   if (!gst_gl_display_use_fbo (src->display, src->width, src->height, src->fbo, src->depthbuffer, outbuf->texture, gst_gl_test_src_callback, 0, 0, 0,   //no input texture
           0, src->width, 0, src->height,
           GST_GL_DISPLAY_PROJECTION_ORTHO2D, (gpointer) src)) {
-    gst_buffer_unref (GST_BUFFER_CAST (outbuf));
     goto eos;
-  }
+  } */
 
-  GST_BUFFER_TIMESTAMP (GST_BUFFER (outbuf)) =
-      src->timestamp_offset + src->running_time;
-  GST_BUFFER_OFFSET (GST_BUFFER (outbuf)) = src->n_frames;
+  GST_BUFFER_TIMESTAMP (*buffer) = src->timestamp_offset + src->running_time;
+  GST_BUFFER_OFFSET (*buffer) = src->n_frames;
   src->n_frames++;
-  GST_BUFFER_OFFSET_END (GST_BUFFER (outbuf)) = src->n_frames;
+  GST_BUFFER_OFFSET_END (*buffer) = src->n_frames;
   if (src->rate_numerator) {
     next_time = gst_util_uint64_scale_int (src->n_frames * GST_SECOND,
         src->rate_denominator, src->rate_numerator);
-    GST_BUFFER_DURATION (GST_BUFFER (outbuf)) = next_time - src->running_time;
+    GST_BUFFER_DURATION (*buffer) = next_time - src->running_time;
   } else {
     next_time = src->timestamp_offset;
     /* NONE means forever */
-    GST_BUFFER_DURATION (GST_BUFFER (outbuf)) = GST_CLOCK_TIME_NONE;
+    GST_BUFFER_DURATION (*buffer) = GST_CLOCK_TIME_NONE;
   }
 
   src->running_time = next_time;
 
-  *buffer = GST_BUFFER (outbuf);
-
   return GST_FLOW_OK;
 
 not_negotiated:
@@ -601,16 +597,8 @@ not_negotiated:
 eos:
   {
     GST_DEBUG_OBJECT (src, "eos: 0 framerate, frame %d", (gint) src->n_frames);
-    return GST_FLOW_UNEXPECTED;
+    return GST_FLOW_EOS;
   }
-#if 0
-no_buffer:
-  {
-    GST_DEBUG_OBJECT (src, "could not allocate buffer, reason %s",
-        gst_flow_get_name (res));
-    return res;
-  }
-#endif
 }
 
 static gboolean
@@ -628,8 +616,8 @@ gst_gl_test_src_start (GstBaseSrc * basesrc)
     return FALSE;
   }
 
-  structure = gst_structure_new (gst_element_get_name (src), NULL);
-  query = gst_query_new_application (GST_QUERY_CUSTOM, structure);
+  structure = gst_structure_new_empty (gst_element_get_name (src));
+  query = gst_query_new_custom (GST_QUERY_CUSTOM, structure);
 
   isPerformed = gst_element_query (parent, query);
 
@@ -677,11 +665,11 @@ gst_gl_test_src_stop (GstBaseSrc * basesrc)
 }
 
 //opengl scene
-static void
+/*static void
 gst_gl_test_src_callback (gint width, gint height, guint texture,
     gpointer stuff)
 {
   GstGLTestSrc *src = GST_GL_TEST_SRC (stuff);
 
   src->make_image (src, src->buffer, src->width, src->height);
-}
+} */
index 4ec19a6..a8f8623 100644 (file)
@@ -101,7 +101,7 @@ struct _GstGLTestSrc {
     GLuint fbo;
     GLuint depthbuffer;
 
-    GstGLBuffer* buffer;
+    GstBuffer* buffer;
 
     /* private */
     GstGLDisplay *display;
@@ -110,7 +110,7 @@ struct _GstGLTestSrc {
     gint64 n_frames;                      /* total frames sent */
     gboolean negotiated;
 
-    void (*make_image) (GstGLTestSrc* v, GstGLBuffer* buffer, gint w, gint h);
+    void (*make_image) (GstGLTestSrc* v, GstBuffer* buffer, gint w, gint h);
 };
 
 struct _GstGLTestSrcClass {