• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer Tuner
2  * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
3  *
4  * tunerchannel.c: tuner channel object design
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library 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 GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25 
26 #include "tunerchannel.h"
27 
28 /**
29  * SECTION:gsttunerchannel
30  * @title: GstTunerChannel
31  * @short_description: A channel from an element implementing the #GstTuner
32  * interface.
33  *
34  * The #GstTunerChannel object is provided by an element implementing
35  * the #GstTuner interface.
36  *
37  * GstTunerChannel provides a name and flags to determine the type and
38  * capabilities of the channel. If the GST_TUNER_CHANNEL_FREQUENCY flag is
39  * set, then the channel also information about the minimum and maximum
40  * frequency, and range of the reported signal strength.
41  */
42 
43 enum
44 {
45   /* FILL ME */
46   SIGNAL_FREQUENCY_CHANGED,
47   SIGNAL_SIGNAL_CHANGED,
48   LAST_SIGNAL
49 };
50 
51 G_DEFINE_TYPE (GstTunerChannel, gst_tuner_channel, G_TYPE_OBJECT);
52 
53 static void gst_tuner_channel_dispose (GObject * object);
54 
55 static guint signals[LAST_SIGNAL] = { 0 };
56 
57 static void
gst_tuner_channel_class_init(GstTunerChannelClass * klass)58 gst_tuner_channel_class_init (GstTunerChannelClass * klass)
59 {
60   GObjectClass *object_klass = (GObjectClass *) klass;
61 
62   /**
63    * GstTunerChannel::frequency-changed:
64    * @tunerchannel: The #GstTunerChannel
65    * @frequency: The new frequency (an unsigned long)
66    *
67    * Reports that the current frequency has changed.
68    */
69   signals[SIGNAL_FREQUENCY_CHANGED] =
70       g_signal_new ("frequency-changed", G_TYPE_FROM_CLASS (klass),
71       G_SIGNAL_RUN_LAST,
72       G_STRUCT_OFFSET (GstTunerChannelClass, frequency_changed),
73       NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_ULONG);
74   /**
75    * GstTunerChannel::signal-changed:
76    * @tunerchannel: The #GstTunerChannel
77    * @signal: The new signal strength (an integer)
78    *
79    * Reports that the signal strength has changed.
80    */
81   signals[SIGNAL_SIGNAL_CHANGED] =
82       g_signal_new ("signal-changed", G_TYPE_FROM_CLASS (klass),
83       G_SIGNAL_RUN_LAST,
84       G_STRUCT_OFFSET (GstTunerChannelClass, signal_changed),
85       NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_INT);
86 
87   object_klass->dispose = gst_tuner_channel_dispose;
88 }
89 
90 static void
gst_tuner_channel_init(GstTunerChannel * channel)91 gst_tuner_channel_init (GstTunerChannel * channel)
92 {
93   channel->label = NULL;
94   channel->flags = 0;
95   channel->min_frequency = channel->max_frequency = 0;
96   channel->min_signal = channel->max_signal = 0;
97 }
98 
99 static void
gst_tuner_channel_dispose(GObject * object)100 gst_tuner_channel_dispose (GObject * object)
101 {
102   GstTunerChannel *channel = GST_TUNER_CHANNEL (object);
103 
104   if (channel->label) {
105     g_free (channel->label);
106     channel->label = NULL;
107   }
108 
109   G_OBJECT_CLASS (gst_tuner_channel_parent_class)->dispose (object);
110 }
111