Skip to content

Commit

Permalink
Init commit after Appy Days
Browse files Browse the repository at this point in the history
  • Loading branch information
mbogh committed Sep 24, 2012
0 parents commit 4cea0a0
Show file tree
Hide file tree
Showing 151 changed files with 3,655 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Xcode
build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.xcworkspace
!default.xcworkspace
xcuserdata
profile
*.moved-aside

.DS_Store
484 changes: 484 additions & 0 deletions BeMyEyes.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions BeMyEyes/BMEAppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// BMEAppDelegate.h
// BeMyEyes
//
// Created by Morten Bøgh on 15/09/12.
// Copyright (c) 2012 Morten Bøgh. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface BMEAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end
27 changes: 27 additions & 0 deletions BeMyEyes/BMEAppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// BMEAppDelegate.m
// BeMyEyes
//
// Created by Morten Bøgh on 15/09/12.
// Copyright (c) 2012 Morten Bøgh. All rights reserved.
//

#import "BMEAppDelegate.h"
#import "BMELoginViewController.h"

@implementation BMEAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#warning implement user session feature
[self.window makeKeyAndVisible];
if (YES) {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UINavigationController *loginNavigationController = [storyboard instantiateViewControllerWithIdentifier:@"BMELoginNavigationController"];

[self.window.rootViewController presentModalViewController:loginNavigationController animated:NO];
}
return YES;
}

@end
14 changes: 14 additions & 0 deletions BeMyEyes/BMEViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// BMEViewController.h
// BeMyEyes
//
// Created by Morten Bøgh on 15/09/12.
// Copyright (c) 2012 Morten Bøgh. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface BMEViewController : UIViewController
@property (strong, nonatomic) IBOutlet UILabel *titleLabel;

@end
245 changes: 245 additions & 0 deletions BeMyEyes/BMEViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
//
// BMEViewController.m
// BeMyEyes
//
// Created by Morten Bøgh on 15/09/12.
// Copyright (c) 2012 Morten Bøgh. All rights reserved.
//

#import "BMEViewController.h"
#import <OpenTok/Opentok.h>

static NSString* const kApiKey = @"20403682";
static NSString* const kToken = @"T1==cGFydG5lcl9pZD0yMDQwMzY4MiZzZGtfdmVyc2lvbj10YnB5LUBzZGtfdmVyc2lvbkAuQG9wZW50b2suc2RrLnB5dGhvbi5tb2RfdGltZUAmc2lnPWQ2OTZiYWE0NDU4MmJkY2NlYjQyYzNmYTRkZjcyMjRhMDQ1ZjcwYjQ6bm9uY2U9NjQ1NzAwJmNyZWF0ZV90aW1lPTEzNDgxMTgwNzAmcm9sZT1wdWJsaXNoZXImc2Vzc2lvbl9pZD0xX01YNHlNRFF3TXpZNE1uNS1WMlZrSUZObGNDQXhPU0F5TWpveE5Eb3pNQ0JRUkZRZ01qQXhNbjR3TGpVek1qUXpNek4t";
static NSString* const kSessionId = @"1_MX4yMDQwMzY4Mn5-V2VkIFNlcCAxOSAyMjoxNDozMCBQRFQgMjAxMn4wLjUzMjQzMzN-";

@interface BMEViewController () <OTPublisherDelegate, OTSessionDelegate, OTSubscriberDelegate>
@property (weak, nonatomic) IBOutlet UIView *videoPlaceholderView;
@property (weak, nonatomic) IBOutlet UIButton *startButton;
@property (weak, nonatomic) IBOutlet UIButton *disconnectButton;
@property (strong) OTSession *session;
@property (strong) OTPublisher *publisher;
@property (strong) OTSubscriber *subscriber;
@property (assign) BMEUserType userType;
@end

@implementation BMEViewController
@synthesize titleLabel = _titleLabel;
@synthesize videoPlaceholderView;
@synthesize startButton;
@synthesize disconnectButton;

