Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
// Released under the MIT license
// http://opensource.org/licenses/mit-license.php
//

#import <UserNotifications/UserNotifications.h>
#import <Photos/Photos.h>
#import <MobileCoreServices/UTCoreTypes.h>
#import "DPHostCameraRecorder.h"
#import "DPHostRecorder.h"
#import "DPHostUtils.h"
#import "DPHostRecorderUtils.h"
@interface DPHostCameraRecorder()

static NSString *const kDPHostStartPreviewNotificationId = @"kDPHostStartPreviewNotificationId";
@interface DPHostCameraRecorder()<UNUserNotificationCenterDelegate>
@property (nonatomic) DPHostSimpleHttpServer *httpServer;
/// Preview APIでプレビュー画像URIの配送を行うかどうか。
@property (nonatomic) BOOL sendPreview;
Expand Down Expand Up @@ -117,14 +119,15 @@ - (void)takePhotoWithSuccessCompletion:(void (^)(NSURL *assetURL))successComplet
}
[weakSelf saveFileWithCompletionHandler:^(NSURL *assetURL, NSError *error) {

if ([weakSelf.session isRunning]) {
if ([weakSelf.session isRunning] && !weakSelf.sendPreview) {
[weakSelf.session stopRunning];
}
if (error) {
failCompletion(error.localizedDescription);
} else {
successCompletion(assetURL);
}

}];
}];
}
Expand Down Expand Up @@ -179,6 +182,7 @@ - (void)startWebServerWithSuccessCompletion:(void (^)(NSString *uri))successComp
failCompletion(@"MJPEG Server cannot running.");
return;
}
[self showPreviewNotification];
successCompletion(url);
}

Expand All @@ -193,7 +197,7 @@ - (void)stopWebServer
self.sendPreview = NO;
// 次回プレビュー開始時に影響を与えない為に、初期値(無効値)を設定する。
self.lastPreviewTimestamp = kCMTimeInvalid;

[self hidePreviewNotification];
}

#pragma mark - Private Method
Expand Down Expand Up @@ -420,4 +424,60 @@ - (void) sendPreviewDataWithSampleBuffer:(CMSampleBufferRef)sampleBuffer
}

}

#pragma mark - Notification Control
- (void)showPreviewNotification
{
UNMutableNotificationContent* content = [[UNMutableNotificationContent alloc] init];
content.title = @"カメラ撮影中(iOS Host Camera Preview)";
content.body = @"タップして撮影を停止します。";
// Deliver the notification in five seconds.
UNTimeIntervalNotificationTrigger* trigger = [UNTimeIntervalNotificationTrigger
triggerWithTimeInterval:1
repeats:NO];
UNNotificationRequest* nRequest = [UNNotificationRequest
requestWithIdentifier:kDPHostStartPreviewNotificationId
content:content
trigger:trigger];

// Schedule the notification.
dispatch_async(dispatch_get_main_queue(), ^{
UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center addNotificationRequest:nRequest
withCompletionHandler:^(NSError * _Nullable error) {
}];

});
}

- (void)hidePreviewNotification
{
UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
[center getDeliveredNotificationsWithCompletionHandler:^(NSArray<UNNotification *> * _Nonnull notifications) {
for (UNNotification *notification in notifications) {
NSString *currentId = notification.request.identifier;
if ([currentId isEqualToString:kDPHostStartPreviewNotificationId]) {
[center removeDeliveredNotificationsWithIdentifiers:@[kDPHostStartPreviewNotificationId]];
return;
}
}
}];

}
#pragma mark - Notification Delegate
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)(void))completionHandler {
completionHandler();
[self stopWebServer];
}

- (void)userNotificationCenter:(UNUserNotificationCenter *)center
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
completionHandler(UNNotificationPresentationOptionBadge |
UNNotificationPresentationOptionSound |
UNNotificationPresentationOptionAlert);
};
@end
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ - (instancetype)init
_notificationInfoDict = @{}.mutableCopy;

[self setNotificationIdLength: 3];

UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
dispatch_async(dispatch_get_main_queue(), ^{
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
});

