encoding-profile: add a function to create a profile from a discoverer info

Only A/V streams are added at the moment, there does not seem to be
a similar way to add other streams (eg, subtitles).

https://bugzilla.gnome.org/show_bug.cgi?id=642878
This commit is contained in:
Vincent Penquerc'h 2011-02-18 11:48:37 +00:00 committed by Sebastian Dröge
parent c7282a5718
commit 93900d47ed
4 changed files with 76 additions and 0 deletions

View file

@ -2114,6 +2114,7 @@ GstEncodingProfile
gst_encoding_profile_unref
gst_encoding_profile_ref
gst_encoding_profile_find
gst_encoding_profile_from_discoverer
gst_encoding_profile_get_name
gst_encoding_profile_get_description
gst_encoding_profile_get_format

View file

@ -964,3 +964,73 @@ gst_encoding_profile_deserialize_valfunc (GValue * value, const gchar * s)
return FALSE;
}
/**
* gst_encoding_profile_from_discoverer:
* @info: (transfer none): The #GstDiscovererInfo to read from
*
* Creates a #GstEncodingProfile matching the formats from the given
* #GstEncodingProfile. Streams other than audio or video (eg,
* subtitles), are currently ignored.
*
* Returns: (transfer full): The new #GstEncodingProfile or %NULL.
*
* Since: 0.10.36
*/
GstEncodingProfile *
gst_encoding_profile_from_discoverer (GstDiscovererInfo * info)
{
GstEncodingContainerProfile *profile;
GstDiscovererStreamInfo *sinfo;
GList *streams, *stream;
GstCaps *caps = NULL;
if (!info || gst_discoverer_info_get_result (info) != GST_DISCOVERER_OK)
return NULL;
sinfo = gst_discoverer_info_get_stream_info (info);
if (!sinfo)
return NULL;
caps = gst_discoverer_stream_info_get_caps (sinfo);
GST_LOG ("Container: %" GST_PTR_FORMAT "\n", caps);
profile =
gst_encoding_container_profile_new ("auto-generated",
"Automatically generated from GstDiscovererInfo", caps, NULL);
gst_caps_unref (caps);
if (!profile) {
GST_ERROR ("Failed to create container profile from caps %" GST_PTR_FORMAT,
caps);
return NULL;
}
streams =
gst_discoverer_container_info_get_streams (GST_DISCOVERER_CONTAINER_INFO
(sinfo));
for (stream = streams; stream; stream = stream->next) {
GstEncodingProfile *sprofile = NULL;
sinfo = (GstDiscovererStreamInfo *) stream->data;
caps = gst_discoverer_stream_info_get_caps (sinfo);
GST_LOG ("Stream: %" GST_PTR_FORMAT "\n", caps);
if (GST_IS_DISCOVERER_AUDIO_INFO (sinfo)) {
sprofile =
(GstEncodingProfile *) gst_encoding_audio_profile_new (caps, NULL,
NULL, 0);
} else if (GST_IS_DISCOVERER_VIDEO_INFO (sinfo)) {
sprofile =
(GstEncodingProfile *) gst_encoding_video_profile_new (caps, NULL,
NULL, 0);
} else {
/* subtitles or other ? ignore for now */
}
if (sprofile)
gst_encoding_container_profile_add_profile (profile, sprofile);
else
GST_ERROR ("Failed to create stream profile from caps %" GST_PTR_FORMAT,
caps);
gst_caps_unref (caps);
}
gst_discoverer_stream_info_list_free (streams);
return (GstEncodingProfile *) profile;
}

View file

@ -26,6 +26,7 @@
G_BEGIN_DECLS
#include <gst/pbutils/pbutils-enumtypes.h>
#include <gst/pbutils/gstdiscoverer.h>
/**
* GstEncodingProfile:
@ -182,6 +183,9 @@ void gst_encoding_video_profile_set_pass (GstEncodingVideoProfi
guint pass);
void gst_encoding_video_profile_set_variableframerate (GstEncodingVideoProfile *prof,
gboolean variableframerate);
GstEncodingProfile * gst_encoding_profile_from_discoverer (GstDiscovererInfo *info);
G_END_DECLS
#endif /* __GST_PROFILE_H__ */

View file

@ -73,6 +73,7 @@ EXPORTS
gst_encoding_list_all_targets
gst_encoding_list_available_categories
gst_encoding_profile_find
gst_encoding_profile_from_discoverer
gst_encoding_profile_get_description
gst_encoding_profile_get_format
gst_encoding_profile_get_input_caps