1 /* GStreamer encoding profiles library
2 * Copyright (C) 2009-2010 Edward Hervey <edward.hervey@collabora.co.uk>
3 * (C) 2009-2010 Nokia Corporation
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 * SECTION:encoding-profile
23 * @short_description: Encoding profile library
27 * Functions to create and handle encoding profiles.
30 * Encoding profiles describe the media types and settings one wishes to use for
31 * an encoding process. The top-level profiles are commonly
32 * #GstEncodingContainerProfile(s) (which contains a user-readable name and
33 * description along with which container format to use). These, in turn,
34 * reference one or more #GstEncodingProfile(s) which indicate which encoding
35 * format should be used on each individual streams.
38 * #GstEncodingProfile(s) can be provided to the 'encodebin' element, which will take
39 * care of selecting and setting up the required elements to produce an output stream
40 * conforming to the specifications of the profile.
43 * Unlike other systems, the encoding profiles do not specify which #GstElement to use
44 * for the various encoding and muxing steps, but instead relies on specifying the format
48 * Encoding profiles can be created at runtime by the application or loaded from (and saved
49 * to) file using the #GstEncodingTarget API.
53 * <title>Example: Creating a profile</title>
56 * #include <gst/pbutils/encoding-profile.h>
58 * GstEncodingProfile *
59 * create_ogg_theora_profile(void)
61 * GstEncodingContainerProfile *prof;
64 * caps = gst_caps_from_string("application/ogg");
65 * prof = gst_encoding_container_profile_new("Ogg audio/video",
66 * "Standard OGG/THEORA/VORBIS",
68 * gst_caps_unref (caps);
70 * caps = gst_caps_from_string("video/x-theora");
71 * gst_encoding_container_profile_add_profile(prof,
72 * (GstEncodingProfile*) gst_encoding_video_profile_new(caps, NULL, NULL, 0));
73 * gst_caps_unref (caps);
75 * caps = gst_caps_from_string("audio/x-vorbis");
76 * gst_encoding_container_profile_add_profile(prof,
77 * (GstEncodingProfile*) gst_encoding_audio_profile_new(caps, NULL, NULL, 0));
78 * gst_caps_unref (caps);
80 * return (GstEncodingProfile*) prof;
88 * <title>Example: Listing categories, targets and profiles</title>
91 * #include <gst/pbutils/encoding-profile.h>
93 * GstEncodingProfile *prof;
94 * GList *categories, *tmpc;
95 * GList *targets, *tmpt;
97 * categories = gst_encoding_target_list_available_categories();
99 * ... Show available categories to user ...
101 * for (tmpc = categories; tmpc; tmpc = tmpc->next) {
102 * gchar *category = (gchar *) tmpc->data;
104 * ... and we can list all targets within that category ...
106 * targets = gst_encoding_target_list_all (category);
108 * ... and show a list to our users ...
110 * g_list_foreach (targets, (GFunc) gst_encoding_target_unref, NULL);
111 * g_list_free (targets);
114 * g_list_foreach (categories, (GFunc) g_free, NULL);
115 * g_list_free (categories);
129 #include "encoding-profile.h"
130 #include "encoding-target.h"
132 /* GstEncodingProfile API */
134 struct _GstEncodingProfile
144 GstCaps *restriction;
147 static void string_to_profile_transform (const GValue * src_value,
148 GValue * dest_value);
149 static gboolean gst_encoding_profile_deserialize_valfunc (GValue * value,
152 static void gst_encoding_profile_class_init (GstEncodingProfileClass * klass);
153 static gpointer gst_encoding_profile_parent_class = NULL;
156 gst_encoding_profile_class_intern_init (gpointer klass)
158 gst_encoding_profile_parent_class = g_type_class_peek_parent (klass);
159 gst_encoding_profile_class_init ((GstEncodingProfileClass *) klass);
163 gst_encoding_profile_get_type (void)
165 static volatile gsize g_define_type_id__volatile = 0;
167 if (g_once_init_enter (&g_define_type_id__volatile)) {
168 GType g_define_type_id = g_type_register_static_simple (G_TYPE_OBJECT,
169 g_intern_static_string ("GstEncodingProfile"),
170 sizeof (GstEncodingProfileClass),
171 (GClassInitFunc) gst_encoding_profile_class_intern_init,
172 sizeof (GstEncodingProfile),
175 static GstValueTable gstvtable = {
177 (GstValueCompareFunc) NULL,
178 (GstValueSerializeFunc) NULL,
179 (GstValueDeserializeFunc) gst_encoding_profile_deserialize_valfunc
182 gstvtable.type = g_define_type_id;
184 /* Register a STRING=>PROFILE GValueTransformFunc */
185 g_value_register_transform_func (G_TYPE_STRING, g_define_type_id,
186 string_to_profile_transform);
187 /* Register gst-specific GValue functions */
188 gst_value_register (&gstvtable);
190 g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
192 return g_define_type_id__volatile;
196 gst_encoding_profile_finalize (GObject * object)
198 GstEncodingProfile *prof = (GstEncodingProfile *) object;
202 gst_caps_unref (prof->format);
204 g_free (prof->preset);
205 if (prof->description)
206 g_free (prof->description);
207 if (prof->restriction)
208 gst_caps_unref (prof->restriction);
212 gst_encoding_profile_class_init (GObjectClass * klass)
214 klass->finalize = gst_encoding_profile_finalize;
218 * gst_encoding_profile_get_name:
219 * @profile: a #GstEncodingProfile
223 * Returns: the name of the profile, can be %NULL.
226 gst_encoding_profile_get_name (GstEncodingProfile * profile)
228 return profile->name;
232 * gst_encoding_profile_get_description:
233 * @profile: a #GstEncodingProfile
237 * Returns: the description of the profile, can be %NULL.
240 gst_encoding_profile_get_description (GstEncodingProfile * profile)
242 return profile->description;
246 * gst_encoding_profile_get_format:
247 * @profile: a #GstEncodingProfile
251 * Returns: (transfer full): the #GstCaps corresponding to the media format used
252 * in the profile. Unref after usage.
255 gst_encoding_profile_get_format (GstEncodingProfile * profile)
257 return (profile->format ? gst_caps_ref (profile->format) : NULL);
261 * gst_encoding_profile_get_preset:
262 * @profile: a #GstEncodingProfile
266 * Returns: the name of the #GstPreset to be used in the profile.
269 gst_encoding_profile_get_preset (GstEncodingProfile * profile)
271 return profile->preset;
275 * gst_encoding_profile_get_presence:
276 * @profile: a #GstEncodingProfile
280 * Returns: The number of times the profile is used in its parent
281 * container profile. If 0, it is not a mandatory stream.
284 gst_encoding_profile_get_presence (GstEncodingProfile * profile)
286 return profile->presence;
290 * gst_encoding_profile_get_restriction:
291 * @profile: a #GstEncodingProfile
295 * Returns: (transfer full): The restriction #GstCaps to apply before the encoder
296 * that will be used in the profile. The fields present in restriction caps are
297 * properties of the raw stream (that is before encoding), such as height and
298 * width for video and depth and sampling rate for audio. Does not apply to
299 * #GstEncodingContainerProfile (since there is no corresponding raw stream).
300 * Can be %NULL. Unref after usage.
303 gst_encoding_profile_get_restriction (GstEncodingProfile * profile)
305 return (profile->restriction ? gst_caps_ref (profile->restriction) : NULL);
309 * gst_encoding_profile_set_name:
310 * @profile: a #GstEncodingProfile
311 * @name: the name to set on the profile
313 * Set @name as the given name for the @profile. A copy of @name will be made
319 gst_encoding_profile_set_name (GstEncodingProfile * profile, const gchar * name)
322 g_free (profile->name);
323 profile->name = g_strdup (name);
327 * gst_encoding_profile_set_description:
328 * @profile: a #GstEncodingProfile
329 * @description: the description to set on the profile
331 * Set @description as the given description for the @profile. A copy of
332 * @description will be made internally.
337 gst_encoding_profile_set_description (GstEncodingProfile * profile,
338 const gchar * description)
340 if (profile->description)
341 g_free (profile->description);
342 profile->description = g_strdup (description);
346 * gst_encoding_profile_set_format:
347 * @profile: a #GstEncodingProfile
348 * @format: the media format to use in the profile.
350 * Sets the media format used in the profile.
355 gst_encoding_profile_set_format (GstEncodingProfile * profile, GstCaps * format)
358 gst_caps_unref (profile->format);
359 profile->format = gst_caps_ref (format);
363 * gst_encoding_profile_set_preset:
364 * @profile: a #GstEncodingProfile
365 * @preset: the element preset to use
367 * Sets the preset to use for the profile.
372 gst_encoding_profile_set_preset (GstEncodingProfile * profile,
373 const gchar * preset)
376 g_free (profile->preset);
377 profile->preset = g_strdup (preset);
381 * gst_encoding_profile_set_presence:
382 * @profile: a #GstEncodingProfile
383 * @presence: the number of time the profile can be used
385 * Set the number of time the profile is used in its parent
386 * container profile. If 0, it is not a mandatory stream
391 gst_encoding_profile_set_presence (GstEncodingProfile * profile, guint presence)
393 profile->presence = presence;
397 * gst_encoding_profile_set_restriction:
398 * @profile: a #GstEncodingProfile
399 * @restriction: the restriction to apply
401 * Set the restriction #GstCaps to apply before the encoder
402 * that will be used in the profile. See gst_encoding_profile_set_restriction()
403 * for more about restrictions. Does not apply to #GstEncodingContainerProfile.
408 gst_encoding_profile_set_restriction (GstEncodingProfile * profile,
409 GstCaps * restriction)
411 if (profile->restriction)
412 gst_caps_unref (profile->restriction);
413 profile->restriction = restriction;
416 /* Container profiles */
418 struct _GstEncodingContainerProfile
420 GstEncodingProfile parent;
422 GList *encodingprofiles;
425 G_DEFINE_TYPE (GstEncodingContainerProfile, gst_encoding_container_profile,
426 GST_TYPE_ENCODING_PROFILE);
429 gst_encoding_container_profile_init (GstEncodingContainerProfile * prof)
431 /* Nothing to initialize */
435 gst_encoding_container_profile_finalize (GObject * object)
437 GstEncodingContainerProfile *prof = (GstEncodingContainerProfile *) object;
439 g_list_foreach (prof->encodingprofiles, (GFunc) g_object_unref, NULL);
440 g_list_free (prof->encodingprofiles);
442 G_OBJECT_CLASS (gst_encoding_container_profile_parent_class)->finalize
447 gst_encoding_container_profile_class_init (GObjectClass * klass)
449 klass->finalize = gst_encoding_container_profile_finalize;
453 * gst_encoding_container_profile_get_profiles:
454 * @profile: a #GstEncodingContainerProfile
456 * Returns: (element-type GstPbutils.EncodingProfile) (transfer none):
457 * the list of contained #GstEncodingProfile.
460 gst_encoding_container_profile_get_profiles (GstEncodingContainerProfile *
463 return profile->encodingprofiles;
468 struct _GstEncodingVideoProfile
470 GstEncodingProfile parent;
473 gboolean variableframerate;
476 G_DEFINE_TYPE (GstEncodingVideoProfile, gst_encoding_video_profile,
477 GST_TYPE_ENCODING_PROFILE);
480 gst_encoding_video_profile_init (GstEncodingVideoProfile * prof)
482 /* Nothing to initialize */
486 gst_encoding_video_profile_class_init (GObjectClass * klass)
491 * gst_encoding_video_profile_get_pass:
492 * @prof: a #GstEncodingVideoProfile
494 * Get the pass number if this is part of a multi-pass profile.
496 * Returns: The pass number. Starts at 1 for multi-pass. 0 if this is
497 * not a multi-pass profile
502 gst_encoding_video_profile_get_pass (GstEncodingVideoProfile * prof)
508 * gst_encoding_video_profile_get_variableframerate:
509 * @prof: a #GstEncodingVideoProfile
513 * Returns: Whether non-constant video framerate is allowed for encoding.
516 gst_encoding_video_profile_get_variableframerate (GstEncodingVideoProfile *
519 return prof->variableframerate;
523 * gst_encoding_video_profile_set_pass:
524 * @prof: a #GstEncodingVideoProfile
525 * @pass: the pass number for this profile
527 * Sets the pass number of this video profile. The first pass profile should have
528 * this value set to 1. If this video profile isn't part of a multi-pass profile,
529 * you may set it to 0 (the default value).
534 gst_encoding_video_profile_set_pass (GstEncodingVideoProfile * prof, guint pass)
540 * gst_encoding_video_profile_set_variableframerate:
541 * @prof: a #GstEncodingVideoProfile
542 * @variableframerate: a boolean
544 * If set to %TRUE, then the incoming stream will be allowed to have non-constant
545 * framerate. If set to %FALSE (default value), then the incoming stream will
546 * be normalized by dropping/duplicating frames in order to produce a
547 * constance framerate.
552 gst_encoding_video_profile_set_variableframerate (GstEncodingVideoProfile *
553 prof, gboolean variableframerate)
555 prof->variableframerate = variableframerate;
560 struct _GstEncodingAudioProfile
562 GstEncodingProfile parent;
565 G_DEFINE_TYPE (GstEncodingAudioProfile, gst_encoding_audio_profile,
566 GST_TYPE_ENCODING_PROFILE);
569 gst_encoding_audio_profile_init (GstEncodingAudioProfile * prof)
571 /* Nothing to initialize */
575 gst_encoding_audio_profile_class_init (GObjectClass * klass)
579 static inline gboolean
580 _gst_caps_is_equal_safe (GstCaps * a, GstCaps * b)
584 if ((a == NULL) || (b == NULL))
586 return gst_caps_is_equal (a, b);
590 _compare_container_encoding_profiles (GstEncodingContainerProfile * ca,
591 GstEncodingContainerProfile * cb)
595 if (g_list_length (ca->encodingprofiles) !=
596 g_list_length (cb->encodingprofiles))
599 for (tmp = ca->encodingprofiles; tmp; tmp = tmp->next) {
600 GstEncodingProfile *prof = (GstEncodingProfile *) tmp->data;
601 if (!gst_encoding_container_profile_contains_profile (ca, prof))
609 _compare_encoding_profiles (const GstEncodingProfile * a,
610 const GstEncodingProfile * b)
612 if ((G_TYPE_FROM_INSTANCE (a) != G_TYPE_FROM_INSTANCE (b)) ||
613 !_gst_caps_is_equal_safe (a->format, b->format) ||
614 (g_strcmp0 (a->preset, b->preset) != 0) ||
615 (g_strcmp0 (a->name, b->name) != 0) ||
616 (g_strcmp0 (a->description, b->description) != 0))
619 if (GST_IS_ENCODING_CONTAINER_PROFILE (a))
621 _compare_container_encoding_profiles (GST_ENCODING_CONTAINER_PROFILE
622 (a), GST_ENCODING_CONTAINER_PROFILE (b));
624 if (GST_IS_ENCODING_VIDEO_PROFILE (a)) {
625 GstEncodingVideoProfile *va = (GstEncodingVideoProfile *) a;
626 GstEncodingVideoProfile *vb = (GstEncodingVideoProfile *) b;
628 if ((va->pass != vb->pass)
629 || (va->variableframerate != vb->variableframerate))
637 * gst_encoding_container_profile_contains_profile:
638 * @container: a #GstEncodingContainerProfile
639 * @profile: a #GstEncodingProfile
641 * Checks if @container contains a #GstEncodingProfile identical to
646 * Returns: %TRUE if @container contains a #GstEncodingProfile identical
647 * to @profile, else %FALSE.
650 gst_encoding_container_profile_contains_profile (GstEncodingContainerProfile *
651 container, GstEncodingProfile * profile)
653 g_return_val_if_fail (GST_IS_ENCODING_CONTAINER_PROFILE (container), FALSE);
654 g_return_val_if_fail (GST_IS_ENCODING_PROFILE (profile), FALSE);
656 return (g_list_find_custom (container->encodingprofiles, profile,
657 (GCompareFunc) _compare_encoding_profiles) != NULL);
661 * gst_encoding_container_profile_add_profile:
662 * @container: the #GstEncodingContainerProfile to use
663 * @profile: the #GstEncodingProfile to add.
665 * Add a #GstEncodingProfile to the list of profiles handled by @container.
667 * No copy of @profile will be made, if you wish to use it elsewhere after this
668 * method you should increment its reference count.
672 * Returns: %TRUE if the @stream was properly added, else %FALSE.
675 gst_encoding_container_profile_add_profile (GstEncodingContainerProfile *
676 container, GstEncodingProfile * profile)
678 g_return_val_if_fail (GST_IS_ENCODING_CONTAINER_PROFILE (container), FALSE);
679 g_return_val_if_fail (GST_IS_ENCODING_PROFILE (profile), FALSE);
681 if (g_list_find_custom (container->encodingprofiles, profile,
682 (GCompareFunc) _compare_encoding_profiles)) {
684 ("Encoding profile already contains an identical GstEncodingProfile");
688 container->encodingprofiles =
689 g_list_append (container->encodingprofiles, profile);
694 static GstEncodingProfile *
695 common_creation (GType objtype, GstCaps * format, const gchar * preset,
696 const gchar * name, const gchar * description, GstCaps * restriction,
699 GstEncodingProfile *prof;
701 prof = (GstEncodingProfile *) g_object_new (objtype, NULL);
704 prof->name = g_strdup (name);
706 prof->description = g_strdup (description);
708 prof->preset = g_strdup (preset);
710 prof->format = gst_caps_ref (format);
712 prof->restriction = gst_caps_ref (restriction);
713 prof->presence = presence;
719 * gst_encoding_container_profile_new:
720 * @name: (allow-none): The name of the container profile, can be %NULL
721 * @description: (allow-none): The description of the container profile,
723 * @format: The format to use for this profile
724 * @preset: (allow-none): The preset to use for this profile
726 * Creates a new #GstEncodingContainerProfile.
730 * Returns: The newly created #GstEncodingContainerProfile.
732 GstEncodingContainerProfile *
733 gst_encoding_container_profile_new (const gchar * name,
734 const gchar * description, GstCaps * format, const gchar * preset)
736 g_return_val_if_fail (GST_IS_CAPS (format), NULL);
738 return (GstEncodingContainerProfile *)
739 common_creation (GST_TYPE_ENCODING_CONTAINER_PROFILE, format, preset,
740 name, description, NULL, 0);
744 * gst_encoding_video_profile_new:
745 * @format: the #GstCaps
746 * @preset: (allow-none): the preset(s) to use on the encoder, can be #NULL
747 * @restriction: (allow-none) the #GstCaps used to restrict the input to the encoder, can be
748 * NULL. See gst_encoding_profile_get_restriction() for more details.
749 * @presence: the number of time this stream must be used. 0 means any number of
750 * times (including never)
752 * Creates a new #GstEncodingVideoProfile
754 * All provided allocatable arguments will be internally copied, so can be
755 * safely freed/unreferenced after calling this method.
757 * If you wish to control the pass number (in case of multi-pass scenarios),
758 * please refer to the gst_encoding_video_profile_set_pass() documentation.
760 * If you wish to use/force a constant framerate please refer to the
761 * gst_encoding_video_profile_set_variableframerate() documentation.
765 * Returns: the newly created #GstEncodingVideoProfile.
767 GstEncodingVideoProfile *
768 gst_encoding_video_profile_new (GstCaps * format, const gchar * preset,
769 GstCaps * restriction, guint presence)
771 return (GstEncodingVideoProfile *)
772 common_creation (GST_TYPE_ENCODING_VIDEO_PROFILE, format, preset, NULL,
773 NULL, restriction, presence);
777 * gst_encoding_audio_profile_new:
778 * @format: the #GstCaps
779 * @preset: (allow-none): the preset(s) to use on the encoder, can be #NULL
780 * @restriction: (allow-none): the #GstCaps used to restrict the input to the encoder, can be
781 * NULL. See gst_encoding_profile_get_restriction() for more details.
782 * @presence: the number of time this stream must be used. 0 means any number of
783 * times (including never)
785 * Creates a new #GstEncodingAudioProfile
787 * All provided allocatable arguments will be internally copied, so can be
788 * safely freed/unreferenced after calling this method.
792 * Returns: the newly created #GstEncodingAudioProfile.
794 GstEncodingAudioProfile *
795 gst_encoding_audio_profile_new (GstCaps * format, const gchar * preset,
796 GstCaps * restriction, guint presence)
798 return (GstEncodingAudioProfile *)
799 common_creation (GST_TYPE_ENCODING_AUDIO_PROFILE, format, preset, NULL,
800 NULL, restriction, presence);
805 * gst_encoding_profile_is_equal:
806 * @a: a #GstEncodingProfile
807 * @b: a #GstEncodingProfile
809 * Checks whether the two #GstEncodingProfile are equal
813 * Returns: %TRUE if @a and @b are equal, else %FALSE.
816 gst_encoding_profile_is_equal (GstEncodingProfile * a, GstEncodingProfile * b)
818 return (_compare_encoding_profiles (a, b) == 0);
823 * gst_encoding_profile_get_input_caps:
824 * @profile: a #GstEncodingProfile
826 * Computes the full output caps that this @profile will be able to consume.
830 * Returns: (transfer full): The full caps the given @profile can consume. Call
831 * gst_caps_unref() when you are done with the caps.
834 gst_encoding_profile_get_input_caps (GstEncodingProfile * profile)
838 GstStructure *st, *outst;
843 if (GST_IS_ENCODING_CONTAINER_PROFILE (profile)) {
844 GstCaps *res = gst_caps_new_empty ();
846 for (ltmp = GST_ENCODING_CONTAINER_PROFILE (profile)->encodingprofiles;
847 ltmp; ltmp = ltmp->next) {
848 GstEncodingProfile *sprof = (GstEncodingProfile *) ltmp->data;
849 gst_caps_merge (res, gst_encoding_profile_get_input_caps (sprof));
854 fcaps = profile->format;
857 if ((profile->restriction == NULL) || gst_caps_is_any (profile->restriction))
858 return gst_caps_ref (fcaps);
860 /* Combine the format with the restriction caps */
861 outst = gst_caps_get_structure (fcaps, 0);
862 out_name = gst_structure_get_name_id (outst);
863 tmp = gst_caps_new_empty ();
864 len = gst_caps_get_size (profile->restriction);
866 for (i = 0; i < len; i++) {
867 st = gst_structure_copy (gst_caps_get_structure (profile->restriction, i));
869 gst_caps_append_structure (tmp, st);
872 out = gst_caps_intersect (tmp, fcaps);
873 gst_caps_unref (tmp);
879 * gst_encoding_profile_get_type_nick:
880 * @profile: a #GstEncodingProfile
884 * Returns: the human-readable name of the type of @profile.
887 gst_encoding_profile_get_type_nick (GstEncodingProfile * profile)
889 if (GST_IS_ENCODING_CONTAINER_PROFILE (profile))
891 if (GST_IS_ENCODING_VIDEO_PROFILE (profile))
893 if (GST_IS_ENCODING_AUDIO_PROFILE (profile))
899 * gst_encoding_profile_find:
900 * @targetname: (transfer none): The name of the target
901 * @profilename: (transfer none): The name of the profile
902 * @category: (transfer none) (allow-none): The target category. Can be %NULL
904 * Find the #GstEncodingProfile with the specified name and category.
906 * Returns: (transfer full): The matching #GstEncodingProfile or %NULL.
911 gst_encoding_profile_find (const gchar * targetname, const gchar * profilename,
912 const gchar * category)
914 GstEncodingProfile *res = NULL;
915 GstEncodingTarget *target;
917 g_return_val_if_fail (targetname != NULL, NULL);
918 g_return_val_if_fail (profilename != NULL, NULL);
920 /* FIXME : how do we handle profiles named the same in several
921 * categories but of which only one has the required profile ? */
922 target = gst_encoding_target_load (targetname, category, NULL);
924 res = gst_encoding_target_get_profile (target, profilename);
925 gst_encoding_target_unref (target);
931 static GstEncodingProfile *
932 combo_search (const gchar * pname)
934 GstEncodingProfile *res;
938 split = g_strsplit (pname, "/", 2);
939 if (g_strv_length (split) != 2)
942 res = gst_encoding_profile_find (split[0], split[1], NULL);
949 /* GValue transform function */
951 string_to_profile_transform (const GValue * src_value, GValue * dest_value)
953 const gchar *profilename;
954 GstEncodingProfile *profile;
956 profilename = g_value_get_string (src_value);
958 profile = combo_search (profilename);
961 g_value_take_object (dest_value, (GObject *) profile);
965 gst_encoding_profile_deserialize_valfunc (GValue * value, const gchar * s)
967 GstEncodingProfile *profile;
969 profile = combo_search (s);
972 g_value_take_object (value, (GObject *) profile);
980 * gst_encoding_profile_from_discoverer:
981 * @info: (transfer none): The #GstDiscovererInfo to read from
983 * Creates a #GstEncodingProfile matching the formats from the given
984 * #GstEncodingProfile. Streams other than audio or video (eg,
985 * subtitles), are currently ignored.
987 * Returns: (transfer full): The new #GstEncodingProfile or %NULL.
992 gst_encoding_profile_from_discoverer (GstDiscovererInfo * info)
994 GstEncodingContainerProfile *profile;
995 GstDiscovererStreamInfo *sinfo;
996 GList *streams, *stream;
997 GstCaps *caps = NULL;
999 if (!info || gst_discoverer_info_get_result (info) != GST_DISCOVERER_OK)
1002 sinfo = gst_discoverer_info_get_stream_info (info);
1006 caps = gst_discoverer_stream_info_get_caps (sinfo);
1007 GST_LOG ("Container: %" GST_PTR_FORMAT "\n", caps);
1009 gst_encoding_container_profile_new ("auto-generated",
1010 "Automatically generated from GstDiscovererInfo", caps, NULL);
1011 gst_caps_unref (caps);
1013 GST_ERROR ("Failed to create container profile from caps %" GST_PTR_FORMAT,
1019 gst_discoverer_container_info_get_streams (GST_DISCOVERER_CONTAINER_INFO
1021 for (stream = streams; stream; stream = stream->next) {
1022 GstEncodingProfile *sprofile = NULL;
1023 sinfo = (GstDiscovererStreamInfo *) stream->data;
1024 caps = gst_discoverer_stream_info_get_caps (sinfo);
1025 GST_LOG ("Stream: %" GST_PTR_FORMAT "\n", caps);
1026 if (GST_IS_DISCOVERER_AUDIO_INFO (sinfo)) {
1028 (GstEncodingProfile *) gst_encoding_audio_profile_new (caps, NULL,
1030 } else if (GST_IS_DISCOVERER_VIDEO_INFO (sinfo)) {
1032 (GstEncodingProfile *) gst_encoding_video_profile_new (caps, NULL,
1035 /* subtitles or other ? ignore for now */
1038 gst_encoding_container_profile_add_profile (profile, sprofile);
1040 GST_ERROR ("Failed to create stream profile from caps %" GST_PTR_FORMAT,
1042 gst_caps_unref (caps);
1044 gst_discoverer_stream_info_list_free (streams);
1046 return (GstEncodingProfile *) profile;