Skip to content

Commit

Permalink
Add Settings Bundle, Use InAppSettingsKit as a submodule, Add support…
Browse files Browse the repository at this point in the history
… for multiple video recordings. Fix crash on 2nd recording.
  • Loading branch information
coolstar committed Jan 22, 2013
1 parent af135f9 commit 374f12d
Show file tree
Hide file tree
Showing 9 changed files with 298 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "InAppSettingsKit"]
path = InAppSettingsKit
url = https://github.com/futuretap/InAppSettingsKit.git
157 changes: 147 additions & 10 deletions RecordMyScreen.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions RecordMyScreen/CSAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "CSAppDelegate.h"
#import "CSRecordViewController.h"
#import "CSRecordingListViewController.h"
#import "IASKAppSettingsViewController.h"

@implementation CSAppDelegate

Expand All @@ -23,8 +24,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
UINavigationController *savedNavVC;
UINavigationController *savedNavVC,*settingsNavVC;
UIViewController *recordVC,*savedVC;
IASKAppSettingsViewController *settingsVC;

// Check for iPad
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
Expand All @@ -37,8 +39,15 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
savedNavVC = [[[UINavigationController alloc] initWithRootViewController:savedVC] autorelease];
savedNavVC.navigationBar.barStyle = UIBarStyleBlack;

settingsVC = [[[IASKAppSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped] autorelease];
settingsVC.title = NSLocalizedString(@"Settings", @"");
settingsVC.tabBarItem = [[[UITabBarItem alloc] initWithTitle:settingsVC.title image:[UIImage imageNamed:@"settings"] tag:0] autorelease];
settingsVC.showDoneButton = NO;
settingsNavVC = [[[UINavigationController alloc] initWithRootViewController:settingsVC] autorelease];
settingsNavVC.navigationBar.barStyle = UIBarStyleBlack;

self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = @[recordVC,savedNavVC];
self.tabBarController.viewControllers = @[recordVC,savedNavVC,settingsNavVC];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
Expand Down
29 changes: 24 additions & 5 deletions RecordMyScreen/CSRecordViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,11 @@ - (void)record: (id)sender
[[AVAudioSession sharedInstance] setActive:YES error:&sessionError];

// Set the number of audio channels
NSNumber *audioChannels = [[NSUserDefaults standardUserDefaults] objectForKey:@"channels"];
NSNumber *sampleRate = [[NSUserDefaults standardUserDefaults] objectForKey:@"samplerate"];
NSDictionary *audioSettings = @{
AVNumberOfChannelsKey : [NSNumber numberWithInt:2]
AVNumberOfChannelsKey : audioChannels ? audioChannels : [NSNumber numberWithInt:2],
AVSampleRateKey : sampleRate ? sampleRate : [NSNumber numberWithFloat:44100.0f]
};

// Set output path of the audio file
Expand Down Expand Up @@ -281,7 +284,7 @@ - (void)captureShot:(CMTime)frameTime
static NSMutableArray * buffers = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
buffers = [NSMutableArray array];
buffers = [[NSMutableArray alloc] init];
});

