diff options
-rw-r--r-- | docs/libs/gst-plugins-base-libs-sections.txt | 1 | ||||
-rw-r--r-- | gst-libs/gst/pbutils/encoding-profile.c | 70 | ||||
-rw-r--r-- | gst-libs/gst/pbutils/encoding-profile.h | 4 | ||||
-rw-r--r-- | win32/common/libgstpbutils.def | 1 |
4 files changed, 76 insertions, 0 deletions
diff --git a/docs/libs/gst-plugins-base-libs-sections.txt b/docs/libs/gst-plugins-base-libs-sections.txt index 4e998e484..fe52a0cbd 100644 --- a/docs/libs/gst-plugins-base-libs-sections.txt +++ b/docs/libs/gst-plugins-base-libs-sections.txt @@ -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 diff --git a/gst-libs/gst/pbutils/encoding-profile.c b/gst-libs/gst/pbutils/encoding-profile.c index eaa7507cb..65af1b13f 100644 --- a/gst-libs/gst/pbutils/encoding-profile.c +++ b/gst-libs/gst/pbutils/encoding-profile.c @@ -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; +} diff --git a/gst-libs/gst/pbutils/encoding-profile.h b/gst-libs/gst/pbutils/encoding-profile.h index 86beccaf8..826db5294 100644 --- a/gst-libs/gst/pbutils/encoding-profile.h +++ b/gst-libs/gst/pbutils/encoding-profile.h @@ -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__ */ diff --git a/win32/common/libgstpbutils.def b/win32/common/libgstpbutils.def index 3fa74d44b..0e2fcf952 100644 --- a/win32/common/libgstpbutils.def +++ b/win32/common/libgstpbutils.def @@ -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 |