diff --git a/gst/encoding/gstencodebin.c b/gst/encoding/gstencodebin.c index 4aeb09b211..2f2199a463 100644 --- a/gst/encoding/gstencodebin.c +++ b/gst/encoding/gstencodebin.c @@ -928,6 +928,7 @@ _create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof, GList *tmp, *tosync = NULL; const GstCaps *format; const GstCaps *restriction; + const gchar *missing_element_name; format = gst_encoding_profile_get_format (sprof); restriction = gst_encoding_profile_get_restriction (sprof); @@ -1173,10 +1174,19 @@ _create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof, cspace = gst_element_factory_make ("ffmpegcolorspace", NULL); scale = gst_element_factory_make ("videoscale", NULL); + if (!scale) { + missing_element_name = "videoscale"; + goto missing_element; + } /* 4-tap scaling and black borders */ g_object_set (scale, "method", 2, "add-borders", TRUE, NULL); cspace2 = gst_element_factory_make ("ffmpegcolorspace", NULL); + if (!cspace || !cspace2) { + missing_element_name = "ffmpegcolorspace"; + goto missing_element; + } + gst_bin_add_many ((GstBin *) ebin, cspace, scale, cspace2, NULL); tosync = g_list_append (tosync, cspace); tosync = g_list_append (tosync, scale); @@ -1193,6 +1203,11 @@ _create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof, if (!gst_encoding_video_profile_get_variableframerate (GST_ENCODING_VIDEO_PROFILE (sprof))) { vrate = gst_element_factory_make ("videorate", NULL); + if (!vrate) { + missing_element_name = "videorate"; + goto missing_element; + } + gst_bin_add ((GstBin *) ebin, vrate); tosync = g_list_prepend (tosync, vrate); sgroup->converters = g_list_prepend (sgroup->converters, vrate); @@ -1211,9 +1226,21 @@ _create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof, arate = gst_element_factory_make ("audiorate", NULL); g_object_set (arate, "tolerance", (guint64) ebin->tolerance, NULL); + if (!arate) { + missing_element_name = "audiorate"; + goto missing_element; + } aconv = gst_element_factory_make ("audioconvert", NULL); aconv2 = gst_element_factory_make ("audioconvert", NULL); ares = gst_element_factory_make ("audioresample", NULL); + if (!aconv || !aconv2) { + missing_element_name = "audioconvert"; + goto missing_element; + } + if (!ares) { + missing_element_name = "audioresample"; + goto missing_element; + } gst_bin_add_many ((GstBin *) ebin, arate, aconv, ares, aconv2, NULL); tosync = g_list_append (tosync, arate); @@ -1283,6 +1310,15 @@ no_muxer_pad: "Couldn't find a compatible muxer pad to link encoder to"); goto cleanup; +missing_element: + gst_element_post_message (GST_ELEMENT_CAST (ebin), + gst_missing_element_message_new (GST_ELEMENT_CAST (ebin), + missing_element_name)); + GST_ELEMENT_ERROR (ebin, CORE, MISSING_PLUGIN, + (_("Missing element '%s' - check your GStreamer installation."), + missing_element_name), (NULL)); + goto cleanup; + encoder_link_failure: GST_ERROR_OBJECT (ebin, "Failed to link the encoder"); goto cleanup;