247
gst_real_video_dec_activate_push (GstPad * pad, gboolean active)
247
gst_real_video_dec_getcaps (GstPad * pad)
249
GstRealVideoDec *dec = GST_REAL_VIDEO_DEC (GST_PAD_PARENT (pad));
252
if (dec->checked_modules) {
253
GValue versions = { 0 };
254
GValue version = { 0 };
256
GST_LOG_OBJECT (dec, "constructing caps");
257
res = gst_caps_new_empty ();
259
g_value_init (&versions, GST_TYPE_LIST);
260
g_value_init (&version, G_TYPE_INT);
262
if (dec->valid_rv20) {
263
g_value_set_int (&version, GST_REAL_VIDEO_DEC_VERSION_2);
264
gst_value_list_append_value (&versions, &version);
266
if (dec->valid_rv30) {
267
g_value_set_int (&version, GST_REAL_VIDEO_DEC_VERSION_3);
268
gst_value_list_append_value (&versions, &version);
270
if (dec->valid_rv40) {
271
g_value_set_int (&version, GST_REAL_VIDEO_DEC_VERSION_4);
272
gst_value_list_append_value (&versions, &version);
275
if (gst_value_list_get_size (&versions) > 0) {
276
res = gst_caps_new_simple ("video/x-pn-realvideo", NULL);
277
gst_structure_set_value (gst_caps_get_structure (res, 0),
278
"rmversion", &versions);
280
res = gst_caps_new_empty ();
282
g_value_unset (&versions);
283
g_value_unset (&version);
285
GST_LOG_OBJECT (dec, "returning padtemplate caps");
286
res = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
288
GST_LOG_OBJECT (dec, "returning caps %" GST_PTR_FORMAT, res);
273
313
GST_LOG_OBJECT (dec, "Setting version to %d", version);
275
if (!open_library (dec, &hooks, version))
315
close_library (dec, &dec->lib);
317
if (!open_library (dec, version, &dec->lib))
278
320
/* Initialize REAL driver. */
279
321
GST_WRITE_UINT16_LE (data + 0, 11);
339
380
"format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
340
381
"framerate", GST_TYPE_FRACTION, framerate_num, framerate_denom,
341
382
"width", G_TYPE_INT, width, "height", G_TYPE_INT, height, NULL);
384
/* set PAR if one was specified in the sink caps */
385
if ((v = gst_structure_get_value (s, "pixel-aspect-ratio"))) {
386
gst_structure_set_value (gst_caps_get_structure (caps, 0),
387
"pixel-aspect-ratio", v);
342
390
bres = gst_pad_set_caps (GST_PAD (dec->src), caps);
343
391
gst_caps_unref (caps);
345
393
goto could_not_set_caps;
347
close_library (dec->hooks);
349
395
dec->version = version;
350
396
dec->width = width;
351
397
dec->height = height;
361
407
GST_ERROR_OBJECT (dec, "Could not find all necessary keys in structure.");
412
GST_ERROR_OBJECT (dec, "failed to open library");
365
415
could_not_initialize:
367
close_library (hooks);
368
417
GST_ERROR_OBJECT (dec, "Initialization of REAL driver failed (%i).", res);
418
close_library (dec, &dec->lib);
372
421
could_not_allocate:
374
close_library (hooks);
375
423
GST_ERROR_OBJECT (dec, "Could not allocate memory.");
424
close_library (dec, &dec->lib);
379
427
could_not_send_message:
381
close_library (hooks);
382
429
GST_ERROR_OBJECT (dec, "Failed to send custom message needed for "
383
430
"initialization (%i).", res);
431
close_library (dec, &dec->lib);
387
434
could_not_set_caps:
389
close_library (hooks);
390
436
GST_ERROR_OBJECT (dec, "Could not convince peer to accept dimensions "
391
437
"%i x %i.", dec->width, dec->height);
438
close_library (dec, &dec->lib);
461
511
goto could_not_load;
464
hooks->init = (GstRealVideoDecInitFunc) rv_init;
465
hooks->free = (GstRealVideoDecFreeFunc) rv_free;
466
hooks->transform = (GstRealVideoDecTransformFunc) rv_transform;
467
hooks->custom_message = (GstRealVideoDecMessageFunc) rv_custom_msg;
468
hooks->module = module;
514
lib->Init = (guint32 (*)(gpointer, gpointer)) rv_init;
515
lib->Free = (guint32 (*)(gpointer)) rv_free;
516
lib->Transform = (guint32 (*)(gchar *, gchar *, gpointer, gpointer, gpointer))
518
lib->Message = (guint32 (*)(gpointer, gpointer)) rv_custom_msg;
519
lib->module = module;
470
521
dec->error_count = 0;
476
527
GST_ERROR_OBJECT (dec, "Cannot handle version %i.", version);
482
532
GST_ERROR_OBJECT (dec, "Could not open library '%s' in '%s': %s", names,
483
533
path, g_module_error ());
489
close_library (*hooks);
538
close_library (dec, lib);
490
539
GST_ERROR_OBJECT (dec, "Could not load all symbols: %s", g_module_error ());
496
close_library (GstRealVideoDecHooks hooks)
498
if (hooks.context && hooks.free)
499
hooks.free (hooks.context);
502
g_module_close (hooks.module);
545
close_library (GstRealVideoDec * dec, GstRVDecLibrary * lib)
548
GST_LOG_OBJECT (dec, "closing library");
550
lib->Free (lib->context);
553
GST_LOG_OBJECT (dec, "closing library module");
554
g_module_close (lib->module);
557
memset (lib, 0, sizeof (*lib));
561
gst_real_video_dec_probe_modules (GstRealVideoDec * dec)
563
GstRVDecLibrary dummy = { NULL };
565
if ((dec->valid_rv20 =
566
open_library (dec, GST_REAL_VIDEO_DEC_VERSION_2, &dummy)))
567
close_library (dec, &dummy);
568
if ((dec->valid_rv30 =
569
open_library (dec, GST_REAL_VIDEO_DEC_VERSION_3, &dummy)))
570
close_library (dec, &dummy);
571
if ((dec->valid_rv40 =
572
open_library (dec, GST_REAL_VIDEO_DEC_VERSION_4, &dummy)))
573
close_library (dec, &dummy);
576
static GstStateChangeReturn
577
gst_real_video_dec_change_state (GstElement * element,
578
GstStateChange transition)
580
GstStateChangeReturn ret;
581
GstRealVideoDec *dec = GST_REAL_VIDEO_DEC (element);
583
switch (transition) {
584
case GST_STATE_CHANGE_NULL_TO_READY:
585
gst_real_video_dec_probe_modules (dec);
586
dec->checked_modules = TRUE;
592
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
594
switch (transition) {
595
case GST_STATE_CHANGE_PAUSED_TO_READY:
596
close_library (dec, &dec->lib);
598
case GST_STATE_CHANGE_READY_TO_NULL:
599
dec->checked_modules = FALSE;
508
608
gst_real_video_dec_init (GstRealVideoDec * dec, GstRealVideoDecClass * klass)
510
610
dec->snk = gst_pad_new_from_static_template (&snk_t, "sink");
611
gst_pad_set_getcaps_function (dec->snk,
612
GST_DEBUG_FUNCPTR (gst_real_video_dec_getcaps));
511
613
gst_pad_set_setcaps_function (dec->snk,
512
614
GST_DEBUG_FUNCPTR (gst_real_video_dec_setcaps));
513
615
gst_pad_set_chain_function (dec->snk,
514
616
GST_DEBUG_FUNCPTR (gst_real_video_dec_chain));
515
gst_pad_set_activatepush_function (dec->snk,
516
GST_DEBUG_FUNCPTR (gst_real_video_dec_activate_push));
517
617
gst_element_add_pad (GST_ELEMENT (dec), dec->snk);
519
619
dec->src = gst_pad_new_from_static_template (&src_t, "src");
638
737
gst_real_video_dec_class_init (GstRealVideoDecClass * klass)
640
739
GObjectClass *object_class = G_OBJECT_CLASS (klass);
740
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
642
742
object_class->set_property = gst_real_video_dec_set_property;
643
743
object_class->get_property = gst_real_video_dec_get_property;
644
744
object_class->finalize = gst_real_video_dec_finalize;
746
element_class->change_state = gst_real_video_dec_change_state;
646
748
g_object_class_install_property (object_class, PROP_REAL_CODECS_PATH,
647
749
g_param_spec_string ("real-codecs-path",
648
750
"Path where to search for RealPlayer codecs",