Commit 8744425b authored by Felix Paul Kühne's avatar Felix Paul Kühne

windowsless mac: implement video output

Note that the colors aren't quite correct yet
parent 5383ac08
...@@ -79,7 +79,7 @@ void VlcPluginBase::eventAsync(void *param) ...@@ -79,7 +79,7 @@ void VlcPluginBase::eventAsync(void *param)
void VlcPluginBase::event_callback(const libvlc_event_t* event, void VlcPluginBase::event_callback(const libvlc_event_t* event,
NPVariant *npparams, uint32_t npcount) NPVariant *npparams, uint32_t npcount)
{ {
#if defined(XP_UNIX) || defined(XP_WIN) #if defined(XP_UNIX) || defined(XP_WIN) || defined (XP_MACOSX)
events.callback(event, npparams, npcount); events.callback(event, npparams, npcount);
NPN_PluginThreadAsyncCall(getBrowser(), eventAsync, this); NPN_PluginThreadAsyncCall(getBrowser(), eventAsync, this);
#else #else
...@@ -100,7 +100,7 @@ NPError VlcPluginBase::init(int argc, char* const argn[], char* const argv[]) ...@@ -100,7 +100,7 @@ NPError VlcPluginBase::init(int argc, char* const argn[], char* const argv[])
/* locate VLC module path */ /* locate VLC module path */
#ifdef XP_MACOSX #ifdef XP_MACOSX
ppsz_argv[ppsz_argc++] = "--vout=vout_macosx"; ppsz_argv[ppsz_argc++] = "--vout=vmem"; //vout_macosx";
#elif defined(XP_WIN) #elif defined(XP_WIN)
HKEY h_key; HKEY h_key;
DWORD i_type, i_data = MAX_PATH + 1; DWORD i_type, i_data = MAX_PATH + 1;
......
...@@ -55,7 +55,7 @@ void VlcWindowlessMac::drawBackground(NPCocoaEvent *cocoaEvent) ...@@ -55,7 +55,7 @@ void VlcWindowlessMac::drawBackground(NPCocoaEvent *cocoaEvent)
unsigned r = 0, g = 0, b = 0; unsigned r = 0, g = 0, b = 0;
HTMLColor2RGB(get_options().get_bg_color().c_str(), &r, &g, &b); HTMLColor2RGB(get_options().get_bg_color().c_str(), &r, &g, &b);
// draw a gray background // draw background
CGContextAddRect(cgContext, CGRectMake(0, 0, windowWidth, windowHeight)); CGContextAddRect(cgContext, CGRectMake(0, 0, windowWidth, windowHeight));
CGContextSetRGBFillColor(cgContext,r/255.,g/255.,b/255.,1.); CGContextSetRGBFillColor(cgContext,r/255.,g/255.,b/255.,1.);
CGContextDrawPath(cgContext, kCGPathFill); CGContextDrawPath(cgContext, kCGPathFill);
...@@ -92,9 +92,6 @@ bool VlcWindowlessMac::handle_event(void *event) ...@@ -92,9 +92,6 @@ bool VlcWindowlessMac::handle_event(void *event)
} }
if (eventType == NPCocoaEventDrawRect) { if (eventType == NPCocoaEventDrawRect) {
if (VlcPluginBase::playlist_isplaying() && VlcPluginBase::player_has_vout())
return false;
CGContextRef cgContext = cocoaEvent->data.draw.context; CGContextRef cgContext = cocoaEvent->data.draw.context;
if (!cgContext) { if (!cgContext) {
return false; return false;
...@@ -102,6 +99,59 @@ bool VlcWindowlessMac::handle_event(void *event) ...@@ -102,6 +99,59 @@ bool VlcWindowlessMac::handle_event(void *event)
drawBackground(cocoaEvent); drawBackground(cocoaEvent);
if(!VlcPluginBase::player_has_vout())
return true;
if (m_media_width == 0 || m_media_height == 0)
return true;
CGContextSaveGState(cgContext);
/* context is flipped */
CGContextTranslateCTM(cgContext, 0.0, npwindow.height);
CGContextScaleCTM(cgContext, 1., -1.);
/* Compute the position of the video */
float left = (npwindow.width - m_media_width) / 2.;
float top = (npwindow.height - m_media_height) / 2.;
static const size_t kComponentsPerPixel = 4;
static const size_t kBitsPerComponent = sizeof(unsigned char) * 8;
/* render frame */
CFDataRef dataRef = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault,
(const uint8_t *)&m_frame_buf[0],
sizeof(m_frame_buf[0]),
kCFAllocatorNull);
CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData(dataRef);
CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGBLinear);
CGImageRef image = CGImageCreate(m_media_width,
m_media_height,
kBitsPerComponent,
kBitsPerComponent * kComponentsPerPixel,
kComponentsPerPixel * m_media_width,
colorspace,
kCGBitmapByteOrder16Big,
dataProvider,
NULL,
true,
kCGRenderingIntentPerceptual);
if (!image) {
CGColorSpaceRelease(colorspace);
CGImageRelease(image);
CGDataProviderRelease(dataProvider);
CGContextRestoreGState(cgContext);
return true;
}
CGRect rect = CGRectMake(left, top, m_media_width, m_media_height);
CGContextDrawImage(cgContext, rect, image);
CGColorSpaceRelease(colorspace);
CGImageRelease(image);
CGDataProviderRelease(dataProvider);
CGContextRestoreGState(cgContext);
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment