static void build_pipeline (NscGStreamer *gstreamer) { NscGStreamerPrivate *priv; GstBus *bus; g_return_if_fail (NSC_IS_GSTREAMER (gstreamer)); priv = NSC_GSTREAMER_GET_PRIVATE (gstreamer); if (priv->pipeline != NULL) { gst_object_unref (GST_OBJECT (priv->pipeline)); } priv->pipeline = gst_pipeline_new ("pipeline"); bus = gst_element_get_bus (priv->pipeline); gst_bus_add_signal_watch (bus); /* Connect the signals we want to listen to on the bus */ g_signal_connect (G_OBJECT (bus), "message::error", G_CALLBACK (error_cb), gstreamer); g_signal_connect (G_OBJECT (bus), "message::eos", G_CALLBACK (eos_cb), gstreamer); /* Read from disk */ priv->filesrc = gst_element_factory_make (FILE_SOURCE, "file_src"); if (priv->filesrc == NULL) { g_set_error (&priv->construct_error, NSC_ERROR, NSC_ERROR_INTERNAL_ERROR, _("Could not create GStreamer file input")); return; } /* Decode */ priv->decode = gst_element_factory_make ("decodebin", "decode"); if (priv->decode == NULL) { g_set_error (&priv->construct_error, NSC_ERROR, NSC_ERROR_INTERNAL_ERROR, _("Could not create GStreamer file input")); return; } /* Encode */ priv->encode = build_encoder (gstreamer); if (priv->encode == NULL) { g_set_error (&priv->construct_error, NSC_ERROR, NSC_ERROR_INTERNAL_ERROR, _("Could not create GStreamer encoders for %s"), gm_audio_profile_get_name (priv->profile)); return; } /* Decodebin uses dynamic pads, so lets set up a callback. */ g_signal_connect (G_OBJECT (priv->decode), "new-decoded-pad", G_CALLBACK (connect_decodebin_cb), priv->encode); /* Write to disk */ priv->filesink = gst_element_factory_make (FILE_SINK, "file_sink"); if (priv->filesink == NULL) { g_set_error (&priv->construct_error, NSC_ERROR, NSC_ERROR_INTERNAL_ERROR, _("Could not create GStreamer file output")); return; } /* * TODO: Eventually, we should ask the user if they want to * overwrite any existing file. */ g_signal_connect (G_OBJECT (priv->filesink), "allow-overwrite", G_CALLBACK (just_say_yes), gstreamer); /* Add the elements to the pipeline */ gst_bin_add_many (GST_BIN (priv->pipeline), priv->filesrc, priv->decode, priv->encode, priv->filesink, NULL); /* Link filessrc and decoder */ if (!gst_element_link_many (priv->filesrc, priv->decode, NULL)) { g_set_error (&priv->construct_error, NSC_ERROR, NSC_ERROR_INTERNAL_ERROR, _("Could not link pipeline")); return; } /* Link the rest */ if (!gst_element_link (priv->encode, priv->filesink)) { g_set_error (&priv->construct_error, NSC_ERROR, NSC_ERROR_INTERNAL_ERROR, _("Could not link pipeline")); return; } priv->rebuild_pipeline = FALSE; }
static void build_pipeline (SjExtractor *extractor) { SjExtractorPrivate *priv; GstBus *bus; g_return_if_fail (SJ_IS_EXTRACTOR (extractor)); priv = extractor->priv; if (priv->pipeline != NULL) { gst_object_unref (GST_OBJECT (priv->pipeline)); } priv->pipeline = gst_pipeline_new ("pipeline"); bus = gst_element_get_bus (priv->pipeline); gst_bus_add_signal_watch (bus); g_signal_connect (G_OBJECT (bus), "message::error", G_CALLBACK (error_cb), extractor); /* Read from CD */ priv->cdsrc = gst_element_make_from_uri (GST_URI_SRC, "cdda://1", "cd_src", NULL); if (priv->cdsrc == NULL) { g_set_error (&priv->construct_error, SJ_ERROR, SJ_ERROR_INTERNAL_ERROR, _("Could not create GStreamer CD reader")); return; } g_object_set (G_OBJECT (priv->cdsrc), "device", priv->device_path, NULL); if (g_object_class_find_property (G_OBJECT_GET_CLASS (priv->cdsrc), "paranoia-mode")) { g_object_set (G_OBJECT (priv->cdsrc), "paranoia-mode", priv->paranoia_mode, NULL); } /* Get the track format for seeking later */ priv->track_format = gst_format_get_by_nick ("track"); g_assert (priv->track_format != 0); /* Encode */ priv->encodebin = build_encoder (extractor); if (priv->encodebin == NULL) { g_set_error (&priv->construct_error, SJ_ERROR, SJ_ERROR_INTERNAL_ERROR, _("Could not create GStreamer encoders for %s"), gst_encoding_profile_get_name (priv->profile)); return; } /* Connect to the eos so we know when its finished */ g_signal_connect (bus, "message::eos", G_CALLBACK (eos_cb), extractor); /* Write to disk */ priv->filesink = gst_element_factory_make (FILE_SINK, "file_sink"); if (priv->filesink == NULL) { g_set_error (&priv->construct_error, SJ_ERROR, SJ_ERROR_INTERNAL_ERROR, _("Could not create GStreamer file output")); return; } #if 0 g_signal_connect (G_OBJECT (priv->filesink), "allow-overwrite", G_CALLBACK (just_say_yes), extractor); #endif /* Add the elements to the pipeline */ gst_bin_add_many (GST_BIN (priv->pipeline), priv->cdsrc, priv->encodebin, priv->filesink, NULL); /* Link it all together */ if (!gst_element_link_many (priv->cdsrc, priv->encodebin, priv->filesink, NULL)) { g_set_error (&priv->construct_error, SJ_ERROR, SJ_ERROR_INTERNAL_ERROR, _("Could not link pipeline")); return; } priv->rebuild_pipeline = FALSE; }