ArDrone SDK 1.8 added
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / ControlEngine / iPhone / Classes / OpenGLVideo.m
diff --git a/mardrone/ARDrone_SDK_Version_1_8_20110726/ControlEngine/iPhone/Classes/OpenGLVideo.m b/mardrone/ARDrone_SDK_Version_1_8_20110726/ControlEngine/iPhone/Classes/OpenGLVideo.m
new file mode 100644 (file)
index 0000000..3dad9c1
--- /dev/null
@@ -0,0 +1,56 @@
+/**
+ *  @file OpenGLVideo.m
+ *
+ * Copyright 2009 Parrot SA. All rights reserved.
+ * @author D HAEYER Frederic
+ * @date 2009/10/26
+ */
+#import "OpenGLVideo.h"
+
+static int32_t current_num_picture_decoded = 0;
+
+int get_video_current_numframes( void )
+{
+       return current_num_picture_decoded;
+}
+
+@implementation OpenGLVideo
+
+- (id)initWithPath:(NSString *)path withScreenSize:(CGSize)size
+{
+       if((self = [super initWithPath:path withScaling:FIT_XY withScreenSize:size]) != nil)
+       {
+               
+       }
+       
+       return self;
+}
+
+- (void)drawSelf
+{
+       BOOL needToUpdate = NO;
+       video_stage_config_t *config = video_stage_get();
+       
+       if ((config != NULL) && (config->data != NULL) && (config->num_picture_decoded > 0))
+       {
+               vp_os_mutex_lock( &config->mutex );
+               
+               texture.bytesPerPixel   = config->bytesPerPixel;
+               texture.widthImage              = config->widthImage;
+               texture.heightImage             = config->heightImage;
+               texture.data            = config->data; 
+               
+               if (config->num_picture_decoded > current_num_picture_decoded)
+               {
+                       needToUpdate = YES;
+               }
+               
+               current_num_picture_decoded = config->num_picture_decoded;
+               
+               vp_os_mutex_unlock( &config->mutex );
+       }
+
+       [super drawSelfIfNeeded:needToUpdate];          
+}
+
+@end