gst_plugins_base/gst/videotestsrc/gstvideotestsrc.c
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
    19  */
    19  */
    20 
    20 
    21 /**
    21 /**
    22  * SECTION:element-videotestsrc
    22  * SECTION:element-videotestsrc
    23  *
    23  *
       
    24  * <refsect2>
       
    25  * <para>
    24  * The videotestsrc element is used to produce test video data in a wide variaty
    26  * The videotestsrc element is used to produce test video data in a wide variaty
    25  * of formats. The video test data produced can be controlled with the "pattern"
    27  * of formats. The video test data produced can be controlled with the "pattern"
    26  * property.
    28  * property.
    27  *
    29  * </para>
    28  * <refsect2>
       
    29  * <title>Example launch line</title>
    30  * <title>Example launch line</title>
    30  * |[
    31  * <para>
       
    32  * <programlisting>
    31  * gst-launch -v videotestsrc pattern=snow ! ximagesink
    33  * gst-launch -v videotestsrc pattern=snow ! ximagesink
    32  * ]| Shows random noise in an X window.
    34  * </programlisting>
       
    35  * Shows random noise in an X window.
       
    36  * </para>
    33  * </refsect2>
    37  * </refsect2>
    34  */
    38  */
    35 
    39 
    36 #ifdef HAVE_CONFIG_H
    40 #ifdef HAVE_CONFIG_H
    37 #include "config.h"
    41 #include "config.h"
    39 #include "gstvideotestsrc.h"
    43 #include "gstvideotestsrc.h"
    40 #include "videotestsrc.h"
    44 #include "videotestsrc.h"
    41 
    45 
    42 #include <string.h>
    46 #include <string.h>
    43 #include <stdlib.h>
    47 #include <stdlib.h>
    44 #include <liboil/liboil.h>
    48 #include <gst/liboil.h>
    45 
    49 
    46 #ifdef __SYMBIAN32__
    50 #define USE_PEER_BUFFERALLOC
    47 #include <liboil/globals.h>
       
    48 #endif
       
    49 
    51 
    50 GST_DEBUG_CATEGORY_STATIC (video_test_src_debug);
    52 GST_DEBUG_CATEGORY_STATIC (video_test_src_debug);
    51 #define GST_CAT_DEFAULT video_test_src_debug
    53 #define GST_CAT_DEFAULT video_test_src_debug
       
    54 
    52 
    55 
    53 static const GstElementDetails video_test_src_details =
    56 static const GstElementDetails video_test_src_details =
    54 GST_ELEMENT_DETAILS ("Video test source",
    57 GST_ELEMENT_DETAILS ("Video test source",
    55     "Source/Video",
    58     "Source/Video",
    56     "Creates a test video stream",
    59     "Creates a test video stream",
    57     "David A. Schleef <ds@schleef.org>");
    60     "David A. Schleef <ds@schleef.org>");
    58 
    61 
    59 #define DEFAULT_PATTERN            GST_VIDEO_TEST_SRC_SMPTE
       
    60 #define DEFAULT_TIMESTAMP_OFFSET   0
       
    61 #define DEFAULT_IS_LIVE            FALSE
       
    62 #define DEFAULT_PEER_ALLOC         TRUE
       
    63 #define DEFAULT_COLOR_SPEC         GST_VIDEO_TEST_SRC_BT601
       
    64 
    62 
    65 enum
    63 enum
    66 {
    64 {
    67   PROP_0,
    65   PROP_0,
    68   PROP_PATTERN,
    66   PROP_PATTERN,
    69   PROP_TIMESTAMP_OFFSET,
    67   PROP_TIMESTAMP_OFFSET,
    70   PROP_IS_LIVE,
    68   PROP_IS_LIVE
    71   PROP_PEER_ALLOC,
    69       /* FILL ME */
    72   PROP_COLOR_SPEC,
       
    73   PROP_K0,
       
    74   PROP_KX,
       
    75   PROP_KY,
       
    76   PROP_KT,
       
    77   PROP_KXT,
       
    78   PROP_KYT,
       
    79   PROP_KXY,
       
    80   PROP_KX2,
       
    81   PROP_KY2,
       
    82   PROP_KT2,
       
    83   PROP_XOFFSET,
       
    84   PROP_YOFFSET,
       
    85   PROP_LAST
       
    86 };
    70 };
    87 
    71 
    88 
    72 
    89 GST_BOILERPLATE (GstVideoTestSrc, gst_video_test_src, GstPushSrc,
    73 GST_BOILERPLATE (GstVideoTestSrc, gst_video_test_src, GstPushSrc,
    90     GST_TYPE_PUSH_SRC);
    74     GST_TYPE_PUSH_SRC);
   129     {GST_VIDEO_TEST_SRC_CHECKERS2, "Checkers 2px", "checkers-2"},
   113     {GST_VIDEO_TEST_SRC_CHECKERS2, "Checkers 2px", "checkers-2"},
   130     {GST_VIDEO_TEST_SRC_CHECKERS4, "Checkers 4px", "checkers-4"},
   114     {GST_VIDEO_TEST_SRC_CHECKERS4, "Checkers 4px", "checkers-4"},
   131     {GST_VIDEO_TEST_SRC_CHECKERS8, "Checkers 8px", "checkers-8"},
   115     {GST_VIDEO_TEST_SRC_CHECKERS8, "Checkers 8px", "checkers-8"},
   132     {GST_VIDEO_TEST_SRC_CIRCULAR, "Circular", "circular"},
   116     {GST_VIDEO_TEST_SRC_CIRCULAR, "Circular", "circular"},
   133     {GST_VIDEO_TEST_SRC_BLINK, "Blink", "blink"},
   117     {GST_VIDEO_TEST_SRC_BLINK, "Blink", "blink"},
   134     {GST_VIDEO_TEST_SRC_SMPTE75, "SMPTE 75% color bars", "smpte75"},
       
   135     {GST_VIDEO_TEST_SRC_ZONE_PLATE, "Zone plate", "zone-plate"},
       
   136     {0, NULL, NULL}
   118     {0, NULL, NULL}
   137   };
   119   };
   138 
   120 
   139   if (!video_test_src_pattern_type) {
   121   if (!video_test_src_pattern_type) {
   140     video_test_src_pattern_type =
   122     video_test_src_pattern_type =
   141         g_enum_register_static ("GstVideoTestSrcPattern", pattern_types);
   123         g_enum_register_static ("GstVideoTestSrcPattern", pattern_types);
   142   }
   124   }
   143   return video_test_src_pattern_type;
   125   return video_test_src_pattern_type;
   144 }
   126 }
   145 
   127 
   146 #define GST_TYPE_VIDEO_TEST_SRC_COLOR_SPEC (gst_video_test_src_color_spec_get_type ())
       
   147 static GType
       
   148 gst_video_test_src_color_spec_get_type (void)
       
   149 {
       
   150   static GType video_test_src_color_spec_type = 0;
       
   151   static const GEnumValue color_spec_types[] = {
       
   152     {GST_VIDEO_TEST_SRC_BT601, "ITU-R Rec. BT.601", "bt601"},
       
   153     {GST_VIDEO_TEST_SRC_BT709, "ITU-R Rec. BT.709", "bt709"},
       
   154     {0, NULL, NULL}
       
   155   };
       
   156 
       
   157   if (!video_test_src_color_spec_type) {
       
   158     video_test_src_color_spec_type =
       
   159         g_enum_register_static ("GstVideoTestSrcColorSpec", color_spec_types);
       
   160   }
       
   161   return video_test_src_color_spec_type;
       
   162 }
       
   163 
       
   164 static void
   128 static void
   165 gst_video_test_src_base_init (gpointer g_class)
   129 gst_video_test_src_base_init (gpointer g_class)
   166 {
   130 {
   167   GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
   131   GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
   168 
   132 
   188   gobject_class->get_property = gst_video_test_src_get_property;
   152   gobject_class->get_property = gst_video_test_src_get_property;
   189 
   153 
   190   g_object_class_install_property (gobject_class, PROP_PATTERN,
   154   g_object_class_install_property (gobject_class, PROP_PATTERN,
   191       g_param_spec_enum ("pattern", "Pattern",
   155       g_param_spec_enum ("pattern", "Pattern",
   192           "Type of test pattern to generate", GST_TYPE_VIDEO_TEST_SRC_PATTERN,
   156           "Type of test pattern to generate", GST_TYPE_VIDEO_TEST_SRC_PATTERN,
   193           DEFAULT_PATTERN, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
   157           GST_VIDEO_TEST_SRC_SMPTE, G_PARAM_READWRITE));
   194   g_object_class_install_property (gobject_class, PROP_TIMESTAMP_OFFSET,
   158   g_object_class_install_property (gobject_class,
   195       g_param_spec_int64 ("timestamp-offset", "Timestamp offset",
   159       PROP_TIMESTAMP_OFFSET, g_param_spec_int64 ("timestamp-offset",
       
   160           "Timestamp offset",
   196           "An offset added to timestamps set on buffers (in ns)", G_MININT64,
   161           "An offset added to timestamps set on buffers (in ns)", G_MININT64,
   197           G_MAXINT64, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
   162           G_MAXINT64, 0, G_PARAM_READWRITE));
   198   g_object_class_install_property (gobject_class, PROP_IS_LIVE,
   163   g_object_class_install_property (gobject_class, PROP_IS_LIVE,
   199       g_param_spec_boolean ("is-live", "Is Live",
   164       g_param_spec_boolean ("is-live", "Is Live",
   200           "Whether to act as a live source", DEFAULT_IS_LIVE,
   165           "Whether to act as a live source", FALSE, G_PARAM_READWRITE));
   201           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
       
   202   g_object_class_install_property (gobject_class, PROP_PEER_ALLOC,
       
   203       g_param_spec_boolean ("peer-alloc", "Peer Alloc",
       
   204           "Ask the peer to allocate an output buffer", DEFAULT_PEER_ALLOC,
       
   205           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
       
   206   g_object_class_install_property (gobject_class, PROP_COLOR_SPEC,
       
   207       g_param_spec_enum ("colorspec", "Color Specification",
       
   208           "Generate video in the given color specification",
       
   209           GST_TYPE_VIDEO_TEST_SRC_COLOR_SPEC,
       
   210           DEFAULT_COLOR_SPEC, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
       
   211   g_object_class_install_property (gobject_class, PROP_K0,
       
   212       g_param_spec_int ("k0", "Zoneplate zero order phase",
       
   213           "Zoneplate zero order phase, for generating plain fields or phase offsets",
       
   214           G_MININT32, G_MAXINT32, 0,
       
   215           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
       
   216   g_object_class_install_property (gobject_class, PROP_KX,
       
   217       g_param_spec_int ("kx", "Zoneplate 1st order x phase",
       
   218           "Zoneplate 1st order x phase, for generating constant horizontal frequencies",
       
   219           G_MININT32, G_MAXINT32, 0,
       
   220           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
       
   221   g_object_class_install_property (gobject_class, PROP_KY,
       
   222       g_param_spec_int ("ky", "Zoneplate 1st order y phase",
       
   223           "Zoneplate 1st order y phase, for generating contant vertical frequencies",
       
   224           G_MININT32, G_MAXINT32, 0,
       
   225           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
       
   226   g_object_class_install_property (gobject_class, PROP_KT,
       
   227       g_param_spec_int ("kt", "Zoneplate 1st order t phase",
       
   228           "Zoneplate 1st order t phase, for generating phase rotation as a function of time",
       
   229           G_MININT32, G_MAXINT32, 0,
       
   230           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
       
   231   g_object_class_install_property (gobject_class, PROP_KXT,
       
   232       g_param_spec_int ("kxt", "Zoneplate x*t product phase",
       
   233           "Zoneplate x*t product phase, normalised to kxy/256 cycles per vertical pixel at width/2 from origin",
       
   234           G_MININT32, G_MAXINT32, 0,
       
   235           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
       
   236   g_object_class_install_property (gobject_class, PROP_KYT,
       
   237       g_param_spec_int ("kyt", "Zoneplate y*t product phase",
       
   238           "Zoneplate y*t product phase", G_MININT32, G_MAXINT32, 0,
       
   239           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
       
   240   g_object_class_install_property (gobject_class, PROP_KXY,
       
   241       g_param_spec_int ("kxy", "Zoneplate x*y product phase",
       
   242           "Zoneplate x*t product phase", G_MININT32, G_MAXINT32, 0,
       
   243           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
       
   244   g_object_class_install_property (gobject_class, PROP_KX2,
       
   245       g_param_spec_int ("kx2", "Zoneplate 2nd order x phase",
       
   246           "Zoneplate 2nd order x phase, normalised to kx2/256 cycles per horizontal pixel at width/2 from origin",
       
   247           G_MININT32, G_MAXINT32, 0,
       
   248           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
       
   249   g_object_class_install_property (gobject_class, PROP_KY2,
       
   250       g_param_spec_int ("ky2", "Zoneplate 2nd order y phase",
       
   251           "Zoneplate 2nd order y phase, normailsed to ky2/256 cycles per vertical pixel at height/2 from origin",
       
   252           G_MININT32, G_MAXINT32, 0,
       
   253           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
       
   254   g_object_class_install_property (gobject_class, PROP_KT2,
       
   255       g_param_spec_int ("kt2", "Zoneplate 2nd order t phase",
       
   256           "Zoneplate 2nd order t phase, t*t/256 cycles per picture", G_MININT32,
       
   257           G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
       
   258   g_object_class_install_property (gobject_class, PROP_XOFFSET,
       
   259       g_param_spec_int ("xoffset", "Zoneplate 2nd order products x offset",
       
   260           "Zoneplate 2nd order products x offset", G_MININT32, G_MAXINT32, 0,
       
   261           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
       
   262   g_object_class_install_property (gobject_class, PROP_YOFFSET,
       
   263       g_param_spec_int ("yoffset", "Zoneplate 2nd order products y offset",
       
   264           "Zoneplate 2nd order products y offset", G_MININT32, G_MAXINT32, 0,
       
   265           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
       
   266 
   166 
   267   gstbasesrc_class->get_caps = gst_video_test_src_getcaps;
   167   gstbasesrc_class->get_caps = gst_video_test_src_getcaps;
   268   gstbasesrc_class->set_caps = gst_video_test_src_setcaps;
   168   gstbasesrc_class->set_caps = gst_video_test_src_setcaps;
   269   gstbasesrc_class->is_seekable = gst_video_test_src_is_seekable;
   169   gstbasesrc_class->is_seekable = gst_video_test_src_is_seekable;
   270   gstbasesrc_class->do_seek = gst_video_test_src_do_seek;
   170   gstbasesrc_class->do_seek = gst_video_test_src_do_seek;
   280 {
   180 {
   281   GstPad *pad = GST_BASE_SRC_PAD (src);
   181   GstPad *pad = GST_BASE_SRC_PAD (src);
   282 
   182 
   283   gst_pad_set_fixatecaps_function (pad, gst_video_test_src_src_fixate);
   183   gst_pad_set_fixatecaps_function (pad, gst_video_test_src_src_fixate);
   284 
   184 
   285   gst_video_test_src_set_pattern (src, DEFAULT_PATTERN);
   185   gst_video_test_src_set_pattern (src, GST_VIDEO_TEST_SRC_SMPTE);
   286 
   186 
   287   src->timestamp_offset = DEFAULT_TIMESTAMP_OFFSET;
   187   src->timestamp_offset = 0;
   288 
   188 
   289   /* we operate in time */
   189   /* we operate in time */
   290   gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME);
   190   gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME);
   291   gst_base_src_set_live (GST_BASE_SRC (src), DEFAULT_IS_LIVE);
   191   gst_base_src_set_live (GST_BASE_SRC (src), FALSE);
   292   src->peer_alloc = DEFAULT_PEER_ALLOC;
       
   293 }
   192 }
   294 
   193 
   295 static void
   194 static void
   296 gst_video_test_src_src_fixate (GstPad * pad, GstCaps * caps)
   195 gst_video_test_src_src_fixate (GstPad * pad, GstCaps * caps)
   297 {
   196 {
   350       videotestsrc->make_image = gst_video_test_src_circular;
   249       videotestsrc->make_image = gst_video_test_src_circular;
   351       break;
   250       break;
   352     case GST_VIDEO_TEST_SRC_BLINK:
   251     case GST_VIDEO_TEST_SRC_BLINK:
   353       videotestsrc->make_image = gst_video_test_src_black;
   252       videotestsrc->make_image = gst_video_test_src_black;
   354       break;
   253       break;
   355     case GST_VIDEO_TEST_SRC_SMPTE75:
       
   356       videotestsrc->make_image = gst_video_test_src_smpte75;
       
   357       break;
       
   358     case GST_VIDEO_TEST_SRC_ZONE_PLATE:
       
   359       videotestsrc->make_image = gst_video_test_src_zoneplate;
       
   360       break;
       
   361     default:
   254     default:
   362       g_assert_not_reached ();
   255       g_assert_not_reached ();
   363   }
   256   }
   364 }
   257 }
   365 
   258 
   377       src->timestamp_offset = g_value_get_int64 (value);
   270       src->timestamp_offset = g_value_get_int64 (value);
   378       break;
   271       break;
   379     case PROP_IS_LIVE:
   272     case PROP_IS_LIVE:
   380       gst_base_src_set_live (GST_BASE_SRC (src), g_value_get_boolean (value));
   273       gst_base_src_set_live (GST_BASE_SRC (src), g_value_get_boolean (value));
   381       break;
   274       break;
   382     case PROP_PEER_ALLOC:
       
   383       src->peer_alloc = g_value_get_boolean (value);
       
   384       break;
       
   385     case PROP_COLOR_SPEC:
       
   386       src->color_spec = g_value_get_enum (value);
       
   387       break;
       
   388     case PROP_K0:
       
   389       src->k0 = g_value_get_int (value);
       
   390       break;
       
   391     case PROP_KX:
       
   392       src->kx = g_value_get_int (value);
       
   393       break;
       
   394     case PROP_KY:
       
   395       src->ky = g_value_get_int (value);
       
   396       break;
       
   397     case PROP_KT:
       
   398       src->kt = g_value_get_int (value);
       
   399       break;
       
   400     case PROP_KXT:
       
   401       src->kxt = g_value_get_int (value);
       
   402       break;
       
   403     case PROP_KYT:
       
   404       src->kyt = g_value_get_int (value);
       
   405       break;
       
   406     case PROP_KXY:
       
   407       src->kxy = g_value_get_int (value);
       
   408       break;
       
   409     case PROP_KX2:
       
   410       src->kx2 = g_value_get_int (value);
       
   411       break;
       
   412     case PROP_KY2:
       
   413       src->ky2 = g_value_get_int (value);
       
   414       break;
       
   415     case PROP_KT2:
       
   416       src->kt2 = g_value_get_int (value);
       
   417       break;
       
   418     case PROP_XOFFSET:
       
   419       src->xoffset = g_value_get_int (value);
       
   420       break;
       
   421     case PROP_YOFFSET:
       
   422       src->yoffset = g_value_get_int (value);
       
   423       break;
       
   424     default:
   275     default:
   425       break;
   276       break;
   426   }
   277   }
   427 }
   278 }
   428 
   279 
   440       g_value_set_int64 (value, src->timestamp_offset);
   291       g_value_set_int64 (value, src->timestamp_offset);
   441       break;
   292       break;
   442     case PROP_IS_LIVE:
   293     case PROP_IS_LIVE:
   443       g_value_set_boolean (value, gst_base_src_is_live (GST_BASE_SRC (src)));
   294       g_value_set_boolean (value, gst_base_src_is_live (GST_BASE_SRC (src)));
   444       break;
   295       break;
   445     case PROP_PEER_ALLOC:
       
   446       g_value_set_boolean (value, src->peer_alloc);
       
   447       break;
       
   448     case PROP_COLOR_SPEC:
       
   449       g_value_set_enum (value, src->color_spec);
       
   450       break;
       
   451     case PROP_K0:
       
   452       g_value_set_int (value, src->k0);
       
   453       break;
       
   454     case PROP_KX:
       
   455       g_value_set_int (value, src->kx);
       
   456       break;
       
   457     case PROP_KY:
       
   458       g_value_set_int (value, src->ky);
       
   459       break;
       
   460     case PROP_KT:
       
   461       g_value_set_int (value, src->kt);
       
   462       break;
       
   463     case PROP_KXT:
       
   464       g_value_set_int (value, src->kxt);
       
   465       break;
       
   466     case PROP_KYT:
       
   467       g_value_set_int (value, src->kyt);
       
   468       break;
       
   469     case PROP_KXY:
       
   470       g_value_set_int (value, src->kxy);
       
   471       break;
       
   472     case PROP_KX2:
       
   473       g_value_set_int (value, src->kx2);
       
   474       break;
       
   475     case PROP_KY2:
       
   476       g_value_set_int (value, src->ky2);
       
   477       break;
       
   478     case PROP_KT2:
       
   479       g_value_set_int (value, src->kt2);
       
   480       break;
       
   481     case PROP_XOFFSET:
       
   482       g_value_set_int (value, src->xoffset);
       
   483       break;
       
   484     case PROP_YOFFSET:
       
   485       g_value_set_int (value, src->yoffset);
       
   486       break;
       
   487     default:
   296     default:
   488       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
   297       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
   489       break;
   298       break;
   490   }
   299   }
   491 }
   300 }
   492 
   301 
   493 /* threadsafe because this gets called as the plugin is loaded */
   302 /* threadsafe because this gets called as the plugin is loaded */
   494 static GstCaps *
   303 static GstCaps *
   495 gst_video_test_src_getcaps (GstBaseSrc * bsrc)
   304 gst_video_test_src_getcaps (GstBaseSrc * unused)
   496 {
   305 {
   497   static GstCaps *capslist = NULL;
   306   static GstCaps *capslist = NULL;
   498   GstVideoTestSrc *videotestsrc;
       
   499 
       
   500   videotestsrc = GST_VIDEO_TEST_SRC (bsrc);
       
   501 
   307 
   502   if (!capslist) {
   308   if (!capslist) {
   503     GstCaps *caps;
   309     GstCaps *caps;
   504     GstStructure *structure;
   310     GstStructure *structure;
   505     int i;
   311     int i;
   727 
   533 
   728 static GstFlowReturn
   534 static GstFlowReturn
   729 gst_video_test_src_create (GstPushSrc * psrc, GstBuffer ** buffer)
   535 gst_video_test_src_create (GstPushSrc * psrc, GstBuffer ** buffer)
   730 {
   536 {
   731   GstVideoTestSrc *src;
   537   GstVideoTestSrc *src;
   732   gulong newsize, size;
   538   gulong newsize;
   733   GstBuffer *outbuf = NULL;
   539   GstBuffer *outbuf;
   734   GstFlowReturn res;
   540   GstFlowReturn res;
   735   GstClockTime next_time;
   541   GstClockTime next_time;
   736 
   542 
   737   src = GST_VIDEO_TEST_SRC (psrc);
   543   src = GST_VIDEO_TEST_SRC (psrc);
   738 
   544 
   749 
   555 
   750   GST_LOG_OBJECT (src,
   556   GST_LOG_OBJECT (src,
   751       "creating buffer of %lu bytes with %dx%d image for frame %d", newsize,
   557       "creating buffer of %lu bytes with %dx%d image for frame %d", newsize,
   752       src->width, src->height, (gint) src->n_frames);
   558       src->width, src->height, (gint) src->n_frames);
   753 
   559 
   754   if (src->peer_alloc) {
   560 #ifdef USE_PEER_BUFFERALLOC
   755     res =
   561   res =
   756         gst_pad_alloc_buffer_and_set_caps (GST_BASE_SRC_PAD (psrc),
   562       gst_pad_alloc_buffer_and_set_caps (GST_BASE_SRC_PAD (psrc),
   757         GST_BUFFER_OFFSET_NONE, newsize, GST_PAD_CAPS (GST_BASE_SRC_PAD (psrc)),
   563       GST_BUFFER_OFFSET_NONE, newsize, GST_PAD_CAPS (GST_BASE_SRC_PAD (psrc)),
   758         &outbuf);
   564       &outbuf);
   759     if (res != GST_FLOW_OK)
   565   if (res != GST_FLOW_OK)
   760       goto no_buffer;
   566     goto no_buffer;
   761 
   567 #else
   762     /* the buffer could have renegotiated, we need to discard any buffers of the
   568   outbuf = gst_buffer_new_and_alloc (newsize);
   763      * wrong size. */
   569   gst_buffer_set_caps (outbuf, GST_PAD_CAPS (GST_BASE_SRC_PAD (psrc)));
   764     size = GST_BUFFER_SIZE (outbuf);
   570 #endif
   765     newsize = gst_video_test_src_get_size (src, src->width, src->height);
       
   766 
       
   767     if (size != newsize) {
       
   768       gst_buffer_unref (outbuf);
       
   769       outbuf = NULL;
       
   770     }
       
   771   }
       
   772 
       
   773   if (outbuf == NULL) {
       
   774     outbuf = gst_buffer_new_and_alloc (newsize);
       
   775     gst_buffer_set_caps (outbuf, GST_PAD_CAPS (GST_BASE_SRC_PAD (psrc)));
       
   776   }
       
   777 
       
   778   memset (GST_BUFFER_DATA (outbuf), 0, GST_BUFFER_SIZE (outbuf));
       
   779 
   571 
   780   if (src->pattern_type == GST_VIDEO_TEST_SRC_BLINK) {
   572   if (src->pattern_type == GST_VIDEO_TEST_SRC_BLINK) {
   781     if (src->n_frames & 0x1) {
   573     if (src->n_frames & 0x1) {
   782       gst_video_test_src_white (src, (void *) GST_BUFFER_DATA (outbuf),
   574       gst_video_test_src_white (src, (void *) GST_BUFFER_DATA (outbuf),
   783           src->width, src->height);
   575           src->width, src->height);
   841 }
   633 }
   842 
   634 
   843 static gboolean
   635 static gboolean
   844 plugin_init (GstPlugin * plugin)
   636 plugin_init (GstPlugin * plugin)
   845 {
   637 {
   846   oil_init ();
   638   //oil_init ();
   847 
   639 
   848   GST_DEBUG_CATEGORY_INIT (video_test_src_debug, "videotestsrc", 0,
   640   GST_DEBUG_CATEGORY_INIT (video_test_src_debug, "videotestsrc", 0,
   849       "Video Test Source");
   641       "Video Test Source");
   850 
   642 
   851   return gst_element_register (plugin, "videotestsrc", GST_RANK_NONE,
   643   return gst_element_register (plugin, "videotestsrc", GST_RANK_NONE,