29 #include <string.h> |
29 #include <string.h> |
30 |
30 |
31 /** |
31 /** |
32 * SECTION:gsttuner |
32 * SECTION:gsttuner |
33 * @short_description: Interface for elements providing tuner operations |
33 * @short_description: Interface for elements providing tuner operations |
|
34 * |
|
35 * <refsect2> |
|
36 * <para> |
|
37 * The GstTuner interface is provided by elements that have the ability to |
|
38 * tune into multiple input signals, for example TV or radio capture cards. |
|
39 * </para><para> |
|
40 * The interpretation of 'tuning into' an input stream depends on the element |
|
41 * implementing the interface. For v4lsrc, it might imply selection of an |
|
42 * input source and/or frequency to be configured on a TV card. Another |
|
43 * GstTuner implementation might be to allow selection of an active input pad |
|
44 * from multiple input pads. |
|
45 * </para><para> |
|
46 * That said, the GstTuner interface functions are biased toward the |
|
47 * TV capture scenario. |
|
48 * </para><para> |
|
49 * The general parameters provided are for configuration are: |
|
50 * <itemizedlist> |
|
51 * <listitem>Selection of a current #GstTunerChannel. The current channel |
|
52 * represents the input source (e.g. Composite, S-Video etc for TV capture). |
|
53 * </listitem> |
|
54 * <listitem>The #GstTunerNorm for the channel. The norm chooses the |
|
55 * interpretation of the incoming signal for the current channel. For example, |
|
56 * PAL or NTSC, or more specific variants there-of. |
|
57 * </listitem> |
|
58 * <listitem>Channel frequency. If the current channel has the ability to tune |
|
59 * between multiple frequencies (if it has the GST_TUNER_CHANNEL_FREQUENCY flag) |
|
60 * then the frequency can be changed/ |
|
61 #ifdef __SYMBIAN32__ |
|
62 EXPORT_C |
|
63 #endif |
|
64 retrieved via the |
|
65 * gst_tuner_set_frequency() and gst_tuner_get_frequency() methods. |
|
66 * </listitem> |
|
67 * </itemizedlist> |
|
68 * </para> |
|
69 * <para> |
|
70 * Where applicable, the signal strength can be retrieved and/or monitored |
|
71 * via a signal. |
|
72 * </para> |
|
73 * </refsect2> |
34 */ |
74 */ |
35 |
75 |
36 enum |
76 enum |
37 { |
77 { |
38 NORM_CHANGED, |
78 NORM_CHANGED, |
81 gst_tuner_class_init (GstTunerClass * klass) |
121 gst_tuner_class_init (GstTunerClass * klass) |
82 { |
122 { |
83 static gboolean initialized = FALSE; |
123 static gboolean initialized = FALSE; |
84 |
124 |
85 if (!initialized) { |
125 if (!initialized) { |
|
126 /** |
|
127 * GstTuner::norm-changed: |
|
128 * @tuner: The element providing the GstTuner interface |
|
129 * @norm: The new configured norm. |
|
130 * |
|
131 * Reports that the current #GstTunerNorm has changed. |
|
132 */ |
86 gst_tuner_signals[NORM_CHANGED] = |
133 gst_tuner_signals[NORM_CHANGED] = |
87 g_signal_new ("norm-changed", |
134 g_signal_new ("norm-changed", |
88 GST_TYPE_TUNER, G_SIGNAL_RUN_LAST, |
135 GST_TYPE_TUNER, G_SIGNAL_RUN_LAST, |
89 G_STRUCT_OFFSET (GstTunerClass, norm_changed), |
136 G_STRUCT_OFFSET (GstTunerClass, norm_changed), |
90 NULL, NULL, |
137 NULL, NULL, |
91 g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_TUNER_NORM); |
138 g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_TUNER_NORM); |
|
139 /** |
|
140 * GstTuner::channel-changed: |
|
141 * @tuner: The element providing the GstTuner interface |
|
142 * @channel: The new configured channel. |
|
143 * |
|
144 * Reports that the current #GstTunerChannel has changed. |
|
145 */ |
92 gst_tuner_signals[CHANNEL_CHANGED] = |
146 gst_tuner_signals[CHANNEL_CHANGED] = |
93 g_signal_new ("channel-changed", |
147 g_signal_new ("channel-changed", |
94 GST_TYPE_TUNER, G_SIGNAL_RUN_LAST, |
148 GST_TYPE_TUNER, G_SIGNAL_RUN_LAST, |
95 G_STRUCT_OFFSET (GstTunerClass, channel_changed), |
149 G_STRUCT_OFFSET (GstTunerClass, channel_changed), |
96 NULL, NULL, |
150 NULL, NULL, |
97 g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, |
151 g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, |
98 GST_TYPE_TUNER_CHANNEL); |
152 GST_TYPE_TUNER_CHANNEL); |
|
153 /** |
|
154 * GstTuner::frequency-changed: |
|
155 * @tuner: The element providing the GstTuner interface |
|
156 * @frequency: The new frequency (an unsigned long) |
|
157 * |
|
158 * Reports that the current frequency has changed. |
|
159 */ |
99 gst_tuner_signals[FREQUENCY_CHANGED] = |
160 gst_tuner_signals[FREQUENCY_CHANGED] = |
100 g_signal_new ("frequency-changed", |
161 g_signal_new ("frequency-changed", |
101 GST_TYPE_TUNER, G_SIGNAL_RUN_LAST, |
162 GST_TYPE_TUNER, G_SIGNAL_RUN_LAST, |
102 G_STRUCT_OFFSET (GstTunerClass, frequency_changed), |
163 G_STRUCT_OFFSET (GstTunerClass, frequency_changed), |
103 NULL, NULL, |
164 NULL, NULL, |
104 gst_interfaces_marshal_VOID__OBJECT_ULONG, G_TYPE_NONE, 2, |
165 gst_interfaces_marshal_VOID__OBJECT_ULONG, G_TYPE_NONE, 2, |
105 GST_TYPE_TUNER_CHANNEL, G_TYPE_ULONG); |
166 GST_TYPE_TUNER_CHANNEL, G_TYPE_ULONG); |
|
167 /** |
|
168 * GstTuner::signal-changed: |
|
169 * @tuner: The element providing the GstTuner interface |
|
170 * @channel: The current #GstTunerChannel |
|
171 * @signal: The new signal strength (an integer) |
|
172 * |
|
173 * Reports that the signal strength has changed. |
|
174 * |
|
175 * See Also: gst_tuner_signal_strength() |
|
176 */ |
106 gst_tuner_signals[SIGNAL_CHANGED] = |
177 gst_tuner_signals[SIGNAL_CHANGED] = |
107 g_signal_new ("signal-changed", |
178 g_signal_new ("signal-changed", |
108 GST_TYPE_TUNER, G_SIGNAL_RUN_LAST, |
179 GST_TYPE_TUNER, G_SIGNAL_RUN_LAST, |
109 G_STRUCT_OFFSET (GstTunerClass, signal_changed), |
180 G_STRUCT_OFFSET (GstTunerClass, signal_changed), |
110 NULL, NULL, |
181 NULL, NULL, |
294 return NULL; |
366 return NULL; |
295 } |
367 } |
296 |
368 |
297 /** |
369 /** |
298 * gst_tuner_set_frequency: |
370 * gst_tuner_set_frequency: |
299 * @tuner: the #Gsttuner (a #GstElement) that owns the given channel. |
371 * @tuner: The #Gsttuner (a #GstElement) that owns the given channel. |
300 * @channel: the #GstTunerChannel to set the frequency on. |
372 * @channel: The #GstTunerChannel to set the frequency on. |
301 * @frequency: the frequency to tune in to. |
373 * @frequency: The frequency to tune in to. |
302 * |
374 * |
303 * Sets a tuning frequency on the given tuner/channel. Note that this |
375 * Sets a tuning frequency on the given tuner/channel. Note that this |
304 * requires the given channel to be a "tuning" channel, which can be |
376 * requires the given channel to be a "tuning" channel, which can be |
305 * checked using GST_TUNER_CHANNEL_HAS_FLAG (), with the proper flag |
377 * checked using GST_TUNER_CHANNEL_HAS_FLAG (), with the proper flag |
306 * being GST_TUNER_CHANNEL_FREQUENCY. |
378 * being GST_TUNER_CHANNEL_FREQUENCY. |
307 */ |
379 * |
308 #ifdef __SYMBIAN32__ |
380 * The frequency is in Hz, with minimum steps indicated by the |
309 EXPORT_C |
381 * frequency_multiplicator provided in the #GstTunerChannel. The |
310 #endif |
382 * valid range is provided in the min_frequency and max_frequency properties |
311 |
383 * of the #GstTunerChannel. |
|
384 */ |
|
385 #ifdef __SYMBIAN32__ |
|
386 EXPORT_C |
|
387 #endif |
312 |
388 |
313 void |
389 void |
314 gst_tuner_set_frequency (GstTuner * tuner, |
390 gst_tuner_set_frequency (GstTuner * tuner, |
315 GstTunerChannel * channel, gulong frequency) |
391 GstTunerChannel * channel, gulong frequency) |
316 { |
392 { |
360 |
437 |
361 return 0; |
438 return 0; |
362 } |
439 } |
363 |
440 |
364 /** |
441 /** |
365 * gst_tuner_get_signal_strength: |
442 * gst_tuner_signal_strength: |
366 * @tuner: the #GstTuner (a #GstElement) that owns the given channel. |
443 * @tuner: the #GstTuner (a #GstElement) that owns the given channel. |
367 * @channel: the #GstTunerChannel to get the signal strength from. |
444 * @channel: the #GstTunerChannel to get the signal strength from. |
368 * |
445 * |
369 * get the strength of the signal on this channel. Note that this |
446 * Get the strength of the signal on this channel. Note that this |
370 * requires the current channel to be a "tuning" channel, e.g. a |
447 * requires the current channel to be a "tuning" channel, i.e. a |
371 * channel on which frequency can be set. This can be checked using |
448 * channel on which frequency can be set. This can be checked using |
372 * GST_TUNER_CHANNEL_HAS_FLAG (), and the appropriate flag to check |
449 * GST_TUNER_CHANNEL_HAS_FLAG (), and the appropriate flag to check |
373 * for is GST_TUNER_CHANNEL_FREQUENCY. |
450 * for is GST_TUNER_CHANNEL_FREQUENCY. |
374 * |
451 * |
375 * Returns: signal strength, or 0 on error. |
452 * The valid range of the signal strength is indicated in the |
376 */ |
453 * min_signal and max_signal properties of the #GstTunerChannel. |
377 #ifdef __SYMBIAN32__ |
454 * |
378 EXPORT_C |
455 * Returns: Signal strength, or 0 on error. |
379 #endif |
456 */ |
380 |
457 #ifdef __SYMBIAN32__ |
|
458 EXPORT_C |
|
459 #endif |
381 |
460 |
382 gint |
461 gint |
383 gst_tuner_signal_strength (GstTuner * tuner, GstTunerChannel * channel) |
462 gst_tuner_signal_strength (GstTuner * tuner, GstTunerChannel * channel) |
384 { |
463 { |
385 GstTunerClass *klass; |
464 GstTunerClass *klass; |
436 return GST_TUNER_CHANNEL (walk->data); |
535 return GST_TUNER_CHANNEL (walk->data); |
437 walk = g_list_next (walk); |
536 walk = g_list_next (walk); |
438 } |
537 } |
439 return NULL; |
538 return NULL; |
440 } |
539 } |
441 #ifdef __SYMBIAN32__ |
540 |
442 EXPORT_C |
541 /** |
443 #endif |
542 * gst_tuner_channel_changed: |
444 |
543 * @tuner: A #GstTuner instance |
|
544 * @channel: A #GstTunerChannel instance |
|
545 * |
|
546 * Called by elements implementing the #GstTuner interface when the |
|
547 * current channel changes. Fires the #GstTuner::channel-changed signal. |
|
548 */ |
|
549 #ifdef __SYMBIAN32__ |
|
550 EXPORT_C |
|
551 #endif |
445 |
552 |
446 void |
553 void |
447 gst_tuner_channel_changed (GstTuner * tuner, GstTunerChannel * channel) |
554 gst_tuner_channel_changed (GstTuner * tuner, GstTunerChannel * channel) |
448 { |
555 { |
449 g_return_if_fail (GST_IS_TUNER (tuner)); |
556 g_return_if_fail (GST_IS_TUNER (tuner)); |
450 g_return_if_fail (GST_IS_TUNER_CHANNEL (channel)); |
557 g_return_if_fail (GST_IS_TUNER_CHANNEL (channel)); |
451 |
558 |
452 g_signal_emit (G_OBJECT (tuner), |
559 g_signal_emit (G_OBJECT (tuner), |
453 gst_tuner_signals[CHANNEL_CHANGED], 0, channel); |
560 gst_tuner_signals[CHANNEL_CHANGED], 0, channel); |
454 } |
561 } |
455 #ifdef __SYMBIAN32__ |
562 |
456 EXPORT_C |
563 /** |
457 #endif |
564 * gst_tuner_norm_changed: |
458 |
565 * @tuner: A #GstTuner instance |
|
566 * @norm: A #GstTunerNorm instance |
|
567 * |
|
568 * Called by elements implementing the #GstTuner interface when the |
|
569 * current norm changes. Fires the #GstTuner::norm-changed signal. |
|
570 * |
|
571 */ |
|
572 #ifdef __SYMBIAN32__ |
|
573 EXPORT_C |
|
574 #endif |
459 |
575 |
460 void |
576 void |
461 gst_tuner_norm_changed (GstTuner * tuner, GstTunerNorm * norm) |
577 gst_tuner_norm_changed (GstTuner * tuner, GstTunerNorm * norm) |
462 { |
578 { |
463 g_return_if_fail (GST_IS_TUNER (tuner)); |
579 g_return_if_fail (GST_IS_TUNER (tuner)); |
464 g_return_if_fail (GST_IS_TUNER_NORM (norm)); |
580 g_return_if_fail (GST_IS_TUNER_NORM (norm)); |
465 |
581 |
466 g_signal_emit (G_OBJECT (tuner), gst_tuner_signals[NORM_CHANGED], 0, norm); |
582 g_signal_emit (G_OBJECT (tuner), gst_tuner_signals[NORM_CHANGED], 0, norm); |
467 } |
583 } |
468 #ifdef __SYMBIAN32__ |
584 |
469 EXPORT_C |
585 /** |
470 #endif |
586 * gst_tuner_frequency_changed: |
471 |
587 * @tuner: A #GstTuner instance |
|
588 * @channel: The current #GstTunerChannel |
|
589 * @frequency: The new frequency setting |
|
590 * |
|
591 * Called by elements implementing the #GstTuner interface when the |
|
592 * configured frequency changes. Fires the #GstTuner::frequency-changed |
|
593 * signal on the tuner, and the #GstTunerChannel::frequency-changed signal |
|
594 * on the channel. |
|
595 */ |
|
596 #ifdef __SYMBIAN32__ |
|
597 EXPORT_C |
|
598 #endif |
472 |
599 |
473 void |
600 void |
474 gst_tuner_frequency_changed (GstTuner * tuner, |
601 gst_tuner_frequency_changed (GstTuner * tuner, |
475 GstTunerChannel * channel, gulong frequency) |
602 GstTunerChannel * channel, gulong frequency) |
476 { |
603 { |
480 g_signal_emit (G_OBJECT (tuner), |
607 g_signal_emit (G_OBJECT (tuner), |
481 gst_tuner_signals[FREQUENCY_CHANGED], 0, channel, frequency); |
608 gst_tuner_signals[FREQUENCY_CHANGED], 0, channel, frequency); |
482 |
609 |
483 g_signal_emit_by_name (G_OBJECT (channel), "frequency_changed", frequency); |
610 g_signal_emit_by_name (G_OBJECT (channel), "frequency_changed", frequency); |
484 } |
611 } |
485 #ifdef __SYMBIAN32__ |
612 |
486 EXPORT_C |
613 /** |
487 #endif |
614 * gst_tuner_signal_changed: |
488 |
615 * @tuner: A #GstTuner instance |
|
616 * @channel: The current #GstTunerChannel |
|
617 * @signal: The new signal strength |
|
618 * |
|
619 * Called by elements implementing the #GstTuner interface when the |
|
620 * incoming signal strength changes. Fires the #GstTuner::signal-changed |
|
621 * signal on the tuner and the #GstTunerChannel::signal-changed signal on |
|
622 * the channel. |
|
623 */ |
|
624 #ifdef __SYMBIAN32__ |
|
625 EXPORT_C |
|
626 #endif |
489 |
627 |
490 void |
628 void |
491 gst_tuner_signal_changed (GstTuner * tuner, |
629 gst_tuner_signal_changed (GstTuner * tuner, |
492 GstTunerChannel * channel, gint signal) |
630 GstTunerChannel * channel, gint signal) |
493 { |
631 { |