I have to pass this pixel buffer to another app (process) so I have created IOSurface and copied pixel buffer into it. Now, before passing it to another process I am trying to validate this IOSurface in cefsimple itself (by redering it on local window/NSview).
After running cefsimple with youtube url and with my rendering changes, I can hear audio but there is no video on NSView.
My OnPaint() implementation is something like below:
- Code: Select all
void SimpleHandler::OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type,
const RectList &dirtyRects, const void* buffer,
int width, int height)
{
if (type == PET_VIEW) {
if (!ioSurface) //ioSurface is created in ctor
ioSurface = CreateIOSurface(width, height);
CopyPixelBufferToIOSurface(buffer, width, height, ioSurface);
RenderOnLocalWindow(buffer, ioSurface);
}
and rendering code is as follow (using CALayer)
- Code: Select all
// Create a CALayer with IOSurface as its contents
CALayer* surfaceLayer = [CALayer layer];
// Set the IOSurface as the contents of the layer
surfaceLayer.contents = (__bridge id)ioSurface;
// Set layer bounds to match IOSurface dimensions
surfaceLayer.bounds = CGRectMake(0, 0, width, height);
// Add the layer to the NSView's layer
[m_NSView setLayer:surfaceLayer];
[m_NSView setWantsLayer:YES];
Log shows that I am getting pixel buffers for playing youtube video but somehow rendering video is not working. Do I need to use different framework for rendering?
Has anyone implemented this before? It would be great if someone could provide input on this.