QtGStreamer  0.10.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
propertyprobe.cpp
1 /*
2  Copyright (C) 2010 George Kiagiadakis <kiagiadakis.george@gmail.com>
3 
4  This library is free software; you can redistribute it and/or modify
5  it under the terms of the GNU Lesser General Public License as published
6  by the Free Software Foundation; either version 2.1 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17 #include "propertyprobe.h"
18 #include <gst/interfaces/propertyprobe.h>
19 
20 namespace QGst {
21 
22 QList<QGlib::ParamSpecPtr> PropertyProbe::properties() const
23 {
24  QList<QGlib::ParamSpecPtr> result;
25  const GList *list = gst_property_probe_get_properties(object<GstPropertyProbe>());
26  while(list) {
27  result.append(QGlib::ParamSpecPtr::wrap(G_PARAM_SPEC(list->data)));
28  list = list->next;
29  }
30  return result;
31 }
32 
33 bool PropertyProbe::propertySupportsProbe(const QGlib::ParamSpecPtr & property) const
34 {
35  const GList *list = gst_property_probe_get_properties(object<GstPropertyProbe>());
36  while(list) {
37  GParamSpec *param = G_PARAM_SPEC(list->data);
38  if (param == property) {
39  return true;
40  }
41  list = list->next;
42  }
43  return false;
44 }
45 
46 bool PropertyProbe::propertySupportsProbe(const char *property) const
47 {
48  const GParamSpec *param = gst_property_probe_get_property(object<GstPropertyProbe>(), property);
49  return param != NULL;
50 }
51 
52 bool PropertyProbe::needsProbe(const QGlib::ParamSpecPtr & property) const
53 {
54  return gst_property_probe_needs_probe(object<GstPropertyProbe>(), property);
55 }
56 
57 bool PropertyProbe::needsProbe(const char *property) const
58 {
59  return gst_property_probe_needs_probe_name(object<GstPropertyProbe>(), property);
60 }
61 
62 void PropertyProbe::probe(const QGlib::ParamSpecPtr & property)
63 {
64  gst_property_probe_probe_property(object<GstPropertyProbe>(), property);
65 }
66 
67 void PropertyProbe::probe(const char *property)
68 {
69  gst_property_probe_probe_property_name(object<GstPropertyProbe>(), property);
70 }
71 
72 static QList<QGlib::Value> valueArrayToList(GValueArray *array)
73 {
74  QList<QGlib::Value> result;
75  if (array) {
76  for(uint i = 0; i < array->n_values; ++i) {
77  const GValue *v = g_value_array_get_nth(array, i);
78  result.append(QGlib::Value(v));
79  }
80  g_value_array_free(array);
81  }
82  return result;
83 }
84 
85 QList<QGlib::Value> PropertyProbe::values(const QGlib::ParamSpecPtr & property) const
86 {
87  GValueArray *array = gst_property_probe_get_values(object<GstPropertyProbe>(), property);
88  return valueArrayToList(array);
89 }
90 
91 QList<QGlib::Value> PropertyProbe::values(const char *property) const
92 {
93  GValueArray *array = gst_property_probe_get_values_name(object<GstPropertyProbe>(), property);
94  return valueArrayToList(array);
95 }
96 
97 QList<QGlib::Value> PropertyProbe::probeAndGetValues(const QGlib::ParamSpecPtr & property)
98 {
99  GValueArray *array = gst_property_probe_probe_and_get_values(object<GstPropertyProbe>(), property);
100  return valueArrayToList(array);
101 }
102 
103 QList<QGlib::Value> PropertyProbe::probeAndGetValues(const char *property)
104 {
105  GValueArray *array = gst_property_probe_probe_and_get_values_name(object<GstPropertyProbe>(), property);
106  return valueArrayToList(array);
107 }
108 
109 }