[rygel-gst-0-10-media-engine] cleanup
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel-gst-0-10-media-engine] cleanup
- Date: Thu, 20 Dec 2012 16:01:18 +0000 (UTC)
commit 41237652376742e17ba9e8df808220580c96c226
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Dec 20 17:01:12 2012 +0100
cleanup
src/rygel-gst-utils.c | 360 ++++++++++++++-----------------------------------
1 files changed, 99 insertions(+), 261 deletions(-)
---
diff --git a/src/rygel-gst-utils.c b/src/rygel-gst-utils.c
index 3965b9f..234e279 100644
--- a/src/rygel-gst-utils.c
+++ b/src/rygel-gst-utils.c
@@ -21,216 +21,98 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#include <glib.h>
-#include <glib-object.h>
-#include <stdlib.h>
-#include <string.h>
#include <gst/gst.h>
#include <glib/gi18n-lib.h>
#include <gst/pbutils/pbutils.h>
#include <gobject/gvaluecollector.h>
#include "rygel-gst-data-source.h"
+#include "rygel-gst-utils.h"
static gboolean rygel_gst_utils_need_rtp_depayloader (GstCaps* caps);
-GstElement* rygel_gst_utils_create_element (const gchar* factoryname, const gchar* name, GError** error) {
- GstElement* result = NULL;
- const gchar* _tmp0_;
- const gchar* _tmp1_;
- GstElement* _tmp2_ = NULL;
+GstElement*
+rygel_gst_utils_create_element (const gchar* factoryname, const gchar* name, GError** error) {
GstElement* element;
- GstElement* _tmp3_;
- GError * _inner_error_ = NULL;
+
g_return_val_if_fail (factoryname != NULL, NULL);
- _tmp0_ = factoryname;
- _tmp1_ = name;
- _tmp2_ = gst_element_factory_make (_tmp0_, _tmp1_);
- if (_tmp2_ != NULL) {
- gst_object_ref_sink (_tmp2_);
- }
- element = _tmp2_;
- _tmp3_ = element;
- if (_tmp3_ == NULL) {
- const gchar* _tmp4_ = NULL;
- const gchar* _tmp5_;
- GError* _tmp6_;
- _tmp4_ = _ ("Required element %s missing");
- _tmp5_ = factoryname;
- _tmp6_ = g_error_new (RYGEL_GST_ERROR, RYGEL_GST_ERROR_MISSING_PLUGIN, _tmp4_, _tmp5_);
- _inner_error_ = _tmp6_;
- g_propagate_error (error, _inner_error_);
- _gst_object_unref0 (element);
- return NULL;
- }
- result = element;
- return result;
-}
+ element = gst_element_factory_make (factoryname, name);
+ if (element) {
+ gst_object_ref_sink (element);
+ } else {
+ g_set_error (RYGEL_GST_ERROR,
+ RYGEL_GST_ERROR_MISSING_PLUGIN,
+ _("Required element %s missing"),
+ factoryname);
+ }
-static inline void _dynamic_set_blocksize4 (GstElement* obj, glong value) {
- g_object_set (obj, "blocksize", value, NULL);
+ return element;
}
+GstElement*
+rygel_gst_utils_create_source_for_uri (const gchar* uri) {
+ GstElement* src;
-static inline void _dynamic_set_tcp_timeout5 (GstElement* obj, gint64 value) {
- g_object_set (obj, "tcp-timeout", value, NULL);
-}
+ g_return_val_if_fail (uri != NULL, NULL);
+ src = gst_element_make_from_uri (GST_URI_SRC, uri, NULL);
-GstElement* rygel_gst_utils_create_source_for_uri (const gchar* uri) {
- GstElement* result = NULL;
- const gchar* _tmp0_;
- GstElement* _tmp1_ = NULL;
- GstElement* src;
- GstElement* _tmp2_;
- g_return_val_if_fail (uri != NULL, NULL);
- _tmp0_ = uri;
- _tmp1_ = gst_element_make_from_uri (GST_URI_SRC, _tmp0_, NULL);
- if (_tmp1_ != NULL) {
- gst_object_ref_sink (_tmp1_);
- }
- src = _tmp1_;
- _tmp2_ = src;
- if (_tmp2_ != NULL) {
- GstElement* _tmp3_;
- gboolean _tmp4_ = FALSE;
- GstElement* _tmp6_;
- GObjectClass* _tmp7_ = NULL;
- GParamSpec* _tmp8_ = NULL;
- GstElement* _tmp10_;
- GObjectClass* _tmp11_ = NULL;
- GParamSpec* _tmp12_ = NULL;
- _tmp3_ = src;
- _tmp4_ = GST_OBJECT_IS_FLOATING ((GstObject*) _tmp3_);
- if (_tmp4_) {
- GstElement* _tmp5_;
- _tmp5_ = src;
- gst_object_ref_sink ((GstObject*) _tmp5_);
+ if (src) {
+ if (GST_OBJECT_IS_FLOATING (GST_OBJECT (src))) {
+ gst_object_ref_sink (src);
}
- _tmp6_ = src;
- _tmp7_ = G_OBJECT_GET_CLASS ((GObject*) _tmp6_);
- _tmp8_ = g_object_class_find_property (_tmp7_, "blocksize");
- if (_tmp8_ != NULL) {
- GstElement* _tmp9_;
- _tmp9_ = src;
- _dynamic_set_blocksize4 (_tmp9_, (glong) 65536);
+
+ if (g_object_class_find_property (G_OBJECT_GET_CLASS (src), "blocksize")) {
+ g_object_set (src, "blocksize", (glong) 65536, NULL);
}
- _tmp10_ = src;
- _tmp11_ = G_OBJECT_GET_CLASS ((GObject*) _tmp10_);
- _tmp12_ = g_object_class_find_property (_tmp11_, "tcp-timeout");
- if (_tmp12_ != NULL) {
- GstElement* _tmp13_;
- _tmp13_ = src;
- _dynamic_set_tcp_timeout5 (_tmp13_, (gint64) 60000000);
+
+ if (g_object_class_find_property (G_OBJECT_GET_CLASS (src), "tcp-timeout")) {
+ g_object_set (src, "tcp-timeout", (gint64) 60000000, NULL);
}
}
- result = src;
- return result;
-}
-
-static gpointer _gst_encoding_profile_ref0 (gpointer self) {
- return self ? gst_encoding_profile_ref (self) : NULL;
+ return src;
}
-
-void rygel_gst_utils_dump_encoding_profile (GstEncodingProfile* profile, gint indent) {
- gint _tmp0_;
- gchar* _tmp1_ = NULL;
+void
+rygel_gst_utils_dump_encoding_profile (GstEncodingProfile* profile, gint indent) {
gchar* indent_s;
- const gchar* _tmp2_;
- gchar* _tmp3_;
- gchar* _tmp4_;
- GstEncodingProfile* _tmp5_;
- const gchar* _tmp6_ = NULL;
- const gchar* _tmp7_;
- gchar* _tmp8_;
- gchar* _tmp9_;
- GstEncodingProfile* _tmp10_;
- GstCaps* _tmp11_ = NULL;
- gchar* _tmp12_ = NULL;
- gchar* _tmp13_;
- GstEncodingProfile* _tmp14_;
- GstCaps* _tmp15_ = NULL;
- GstEncodingProfile* _tmp23_;
+ const GstCaps* caps;
+ gchar* format_name;
+ const GstCaps* restriction;
+
g_return_if_fail (profile != NULL);
- _tmp0_ = indent;
- _tmp1_ = g_strnfill ((gsize) _tmp0_, ' ');
- indent_s = _tmp1_;
- _tmp2_ = indent_s;
- _tmp3_ = g_strconcat (_tmp2_, "%s:", NULL);
- _tmp4_ = _tmp3_;
- _tmp5_ = profile;
- _tmp6_ = gst_encoding_profile_get_name (_tmp5_);
- g_debug (_tmp4_, _tmp6_);
- _g_free0 (_tmp4_);
- _tmp7_ = indent_s;
- _tmp8_ = g_strconcat (_tmp7_, " Format: %s", NULL);
- _tmp9_ = _tmp8_;
- _tmp10_ = profile;
- _tmp11_ = gst_encoding_profile_get_format (_tmp10_);
- _tmp12_ = gst_caps_to_string (_tmp11_);
- _tmp13_ = _tmp12_;
- g_debug (_tmp9_, _tmp13_);
- _g_free0 (_tmp13_);
- _g_free0 (_tmp9_);
- _tmp14_ = profile;
- _tmp15_ = gst_encoding_profile_get_restriction (_tmp14_);
- if (_tmp15_ != NULL) {
- const gchar* _tmp16_;
- gchar* _tmp17_;
- gchar* _tmp18_;
- GstEncodingProfile* _tmp19_;
- GstCaps* _tmp20_ = NULL;
- gchar* _tmp21_ = NULL;
- gchar* _tmp22_;
- _tmp16_ = indent_s;
- _tmp17_ = g_strconcat (_tmp16_, " Restriction: %s", NULL);
- _tmp18_ = _tmp17_;
- _tmp19_ = profile;
- _tmp20_ = gst_encoding_profile_get_restriction (_tmp19_);
- _tmp21_ = gst_caps_to_string (_tmp20_);
- _tmp22_ = _tmp21_;
- g_debug (_tmp18_, _tmp22_);
- _g_free0 (_tmp22_);
- _g_free0 (_tmp18_);
+
+ indent_s = g_strnfill ((gsize) indent, ' ');
+ g_debug ("%s%s:", indent_s, gst_encoding_profile_get_name (profile));
+
+ caps = gst_encoding_profile_get_format (profile);
+ format_name = gst_caps_to_string (caps);
+ g_debug ("%s Format: %s", indent_s, format_name);
+ g_free (format_name);
+
+ restriction = gst_encoding_profile_get_restriction (profile);
+ if (restriction) {
+ gchar* restriction_name = gst_caps_to_string (restriction);
+ g_debug ("%s Restriction: %s", indent_s, restriction_name);
+ g_free (restriction_name);
}
- _tmp23_ = profile;
- if (GST_IS_ENCODING_CONTAINER_PROFILE (_tmp23_)) {
- GstEncodingProfile* _tmp24_;
- GstEncodingContainerProfile* _tmp25_;
- GstEncodingContainerProfile* container;
- GstEncodingContainerProfile* _tmp26_;
- GList* _tmp27_ = NULL;
- _tmp24_ = profile;
- _tmp25_ = _gst_encoding_profile_ref0 (GST_IS_ENCODING_CONTAINER_PROFILE (_tmp24_) ? ((GstEncodingContainerProfile*) _tmp24_) : NULL);
- container = _tmp25_;
- _tmp26_ = container;
- _tmp27_ = gst_encoding_container_profile_get_profiles (_tmp26_);
- {
- GList* subprofile_collection = NULL;
- GList* subprofile_it = NULL;
- subprofile_collection = _tmp27_;
- for (subprofile_it = subprofile_collection; subprofile_it != NULL; subprofile_it = subprofile_it->next) {
- GstEncodingProfile* _tmp28_;
- GstEncodingProfile* subprofile = NULL;
- _tmp28_ = _gst_encoding_profile_ref0 ((GstEncodingProfile*) subprofile_it->data);
- subprofile = _tmp28_;
- {
- GstEncodingProfile* _tmp29_;
- gint _tmp30_;
- _tmp29_ = subprofile;
- _tmp30_ = indent;
- rygel_gst_utils_dump_encoding_profile (_tmp29_, _tmp30_ + 4);
- _gst_encoding_profile_unref0 (subprofile);
- }
- }
+
+ if (GST_IS_ENCODING_CONTAINER_PROFILE (profile)) {
+ GstEncodingContainerProfile* container =
+ GST_ENCODING_CONTAINER_PROFILE (profile);
+
+ GList* subprofile_collection = gst_encoding_container_profile_get_profiles (container);
+ GList* subprofile_it;
+ for (subprofile_it = subprofile_collection; subprofile_it != NULL; subprofile_it = subprofile_it->next) {
+ GstEncodingProfile* subprofile = GST_ENCODING_PROFILE (subprofile_it->data);
+ rygel_gst_utils_dump_encoding_profile (subprofile, indent + 4);
+ gst_encoding_profile_unref (subprofile);
}
- _gst_encoding_profile_unref0 (container);
}
- _g_free0 (indent_s);
-}
+ g_free (indent_s);
+}
static void _gst_object_unref0_ (gpointer var) {
(var == NULL) ? NULL : (var = (gst_object_unref (var), NULL));
@@ -244,98 +126,54 @@ static void _g_list_free__gst_object_unref0_ (GList* self) {
GstElement* rygel_gst_utils_get_rtp_depayloader (GstCaps* caps) {
- GstElement* result = NULL;
- GstCaps* _tmp0_;
- gboolean _tmp1_ = FALSE;
- GList* _tmp2_ = NULL;
GList* features;
- GList* _tmp3_;
- GstCaps* _tmp4_;
- GList* _tmp5_ = NULL;
- GList* _tmp6_;
- gconstpointer _tmp7_;
- const gchar* _tmp8_ = NULL;
- g_return_val_if_fail (caps != NULL, NULL);
- _tmp0_ = caps;
- _tmp1_ = rygel_gst_utils_need_rtp_depayloader (_tmp0_);
- if (!_tmp1_) {
- result = NULL;
- return result;
+ GList* temp;
+ const gchar* feature_name;
+
+ if (!rygel_gst_utils_need_rtp_depayloader (caps)) {
+ return NULL;
}
- _tmp2_ = gst_element_factory_list_get_elements ((GstElementFactoryListType) GST_ELEMENT_FACTORY_TYPE_DEPAYLOADER, GST_RANK_NONE);
- features = _tmp2_;
- _tmp3_ = features;
- _tmp4_ = caps;
- _tmp5_ = gst_element_factory_list_filter (_tmp3_, _tmp4_, GST_PAD_SINK, FALSE);
- __g_list_free__gst_object_unref0_0 (features);
- features = _tmp5_;
- _tmp6_ = features;
- _tmp7_ = _tmp6_->data;
- _tmp8_ = gst_plugin_feature_get_name ((GstPluginFeature*) ((GstElementFactory*) _tmp7_));
- if (g_strcmp0 (_tmp8_, "rtpdepay") == 0) {
- GList* _tmp9_;
- GList* _tmp10_;
- _tmp9_ = features;
- _tmp10_ = _tmp9_->next;
- if (_tmp10_ != NULL) {
- GList* _tmp11_;
- GList* _tmp12_;
- gconstpointer _tmp13_;
- GstElement* _tmp14_ = NULL;
- _tmp11_ = features;
- _tmp12_ = _tmp11_->next;
- _tmp13_ = _tmp12_->data;
- _tmp14_ = gst_element_factory_create ((GstElementFactory*) _tmp13_, NULL);
- if (_tmp14_ != NULL) {
- gst_object_ref_sink (_tmp14_);
+
+ features = gst_element_factory_list_get_elements ((GstElementFactoryListType) GST_ELEMENT_FACTORY_TYPE_DEPAYLOADER, GST_RANK_NONE);
+ temp = features;
+ features = gst_element_factory_list_filter (features, caps, GST_PAD_SINK, FALSE);
+ g_list_free_full (features, gst_object_unref);
+
+ feature_name = gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (features->data));
+ if (g_strcmp0 (feature_name, "rtpdepay") == 0) {
+ if (features->next) {
+ GstElement* element = gst_element_factory_create (GST_ELEMENT_FACTORY (features->next), NULL);
+ if (element) {
+ gst_object_ref_sink (element);
}
- result = _tmp14_;
- __g_list_free__gst_object_unref0_0 (features);
- return result;
+
+ g_list_free_full (features, gst_object_unref);
+ return element;
}
- result = NULL;
- __g_list_free__gst_object_unref0_0 (features);
- return result;
+
+ return NULL;
} else {
- GList* _tmp15_;
- gconstpointer _tmp16_;
- GstElement* _tmp17_ = NULL;
- _tmp15_ = features;
- _tmp16_ = _tmp15_->data;
- _tmp17_ = gst_element_factory_create ((GstElementFactory*) _tmp16_, NULL);
- if (_tmp17_ != NULL) {
- gst_object_ref_sink (_tmp17_);
+ GstElement* element = gst_element_factory_create (GST_ELEMENT_FACTORY (features), NULL);
+ if (element) {
+ gst_object_ref_sink (element);
}
- result = _tmp17_;
- __g_list_free__gst_object_unref0_0 (features);
- return result;
- }
- __g_list_free__gst_object_unref0_0 (features);
-}
-
-static gpointer _gst_structure_copy0 (gpointer self) {
- return self ? gst_structure_copy (self) : NULL;
+ g_list_free_full (features, gst_object_unref);
+ return element;
+ }
}
+static gboolean
+rygel_gst_utils_need_rtp_depayloader (GstCaps* caps) {
+ const GstStructure* structure;
+ const gchar* name;
+ gboolean result;
-static gboolean rygel_gst_utils_need_rtp_depayloader (GstCaps* caps) {
- gboolean result = FALSE;
- GstCaps* _tmp0_;
- const GstStructure* _tmp1_ = NULL;
- GstStructure* _tmp2_;
- GstStructure* structure;
- const gchar* _tmp3_ = NULL;
g_return_val_if_fail (caps != NULL, FALSE);
- _tmp0_ = caps;
- _tmp1_ = gst_caps_get_structure (_tmp0_, (guint) 0);
- _tmp2_ = _gst_structure_copy0 (_tmp1_);
- structure = _tmp2_;
- _tmp3_ = gst_structure_get_name (structure);
- result = g_strcmp0 (_tmp3_, "application/x-rtp") == 0;
- _gst_structure_free0 (structure);
- return result;
-}
+ structure = gst_caps_get_structure (caps, (guint) 0);
+ name = gst_structure_get_name (structure);
+ return g_strcmp0 (name, "application/x-rtp") == 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]