- (void)viewDidLoad
{
[super viewDidLoad];
self.videoPlaceholderView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"BackgroundImage"]];
}

- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.userType = [[NSUserDefaults standardUserDefaults] integerForKey:kBMEUserType];
[self.disconnectButton setTitle:@"Disconnect" forState:UIControlStateNormal];
[self.startButton setTitle:self.userType == BMEUserTypeBlind ? @"Yes, I'm blind!" : @"Let me help!" forState:UIControlStateNormal];

self.titleLabel.text = self.userType == BMEUserTypeBlind ? @"Do you need help?" : @"Thank you - we appreciate you help!";
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)updateSubscriber
{
for (NSString* streamId in _session.streams) {
OTStream* stream = [_session.streams valueForKey:streamId];
if (stream.connection.connectionId != _session.connection.connectionId) {
self.subscriber = [[OTSubscriber alloc] initWithStream:stream delegate:self];
break;
}
}
}

#pragma mark - Actions

- (IBAction)disconnectAction:(id)sender
{
[self doDisconnect];
}

- (IBAction)startAction:(id)sender
{
[self doConnect];

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *connectingViewController = [storyboard instantiateViewControllerWithIdentifier:@"BMEConnectingViewController"];
connectingViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:connectingViewController animated:YES];
}

#pragma mark - OpenTok methods

- (void)doConnect
{
self.session = [[OTSession alloc] initWithSessionId:kSessionId delegate:self];
[self.session connectWithApiKey:kApiKey token:kToken];
}

- (void)doDisconnect
{
[self.session disconnect];
}

- (void)doPublish
{
self.publisher = [[OTPublisher alloc] initWithDelegate:self name:UIDevice.currentDevice.name];
self.publisher.publishAudio = YES;
self.publisher.publishVideo = self.userType == BMEUserTypeBlind ? YES : NO;
self.publisher.cameraPosition = AVCaptureDevicePositionBack;
[self.session publish:self.publisher];
if (self.userType == BMEUserTypeBlind) {
[self.publisher.view setFrame:self.videoPlaceholderView.frame];
[self.view insertSubview:self.publisher.view aboveSubview:self.videoPlaceholderView];
}
}

#pragma mark - OTSessionDelegate methods

- (void)sessionDidConnect:(OTSession*)session
{
NSLog(@"sessionDidConnect: %@", session.sessionId);
NSLog(@"- connectionId: %@", session.connection.connectionId);
NSLog(@"- creationTime: %@", session.connection.creationTime);
[self doPublish];
}

- (void)sessionDidDisconnect:(OTSession*)session
{
NSLog(@"sessionDidDisconnect: %@", session.sessionId);
[self dismissModalViewControllerAnimated:YES];
self.disconnectButton.hidden = YES;
self.startButton.hidden = NO;
}

- (void)session:(OTSession*)session didFailWithError:(OTError*)error
{
[self dismissModalViewControllerAnimated:YES];
self.disconnectButton.hidden = YES;
self.startButton.hidden = NO;

NSLog(@"session: didFailWithError:");
NSLog(@"- error code: %d", error.code);
NSLog(@"- description: %@", error.localizedDescription);

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
}

- (void)session:(OTSession*)mySession didReceiveStream:(OTStream*)stream
{
NSLog(@"session: didReceiveStream:");
NSLog(@"- connection.connectionId: %@", stream.connection.connectionId);
NSLog(@"- connection.creationTime: %@", stream.connection.creationTime);
NSLog(@"- session.sessionId: %@", stream.session.sessionId);
NSLog(@"- streamId: %@", stream.streamId);
NSLog(@"- type %@", stream.type);
NSLog(@"- creationTime %@", stream.creationTime);
NSLog(@"- name %@", stream.name);
NSLog(@"- hasAudio %@", (stream.hasAudio ? @"YES" : @"NO"));
NSLog(@"- hasVideo %@", (stream.hasVideo ? @"YES" : @"NO"));
if (!self.subscriber) {
self.subscriber = [[OTSubscriber alloc] initWithStream:stream delegate:self];
self.subscriber.subscribeToAudio = YES;
self.subscriber.subscribeToVideo = YES;
}
NSLog(@"subscriber.session.sessionId: %@", self.subscriber.session.sessionId);
NSLog(@"- stream.streamId: %@", self.subscriber.stream.streamId);
NSLog(@"- subscribeToAudio %@", (self.subscriber.subscribeToAudio ? @"YES" : @"NO"));
NSLog(@"- subscribeToVideo %@", (self.subscriber.subscribeToVideo ? @"YES" : @"NO"));
}

