Commit 5395720e authored by Felix Paul Kühne's avatar Felix Paul Kühne

windowed mac plugin: show last frame if input is paused and don't show branding when buffering

parent 8a21163b
...@@ -45,6 +45,9 @@ ...@@ -45,6 +45,9 @@
@interface VLCPlaybackLayer : CALayer { @interface VLCPlaybackLayer : CALayer {
CGColorSpaceRef _colorspace; CGColorSpaceRef _colorspace;
VlcPluginMac *_cppPlugin; VlcPluginMac *_cppPlugin;
CGImageRef _lastFrame;
int _cached_width;
int _cached_height;
} }
@property (readwrite) VlcPluginMac * cppPlugin; @property (readwrite) VlcPluginMac * cppPlugin;
...@@ -268,7 +271,9 @@ void VlcPluginMac::update_controls() ...@@ -268,7 +271,9 @@ void VlcPluginMac::update_controls()
[controllerLayer setIsPlaying: playlist_isplaying()]; [controllerLayer setIsPlaying: playlist_isplaying()];
[controllerLayer setIsFullscreen:this->get_fullscreen()]; [controllerLayer setIsFullscreen:this->get_fullscreen()];
if (player_has_vout()) {
libvlc_state_t currentstate = libvlc_media_player_get_state(getMD());
if (currentstate == libvlc_Playing || currentstate == libvlc_Paused || currentstate == libvlc_Opening) {
[noMediaLayer setHidden: YES]; [noMediaLayer setHidden: YES];
[playbackLayer setHidden: NO]; [playbackLayer setHidden: NO];
} else { } else {
...@@ -444,6 +449,8 @@ bool VlcPluginMac::handle_event(void *event) ...@@ -444,6 +449,8 @@ bool VlcPluginMac::handle_event(void *event)
- (void)dealloc - (void)dealloc
{ {
CGColorSpaceRelease(_colorspace); CGColorSpaceRelease(_colorspace);
if (_lastFrame)
CGImageRelease(_lastFrame);
[super dealloc]; [super dealloc];
} }
...@@ -452,14 +459,26 @@ bool VlcPluginMac::handle_event(void *event) ...@@ -452,14 +459,26 @@ bool VlcPluginMac::handle_event(void *event)
if (!cgContext) if (!cgContext)
return; return;
if (![self cppPlugin]->playlist_isplaying() || ![self cppPlugin]->player_has_vout()) BOOL b_paused = !([self cppPlugin]->playlist_isplaying());
if ((!_lastFrame && b_paused) || ![self cppPlugin]->get_player().is_open()) {
NSLog(@"no last frame or no open player");
return; return;
}
float media_width = [self cppPlugin]->m_media_width; float media_width = [self cppPlugin]->m_media_width;
float media_height = [self cppPlugin]->m_media_height; float media_height = [self cppPlugin]->m_media_height;
if (media_width == 0. || media_height == 0.) if (media_width == 0. || media_height == 0.) {
return; if (_cached_height != 0 && _cached_width != 0) {
media_width = _cached_width;
media_height = _cached_height;
} else
return;
} else {
_cached_width = media_width;
_cached_height = media_height;
}
CGRect layerRect = self.bounds; CGRect layerRect = self.bounds;
float display_width = 0.; float display_width = 0.;
...@@ -494,35 +513,39 @@ bool VlcPluginMac::handle_event(void *event) ...@@ -494,35 +513,39 @@ bool VlcPluginMac::handle_event(void *event)
static const size_t kComponentsPerPixel = 4; static const size_t kComponentsPerPixel = 4;
static const size_t kBitsPerComponent = sizeof(unsigned char) * 8; static const size_t kBitsPerComponent = sizeof(unsigned char) * 8;
/* render frame */ if (!b_paused) {
CFDataRef dataRef = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, /* fetch frame */
(const uint8_t *)&[self cppPlugin]->m_frame_buf[0], CFDataRef dataRef = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault,
sizeof([self cppPlugin]->m_frame_buf[0]), (const uint8_t *)&[self cppPlugin]->m_frame_buf[0],
kCFAllocatorNull); sizeof([self cppPlugin]->m_frame_buf[0]),
CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData(dataRef); kCFAllocatorNull);
CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData(dataRef);
CGImageRef image = CGImageCreate(media_width,
media_height, if (_lastFrame)
kBitsPerComponent, CGImageRelease(_lastFrame);
kBitsPerComponent * kComponentsPerPixel,
kComponentsPerPixel * media_width, _lastFrame = CGImageCreate(media_width,
_colorspace, media_height,
kCGBitmapByteOrder16Big, kBitsPerComponent,
dataProvider, kBitsPerComponent * kComponentsPerPixel,
NULL, kComponentsPerPixel * media_width,
true, _colorspace,
kCGRenderingIntentPerceptual); kCGBitmapByteOrder16Big,
if (!image) { dataProvider,
CGImageRelease(image); NULL,
true,
kCGRenderingIntentPerceptual);
CGDataProviderRelease(dataProvider); CGDataProviderRelease(dataProvider);
CGContextRestoreGState(cgContext);
return; if (!_lastFrame) {
CGImageRelease(_lastFrame);
CGContextRestoreGState(cgContext);
return;
}
} }
CGRect rect = CGRectMake(left, top, display_width, display_height); CGRect rect = CGRectMake(left, top, display_width, display_height);
CGContextDrawImage(cgContext, rect, image); CGContextDrawImage(cgContext, rect, _lastFrame);
CGImageRelease(image);
CGDataProviderRelease(dataProvider);
CGContextRestoreGState(cgContext); CGContextRestoreGState(cgContext);
} }
......
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