]> git.sesse.net Git - vlc/blob - projects/macosx/framework/Sources/VLCVideoLayer.m
More Id and permission fixes.
[vlc] / projects / macosx / framework / Sources / VLCVideoLayer.m
1 /*****************************************************************************
2  * VLCVideoLayer.m: VLC.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
25 #import "VLCVideoLayer.h"
26 #import "VLCLibrary.h"
27 #import "VLCEventManager.h"
28 #import "VLCVideoCommon.h"
29
30 /* Libvlc */
31 #ifdef HAVE_CONFIG_H
32 # include "config.h"
33 #endif
34
35 #include <vlc/vlc.h>
36 #include <vlc/libvlc.h>
37
38 #import <QuartzCore/QuartzCore.h>
39
40 /******************************************************************************
41  * VLCVideoView (Private) 
42  */
43
44 @interface VLCVideoLayer (Private)
45 /* Method */
46 - (void)addVoutLayer:(CALayer *)aLayer;
47 @end
48
49 @interface VLCVideoLayer ()
50 @property (readwrite) BOOL hasVideo;
51 @end
52
53 /******************************************************************************
54  * Implementation VLCVideoLayer 
55  */
56
57 @implementation VLCVideoLayer
58 @synthesize hasVideo;
59
60 - (BOOL)fillScreen
61 {
62     return [self.layoutManager fillScreenEntirely];
63 }
64
65 - (void)setFillScreen:(BOOL)fillScreen
66 {
67     [self.layoutManager setFillScreenEntirely:fillScreen];
68     [self setNeedsLayout];
69 }
70
71 @end
72
73 /******************************************************************************
74  * Implementation VLCVideoLayer  (Private)
75  */
76
77 @implementation VLCVideoLayer (Private)
78
79
80 /* This is called by the libvlc module 'opengllayer' as soon as there is one 
81  * vout available
82  */
83 - (void)addVoutLayer:(CALayer *)voutLayer
84 {
85     [CATransaction begin];
86  
87     voutLayer.name = @"vlcopengllayer";
88     
89     VLCVideoLayoutManager * layoutManager = [VLCVideoLayoutManager layoutManager];
90     layoutManager.originalVideoSize = voutLayer.bounds.size;
91     self.layoutManager = layoutManager;
92     
93     [self insertSublayer:voutLayer atIndex:0];
94     [self setNeedsDisplayOnBoundsChange:YES];
95
96     [CATransaction commit];
97
98     /* Trigger by hand, as it doesn't go through else. Assumed bug from Cocoa */
99     [self willChangeValueForKey:@"hasVideo"];
100     self.hasVideo = YES;
101     [self didChangeValueForKey:@"hasVideo"];
102 }
103
104 - (void)removeVoutLayer:(CALayer*)voutLayer
105 {
106     [CATransaction begin];
107     [voutLayer removeFromSuperlayer];
108     [CATransaction commit];
109     
110     /* Trigger by hand, as it doesn't go through else. Assumed bug from Cocoa */
111     [self willChangeValueForKey:@"hasVideo"];
112     self.hasVideo = NO;
113     [self didChangeValueForKey:@"hasVideo"];
114 }
115
116 @end