Permalink
Browse files

Added an init method to initialize the dictionary using data from a C…

…MSampleBufferRef
  • Loading branch information...
gpambrozio committed May 17, 2011
1 parent 5b6a1f2 commit f2cbd444cb75910c6b0200f5edcc4133a144ad6e
Showing with 10 additions and 1 deletion.
  1. +3 −0 GusUtils/NSMutableDictionary+ImageMetadata.h
  2. +7 −1 GusUtils/NSMutableDictionary+ImageMetadata.m
@@ -5,11 +5,14 @@
//
#import <Foundation/Foundation.h>
+#import <CoreMedia/CoreMedia.h>
#import <CoreLocation/CoreLocation.h>
#import <UIKit/UIKit.h>
@interface NSMutableDictionary (ImageMetadataCategory)
+- (id)initWithImageSampleBuffer:(CMSampleBufferRef) imageDataSampleBuffer;
+
- (void)setLocation:(CLLocation *)currentLocation;
- (void)setUserComment:(NSString*)comment;
- (void)setDateOriginal:(NSDate *)date;
@@ -19,8 +19,14 @@ @implementation FIX_CATEGORY_BUG_ImageMetadataCategory @end
@implementation NSMutableDictionary (ImageMetadataCategory)
-// Mostly from here: http://stackoverflow.com/questions/3884060/need-help-in-saving-geotag-info-with-photo-on-ios4-1
+- (id)initWithImageSampleBuffer:(CMSampleBufferRef) imageDataSampleBuffer {
+ CFDictionaryRef metadataDict = CMCopyDictionaryOfAttachments(NULL, imageDataSampleBuffer, kCMAttachmentMode_ShouldPropagate);
+ self = [self initWithDictionary:(NSDictionary*)metadataDict];
+ CFRelease(metadataDict);
+ return self;
+}
+// Mostly from here: http://stackoverflow.com/questions/3884060/need-help-in-saving-geotag-info-with-photo-on-ios4-1
- (void)setLocation:(CLLocation *)currentLocation {
if (currentLocation) {

0 comments on commit f2cbd44

Please sign in to comment.