113 {GST_VIDEO_TEST_SRC_CHECKERS2, "Checkers 2px", "checkers-2"}, |
129 {GST_VIDEO_TEST_SRC_CHECKERS2, "Checkers 2px", "checkers-2"}, |
114 {GST_VIDEO_TEST_SRC_CHECKERS4, "Checkers 4px", "checkers-4"}, |
130 {GST_VIDEO_TEST_SRC_CHECKERS4, "Checkers 4px", "checkers-4"}, |
115 {GST_VIDEO_TEST_SRC_CHECKERS8, "Checkers 8px", "checkers-8"}, |
131 {GST_VIDEO_TEST_SRC_CHECKERS8, "Checkers 8px", "checkers-8"}, |
116 {GST_VIDEO_TEST_SRC_CIRCULAR, "Circular", "circular"}, |
132 {GST_VIDEO_TEST_SRC_CIRCULAR, "Circular", "circular"}, |
117 {GST_VIDEO_TEST_SRC_BLINK, "Blink", "blink"}, |
133 {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"}, |
118 {0, NULL, NULL} |
136 {0, NULL, NULL} |
119 }; |
137 }; |
120 |
138 |
121 if (!video_test_src_pattern_type) { |
139 if (!video_test_src_pattern_type) { |
122 video_test_src_pattern_type = |
140 video_test_src_pattern_type = |
123 g_enum_register_static ("GstVideoTestSrcPattern", pattern_types); |
141 g_enum_register_static ("GstVideoTestSrcPattern", pattern_types); |
124 } |
142 } |
125 return video_test_src_pattern_type; |
143 return video_test_src_pattern_type; |
126 } |
144 } |
127 |
145 |
|
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 |
128 static void |
164 static void |
129 gst_video_test_src_base_init (gpointer g_class) |
165 gst_video_test_src_base_init (gpointer g_class) |
130 { |
166 { |
131 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); |
167 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); |
132 |
168 |
152 gobject_class->get_property = gst_video_test_src_get_property; |
188 gobject_class->get_property = gst_video_test_src_get_property; |
153 |
189 |
154 g_object_class_install_property (gobject_class, PROP_PATTERN, |
190 g_object_class_install_property (gobject_class, PROP_PATTERN, |
155 g_param_spec_enum ("pattern", "Pattern", |
191 g_param_spec_enum ("pattern", "Pattern", |
156 "Type of test pattern to generate", GST_TYPE_VIDEO_TEST_SRC_PATTERN, |
192 "Type of test pattern to generate", GST_TYPE_VIDEO_TEST_SRC_PATTERN, |
157 GST_VIDEO_TEST_SRC_SMPTE, G_PARAM_READWRITE)); |
193 DEFAULT_PATTERN, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
158 g_object_class_install_property (gobject_class, |
194 g_object_class_install_property (gobject_class, PROP_TIMESTAMP_OFFSET, |
159 PROP_TIMESTAMP_OFFSET, g_param_spec_int64 ("timestamp-offset", |
195 g_param_spec_int64 ("timestamp-offset", "Timestamp offset", |
160 "Timestamp offset", |
|
161 "An offset added to timestamps set on buffers (in ns)", G_MININT64, |
196 "An offset added to timestamps set on buffers (in ns)", G_MININT64, |
162 G_MAXINT64, 0, G_PARAM_READWRITE)); |
197 G_MAXINT64, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
163 g_object_class_install_property (gobject_class, PROP_IS_LIVE, |
198 g_object_class_install_property (gobject_class, PROP_IS_LIVE, |
164 g_param_spec_boolean ("is-live", "Is Live", |
199 g_param_spec_boolean ("is-live", "Is Live", |
165 "Whether to act as a live source", FALSE, G_PARAM_READWRITE)); |
200 "Whether to act as a live source", DEFAULT_IS_LIVE, |
|
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)); |
166 |
266 |
167 gstbasesrc_class->get_caps = gst_video_test_src_getcaps; |
267 gstbasesrc_class->get_caps = gst_video_test_src_getcaps; |
168 gstbasesrc_class->set_caps = gst_video_test_src_setcaps; |
268 gstbasesrc_class->set_caps = gst_video_test_src_setcaps; |
169 gstbasesrc_class->is_seekable = gst_video_test_src_is_seekable; |
269 gstbasesrc_class->is_seekable = gst_video_test_src_is_seekable; |
170 gstbasesrc_class->do_seek = gst_video_test_src_do_seek; |
270 gstbasesrc_class->do_seek = gst_video_test_src_do_seek; |
291 g_value_set_int64 (value, src->timestamp_offset); |
440 g_value_set_int64 (value, src->timestamp_offset); |
292 break; |
441 break; |
293 case PROP_IS_LIVE: |
442 case PROP_IS_LIVE: |
294 g_value_set_boolean (value, gst_base_src_is_live (GST_BASE_SRC (src))); |
443 g_value_set_boolean (value, gst_base_src_is_live (GST_BASE_SRC (src))); |
295 break; |
444 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; |
296 default: |
487 default: |
297 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
488 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
298 break; |
489 break; |
299 } |
490 } |
300 } |
491 } |
301 |
492 |
302 /* threadsafe because this gets called as the plugin is loaded */ |
493 /* threadsafe because this gets called as the plugin is loaded */ |
303 static GstCaps * |
494 static GstCaps * |
304 gst_video_test_src_getcaps (GstBaseSrc * unused) |
495 gst_video_test_src_getcaps (GstBaseSrc * bsrc) |
305 { |
496 { |
306 static GstCaps *capslist = NULL; |
497 static GstCaps *capslist = NULL; |
|
498 GstVideoTestSrc *videotestsrc; |
|
499 |
|
500 videotestsrc = GST_VIDEO_TEST_SRC (bsrc); |
307 |
501 |
308 if (!capslist) { |
502 if (!capslist) { |
309 GstCaps *caps; |
503 GstCaps *caps; |
310 GstStructure *structure; |
504 GstStructure *structure; |
311 int i; |
505 int i; |
555 |
749 |
556 GST_LOG_OBJECT (src, |
750 GST_LOG_OBJECT (src, |
557 "creating buffer of %lu bytes with %dx%d image for frame %d", newsize, |
751 "creating buffer of %lu bytes with %dx%d image for frame %d", newsize, |
558 src->width, src->height, (gint) src->n_frames); |
752 src->width, src->height, (gint) src->n_frames); |
559 |
753 |
560 #ifdef USE_PEER_BUFFERALLOC |
754 if (src->peer_alloc) { |
561 res = |
755 res = |
562 gst_pad_alloc_buffer_and_set_caps (GST_BASE_SRC_PAD (psrc), |
756 gst_pad_alloc_buffer_and_set_caps (GST_BASE_SRC_PAD (psrc), |
563 GST_BUFFER_OFFSET_NONE, newsize, GST_PAD_CAPS (GST_BASE_SRC_PAD (psrc)), |
757 GST_BUFFER_OFFSET_NONE, newsize, GST_PAD_CAPS (GST_BASE_SRC_PAD (psrc)), |
564 &outbuf); |
758 &outbuf); |
565 if (res != GST_FLOW_OK) |
759 if (res != GST_FLOW_OK) |
566 goto no_buffer; |
760 goto no_buffer; |
567 #else |
761 |
568 outbuf = gst_buffer_new_and_alloc (newsize); |
762 /* the buffer could have renegotiated, we need to discard any buffers of the |
569 gst_buffer_set_caps (outbuf, GST_PAD_CAPS (GST_BASE_SRC_PAD (psrc))); |
763 * wrong size. */ |
570 #endif |
764 size = GST_BUFFER_SIZE (outbuf); |
|
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)); |
571 |
779 |
572 if (src->pattern_type == GST_VIDEO_TEST_SRC_BLINK) { |
780 if (src->pattern_type == GST_VIDEO_TEST_SRC_BLINK) { |
573 if (src->n_frames & 0x1) { |
781 if (src->n_frames & 0x1) { |
574 gst_video_test_src_white (src, (void *) GST_BUFFER_DATA (outbuf), |
782 gst_video_test_src_white (src, (void *) GST_BUFFER_DATA (outbuf), |
575 src->width, src->height); |
783 src->width, src->height); |