• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  *
3  * Copyright (C) 2020 Philippe Normand <philn@igalia.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24 
25 #include <gst/play/gstplay-video-renderer.h>
26 
27 #include "gstplayer-wrapped-video-renderer-private.h"
28 #include "gstplayer.h"
29 #include "gstplayer-video-renderer-private.h"
30 
31 /*
32  * This object is an internal wrapper created by the GstPlayer, implementing the
33  * new GstPlayVideoRenderer interface and acting as a bridge from the legacy
34  * GstPlayerVideoRenderer interface.
35  */
36 
37 struct _GstPlayerWrappedVideoRenderer
38 {
39   GObject parent;
40 
41   GstPlayerVideoRenderer *renderer;
42   GstPlayer *player;
43 };
44 
45 struct _GstPlayerWrappedVideoRendererClass
46 {
47   GObjectClass parent_class;
48 };
49 
50 static void
51     gst_player_wrapped_video_renderer_interface_init
52     (GstPlayVideoRendererInterface * iface);
53 
54 G_DEFINE_TYPE_WITH_CODE (GstPlayerWrappedVideoRenderer,
55     gst_player_wrapped_video_renderer, G_TYPE_OBJECT,
56     G_IMPLEMENT_INTERFACE (GST_TYPE_PLAY_VIDEO_RENDERER,
57         gst_player_wrapped_video_renderer_interface_init));
58 
59 static void
gst_player_wrapped_video_renderer_finalize(GObject * object)60 gst_player_wrapped_video_renderer_finalize (GObject * object)
61 {
62   GstPlayerWrappedVideoRenderer *self =
63       GST_PLAYER_WRAPPED_VIDEO_RENDERER (object);
64 
65   g_clear_object (&self->renderer);
66 
67   G_OBJECT_CLASS
68       (gst_player_wrapped_video_renderer_parent_class)->finalize (object);
69 }
70 
71 static void
gst_player_wrapped_video_renderer_class_init(GstPlayerWrappedVideoRendererClass * klass)72 gst_player_wrapped_video_renderer_class_init (GstPlayerWrappedVideoRendererClass
73     * klass)
74 {
75   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
76 
77   gobject_class->finalize = gst_player_wrapped_video_renderer_finalize;
78 }
79 
80 static void
gst_player_wrapped_video_renderer_init(GstPlayerWrappedVideoRenderer * self)81 gst_player_wrapped_video_renderer_init (GstPlayerWrappedVideoRenderer * self)
82 {
83 }
84 
85 static GstElement *
gst_player_wrapped_video_renderer_create_video_sink(GstPlayVideoRenderer * iface,GstPlay * player)86 gst_player_wrapped_video_renderer_create_video_sink (GstPlayVideoRenderer *
87     iface, GstPlay * player)
88 {
89   GstPlayerWrappedVideoRenderer *self =
90       GST_PLAYER_WRAPPED_VIDEO_RENDERER (iface);
91 
92   return gst_player_video_renderer_create_video_sink (self->renderer,
93       self->player);
94 }
95 
96 static void
gst_player_wrapped_video_renderer_interface_init(GstPlayVideoRendererInterface * iface)97 gst_player_wrapped_video_renderer_interface_init (GstPlayVideoRendererInterface
98     * iface)
99 {
100   iface->create_video_sink =
101       gst_player_wrapped_video_renderer_create_video_sink;
102 }
103 
104 GstPlayerVideoRenderer *
gst_player_wrapped_video_renderer_new(GstPlayerVideoRenderer * renderer,GstPlayer * player)105 gst_player_wrapped_video_renderer_new (GstPlayerVideoRenderer * renderer,
106     GstPlayer * player)
107 {
108   GstPlayerWrappedVideoRenderer *self =
109       g_object_new (GST_TYPE_PLAYER_WRAPPED_VIDEO_RENDERER,
110       NULL);
111   self->renderer = g_object_ref (renderer);
112   self->player = player;
113   return (GstPlayerVideoRenderer *) self;
114 }
115