VLCVideoLayer.m 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*****************************************************************************
  2. * VLCVideoLayer.m: VLCKit.framework VLCVideoLayer implementation
  3. *****************************************************************************
  4. * Copyright (C) 2007 Pierre d'Herbemont
  5. * Copyright (C) 2007 the VideoLAN team
  6. * $Id$
  7. *
  8. * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  23. *****************************************************************************/
  24. #import "VLCVideoLayer.h"
  25. #import "VLCLibrary.h"
  26. #import "VLCEventManager.h"
  27. #import "VLCVideoCommon.h"
  28. /* Libvlc */
  29. #ifdef HAVE_CONFIG_H
  30. # include "config.h"
  31. #endif
  32. #include <vlc/vlc.h>
  33. #include <vlc/libvlc.h>
  34. #import <QuartzCore/QuartzCore.h>
  35. /******************************************************************************
  36. * VLCVideoView (Private)
  37. */
  38. @interface VLCVideoLayer (Private)
  39. /* Method */
  40. - (void)addVoutLayer:(CALayer *)aLayer;
  41. @end
  42. @interface VLCVideoLayer ()
  43. @property (readwrite) BOOL hasVideo;
  44. @end
  45. /******************************************************************************
  46. * Implementation VLCVideoLayer
  47. */
  48. @implementation VLCVideoLayer
  49. @synthesize hasVideo;
  50. - (BOOL)fillScreen
  51. {
  52. return [self.layoutManager fillScreenEntirely];
  53. }
  54. - (void)setFillScreen:(BOOL)fillScreen
  55. {
  56. [self.layoutManager setFillScreenEntirely:fillScreen];
  57. [self setNeedsLayout];
  58. }
  59. @end
  60. /******************************************************************************
  61. * Implementation VLCVideoLayer (Private)
  62. */
  63. @implementation VLCVideoLayer (Private)
  64. /* This is called by the libvlc module 'opengllayer' as soon as there is one
  65. * vout available
  66. */
  67. - (void)addVoutLayer:(CALayer *)voutLayer
  68. {
  69. [CATransaction begin];
  70. voutLayer.name = @"vlcopengllayer";
  71. VLCVideoLayoutManager * layoutManager = [VLCVideoLayoutManager layoutManager];
  72. layoutManager.originalVideoSize = voutLayer.bounds.size;
  73. self.layoutManager = layoutManager;
  74. [self insertSublayer:voutLayer atIndex:0];
  75. [self setNeedsDisplayOnBoundsChange:YES];
  76. [CATransaction commit];
  77. /* Trigger by hand, as it doesn't go through else. Assumed bug from Cocoa */
  78. [self willChangeValueForKey:@"hasVideo"];
  79. self.hasVideo = YES;
  80. [self didChangeValueForKey:@"hasVideo"];
  81. }
  82. - (void)removeVoutLayer:(CALayer*)voutLayer
  83. {
  84. [CATransaction begin];
  85. [voutLayer removeFromSuperlayer];
  86. [CATransaction commit];
  87. /* Trigger by hand, as it doesn't go through else. Assumed bug from Cocoa */
  88. [self willChangeValueForKey:@"hasVideo"];
  89. self.hasVideo = NO;
  90. [self didChangeValueForKey:@"hasVideo"];
  91. }
  92. @end