def on_bus_message_sync(bus, message, glsink):
     if message.type == Gst.MessageType.NEED_CONTEXT:
         _, context_type = message.parse_context_type()
         if context_type == GstGL.GL_DISPLAY_CONTEXT_TYPE:
             sinkelement = glsink.get_by_interface(GstVideo.VideoOverlay)
             gl_context = sinkelement.get_property('context')
             if gl_context:
                 display_context = Gst.Context.new(GstGL.GL_DISPLAY_CONTEXT_TYPE, True)
                 GstGL.context_set_gl_display(display_context, gl_context.get_display())
                 message.src.set_context(display_context)
     return Gst.BusSyncReply.PASS
Ejemplo n.º 2
0
 def render_to_texture_gl(self, glcontext, dst, render_func, render_arg):
     libgstgl.gst_gl_framebuffer_draw_to_texture(
         hash(self.fbo),
         hash(dst.peek_memory(0)),
         GstGLFramebufferFunc(render_func),
         render_arg)
     meta = GstGL.buffer_add_gl_sync_meta(glcontext, dst)
     meta.set_sync_point(glcontext)
Ejemplo n.º 3
0
 def __init__(self, pool, glupload):
     self.glcontext = glupload.context
     res, self.dmabuf = pool.acquire_buffer()
     assert res == Gst.FlowReturn.OK
     assert GstAllocators.is_dmabuf_memory(self.dmabuf.peek_memory(0))
     with _gst_buffer_map(self.dmabuf, Gst.MapFlags.WRITE) as mapped:
         self.ptr = ctypes.addressof(mapped)
         self.len = ctypes.sizeof(mapped)
         self.clear()
     meta = GstVideo.buffer_get_video_meta(self.dmabuf)
     assert meta
     self.surface = libcairo.cairo_image_surface_create_for_data(
         self.ptr, int(cairo.FORMAT_ARGB32), meta.width, meta.height,
         meta.stride[0])
     self.cairo = libcairo.cairo_create(self.surface)
     res, self.gl_buffer = glupload.perform_with_buffer(self.dmabuf)
     assert res == GstGL.GLUploadReturn.DONE
     memory = self.gl_buffer.peek_memory(0)
     assert GstGL.is_gl_memory(memory)
     self.texture_id = libgstgl.gst_gl_memory_get_texture_id(hash(memory))
     self.sync = GstGL.buffer_add_gl_sync_meta(self.glcontext,
                                               self.gl_buffer)
Ejemplo n.º 4
0
def is_egl_image(buf):
    memory = buf.peek_memory(0)
    assert GstGL.is_gl_memory(memory)
    return libgstgl.gst_is_gl_memory_egl(hash(memory))
Ejemplo n.º 5
0
def get_gl_texture_id(buf):
    memory = buf.peek_memory(0)
    assert GstGL.is_gl_memory(memory)
    return libgstgl.gst_gl_memory_get_texture_id(hash(memory))
Ejemplo n.º 6
0
 def get_gl_display_context(self):
     if not self.glcontext:
         return None
     context = Gst.Context.new(GstGL.GL_DISPLAY_CONTEXT_TYPE, True)
     GstGL.context_set_gl_display(context, self.glcontext.get_display())
     return context