Revision 440227f8

b/src/main.cpp
49 49
  // VideoTestSource::ptr myseg = std::tr1::dynamic_pointer_cast<VideoTestSource> (myvideotest); 
50 50
  // rt->add_segment (myseg);
51 51

  
52
  
53 52

  
54 53
  rt->run();
55 54
  
b/switcher/Makefile.am
16 16
    base-source.cpp \
17 17
    connector.cpp \
18 18
    controller.cpp \
19
    property.cpp \
19 20
    runtime.cpp \
20 21
    segment.cpp \
21 22
    video-sink.cpp \
......
40 41
    connector.h \
41 42
    controller.h \
42 43
    creator.h \
44
    property.h \
43 45
    runtime.h \
44 46
    segment.h \
45 47
    video-sink.h \
b/switcher/property.cpp
1
/*
2
 * Copyright (C) 2012 Nicolas Bouillot (http://www.nicolasbouillot.net)
3
 *
4
 * This file is part of switcher.
5
 *
6
 * switcher is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * switcher is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with switcher.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19

  
20
/**
21
 * The Param class
22
 */
23

  
24
#include "switcher/property.h"
25
namespace switcher
26
{
27

  
28

  
29
  //should not be used because it is writing a name property
30
  Property::Property (GObject *object, GParamSpec *pspec) :
31
    property_ (pspec),
32
    object_ (object)
33
  {
34
  }
35
  
36

  
37
  //from gst-inspect
38
  void 
39
  Property::print()
40
  {
41
    
42
    guint i;
43
    gboolean readable;
44
    gboolean first_flag;
45
    
46

  
47
    GValue value = { 0, };
48
        
49
    GObject * element = (GObject *) g_param_spec_get_qdata (property_,
50
							    g_quark_from_static_string("origin_object"));
51
	
52
    readable = FALSE;
53
	
54
    g_value_init (&value, property_->value_type);
55
	
56
    g_print ("  %-20s: %s\n", g_param_spec_get_name (property_),
57
	     g_param_spec_get_blurb (property_));
58
	
59
    // first_flag = TRUE;
60
    // g_print ("%-23.23s flags: ", "");
61
    // if (property_->flags & G_PARAM_READABLE) {
62
    // 	g_object_get_property (G_OBJECT (element), property_->name, &value);
63
    // 	readable = TRUE;
64
    // 	g_print ("%s%s", (first_flag) ? "" : ", ", ("readable"));
65
    // 	first_flag = FALSE;
66
    // } else {
67
    // 	/* if we can't read the property value, assume it's set to the default
68
    // 	 * (which might not be entirely true for sub-classes, but that's an
69
    // 	 * unlikely corner-case anyway) */
70
    // 	g_param_value_set_default (property_, &value);
71
    // }
72
    // if (property_->flags & G_PARAM_WRITABLE) {
73
    // 	g_print ("%s%s", (first_flag) ? "" : ", ", ("writable"));
74
    // 	first_flag = FALSE;
75
    // }
76
    // if (property_->flags & GST_PARAM_CONTROLLABLE) {
77
    // 	g_print (", %s", ("controllable"));
78
    // 	first_flag = FALSE;
79
    // }
80
    // if (property_->flags & GST_PARAM_MUTABLE_PLAYING) {
81
    // 	g_print (", %s", ("changeable in NULL, READY, PAUSED or PLAYING state"));
82
    // } else if (property_->flags & GST_PARAM_MUTABLE_PAUSED) {
83
    // 	g_print (", %s", ("changeable only in NULL, READY or PAUSED state"));
84
    // } else if (property_->flags & GST_PARAM_MUTABLE_READY) {
85
    // 	g_print (", %s", ("changeable only in NULL or READY state"));
86
    // }
87
    // if (property_->flags & ~KNOWN_PARAM_FLAGS) {
88
    // 	g_print ("%s0x%0x", (first_flag) ? "" : ", ",
89
    // 		 property_->flags & ~KNOWN_PARAM_FLAGS);
90
    // }
91
    // g_print ("\n");
92

  
93
    switch (G_VALUE_TYPE (&value)) {
94
    case G_TYPE_STRING:
95
      {
96
	const char *string_val = g_value_get_string (&value);
97

  
98
	g_print ("%-23.23s String. ", "");
99

  
100
	if (string_val == NULL)
101
	  g_print ("Default: null");
102
	else
103
	  g_print ("Default: \"%s\"", string_val);
104
	break;
105
      }
106
    case G_TYPE_BOOLEAN:
107
      {
108
	gboolean bool_val = g_value_get_boolean (&value);
109

  
110
	g_print ("%-23.23s Boolean. ", "");
111

  
112
	g_print ("Default: %s", bool_val ? "true" : "false");
113
	break;
114
      }
115
    case G_TYPE_ULONG:
116
      {
117
	GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (property_);
118

  
119
	g_print ("%-23.23s Unsigned Long. ", "");
120
	g_print ("Range: %lu - %lu Default: %lu ",
121
		 pulong->minimum, pulong->maximum, g_value_get_ulong (&value));
122
	break;
123
      }
124
    case G_TYPE_LONG:
125
      {
126
	GParamSpecLong *plong = G_PARAM_SPEC_LONG (property_);
127

  
128
	g_print ("%-23.23s Long. ", "");
129
	g_print ("Range: %ld - %ld Default: %ld ",
130
		 plong->minimum, plong->maximum, g_value_get_long (&value));
131
	break;
132
      }
133
    case G_TYPE_UINT:
134
      {
135
	GParamSpecUInt *puint = G_PARAM_SPEC_UINT (property_);
136

  
137
	g_print ("%-23.23s Unsigned Integer. ", "");
138
	g_print ("Range: %u - %u Default: %u ",
139
		 puint->minimum, puint->maximum, g_value_get_uint (&value));
140
	break;
141
      }
142
    case G_TYPE_INT:
143
      {
144
	GParamSpecInt *pint = G_PARAM_SPEC_INT (property_);
145

  
146
	g_print ("%-23.23s Integer. ", "");
147
	g_print ("Range: %d - %d Default: %d ",
148
		 pint->minimum, pint->maximum, g_value_get_int (&value));
149
	break;
150
      }
151
    case G_TYPE_UINT64:
152
      {
153
	GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (property_);
154

  
155
	g_print ("%-23.23s Unsigned Integer64. ", "");
156
	g_print ("Range: %" G_GUINT64_FORMAT " - %" G_GUINT64_FORMAT
157
		 " Default: %" G_GUINT64_FORMAT " ",
158
		 puint64->minimum, puint64->maximum, g_value_get_uint64 (&value));
159
	break;
160
      }
161
    case G_TYPE_INT64:
162
      {
163
	GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (property_);
164

  
165
	g_print ("%-23.23s Integer64. ", "");
166
	g_print ("Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT
167
		 " Default: %" G_GINT64_FORMAT " ",
168
		 pint64->minimum, pint64->maximum, g_value_get_int64 (&value));
169
	break;
170
      }
171
    case G_TYPE_FLOAT:
172
      {
173
	GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (property_);
174

  
175
	g_print ("%-23.23s Float. ", "");
176
	g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
177
		 pfloat->minimum, pfloat->maximum, g_value_get_float (&value));
178
	break;
179
      }
180
    case G_TYPE_DOUBLE:
181
      {
182
	GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (property_);
183

  
184
	g_print ("%-23.23s Double. ", "");
185
	g_print ("Range: %15.7g - %15.7g Default: %15.7g ",
186
		 pdouble->minimum, pdouble->maximum, g_value_get_double (&value));
187
	break;
188
      }
189
    default:
190
      if (property_->value_type == GST_TYPE_CAPS) {
191
	const GstCaps *caps = gst_value_get_caps (&value);
192

  
193
	if (!caps)
194
	  g_print ("%-23.23s Caps (NULL)", "");
195
	else {
196
	  g_print ("%-23.23s Caps (%s)", "", gst_caps_to_string (caps));
197
	}
198
      } else if (G_IS_PARAM_SPEC_ENUM (property_)) {
199
	GEnumValue *values;
200
	guint j = 0;
201
	gint enum_value;
202
	const gchar *value_nick = "";
203

  
204
	values = G_ENUM_CLASS (g_type_class_ref (property_->value_type))->values;
205
	enum_value = g_value_get_enum (&value);
206

  
207
	while (values[j].value_name) {
208
	  if (values[j].value == enum_value)
209
	    value_nick = values[j].value_nick;
210
	  j++;
211
	}
212

  
213
	g_print ("%-23.23s Enum \"%s\" Default: %d, \"%s\"", "",
214
		 g_type_name (G_VALUE_TYPE (&value)), enum_value, value_nick);
215

  
216
	j = 0;
217
	while (values[j].value_name) {
218
	  g_print ("\n");
219
	  // if (_name)
220
	  //   g_print ("%s", _name);
221
	  g_print ("%-23.23s    (%d): %-16s - %s", "",
222
		   values[j].value, values[j].value_nick, values[j].value_name);
223
	  j++;
224
	}
225
	/* g_type_class_unref (ec); */
226
      } else if (G_IS_PARAM_SPEC_FLAGS (property_)) {
227
	// GParamSpecFlags *pflags = G_PARAM_SPEC_FLAGS (property_);
228
	// GFlagsValue *vals;
229
	// gchar *cur;
230

  
231
	// vals = pflags->flags_class->values;
232

  
233
	// cur = flags_to_string (vals, g_value_get_flags (&value));
234

  
235
	// g_print ("%-23.23s Flags \"%s\" Default: 0x%08x, \"%s\"", "",
236
	// 	   g_type_name (G_VALUE_TYPE (&value)),
237
	// 	   g_value_get_flags (&value), cur);
238

  
239
	// while (vals[0].value_name) {
240
	//   g_print ("\n");
241
	//   if (_name)
242
	//     g_print ("%s", _name);
243
	//   g_print ("%-23.23s    (0x%08x): %-16s - %s", "",
244
	// 	     vals[0].value, vals[0].value_nick, vals[0].value_name);
245
	//   ++vals;
246
	// }
247

  
248
	// g_free (cur);
249
      } else if (G_IS_PARAM_SPEC_OBJECT (property_)) {
250
	g_print ("%-23.23s Object of type \"%s\"", "",
251
		 g_type_name (property_->value_type));
252
      } else if (G_IS_PARAM_SPEC_BOXED (property_)) {
253
	g_print ("%-23.23s Boxed pointer of type \"%s\"", "",
254
		 g_type_name (property_->value_type));
255
      } else if (G_IS_PARAM_SPEC_POINTER (property_)) {
256
	if (property_->value_type != G_TYPE_POINTER) {
257
	  g_print ("%-23.23s Pointer of type \"%s\".", "",
258
		   g_type_name (property_->value_type));
259
	} else {
260
	  g_print ("%-23.23s Pointer.", "");
261
	}
262
      } else if (property_->value_type == G_TYPE_VALUE_ARRAY) {
263
	GParamSpecValueArray *pvarray = G_PARAM_SPEC_VALUE_ARRAY (property_);
264

  
265
	if (pvarray->element_spec) {
266
	  g_print ("%-23.23s Array of GValues of type \"%s\"", "",
267
		   g_type_name (pvarray->element_spec->value_type));
268
	} else {
269
	  g_print ("%-23.23s Array of GValues", "");
270
	}
271
      } else if (GST_IS_PARAM_SPEC_FRACTION (property_)) {
272
	GstParamSpecFraction *pfraction = GST_PARAM_SPEC_FRACTION (property_);
273

  
274
	g_print ("%-23.23s Fraction. ", "");
275

  
276
	g_print ("Range: %d/%d - %d/%d Default: %d/%d ",
277
		 pfraction->min_num, pfraction->min_den,
278
		 pfraction->max_num, pfraction->max_den,
279
		 gst_value_get_fraction_numerator (&value),
280
		 gst_value_get_fraction_denominator (&value));
281
      } else if (GST_IS_PARAM_SPEC_MINI_OBJECT (property_)) {
282
	g_print ("%-23.23s MiniObject of type \"%s\"", "",
283
		 g_type_name (property_->value_type));
284
      } else {
285
	g_print ("%-23.23s Unknown type %ld \"%s\"", "", property_->value_type,
286
		 g_type_name (property_->value_type));
287
      }
288
      break;
289
    }
290
    if (!readable)
291
      g_print (" Write only\n");
292
    else
293
      g_print ("\n");
294

  
295
    g_value_reset (&value);
296
  }
