ArDrone SDK 1.8 added
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / ControlEngine / iPhone / Classes / OpenGLVideo.m
1 /**
2  *  @file OpenGLVideo.m
3  *
4  * Copyright 2009 Parrot SA. All rights reserved.
5  * @author D HAEYER Frederic
6  * @date 2009/10/26
7  */
8 #import "OpenGLVideo.h"
9
10 static int32_t current_num_picture_decoded = 0;
11
12 int get_video_current_numframes( void )
13 {
14         return current_num_picture_decoded;
15 }
16
17 @implementation OpenGLVideo
18
19 - (id)initWithPath:(NSString *)path withScreenSize:(CGSize)size
20 {
21         if((self = [super initWithPath:path withScaling:FIT_XY withScreenSize:size]) != nil)
22         {
23                 
24         }
25         
26         return self;
27 }
28
29 - (void)drawSelf
30 {
31         BOOL needToUpdate = NO;
32         video_stage_config_t *config = video_stage_get();
33         
34         if ((config != NULL) && (config->data != NULL) && (config->num_picture_decoded > 0))
35         {
36                 vp_os_mutex_lock( &config->mutex );
37                 
38                 texture.bytesPerPixel   = config->bytesPerPixel;
39                 texture.widthImage              = config->widthImage;
40                 texture.heightImage             = config->heightImage;
41                 texture.data            = config->data; 
42                 
43                 if (config->num_picture_decoded > current_num_picture_decoded)
44                 {
45                         needToUpdate = YES;
46                 }
47                 
48                 current_num_picture_decoded = config->num_picture_decoded;
49                 
50                 vp_os_mutex_unlock( &config->mutex );
51         }
52
53         [super drawSelfIfNeeded:needToUpdate];          
54 }
55
56 @end