Best way to pass binary data (YUV Buffer) from plugin to browser

109 Views Asked by At

What is the best way to transfer binary data from plugin to browser. We want to play YUV buffer received from network on browser tab. currently am converting to base64 and giving via callback. but it is not efficient and am finding below issues

1> CPU and Memory is going up 2> Callback events are not passed when we change the browser tab, later all events are given at one shot on moving back to our tab.

I would also like to know is there any way we can directly draw YUV frame on browser using plugin thread itself.

Thanks in advance.

1

There are 1 best solutions below

3
taxilian On

NPAPI has been removed from most major browsers... the last holdout, Safari, will be removing it as of macOS Mojave. That being the case, don't expect any updates of any kind to the spec -- however you're using it is likely a dying method.

That being the case, on windows there is a method (super hack, really) that you can use to draw directly to the window in the browser from a native message extension, but it's not portable and it depends on internal implementation details. I haven't actually looked into it since I wrote that other answer (linked in this paragraph) so I don't know if it still works or not.

Anyway, if you're on a browser which fully supports NPAPI then you could draw the YUV data directly to the plugin window given to you on the browser; there is an example of blitting image data in FireBreath which you could possibly trace through as an example.

You could also try some variation of listening on a TCP port in the plugin and connecting to it from the browser; you could easily run into some security issues there, but it is the only other method I can think of.

NPAPI simply wasn't ever designed to allow fast transfer of data between the plugin and the browser; I submitted a proposal to add that capability years ago but it was basically too close to the death of NPAPI (which is basically past at this point) for it to go anywhere. The issues you're seeing are 100% consistent with what I would expect, though... and it's still the best way I know.