Skip to content

Commit

Permalink
#3754 refactoring: add utility buffer method
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Feb 2, 2023
1 parent 774b66c commit c057456
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions xpra/codecs/gstreamer/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@ def on_new_sample(self, _bus):
self.frame_queue.put((data, client_info))
return GST_FLOW_OK


def wrap(self, data):
mf = Gst.MemoryFlags
return Gst.Buffer.new_wrapped_full(
mf.PHYSICALLY_CONTIGUOUS | mf.READONLY,
data, len(data),
0, None, None)

def compress_image(self, image, options=None):
if image.get_planes()==ImageWrapper.PACKED:
data = image.get_pixels()
Expand All @@ -266,22 +274,7 @@ def compress_image(self, image, options=None):
if self.state in ("stopped", "error"):
log(f"pipeline is in {self.state} state, dropping buffer")
return None
mf = Gst.MemoryFlags
buf = Gst.Buffer.new_wrapped_full(
mf.PHYSICALLY_CONTIGUOUS | mf.READONLY,
data,
len(data),
0,
None,
None)
#duration = normv(0)
#if duration>0:
# buf.duration = duration
#buf.size = size
#buf.timestamp = timestamp
#buf.offset = offset
#buf.offset_end = offset_end
return self.process_buffer(buf)
return self.process_buffer(self.wrap(data))

GObject.type_register(Encoder)

Expand Down

0 comments on commit c057456

Please sign in to comment.