]> git.sesse.net Git - vlc/blobdiff - modules/access/screen/mac.c
Update: correctly handle different line endings
[vlc] / modules / access / screen / mac.c
index c8f69569f3380b9d6497d0f5a245275703540575..3e31e8968ee3a3e29591a748444b38607e2ba802 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#import <stdlib.h>
 
 #ifdef HAVE_CONFIG_H
 # import "config.h"
 #endif
 
-#import <vlc/vlc.h>
+#import <vlc_common.h>
 
+// Fix ourselves ColorSync headers that gets included in ApplicationServices.
+#define DisposeCMProfileIterateUPP(a) DisposeCMProfileIterateUPP(CMProfileIterateUPP userUPP __attribute__((unused)))
+#define DisposeCMMIterateUPP(a) DisposeCMMIterateUPP(CMProfileIterateUPP userUPP __attribute__((unused)))
+#define __MACHINEEXCEPTIONS__
 #import <ApplicationServices/ApplicationServices.h>
+
 #import <OpenGL/OpenGL.h>
+#import <OpenGL/gl.h>
+#import <stdlib.h>
 
 typedef int CGSConnectionRef;
 extern CGError CGSNewConnection( void *, CGSConnectionRef * );
@@ -102,10 +108,14 @@ int screen_InitCapture( demux_t *p_demux )
     p_data->screen_width = viewport[2];
     p_data->screen_height = viewport[3];
     
-    p_data->left = 0;
-    p_data->top = 0;
-    p_data->src_width = p_data->screen_width;
-    p_data->src_height = p_data->screen_height;
+    p_data->left = p_sys->i_left;
+    p_data->top = p_sys->i_top;
+    p_data->src_width = var_CreateGetInteger( p_demux, "screen-width" );
+    p_data->src_height = var_CreateGetInteger( p_demux, "screen-height" );
+    if (p_data->src_width <= 0 || p_data->src_height <= 0) {
+      p_data->src_width = p_data->screen_width;
+      p_data->src_height = p_data->screen_height;
+    }
     p_data->dest_width = p_data->src_width;
     p_data->dest_height = p_data->src_height;
     
@@ -124,11 +134,12 @@ int screen_InitCapture( demux_t *p_demux )
     CGLSetOffScreen( p_data->scaled, p_data->dest_width, p_data->dest_height,
                      p_data->dest_width * 4, p_data->scaled_image );
     
-    es_format_Init( &p_sys->fmt, VIDEO_ES, VLC_FOURCC( 'R','V','3','2' ) );
+    es_format_Init( &p_sys->fmt, VIDEO_ES, VLC_CODEC_RGB32 );
     
-    p_sys->fmt.video.i_width = p_data->dest_width;
-    p_sys->fmt.video.i_visible_width = p_data->dest_width;
-    p_sys->fmt.video.i_height = p_data->dest_height;
+    /* p_sys->fmt.video.i_* must set to screen size, not subscreen size */
+    p_sys->fmt.video.i_width = p_data->screen_width;
+    p_sys->fmt.video.i_visible_width = p_data->screen_width;
+    p_sys->fmt.video.i_height = p_data->screen_height;
     p_sys->fmt.video.i_bits_per_pixel = 32;
     
     glGenTextures( 1, &( p_data->texture ) );
@@ -180,7 +191,24 @@ block_t *screen_Capture( demux_t *p_demux )
     if( !( p_block = block_New( p_demux, i_size ) ) )
     {
         msg_Warn( p_demux, "cannot get block" );
-        return 0;
+        return NULL;
+    }
+    
+    CGPoint cursor_pos;
+    CGError cursor_result;
+    
+    cursor_pos.x = 0;
+    cursor_pos.y = 0;
+    
+    cursor_result
+      = CGSGetCurrentCursorLocation( p_data->connection, &cursor_pos );
+    
+    if( p_sys->b_follow_mouse
+        && cursor_result == kCGErrorSuccess )
+    {
+        FollowMouse( p_sys, cursor_pos.x, cursor_pos.y );
+        p_data->left = p_sys->i_left;
+        p_data->top = p_sys->i_top;
     }
     
     CGLSetCurrentContext( p_data->screen );
@@ -211,18 +239,13 @@ block_t *screen_Capture( demux_t *p_demux )
     glEnd();
     glDisable( GL_TEXTURE_2D );
     
-    CGPoint cursor_pos;
     int size;
     int tmp1, tmp2, tmp3, tmp4;
     unsigned char *cursor_image;
     CGRect cursor_rect;
     CGPoint cursor_hot;
     
-    cursor_pos.x = 0;
-    cursor_pos.y = 0;
-    
-    if( CGSGetCurrentCursorLocation( p_data->connection, &cursor_pos )
-        == kCGErrorSuccess
+    if( cursor_result == kCGErrorSuccess
         && CGSGetGlobalCursorDataSize( p_data->connection, &size )
         == kCGErrorSuccess )
     {