1 /* GStreamer
2 * Copyright (C) 2020 Seungha Yang <seungha@centricular.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #ifdef HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23
24 #include "gstvp8picture.h"
25
26 GST_DEBUG_CATEGORY_EXTERN (gst_vp8_decoder_debug);
27 #define GST_CAT_DEFAULT gst_vp8_decoder_debug
28
29 GST_DEFINE_MINI_OBJECT_TYPE (GstVp8Picture, gst_vp8_picture);
30
31 static void
_gst_vp8_picture_free(GstVp8Picture * picture)32 _gst_vp8_picture_free (GstVp8Picture * picture)
33 {
34 GST_TRACE ("Free picture %p", picture);
35
36 if (picture->notify)
37 picture->notify (picture->user_data);
38
39 g_free (picture);
40 }
41
42 /**
43 * gst_vp8_picture_new:
44 *
45 * Create new #GstVp8Picture
46 *
47 * Returns: a new #GstVp8Picture
48 */
49 GstVp8Picture *
gst_vp8_picture_new(void)50 gst_vp8_picture_new (void)
51 {
52 GstVp8Picture *pic;
53
54 pic = g_new0 (GstVp8Picture, 1);
55 pic->pts = GST_CLOCK_TIME_NONE;
56
57 gst_mini_object_init (GST_MINI_OBJECT_CAST (pic), 0,
58 GST_TYPE_VP8_PICTURE, NULL, NULL,
59 (GstMiniObjectFreeFunction) _gst_vp8_picture_free);
60
61 GST_TRACE ("New picture %p", pic);
62
63 return pic;
64 }
65
66 /**
67 * gst_vp8_picture_set_user_data:
68 * @picture: a #GstVp8Picture
69 * @user_data: private data
70 * @notify: (closure user_data): a #GDestroyNotify
71 *
72 * Sets @user_data on the picture and the #GDestroyNotify that will be called when
73 * the picture is freed.
74 *
75 * If a @user_data was previously set, then the previous set @notify will be called
76 * before the @user_data is replaced.
77 */
78 void
gst_vp8_picture_set_user_data(GstVp8Picture * picture,gpointer user_data,GDestroyNotify notify)79 gst_vp8_picture_set_user_data (GstVp8Picture * picture, gpointer user_data,
80 GDestroyNotify notify)
81 {
82 g_return_if_fail (GST_IS_VP8_PICTURE (picture));
83
84 if (picture->notify)
85 picture->notify (picture->user_data);
86
87 picture->user_data = user_data;
88 picture->notify = notify;
89 }
90
91 /**
92 * gst_vp8_picture_get_user_data:
93 * @picture: a #GstVp8Picture
94 *
95 * Gets private data set on the picture via
96 * gst_vp8_picture_set_user_data() previously.
97 *
98 * Returns: (transfer none): The previously set user_data
99 */
100 gpointer
gst_vp8_picture_get_user_data(GstVp8Picture * picture)101 gst_vp8_picture_get_user_data (GstVp8Picture * picture)
102 {
103 return picture->user_data;
104 }
105