// API登録(didReceivePostNotifyRequest相当)
NSString *postNotifyRequestApiPath = [self apiPath: nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ - (void) setZoomByDirection:(NSString *)direction
__block typeof(self) weakSelf = self;

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *tmpMovement = movement;
NSString *tmpMovement = [movement stringByReplacingOccurrencesOfString:@"in-" withString:@""];
if ([movement isEqualToString:@"max"]) {
tmpMovement = @"start";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
// DPOmnidirectionalImageProfile.m
// dConnectDeviceTheta
//
// Created by 星 貴之 on 2015/08/23.
// Copyright (c) 2015年 DOCOMO. All rights reserved.
// Copyright (c) 2015 NTT DOCOMO, INC.
// Released under the MIT license
// http://opensource.org/licenses/mit-license.php
//


#import "DPOmnidirectionalImageProfile.h"

NSString *const DPOmnidirectionalImageProfileName = @"omnidirectionalImage";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ img.plus {

.ac_menu div.ac_content {
box-shadow:0px 1px 5px #AAA inset;
border-bottom: thin solid #558BCA;
background :#f4f4f4;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ body {
margin: 0px;
padding: 0px;
}
div.title {
background-color: #5B9CFC;
padding: 10px;
font-weight: bold;
color: #FFFFFF;
}
a.back{
color:#FFFFFF;
}

div.request_param {
padding: 12px 8px 8px 8px;
Expand Down Expand Up @@ -200,12 +209,31 @@ div.test {
input, select {
vertical-align: middle;
}
div.title {
background-color: #5B9CFC;
padding: 10px;
font-weight: bold;
color: #FFFFFF;

label {
animation-name: fadeIn;
animation-duration: 0.3s;
animation-iteration-count: 1;
animation-timing-function: ease-out;
animation-fill-mode: backwards;
}
a.back{
color:#FFFFFF;

.ac_menu div.ac_content {
animation-name: fadeIn;
animation-duration: 0.3s;
animation-iteration-count: 1;
animation-timing-function: ease-out;
animation-fill-mode: backwards;
}

@keyframes fadeIn {
from {
transform:translateY(300px);
opacity: 0.0;
}

to {
transform:translateY(0px);
opacity: 1.0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
body {
background-color: #FBFBFB;
}
div.title {
background-color: #5B9CFC;
padding: 10px;
font-weight: bold;
color: #FFFFFF;
}
a.back{
color:#FFFFFF;
}

img.icon {
width: 42px;
Expand Down Expand Up @@ -38,20 +47,28 @@ div.profileName {
border-right: solid 1px #E5E5E5;
box-shadow: 0px 0px 2px #F3F3F3;
color: #5B9CFC;
}

animation-name: fadeIn;
animation-duration: 0.3s;
animation-iteration-count: 1;
animation-timing-function: cubic-bezier(0, 1.1, 1, 1.1);
animation-fill-mode: backwards;
}

a { text-decoration: none; }
a:link { color: #5B9CFC; }
a:visited { color: #5B9CFC; }
a:hover { color: #5B9CFC; }
a:active { color: #5B9CFC; }
div.title {
background-color: #5B9CFC;
padding: 10px;
font-weight: bold;
color: #FFFFFF;
}
a.back{
color:#FFFFFF;

@keyframes fadeIn {
from {
transform: scale(0.0, 0.0);
opacity: 0.0;
}

to {
transform: scale(1.0, 1.0);
opacity: 1.0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ div.title {
a.back{
color:#FFFFFF;
}

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<script id="profileCell" type="text/x-template">
<a href="{#url}">
<div class="grid">
<div>
<div style="animation-delay: {#delay}s;">
<img class="icon" src="{#icon}"><br>
<div class="profileName">{#content}</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@

var main = (function(parent, global) {

var delay = 0;

function init() {
util.init(function(name, json) {
createSupportApis(json);
});

}
parent.init = init;

function back() {
location.href = "./index.html?serviceId=" + util.getServiceId();
}
parent.back = back;

function onChangeValue(nav, name) {
var elem = document.forms[nav];
elem['t_' + name].value = elem[name].value;
Expand Down Expand Up @@ -124,15 +126,15 @@ var main = (function(parent, global) {
setRequestText(nav, createRequest(method + " " + path));

if (method == 'PUT') {
dConnect.addEventListener(uri, function(json) {
util.addEventListener(uri, function(json) {
setEventText(nav, createEvent(util.formatJSON(json)));
}, function(json) {
setResponseText(nav, createResponse(util.formatJSON(JSON.stringify(json))));
}, function(errorCode, errorMessage) {
setResponseText(nav, createResponse("errorCode=" + errorCode + " errorMessage=" + errorMessage));
});
} else {
dConnect.removeEventListener(uri, function(json) {
util.removeEventListener(uri, function(json) {
setResponseText(nav, createResponse(util.formatJSON(JSON.stringify(json))));
}, function(errorCode, errorMessage) {
setResponseText(nav, createResponse("errorCode=" + errorCode + " errorMessage=" + errorMessage));
Expand Down Expand Up @@ -246,7 +248,6 @@ var main = (function(parent, global) {
};
return util.createTemplate('param_slider', data);
}

function createBooleanParam(name, value, on) {
var data = {
'name' : name,
Expand All @@ -256,6 +257,7 @@ var main = (function(parent, global) {
};
return util.createTemplate('param_boolean', data);
}


function createRequest(body) {
var data = {
Expand Down Expand Up @@ -346,8 +348,10 @@ var main = (function(parent, global) {
var data = {
'title': method.toUpperCase() + ' ' + createDConnectPath(basePath, path),
'nav' : method + '_' + path,
'content' : createParameter(method, basePath, path, param['x-type'], param.parameters)
'content' : createParameter(method, basePath, path, param['x-type'], param.parameters),
'delay' : delay
};
delay += 0.1;
return util.createTemplate('command', data);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ var main = (function(parent, global) {
'connection' : 'images/icon33_connect6.png',
};

var delay = 0;

function init() {
util.init(function(name, json) {
createProfileList(json.supports);
Expand All @@ -39,8 +41,10 @@ var main = (function(parent, global) {
var data = {
'url' : url,
'content' : content,
'icon' : icon
'icon' : icon,
'delay' : delay
};
delay += 0.08;
return util.createTemplate('profileCell', data);
}

Expand Down
Loading