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
136 GstMiniObject parent;
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 =
169 g_type_register_static_simple (GST_TYPE_MINI_OBJECT,
170 g_intern_static_string ("GstEncodingProfile"),
171 sizeof (GstEncodingProfileClass),
172 (GClassInitFunc) gst_encoding_profile_class_intern_init,
173 sizeof (GstEncodingProfile),
176 static GstValueTable gstvtable = {
178 (GstValueCompareFunc) NULL,
179 (GstValueSerializeFunc) NULL,
180 (GstValueDeserializeFunc) gst_encoding_profile_deserialize_valfunc
183 gstvtable.type = g_define_type_id;
185 /* Register a STRING=>PROFILE GValueTransformFunc */
186 g_value_register_transform_func (G_TYPE_STRING, g_define_type_id,
187 string_to_profile_transform);
188 /* Register gst-specific GValue functions */
189 gst_value_register (&gstvtable);
191 g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
193 return g_define_type_id__volatile;
197 gst_encoding_profile_finalize (GstEncodingProfile * prof)
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 (GstMiniObjectClass * klass)
215 (GstMiniObjectFinalizeFunction) gst_encoding_profile_finalize;
219 * gst_encoding_profile_get_name:
220 * @profile: a #GstEncodingProfile
224 * Returns: the name of the profile, can be %NULL.
227 gst_encoding_profile_get_name (GstEncodingProfile * profile)
229 return profile->name;
233 * gst_encoding_profile_get_description:
234 * @profile: a #GstEncodingProfile
238 * Returns: the description of the profile, can be %NULL.
241 gst_encoding_profile_get_description (GstEncodingProfile * profile)
243 return profile->description;
247 * gst_encoding_profile_get_format:
248 * @profile: a #GstEncodingProfile
252 * Returns: the #GstCaps corresponding to the media format used in the profile.
255 gst_encoding_profile_get_format (GstEncodingProfile * profile)
257 return profile->format;
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: 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).
303 gst_encoding_profile_get_restriction (GstEncodingProfile * profile)
305 return profile->restriction;
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 @description will be made
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 (GstEncodingContainerProfile * prof)
437 g_list_foreach (prof->encodingprofiles, (GFunc) gst_mini_object_unref, NULL);
438 g_list_free (prof->encodingprofiles);
440 GST_MINI_OBJECT_CLASS (gst_encoding_container_profile_parent_class)->finalize
441 ((GstMiniObject *) prof);
445 gst_encoding_container_profile_class_init (GstMiniObjectClass * klass)
448 (GstMiniObjectFinalizeFunction) gst_encoding_container_profile_finalize;
452 gst_encoding_container_profile_get_profiles (GstEncodingContainerProfile *
455 return profile->encodingprofiles;
460 struct _GstEncodingVideoProfile
462 GstEncodingProfile parent;
465 gboolean variableframerate;
468 G_DEFINE_TYPE (GstEncodingVideoProfile, gst_encoding_video_profile,
469 GST_TYPE_ENCODING_PROFILE);
472 gst_encoding_video_profile_init (GstEncodingVideoProfile * prof)
474 /* Nothing to initialize */
478 gst_encoding_video_profile_class_init (GstMiniObjectClass * klass)
483 * gst_encoding_video_profile_get_pass:
484 * @prof: a #GstEncodingVideoProfile
488 * Returns: The pass number if this is part of a multi-pass profile. Starts at
489 * 1 for multi-pass. 0 if this is not a multi-pass profile
492 gst_encoding_video_profile_get_pass (GstEncodingVideoProfile * prof)
498 * gst_encoding_video_profile_get_variableframerate:
499 * @prof: a #GstEncodingVideoProfile
503 * Returns: Whether non-constant video framerate is allowed for encoding.
506 gst_encoding_video_profile_get_variableframerate (GstEncodingVideoProfile *
509 return prof->variableframerate;
513 * gst_encoding_video_profile_set_pass:
514 * @prof: a #GstEncodingVideoProfile
515 * @pass: the pass number for this profile
517 * Sets the pass number of this video profile. The first pass profile should have
518 * this value set to 1. If this video profile isn't part of a multi-pass profile,
519 * you may set it to 0 (the default value).
524 gst_encoding_video_profile_set_pass (GstEncodingVideoProfile * prof, guint pass)
530 * gst_encoding_video_profile_set_variableframerate:
531 * @prof: a #GstEncodingVideoProfile
532 * @variableframerate: a boolean
534 * If set to %TRUE, then the incoming stream will be allowed to have non-constant
535 * framerate. If set to %FALSE (default value), then the incoming stream will
536 * be normalized by dropping/duplicating frames in order to produce a
537 * constance framerate.
542 gst_encoding_video_profile_set_variableframerate (GstEncodingVideoProfile *
543 prof, gboolean variableframerate)
545 prof->variableframerate = variableframerate;
550 struct _GstEncodingAudioProfile
552 GstEncodingProfile parent;
555 G_DEFINE_TYPE (GstEncodingAudioProfile, gst_encoding_audio_profile,
556 GST_TYPE_ENCODING_PROFILE);
559 gst_encoding_audio_profile_init (GstEncodingAudioProfile * prof)
561 /* Nothing to initialize */
565 gst_encoding_audio_profile_class_init (GstMiniObjectClass * klass)
569 static inline gboolean
570 _gst_caps_is_equal_safe (GstCaps * a, GstCaps * b)
574 if ((a == NULL) || (b == NULL))
576 return gst_caps_is_equal (a, b);
580 _compare_container_encoding_profiles (GstEncodingContainerProfile * ca,
581 GstEncodingContainerProfile * cb)
585 if (g_list_length (ca->encodingprofiles) !=
586 g_list_length (cb->encodingprofiles))
589 for (tmp = ca->encodingprofiles; tmp; tmp = tmp->next) {
590 GstEncodingProfile *prof = (GstEncodingProfile *) tmp->data;
591 if (!gst_encoding_container_profile_contains_profile (ca, prof))
599 _compare_encoding_profiles (const GstEncodingProfile * a,
600 const GstEncodingProfile * b)
602 if ((G_TYPE_FROM_INSTANCE (a) != G_TYPE_FROM_INSTANCE (b)) ||
603 !_gst_caps_is_equal_safe (a->format, b->format) ||
604 (g_strcmp0 (a->preset, b->preset) != 0) ||
605 (g_strcmp0 (a->name, b->name) != 0) ||
606 (g_strcmp0 (a->description, b->description) != 0))
609 if (GST_IS_ENCODING_CONTAINER_PROFILE (a))
611 _compare_container_encoding_profiles (GST_ENCODING_CONTAINER_PROFILE
612 (a), GST_ENCODING_CONTAINER_PROFILE (b));
614 if (GST_IS_ENCODING_VIDEO_PROFILE (a)) {
615 GstEncodingVideoProfile *va = (GstEncodingVideoProfile *) a;
616 GstEncodingVideoProfile *vb = (GstEncodingVideoProfile *) b;
618 if ((va->pass != vb->pass)
619 || (va->variableframerate != vb->variableframerate))
627 * gst_encoding_container_profile_contains_profile:
628 * @container: a #GstEncodingContainerProfile
629 * @profile: a #GstEncodingProfile
631 * Checks if @container contains a #GstEncodingProfile identical to
636 * Returns: %TRUE if @container contains a #GstEncodingProfile identical
637 * to @profile, else %FALSE.
640 gst_encoding_container_profile_contains_profile (GstEncodingContainerProfile *
641 container, GstEncodingProfile * profile)
643 g_return_val_if_fail (GST_IS_ENCODING_CONTAINER_PROFILE (container), FALSE);
644 g_return_val_if_fail (GST_IS_ENCODING_PROFILE (profile), FALSE);
646 return (g_list_find_custom (container->encodingprofiles, profile,
647 (GCompareFunc) _compare_encoding_profiles) != NULL);
651 * gst_encoding_container_profile_add_profile:
652 * @container: the #GstEncodingContainerProfile to use
653 * @profile: the #GstEncodingProfile to add.
655 * Add a #GstEncodingProfile to the list of profiles handled by @container.
657 * No copy of @profile will be made, if you wish to use it elsewhere after this
658 * method you should increment its reference count.
662 * Returns: %TRUE if the @stream was properly added, else %FALSE.
665 gst_encoding_container_profile_add_profile (GstEncodingContainerProfile *
666 container, GstEncodingProfile * profile)
668 g_return_val_if_fail (GST_IS_ENCODING_CONTAINER_PROFILE (container), FALSE);
669 g_return_val_if_fail (GST_IS_ENCODING_PROFILE (profile), FALSE);
671 if (g_list_find_custom (container->encodingprofiles, profile,
672 (GCompareFunc) _compare_encoding_profiles)) {
674 ("Encoding profile already contains an identical GstEncodingProfile");
678 container->encodingprofiles =
679 g_list_append (container->encodingprofiles, profile);
684 static GstEncodingProfile *
685 common_creation (GType objtype, GstCaps * format, const gchar * preset,
686 const gchar * name, const gchar * description, GstCaps * restriction,
689 GstEncodingProfile *prof;
691 prof = (GstEncodingProfile *) gst_mini_object_new (objtype);
694 prof->name = g_strdup (name);
696 prof->description = g_strdup (description);
698 prof->preset = g_strdup (preset);
700 prof->format = gst_caps_ref (format);
702 prof->restriction = gst_caps_ref (restriction);
703 prof->presence = presence;
709 * gst_encoding_container_profile_new:
710 * @name: The name of the container profile, can be %NULL
711 * @description: The description of the container profile, can be %NULL
712 * @format: The format to use for this profile
713 * @preset: The preset to use for this profile
715 * Creates a new #GstEncodingContainerProfile.
719 * Returns: The newly created #GstEncodingContainerProfile.
721 GstEncodingContainerProfile *
722 gst_encoding_container_profile_new (const gchar * name,
723 const gchar * description, GstCaps * format, const gchar * preset)
725 g_return_val_if_fail (GST_IS_CAPS (format), NULL);
727 return (GstEncodingContainerProfile *)
728 common_creation (GST_TYPE_ENCODING_CONTAINER_PROFILE, format, preset,
729 name, description, NULL, 0);
733 * gst_encoding_video_profile_new:
734 * @format: the #GstCaps
735 * @preset: the preset(s) to use on the encoder, can be #NULL
736 * @restriction: the #GstCaps used to restrict the input to the encoder, can be
737 * NULL. See gst_encoding_profile_get_restriction() for more details.
738 * @presence: the number of time this stream must be used. 0 means any number of
739 * times (including never)
741 * Creates a new #GstEncodingVideoProfile
743 * All provided allocatable arguments will be internally copied, so can be
744 * safely freed/unreferenced after calling this method.
746 * If you wish to control the pass number (in case of multi-pass scenarios),
747 * please refer to the gst_encoding_video_profile_set_pass() documentation.
749 * If you wish to use/force a constant framerate please refer to the
750 * gst_encoding_video_profile_set_variableframerate() documentation.
754 * Returns: the newly created #GstEncodingVideoProfile.
756 GstEncodingVideoProfile *
757 gst_encoding_video_profile_new (GstCaps * format, const gchar * preset,
758 GstCaps * restriction, guint presence)
760 return (GstEncodingVideoProfile *)
761 common_creation (GST_TYPE_ENCODING_VIDEO_PROFILE, format, preset, NULL,
762 NULL, restriction, presence);
766 * gst_encoding_audio_profile_new:
767 * @format: the #GstCaps
768 * @preset: the preset(s) to use on the encoder, can be #NULL
769 * @restriction: the #GstCaps used to restrict the input to the encoder, can be
770 * NULL. See gst_encoding_profile_get_restriction() for more details.
771 * @presence: the number of time this stream must be used. 0 means any number of
772 * times (including never)
774 * Creates a new #GstEncodingAudioProfile
776 * All provided allocatable arguments will be internally copied, so can be
777 * safely freed/unreferenced after calling this method.
781 * Returns: the newly created #GstEncodingAudioProfile.
783 GstEncodingAudioProfile *
784 gst_encoding_audio_profile_new (GstCaps * format, const gchar * preset,
785 GstCaps * restriction, guint presence)
787 return (GstEncodingAudioProfile *)
788 common_creation (GST_TYPE_ENCODING_AUDIO_PROFILE, format, preset, NULL,
789 NULL, restriction, presence);
794 * gst_encoding_profile_is_equal:
795 * @a: a #GstEncodingProfile
796 * @b: a #GstEncodingProfile
798 * Checks whether the two #GstEncodingProfile are equal
802 * Returns: %TRUE if @a and @b are equal, else %FALSE.
805 gst_encoding_profile_is_equal (GstEncodingProfile * a, GstEncodingProfile * b)
807 return (_compare_encoding_profiles (a, b) == 0);
812 * gst_encoding_profile_get_input_caps:
813 * @profile: a #GstEncodingProfile
815 * Computes the full output caps that this @profile will be able to consume.
819 * Returns: The full caps the given @profile can consume. Call gst_caps_unref()
820 * when you are done with the caps.
823 gst_encoding_profile_get_input_caps (GstEncodingProfile * profile)
827 GstStructure *st, *outst;
830 const GstCaps *fcaps;
832 if (GST_IS_ENCODING_CONTAINER_PROFILE (profile)) {
833 GstCaps *res = gst_caps_new_empty ();
835 for (ltmp = GST_ENCODING_CONTAINER_PROFILE (profile)->encodingprofiles;
836 ltmp; ltmp = ltmp->next) {
837 GstEncodingProfile *sprof = (GstEncodingProfile *) ltmp->data;
838 gst_caps_merge (res, gst_encoding_profile_get_input_caps (sprof));
843 fcaps = profile->format;
846 if ((profile->restriction == NULL) || gst_caps_is_any (profile->restriction))
847 return gst_caps_copy (fcaps);
849 /* Combine the format with the restriction caps */
850 outst = gst_caps_get_structure (fcaps, 0);
851 out_name = gst_structure_get_name_id (outst);
852 tmp = gst_caps_new_empty ();
853 len = gst_caps_get_size (profile->restriction);
855 for (i = 0; i < len; i++) {
856 st = gst_structure_copy (gst_caps_get_structure (profile->restriction, i));
858 gst_caps_append_structure (tmp, st);
861 out = gst_caps_intersect (tmp, fcaps);
862 gst_caps_unref (tmp);
868 * gst_encoding_profile_get_type_nick:
869 * @profile: a #GstEncodingProfile
873 * Returns: the human-readable name of the type of @profile.
876 gst_encoding_profile_get_type_nick (GstEncodingProfile * profile)
878 if (GST_IS_ENCODING_CONTAINER_PROFILE (profile))
880 if (GST_IS_ENCODING_VIDEO_PROFILE (profile))
882 if (GST_IS_ENCODING_AUDIO_PROFILE (profile))
888 * gst_encoding_profile_find:
889 * @targetname: (transfer none): The name of the target
890 * @profilename: (transfer none): The name of the profile
891 * @category: (transfer none) (allow-none): The target category. Can be %NULL
893 * Find the #GstEncodingProfile with the specified name and category.
895 * Returns: (transfer full): The matching #GstEncodingProfile or %NULL.
900 gst_encoding_profile_find (const gchar * targetname, const gchar * profilename,
901 const gchar * category)
903 GstEncodingProfile *res = NULL;
904 GstEncodingTarget *target;
906 g_return_val_if_fail (targetname != NULL, NULL);
907 g_return_val_if_fail (profilename != NULL, NULL);
909 /* FIXME : how do we handle profiles named the same in several
910 * categories but of which only one has the required profile ? */
911 target = gst_encoding_target_load (targetname, category, NULL);
913 res = gst_encoding_target_get_profile (target, profilename);
914 gst_encoding_target_unref (target);
920 static GstEncodingProfile *
921 combo_search (const gchar * pname)
923 GstEncodingProfile *res;
927 split = g_strsplit (pname, "/", 2);
928 if (g_strv_length (split) != 2)
931 res = gst_encoding_profile_find (split[0], split[1], NULL);
938 /* GValue transform function */
940 string_to_profile_transform (const GValue * src_value, GValue * dest_value)
942 const gchar *profilename;
943 GstEncodingProfile *profile;
945 profilename = g_value_get_string (src_value);
947 profile = combo_search (profilename);
950 gst_value_take_mini_object (dest_value, (GstMiniObject *) profile);
954 gst_encoding_profile_deserialize_valfunc (GValue * value, const gchar * s)
956 GstEncodingProfile *profile;
958 profile = combo_search (s);
961 gst_value_take_mini_object (value, (GstMiniObject *) profile);
969 * gst_encoding_profile_from_discoverer:
970 * @info: (transfer none): The #GstDiscovererInfo to read from
972 * Creates a #GstEncodingProfile matching the formats from the given
973 * #GstEncodingProfile. Streams other than audio or video (eg,
974 * subtitles), are currently ignored.
976 * Returns: (transfer full): The new #GstEncodingProfile or %NULL.
981 gst_encoding_profile_from_discoverer (GstDiscovererInfo * info)
983 GstEncodingContainerProfile *profile;
984 GstDiscovererStreamInfo *sinfo;
985 GList *streams, *stream;
986 GstCaps *caps = NULL;
988 if (!info || gst_discoverer_info_get_result (info) != GST_DISCOVERER_OK)
991 sinfo = gst_discoverer_info_get_stream_info (info);
995 caps = gst_discoverer_stream_info_get_caps (sinfo);
996 GST_LOG ("Container: %" GST_PTR_FORMAT "\n", caps);
998 gst_encoding_container_profile_new ("auto-generated",
999 "Automatically generated from GstDiscovererInfo", caps, NULL);
1000 gst_caps_unref (caps);
1002 GST_ERROR ("Failed to create container profile from caps %" GST_PTR_FORMAT,
1008 gst_discoverer_container_info_get_streams (GST_DISCOVERER_CONTAINER_INFO
1010 for (stream = streams; stream; stream = stream->next) {
1011 GstEncodingProfile *sprofile = NULL;
1012 sinfo = (GstDiscovererStreamInfo *) stream->data;
1013 caps = gst_discoverer_stream_info_get_caps (sinfo);
1014 GST_LOG ("Stream: %" GST_PTR_FORMAT "\n", caps);
1015 if (GST_IS_DISCOVERER_AUDIO_INFO (sinfo)) {
1017 (GstEncodingProfile *) gst_encoding_audio_profile_new (caps, NULL,
1019 } else if (GST_IS_DISCOVERER_VIDEO_INFO (sinfo)) {
1021 (GstEncodingProfile *) gst_encoding_video_profile_new (caps, NULL,
1024 /* subtitles or other ? ignore for now */
1027 gst_encoding_container_profile_add_profile (profile, sprofile);
1029 GST_ERROR ("Failed to create stream profile from caps %" GST_PTR_FORMAT,
1031 gst_caps_unref (caps);
1033 gst_discoverer_stream_info_list_free (streams);
1035 return (GstEncodingProfile *) profile;