IOSurfaceLock(_surface, 0, nil);
Expand All @@ -298,7 +301,7 @@ - (void)captureShot:(CMTime)frameTime
//memcpy(rawData, baseAddr, totalBytes);
NSMutableData * rawDataObj = nil;
if (buffers.count == 0)
rawDataObj = [NSMutableData dataWithBytes:baseAddr length:totalBytes];
rawDataObj = [[NSMutableData dataWithBytes:baseAddr length:totalBytes] retain];
else @synchronized(buffers) {
rawDataObj = [buffers lastObject];
memcpy((void *)[rawDataObj bytes], baseAddr, totalBytes);
Expand Down Expand Up @@ -380,6 +383,14 @@ - (void)setupVideoContext

// Get the output file path
NSString *outPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/video.mp4"];
if (![[[NSUserDefaults standardUserDefaults] objectForKey:@"record"] boolValue]){
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM:dd:yyyy h:mm:ss a"];
NSString *date = [dateFormatter stringFromDate:[NSDate date]];
NSString *outName = [NSString stringWithFormat:@"Documents/%@.mp4",date];
outPath = [NSHomeDirectory() stringByAppendingPathComponent:outName];
[dateFormatter release];
}

NSError *error = nil;

Expand All @@ -404,10 +415,18 @@ - (void)setupVideoContext
[compressionProperties setObject: AVVideoProfileLevelH264Main41 forKey: AVVideoProfileLevelKey];

// Setup output settings, Codec, Width, Height, Compression
int videowidth = _width;
int videoheight = _height;
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"vidsize"]) {
if (![[[NSUserDefaults standardUserDefaults] objectForKey:@"vidsize"] boolValue]){
videowidth /= 2; //If it's set to half-size, divide both by 2.
videoheight /= 2;
}
}
NSMutableDictionary *outputSettings = [NSMutableDictionary dictionaryWithObjectsAndKeys:
AVVideoCodecH264, AVVideoCodecKey,
[NSNumber numberWithInt:_width], AVVideoWidthKey,
[NSNumber numberWithInt:_height], AVVideoHeightKey,
[NSNumber numberWithInt:videowidth], AVVideoWidthKey,
[NSNumber numberWithInt:videoheight], AVVideoHeightKey,
compressionProperties, AVVideoCompressionPropertiesKey,
nil];

Expand Down
Binary file modified RecordMyScreen/headers/.DS_Store
Binary file not shown.
Binary file added RecordMyScreen/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added RecordMyScreen/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
113 changes: 113 additions & 0 deletions Settings.bundle/Root.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>Recording Settings</string>
</dict>
<dict>
<key>Type</key>
<string>PSMultiValueSpecifier</string>
<key>Title</key>
<string>Record</string>
<key>Key</key>
<string>record</string>
<key>DefaultValue</key>
<integer>0</integer>
<key>Titles</key>
<array>
<string>Screen Only</string>
</array>
<key>Values</key>
<array>
<integer>0</integer>
</array>
</dict>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>Video Settings</string>
</dict>
<dict>
<key>Type</key>
<string>PSMultiValueSpecifier</string>
<key>Title</key>
<string>Video Size</string>
<key>Key</key>
<string>vidsize</string>
<key>DefaultValue</key>
<integer>1</integer>
<key>Titles</key>
<array>
<string>Native</string>
<string>Half</string>
</array>
<key>Values</key>
<array>
<integer>1</integer>
<integer>0</integer>
</array>
</dict>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>Audio Settings</string>
</dict>
<dict>
<key>Type</key>
<string>PSMultiValueSpecifier</string>
<key>Title</key>
<string>Sample Rate</string>
<key>Key</key>
<string>samplerate</string>
<key>DefaultValue</key>
<integer>44100</integer>
<key>Titles</key>
<array>
<string>44100 Hz</string>
<string>22050 Hz</string>
<string>16000 Hz</string>
<string>11025 Hz</string>
<string>8000 Hz</string>
</array>
<key>Values</key>
<array>
<integer>44100</integer>
<integer>22050</integer>
<integer>16000</integer>
<integer>11025</integer>
<integer>8000</integer>
</array>
</dict>
<dict>
<key>Type</key>
<string>PSMultiValueSpecifier</string>
<key>Title</key>
<string>Channels</string>
<key>Key</key>
<string>channels</string>
<key>DefaultValue</key>
<integer>2</integer>
<key>Titles</key>
<array>
<string>Mono</string>
<string>Stereo</string>
</array>
<key>Values</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
</dict>
</array>
<key>StringsTable</key>
<string>Root</string>
</dict>
</plist>
Binary file added Settings.bundle/en.lproj/Root.strings
Binary file not shown.

0 comments on commit 374f12d

Please sign in to comment.