Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python bindings for FrameCanvas::Serialize/Deserialize #1457

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SolidHal
Copy link
Contributor

this enables usage like in cpp content-streamer

this enables usage like in cpp content-streamer
@@ -53,6 +53,12 @@ cdef class Canvas:
b = (pixel >> 16) & 0xFF
my_canvas.SetPixel(xstart+col, ystart+row, r, g, b)

cdef class FrameData:
cdef const char *__getData(self) except +:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cdef const char *__getData(self) except +:
cdef const char *__getData(self) except NULL:

except + means that code can throw C++ exception
except NULL - check exception state if returned value is NULL

def Serialize(self):
cdef const char* data
cdef size_t length
(<cppinc.FrameCanvas*>self.__getCanvas()).Serialize(&data, &length)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid that this won't work for your purpose. Serialize just returns pointer to internal frame representation (one instance per FrameCanvas), it does not copy it.

One option is to implement buffer protocol for FrameCanvas and then use python for memory management. I'll post PR soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants