Skip to content

Commit

Permalink
Merge pull request #13 from Noreaster76/replace_qtkit
Browse files Browse the repository at this point in the history
Replace QTKit
  • Loading branch information
rharder authored Oct 2, 2017
2 parents ac737a8 + d1b9722 commit d947e68
Show file tree
Hide file tree
Showing 8 changed files with 563 additions and 643 deletions.
79 changes: 79 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
build/
DerivedData

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata

## Other
*.xccheckout
*.moved-aside
*.xcuserstate
*.xcscmblueprint

## Obj-C/Swift specific
*.hmap
*.ipa

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.

fastlane/report.xml
fastlane/screenshots

# OS X
#
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
59 changes: 16 additions & 43 deletions ImageSnap.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,82 +4,55 @@
//
// Created by Robert Harder on 9/10/09.
//

#import <AVFoundation/AVFoundation.h>
#import <Cocoa/Cocoa.h>
#import <QTKit/QTKit.h>
#include "ImageSnap.h"

#define error(...) fprintf(stderr, __VA_ARGS__)
#define console(...) (!g_quiet && printf(__VA_ARGS__))
#define verbose(...) (g_verbose && !g_quiet && fprintf(stderr, __VA_ARGS__))

BOOL g_verbose = NO;
BOOL g_quiet = NO;
//double g_timelapse = -1;
NSString *VERSION = @"0.2.5";

static BOOL g_verbose;
static BOOL g_quiet;

@interface ImageSnap : NSObject {

QTCaptureSession *mCaptureSession;
QTCaptureDeviceInput *mCaptureDeviceInput;
QTCaptureDecompressedVideoOutput *mCaptureDecompressedVideoOutput;
CVImageBufferRef mCurrentImageBuffer;
}
FOUNDATION_EXPORT NSString *const VERSION;

@interface ImageSnap : NSObject

/**
* Returns all attached QTCaptureDevice objects that have video.
* This includes video-only devices (QTMediaTypeVideo) and
* audio/video devices (QTMediaTypeMuxed).
*
* @return autoreleased array of video devices
* @return array of video devices
*/
+(NSArray *)videoDevices;
+ (NSArray *)videoDevices;

/**
* Returns the default QTCaptureDevice object for video
* or nil if none is found.
*/
+(QTCaptureDevice *)defaultVideoDevice;
+ (AVCaptureDevice *)defaultVideoDevice;

/**
* Returns the QTCaptureDevice with the given name
* or nil if the device cannot be found.
*/
+(QTCaptureDevice *)deviceNamed:(NSString *)name;

/**
* Writes an NSImage to disk, formatting it according
* to the file extension. If path is "-" (a dash), then
* an jpeg representation is written to standard out.
*/
+ (BOOL) saveImage:(NSImage *)image toPath: (NSString*)path;

/**
* Converts an NSImage to raw NSData according to a given
* format. A simple string search is performed for such
* characters as jpeg, tiff, png, and so forth.
*/
+(NSData *)dataFrom:(NSImage *)image asType:(NSString *)format;
+ (AVCaptureDevice *)deviceNamed:(NSString *)name;

- (void)setUpSessionWithDevice:(AVCaptureDevice *)device;

- (void)getReadyToTakePicture;

/**
* Primary one-stop-shopping message for capturing an image.
* Activates the video source, saves a frame, stops the source,
* and saves the file.
*/
+(BOOL)saveSingleSnapshotFrom:(QTCaptureDevice *)device toFile:(NSString *)path;
+(BOOL)saveSingleSnapshotFrom:(QTCaptureDevice *)device toFile:(NSString *)path withWarmup:(NSNumber *)warmup;
+(BOOL)saveSingleSnapshotFrom:(QTCaptureDevice *)device toFile:(NSString *)path withWarmup:(NSNumber *)warmup withTimelapse:(NSNumber *)timelapse;

-(id)init;
-(void)dealloc;


-(BOOL)startSession:(QTCaptureDevice *)device;
-(NSImage *)snapshot;
-(void)stopSession;

- (void)saveSingleSnapshotFrom:(AVCaptureDevice *)device
toFile:(NSString *)path
withWarmup:(NSNumber *)warmup
withTimelapse:(NSNumber *)timelapse;

@end
Loading

0 comments on commit d947e68

Please sign in to comment.