static gboolean _track_is_compatible_with_profile (GESPipeline * self, GESTrack * track, GstEncodingProfile * prof) { if (TRACK_COMPATIBLE_PROFILE (track->type, prof)) { if (self->priv->mode == GES_PIPELINE_MODE_SMART_RENDER) { GstCaps *ocaps, *rcaps; GST_DEBUG ("Smart Render mode, setting input caps"); ocaps = gst_encoding_profile_get_input_caps (prof); ocaps = gst_caps_make_writable (ocaps); if (track->type == GES_TRACK_TYPE_AUDIO) rcaps = gst_caps_new_empty_simple ("audio/x-raw"); else rcaps = gst_caps_new_empty_simple ("video/x-raw"); gst_caps_append (ocaps, rcaps); ges_track_set_caps (track, ocaps); gst_caps_unref (ocaps); } else { GstCaps *caps = NULL; /* Raw preview or rendering mode */ if (track->type == GES_TRACK_TYPE_VIDEO) caps = gst_caps_new_empty_simple ("video/x-raw"); else if (track->type == GES_TRACK_TYPE_AUDIO) caps = gst_caps_new_empty_simple ("audio/x-raw"); if (caps) { ges_track_set_caps (track, caps); gst_caps_unref (caps); } } return TRUE; } return FALSE; }
static void ges_track_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { GESTrack *track = GES_TRACK (object); switch (property_id) { case ARG_CAPS: ges_track_set_caps (track, gst_value_get_caps (value)); break; case ARG_TYPE: track->type = g_value_get_flags (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } }
static gboolean ges_timeline_pipeline_update_caps (GESTimelinePipeline * self) { GList *ltrack, *tracks, *lstream; if (!self->priv->profile) return TRUE; GST_DEBUG ("Updating track caps"); tracks = ges_timeline_get_tracks (self->priv->timeline); /* Take each stream of the encoding profile and find a matching * track to set the caps on */ for (ltrack = tracks; ltrack; ltrack = ltrack->next) { GESTrack *track = (GESTrack *) ltrack->data; GList *allstreams; allstreams = (GList *) gst_encoding_container_profile_get_profiles ( (GstEncodingContainerProfile *) self->priv->profile); /* Find a matching stream setting */ for (lstream = allstreams; lstream; lstream = lstream->next) { GstEncodingProfile *prof = (GstEncodingProfile *) lstream->data; if (TRACK_COMPATIBLE_PROFILE (track->type, prof)) { if (self->priv->mode == TIMELINE_MODE_SMART_RENDER) { GstCaps *ocaps, *rcaps; GST_DEBUG ("Smart Render mode, setting input caps"); ocaps = gst_encoding_profile_get_input_caps (prof); if (track->type == GES_TRACK_TYPE_AUDIO) rcaps = gst_caps_from_string ("audio/x-raw-int;audio/x-raw-float"); else rcaps = gst_caps_from_string ("video/x-raw-yuv;video/x-raw-rgb"); gst_caps_append (ocaps, rcaps); ges_track_set_caps (track, ocaps); } else { GstCaps *caps = NULL; /* Raw preview or rendering mode */ if (track->type == GES_TRACK_TYPE_VIDEO) caps = gst_caps_from_string ("video/x-raw-yuv;video/x-raw-rgb"); else if (track->type == GES_TRACK_TYPE_AUDIO) gst_caps_from_string ("audio/x-raw-int;audio/x-raw-float"); if (caps) { ges_track_set_caps (track, caps); gst_caps_unref (caps); } } break; } } g_object_unref (track); } if (tracks) g_list_free (tracks); GST_DEBUG ("Done updating caps"); return TRUE; }
/** * ges_pipeline_set_mode: * @pipeline: a #GESPipeline * @mode: the #GESPipelineFlags to use * * switches the @pipeline to the specified @mode. The default mode when * creating a #GESPipeline is #GES_PIPELINE_MODE_PREVIEW. * * Note: The @pipeline will be set to #GST_STATE_NULL during this call due to * the internal changes that happen. The caller will therefore have to * set the @pipeline to the requested state after calling this method. * * Returns: %TRUE if the mode was properly set, else %FALSE. **/ gboolean ges_pipeline_set_mode (GESPipeline * pipeline, GESPipelineFlags mode) { GList *tmp; g_return_val_if_fail (GES_IS_PIPELINE (pipeline), FALSE); GST_DEBUG_OBJECT (pipeline, "current mode : %d, mode : %d", pipeline->priv->mode, mode); /* fast-path, nothing to change */ if (mode == pipeline->priv->mode) return TRUE; /* FIXME: It would be nice if we are only (de)activating preview * modes to not set the whole pipeline to NULL, but instead just * do the proper (un)linking to playsink. */ /* Switch pipeline to NULL since we're changing the configuration */ gst_element_set_state (GST_ELEMENT_CAST (pipeline), GST_STATE_NULL); if (pipeline->priv->timeline) { gboolean disabled = ! !(mode & (GES_PIPELINE_MODE_RENDER | GES_PIPELINE_MODE_SMART_RENDER)); for (tmp = pipeline->priv->timeline->tracks; tmp; tmp = tmp->next) track_disable_last_gap (GES_TRACK (tmp->data), disabled); } /* remove no-longer needed components */ if (pipeline->priv->mode & GES_PIPELINE_MODE_PREVIEW && !(mode & GES_PIPELINE_MODE_PREVIEW)) { /* Disable playsink */ GST_DEBUG ("Disabling playsink"); gst_object_ref (pipeline->priv->playsink); gst_bin_remove (GST_BIN_CAST (pipeline), pipeline->priv->playsink); } if ((pipeline->priv->mode & (GES_PIPELINE_MODE_RENDER | GES_PIPELINE_MODE_SMART_RENDER)) && !(mode & (GES_PIPELINE_MODE_RENDER | GES_PIPELINE_MODE_SMART_RENDER))) { GList *tmp; GstCaps *caps; for (tmp = pipeline->priv->timeline->tracks; tmp; tmp = tmp->next) { GESTrackType type = GES_TRACK (tmp->data)->type; if (type == GES_TRACK_TYPE_AUDIO) caps = gst_caps_new_empty_simple ("audio/x-raw"); else if (type == GES_TRACK_TYPE_VIDEO) caps = gst_caps_new_empty_simple ("video/x-raw"); else continue; ges_track_set_caps (GES_TRACK (tmp->data), caps); gst_caps_unref (caps); } /* Disable render bin */ GST_DEBUG ("Disabling rendering bin"); gst_object_ref (pipeline->priv->encodebin); gst_object_ref (pipeline->priv->urisink); gst_bin_remove_many (GST_BIN_CAST (pipeline), pipeline->priv->encodebin, pipeline->priv->urisink, NULL); } /* Add new elements */ if (!(pipeline->priv->mode & GES_PIPELINE_MODE_PREVIEW) && (mode & GES_PIPELINE_MODE_PREVIEW)) { /* Add playsink */ GST_DEBUG ("Adding playsink"); if (!gst_bin_add (GST_BIN_CAST (pipeline), pipeline->priv->playsink)) { GST_ERROR_OBJECT (pipeline, "Couldn't add playsink"); return FALSE; } } if (!(pipeline->priv->mode & (GES_PIPELINE_MODE_RENDER | GES_PIPELINE_MODE_SMART_RENDER)) && (mode & (GES_PIPELINE_MODE_RENDER | GES_PIPELINE_MODE_SMART_RENDER))) { /* Adding render bin */ GST_DEBUG ("Adding render bin"); if (G_UNLIKELY (pipeline->priv->urisink == NULL)) { GST_ERROR_OBJECT (pipeline, "Output URI not set !"); return FALSE; } if (!gst_bin_add (GST_BIN_CAST (pipeline), pipeline->priv->encodebin)) { GST_ERROR_OBJECT (pipeline, "Couldn't add encodebin"); return FALSE; } if (!gst_bin_add (GST_BIN_CAST (pipeline), pipeline->priv->urisink)) { GST_ERROR_OBJECT (pipeline, "Couldn't add URI sink"); return FALSE; } g_object_set (pipeline->priv->encodebin, "avoid-reencoding", !(!(mode & GES_PIPELINE_MODE_SMART_RENDER)), NULL); gst_element_link_pads_full (pipeline->priv->encodebin, "src", pipeline->priv->urisink, "sink", GST_PAD_LINK_CHECK_NOTHING); } /* FIXUPS */ /* FIXME * If we are rendering, set playsink to sync=False, * If we are NOT rendering, set playsink to sync=TRUE */ pipeline->priv->mode = mode; return TRUE; }