297
 
298
 
299
}
b/switcher/property.h
1
/*
2
 * Copyright (C) 2012 Nicolas Bouillot (http://www.nicolasbouillot.net)
3
 *
4
 * This file is part of switcher.
5
 *
6
 * switcher is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * switcher is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with switcher.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19

  
20

  
21
#ifndef __SWITCHER_PROPERTY_H__
22
#define __SWITCHER_PROPERTY_H__
23

  
24
#include <gst/gst.h>
25
#include <tr1/memory>
26
#include <map>
27

  
28
namespace switcher
29
{
30

  
31
  
32
  class Property
33
  {
34
  public:
35
    typedef std::tr1::shared_ptr<Property> ptr;
36

  
37
    Property (GObject *object, GParamSpec *pspec);
38
    ~Property ();
39
    void print();
40

  
41
  private:
42
    GParamSpec *property_;
43
    GObject *object_;
44
  };
45

  
46
}  // end of namespace
47

  
48
#endif // ifndef
b/switcher/video-test-source.cpp
17 17
 * along with switcher.  If not, see <http://www.gnu.org/licenses/>.
18 18
 */
19 19

  
20
#include "switcher/property.h"
20 21
#include "switcher/video-test-source.h"
22
#include <gst/gst.h>
21 23

  
22 24
namespace switcher
23 25
{
......
26 28
  {
27 29
    g_print ("video test source constructor \n");
28 30
    videotestsrc_ = gst_element_factory_make ("videotestsrc",NULL);
31

  
32
    guint numproperty;
33
    GParamSpec **property = g_object_class_list_properties (G_OBJECT_GET_CLASS(videotestsrc_), &numproperty);
34
    for (guint i = 0; i < numproperty; i++) {
35
      Property *prop = new Property (G_OBJECT (videotestsrc_),property[i]);
36
      prop->print();
37
    }
38

  
39
    g_print ("-------------------------------\n");
40

  
41
    GParamSpec *pspec = g_object_class_find_property (G_OBJECT_GET_CLASS(videotestsrc_), "pattern");
42
    if (pspec != NULL)
43
      {
44
	Property *prop = new Property (G_OBJECT (videotestsrc_), pspec);
45
	prop->print();
46
      }
47

  
29 48
    name_ = gst_element_get_name (videotestsrc_);
30 49
    set_raw_video_element (videotestsrc_);
31 50
  }

Also available in: Unified diff