Add missing GLIB_DISABLE_DEPRECATION_WARNINGS
[platform/upstream/gstreamer.git] / gst / mpegdemux / flutspmtinfo.c
1  /*
2   * This library is licensed under 2 different licenses and you
3   * can choose to use it under the terms of either one of them. The
4   * two licenses are the MPL 1.1 and the LGPL.
5   *
6   * MPL:
7   *
8   * The contents of this file are subject to the Mozilla Public License
9   * Version 1.1 (the "License"); you may not use this file except in
10   * compliance with the License. You may obtain a copy of the License at
11   * http://www.mozilla.org/MPL/.
12   *
13   * Software distributed under the License is distributed on an "AS IS"
14   * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
15   * License for the specific language governing rights and limitations
16   * under the License.
17   *
18   * LGPL:
19   *
20   * This library is free software; you can redistribute it and/or
21   * modify it under the terms of the GNU Library General Public
22   * License as published by the Free Software Foundation; either
23   * version 2 of the License, or (at your option) any later version.
24   *
25   * This library is distributed in the hope that it will be useful,
26   * but WITHOUT ANY WARRANTY; without even the implied warranty of
27   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
28   * Library General Public License for more details.
29   *
30   * You should have received a copy of the GNU Library General Public
31   * License along with this library; if not, write to the
32   * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
33   * Boston, MA 02111-1307, USA.
34   *
35   * The Original Code is Fluendo MPEG Demuxer plugin.
36   *
37   * The Initial Developer of the Original Code is Fluendo, S.L.
38   * Portions created by Fluendo, S.L. are Copyright (C) 2005
39   * Fluendo, S.L. All Rights Reserved.
40   *
41   * Contributor(s): Jan Schmidt <jan@fluendo.com>
42   */
43
44 #ifdef HAVE_CONFIG_H
45 #include "config.h"
46 #endif
47
48 /* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex
49  * with newer GLib versions (>= 2.31.0) */
50 #define GLIB_DISABLE_DEPRECATION_WARNINGS
51
52 #include <gst/gst.h>
53
54 #include "flutspmtinfo.h"
55
56 enum
57 {
58   PROP_0,
59   PROP_PROGRAM_NO,
60   PROP_VERSION_NO,
61   PROP_PCR_PID,
62   PROP_DESCRIPTORS,
63   PROP_STREAMINFO
64 };
65
66 GST_BOILERPLATE (MpegTsPmtInfo, mpegts_pmt_info, GObject, G_TYPE_OBJECT);
67
68 static void mpegts_pmt_info_finalize (GObject * object);
69 static void mpegts_pmt_info_set_property (GObject * object, guint prop_id,
70     const GValue * value, GParamSpec * spec);
71 static void mpegts_pmt_info_get_property (GObject * object, guint prop_id,
72     GValue * value, GParamSpec * spec);
73
74 static void
75 mpegts_pmt_info_base_init (gpointer klass)
76 {
77 }
78
79 static void
80 mpegts_pmt_info_class_init (MpegTsPmtInfoClass * klass)
81 {
82   GObjectClass *gobject_klass = (GObjectClass *) klass;
83
84   gobject_klass->finalize = mpegts_pmt_info_finalize;
85   gobject_klass->set_property = mpegts_pmt_info_set_property;
86   gobject_klass->get_property = mpegts_pmt_info_get_property;
87
88   g_object_class_install_property (gobject_klass, PROP_PROGRAM_NO,
89       g_param_spec_uint ("program-number", "Program Number",
90           "Program Number for this program", 0, G_MAXUINT16, 1,
91           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
92
93   g_object_class_install_property (gobject_klass, PROP_PCR_PID,
94       g_param_spec_uint ("pcr-pid", "PID carrying the PCR for this program",
95           "PID which carries the PCR for this program", 1, G_MAXUINT16, 1,
96           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
97
98   g_object_class_install_property (gobject_klass, PROP_STREAMINFO,
99       g_param_spec_value_array ("stream-info",
100           "GValueArray containing GObjects with properties",
101           "Array of GObjects containing information about the program streams",
102           g_param_spec_object ("flu-pmt-streaminfo", "FluPMTStreamInfo",
103               "Fluendo TS Demuxer PMT Stream info object",
104               MPEGTS_TYPE_PMT_STREAM_INFO,
105               G_PARAM_READABLE | G_PARAM_STATIC_STRINGS),
106           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
107
108   g_object_class_install_property (gobject_klass, PROP_VERSION_NO,
109       g_param_spec_uint ("version-number", "Version Number",
110           "Version number of this program information", 0, G_MAXUINT8, 1,
111           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
112
113   g_object_class_install_property (gobject_klass, PROP_DESCRIPTORS,
114       g_param_spec_value_array ("descriptors",
115           "Descriptors",
116           "Value array of strings containing program descriptors",
117           g_param_spec_boxed ("descriptor",
118               "descriptor",
119               "", G_TYPE_GSTRING, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS),
120           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
121 }
122
123 static void
124 mpegts_pmt_info_init (MpegTsPmtInfo * pmt_info, MpegTsPmtInfoClass * klass)
125 {
126   pmt_info->streams = g_value_array_new (0);
127   pmt_info->descriptors = g_value_array_new (0);
128 }
129
130 MpegTsPmtInfo *
131 mpegts_pmt_info_new (guint16 program_no, guint16 pcr_pid, guint8 version_no)
132 {
133   MpegTsPmtInfo *info;
134
135   info = g_object_new (MPEGTS_TYPE_PMT_INFO, NULL);
136
137   info->program_no = program_no;
138   info->pcr_pid = pcr_pid;
139   info->version_no = version_no;
140
141   return info;
142 }
143
144 static void
145 mpegts_pmt_info_finalize (GObject * object)
146 {
147   MpegTsPmtInfo *info = MPEGTS_PMT_INFO (object);
148
149   g_value_array_free (info->streams);
150   g_value_array_free (info->descriptors);
151
152   G_OBJECT_CLASS (parent_class)->finalize (object);
153 }
154
155 static void
156 mpegts_pmt_info_set_property (GObject * object, guint prop_id,
157     const GValue * value, GParamSpec * spec)
158 {
159   g_return_if_fail (MPEGTS_IS_PMT_INFO (object));
160
161   /* No settable properties */
162   G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec);
163 }
164
165 static void
166 mpegts_pmt_info_get_property (GObject * object, guint prop_id,
167     GValue * value, GParamSpec * spec)
168 {
169   MpegTsPmtInfo *pmt_info;
170
171   g_return_if_fail (MPEGTS_IS_PMT_INFO (object));
172
173   pmt_info = MPEGTS_PMT_INFO (object);
174
175   switch (prop_id) {
176     case PROP_PROGRAM_NO:
177       g_value_set_uint (value, pmt_info->program_no);
178       break;
179     case PROP_PCR_PID:
180       g_value_set_uint (value, pmt_info->pcr_pid);
181       break;
182     case PROP_STREAMINFO:
183       g_value_set_boxed (value, pmt_info->streams);
184       break;
185     case PROP_VERSION_NO:
186       g_value_set_uint (value, pmt_info->version_no);
187       break;
188     case PROP_DESCRIPTORS:
189       g_value_set_boxed (value, pmt_info->descriptors);
190       break;
191     default:
192       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec);
193       break;
194   }
195 }
196
197 void
198 mpegts_pmt_info_add_descriptor (MpegTsPmtInfo * pmt_info,
199     const gchar * descriptor, guint length)
200 {
201   GValue value = { 0 };
202   GString *string;
203
204   g_return_if_fail (MPEGTS_IS_PMT_INFO (pmt_info));
205
206   string = g_string_new_len (descriptor, length);
207
208   g_value_init (&value, G_TYPE_GSTRING);
209   g_value_take_boxed (&value, string);
210   g_value_array_append (pmt_info->descriptors, &value);
211   g_value_unset (&value);
212 }
213
214 void
215 mpegts_pmt_info_add_stream (MpegTsPmtInfo * pmt_info,
216     MpegTsPmtStreamInfo * stream)
217 {
218   GValue v = { 0, };
219
220   g_return_if_fail (MPEGTS_IS_PMT_INFO (pmt_info));
221   g_return_if_fail (MPEGTS_IS_PMT_STREAM_INFO (stream));
222
223   g_value_init (&v, G_TYPE_OBJECT);
224   g_value_take_object (&v, stream);
225   g_value_array_append (pmt_info->streams, &v);
226   g_value_unset (&v);
227 }