mfc: Check if the hardware is available in GstVideoDecoder::open()

This commit is contained in:
Sebastian Dröge 2013-01-02 10:26:04 +01:00
parent d1e9a96a69
commit 0489f52776

View file

@ -30,6 +30,7 @@
GST_DEBUG_CATEGORY_STATIC (gst_mfc_dec_debug);
#define GST_CAT_DEFAULT gst_mfc_dec_debug
static gboolean gst_mfc_dec_open (GstVideoDecoder * decoder);
static gboolean gst_mfc_dec_start (GstVideoDecoder * decoder);
static gboolean gst_mfc_dec_stop (GstVideoDecoder * decoder);
static gboolean gst_mfc_dec_set_format (GstVideoDecoder * decoder,
@ -109,6 +110,7 @@ gst_mfc_dec_class_init (GstMFCDecClass * klass)
"Decode video streams via Samsung Exynos",
"Sebastian Dröge <sebastian.droege@collabora.co.uk>");
video_decoder_class->open = GST_DEBUG_FUNCPTR (gst_mfc_dec_open);
video_decoder_class->start = GST_DEBUG_FUNCPTR (gst_mfc_dec_start);
video_decoder_class->stop = GST_DEBUG_FUNCPTR (gst_mfc_dec_stop);
video_decoder_class->finish = GST_DEBUG_FUNCPTR (gst_mfc_dec_finish);
@ -132,6 +134,28 @@ gst_mfc_dec_init (GstMFCDec * self)
gst_video_decoder_set_packetized (decoder, TRUE);
}
static gboolean
gst_mfc_dec_open (GstVideoDecoder * decoder)
{
GstMFCDec *self = GST_MFC_DEC (decoder);
GST_DEBUG_OBJECT (self, "Opening");
/* Just check here once if we can create a MFC context, i.e.
* if the hardware is available
*/
self->context = mfc_dec_create (CODEC_TYPE_H264, 1);
if (!self->context) {
GST_ELEMENT_ERROR (self, LIBRARY, INIT,
("Failed to initialize MFC decoder context"), (NULL));
return FALSE;
}
mfc_dec_destroy (self->context);
self->context = NULL;
return TRUE;
}
static gboolean
gst_mfc_dec_start (GstVideoDecoder * decoder)
{