- (void)session:(OTSession*)session didDropStream:(OTStream*)stream
{
NSLog(@"session didDropStream (%@)", stream.streamId);
if (self.subscriber && [self.subscriber.stream.streamId isEqualToString: stream.streamId]) {
self.subscriber = nil;
[self updateSubscriber];
}

self.disconnectButton.hidden = YES;
self.startButton.hidden = NO;
}

#pragma mark - OTPublisherDelegate methods

- (void)publisher:(OTPublisher*)publisher didFailWithError:(OTError*) error
{
self.disconnectButton.hidden = YES;
self.startButton.hidden = NO;

[self dismissModalViewControllerAnimated:YES];

NSLog(@"publisher: %@ didFailWithError:", publisher);
NSLog(@"- error code: %d", error.code);
NSLog(@"- description: %@", error.localizedDescription);

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
}

- (void)publisherDidStartStreaming:(OTPublisher *)publisher
{
self.disconnectButton.hidden = NO;
self.startButton.hidden = YES;

[self dismissModalViewControllerAnimated:YES];

NSLog(@"publisherDidStartStreaming: %@", publisher);
NSLog(@"- publisher.session: %@", publisher.session.sessionId);
NSLog(@"- publisher.name: %@", publisher.name);
}

-(void)publisherDidStopStreaming:(OTPublisher*)publisher
{
NSLog(@"publisherDidStopStreaming:%@", publisher);

self.disconnectButton.hidden = YES;
self.startButton.hidden = NO;
}

#pragma mark - OTSubscriberDelegate methods

- (void)subscriberDidConnectToStream:(OTSubscriber*)subscriber
{
NSLog(@"subscriberDidConnectToStream (%@)", subscriber.stream.connection.connectionId);
if (self.userType == BMEUserTypeHelper && ![subscriber.stream.connection.connectionId isEqualToString:self.session.connection.connectionId]) {
[subscriber.view setFrame:self.videoPlaceholderView.frame];
[self.view insertSubview:subscriber.view aboveSubview:self.videoPlaceholderView];
}
}

- (void)subscriberVideoDataReceived:(OTSubscriber*)subscriber {
NSLog(@"subscriberVideoDataReceived (%@)", subscriber.stream.streamId);
}

- (void)subscriber:(OTSubscriber *)subscriber didFailWithError:(OTError *)error
{
NSLog(@"subscriber: %@ didFailWithError: ", subscriber.stream.streamId);
NSLog(@"- code: %d", error.code);
NSLog(@"- description: %@", error.localizedDescription);
}

- (void)viewDidUnload {
[self setStartButton:nil];
[self setVideoPlaceholderView:nil];
[self setDisconnectButton:nil];
[self setTitleLabel:nil];
[super viewDidUnload];
}
@end
58 changes: 58 additions & 0 deletions BeMyEyes/BeMyEyes-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http:https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>Be My Eyes</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>Icon.png</string>
<string>[email protected]</string>
<string>Default.png</string>
</array>
<key>UIPrerenderedIcon</key>
<true/>
</dict>
</dict>
<key>CFBundleIdentifier</key>
<string>com.justabeech.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>10</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIMainStoryboardFile</key>
<string>MainStoryboard</string>
<key>UIPrerenderedIcon</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleBlackOpaque</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
Loading

0 comments on commit 4cea0a0

Please sign in to comment.