gst_plugins_base/gst-libs/gst/interfaces/tuner.c
changeset 16 8e837d1bf446
parent 0 0e761a78d257
child 30 7e817e7e631c
equal deleted inserted replaced
15:4b0c6ed43234 16:8e837d1bf446
    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,
   130 
   201 
   131 /**
   202 /**
   132  * gst_tuner_list_channels:
   203  * gst_tuner_list_channels:
   133  * @tuner: the #GstTuner (a #GstElement) to get the channels from.
   204  * @tuner: the #GstTuner (a #GstElement) to get the channels from.
   134  *
   205  *
   135  * Retrieve a list of channels (e.g. 'composite', 's-video', ...)
   206  * Retrieve a #GList of #GstTunerChannels available
   136  * from the given tuner object.
   207  * (e.g. 'composite', 's-video', ...) from the given tuner object.
   137  *
   208  *
   138  * Returns: a list of channels available on this tuner.
   209  * Returns: A list of channels available on this tuner. The list is
   139  */
   210  *          owned by the GstTuner and must not be freed.
   140 #ifdef __SYMBIAN32__
   211  */
   141 EXPORT_C
   212 #ifdef __SYMBIAN32__
   142 #endif
   213 EXPORT_C
   143 
   214 #endif
   144 
   215 
   145 const GList *
   216 const GList *
   146 gst_tuner_list_channels (GstTuner * tuner)
   217 gst_tuner_list_channels (GstTuner * tuner)
   147 {
   218 {
   148   GstTunerClass *klass;
   219   GstTunerClass *klass;
   181     klass->set_channel (tuner, channel);
   252     klass->set_channel (tuner, channel);
   182   }
   253   }
   183 }
   254 }
   184 
   255 
   185 /**
   256 /**
   186  * gst_Tuner_get_channel:
   257  * gst_tuner_get_channel:
   187  * @tuner: the #GstTuner (a #GstElement) to get the current channel from.
   258  * @tuner: the #GstTuner (a #GstElement) to get the current channel from.
   188  *
   259  *
   189  * Retrieve the current channel from the tuner.
   260  * Retrieve the current channel from the tuner.
   190  *
   261  *
   191  * Returns: the current channel of the tuner object.
   262  * Returns: the current channel of the tuner object.
   209 
   280 
   210   return NULL;
   281   return NULL;
   211 }
   282 }
   212 
   283 
   213 /**
   284 /**
   214  * gst_tuner_get_norms_list:
   285  * gst_tuner_list_norms:
   215  * @tuner: the #GstTuner (*a #GstElement) to get the list of norms from.
   286  * @tuner: the #GstTuner (*a #GstElement) to get the list of norms from.
   216  *
   287  *
   217  * Retrieve a list of available norms on the currently tuned channel
   288  * Retrieve a GList of available #GstTunerNorm settings for the currently
   218  * from the given tuner object.
   289  * tuned channel on the given tuner object.
   219  *
   290  *
   220  * Returns: A list of norms available on the current channel for this
   291  * Returns: A list of norms available on the current channel for this
   221  *          tuner object.
   292  *          tuner object. The list is owned by the GstTuner and must not
       
   293  *          be freed.
   222  */
   294  */
   223 #ifdef __SYMBIAN32__
   295 #ifdef __SYMBIAN32__
   224 EXPORT_C
   296 EXPORT_C
   225 #endif
   297 #endif
   226 
   298 
   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 {
   327   }
   403   }
   328 }
   404 }
   329 
   405 
   330 /**
   406 /**
   331  * gst_tuner_get_frequency:
   407  * gst_tuner_get_frequency:
   332  * @tuner: the #GstTuner (a #GstElement) that owns the given channel.
   408  * @tuner: The #GstTuner (a #GstElement) that owns the given channel.
   333  * @channel: the #GstTunerChannel to retrieve the frequency from.
   409  * @channel: The #GstTunerChannel to retrieve the frequency from.
   334  *
   410  *
   335  * Retrieve the current frequency from the given channel. The same
   411  * Retrieve the current frequency from the given channel. As for
   336  * applies as for set_frequency (): check the flag.
   412  * gst_tuner_set_frequency(), the #GstTunerChannel must support frequency
   337  *
   413  * operations, as indicated by the GST_TUNER_CHANNEL_FREQUENCY flag.
   338  * Returns: the current frequency, or 0 on error.
   414  *
       
   415  * Returns: The current frequency, or 0 on error.
   339  */
   416  */
   340 #ifdef __SYMBIAN32__
   417 #ifdef __SYMBIAN32__
   341 EXPORT_C
   418 EXPORT_C
   342 #endif
   419 #endif
   343 
   420 
   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;
   394     return klass->signal_strength (tuner, channel);
   473     return klass->signal_strength (tuner, channel);
   395   }
   474   }
   396 
   475 
   397   return 0;
   476   return 0;
   398 }
   477 }
   399 #ifdef __SYMBIAN32__
   478 
   400 EXPORT_C
   479 /**
   401 #endif
   480  * gst_tuner_find_norm_by_name:
   402 
   481  * @tuner: A #GstTuner instance
       
   482  * @norm: A string containing the name of a #GstTunerNorm
       
   483  * 
       
   484  * Look up a #GstTunerNorm by name.
       
   485  *
       
   486  * Returns: A #GstTunerNorm, or NULL if no norm with the provided name
       
   487  * is available.
       
   488  */
       
   489 #ifdef __SYMBIAN32__
       
   490 EXPORT_C
       
   491 #endif
   403 
   492 
   404 GstTunerNorm *
   493 GstTunerNorm *
   405 gst_tuner_find_norm_by_name (GstTuner * tuner, gchar * norm)
   494 gst_tuner_find_norm_by_name (GstTuner * tuner, gchar * norm)
   406 {
   495 {
   407   GList *walk;
   496   GList *walk;
   415       return GST_TUNER_NORM (walk->data);
   504       return GST_TUNER_NORM (walk->data);
   416     walk = g_list_next (walk);
   505     walk = g_list_next (walk);
   417   }
   506   }
   418   return NULL;
   507   return NULL;
   419 }
   508 }
   420 #ifdef __SYMBIAN32__
   509 
   421 EXPORT_C
   510 /**
   422 #endif
   511  * gst_tuner_find_channel_by_name:
   423 
   512  * @tuner: A #GstTuner instance
       
   513  * @channel: A string containing the name of a #GstTunerChannel
       
   514  * 
       
   515  * Look up a #GstTunerChannel by name.
       
   516  *
       
   517  * Returns: A #GstTunerChannel, or NULL if no channel with the provided name
       
   518  * is available.
       
   519  */
       
   520 #ifdef __SYMBIAN32__
       
   521 EXPORT_C
       
   522 #endif
   424 
   523 
   425 GstTunerChannel *
   524 GstTunerChannel *
   426 gst_tuner_find_channel_by_name (GstTuner * tuner, gchar * channel)
   525 gst_tuner_find_channel_by_name (GstTuner * tuner, gchar * channel)
   427 {
   526 {
   428   GList *walk;
   527   GList *walk;
   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 {