Skip to content

Commit 2091960

Browse files
Sonyカメラにターゲットを追加
1 parent 5c56ed3 commit 2091960

3 files changed

Lines changed: 35 additions & 17 deletions

File tree

dConnectDevicePlugin/dConnectDeviceSonyCamera/dConnectDeviceSonyCamera/Classes/SonyCameraManager.m

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
*/
3333
#define SONY_CAMERA_NAME @"sony_came_name"
3434

35-
3635
@interface SonyCameraDevice : NSObject
3736

3837
@property (nonatomic) NSString *serviceId;
@@ -216,6 +215,8 @@ - (void) getCameraState:(SonyCameraStateBlock)block {
216215
[cameraStatus isEqualToString:@"IntervalWaitRecStart"] ||
217216
[cameraStatus isEqualToString:@"IntervalWaitRecStop"]) {
218217
status = DConnectMediaStreamRecordingProfileRecorderStatePaused;
218+
} else {
219+
status = DConnectMediaStreamRecordingProfileRecorderStateUnknown;
219220
}
220221

221222
NSDictionary *dic = [weakSelf.remoteApi getStillSize];
@@ -301,9 +302,9 @@ - (void) takePicture:(SonyCameraTakePictureBlock)block {
301302
block(nil);
302303
} else {
303304
NSArray *arr = resultArray[0];
304-
NSString *uri = arr[0];
305-
if (uri) {
306-
block(uri);
305+
NSString *postImageUrl = arr[0];
306+
if (postImageUrl) {
307+
block([weakSelf saveFileFromURL:postImageUrl]);
307308
} else {
308309
block(nil);
309310
}
@@ -472,17 +473,24 @@ - (NSData *) download:(NSString *)requestURL {
472473

473474
- (NSString *) saveFile:(NSData *)data
474475
{
476+
if (!data) {
477+
return nil;
478+
}
479+
475480
// ファイル名作成
476481
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
477482
[formatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"JST"]];
478483
[formatter setDateFormat:@"yyyyMMdd_HHmmss"];
479484
NSString *dateStr = [formatter stringFromDate:[NSDate date]];
480-
NSString *fileName = [NSString stringWithFormat:@"%@_%@.png", SonyFilePrefix, dateStr];
481-
485+
NSString *fileName = [NSString stringWithFormat:@"%@_%@.jpg", SonyFilePrefix, dateStr];
482486
// ファイルを保存
483487
return [self.mFileManager createFileForPath:fileName contents:data];
484488
}
485489

490+
- (NSString *) saveFileFromURL:(NSString *)requestURL {
491+
return [self saveFile:[self download:requestURL]];
492+
}
493+
486494
- (void) saveSonyCameraDevices
487495
{
488496
NSMutableArray *array = [NSMutableArray array];

dConnectDevicePlugin/dConnectDeviceSonyCamera/dConnectDeviceSonyCamera/Classes/profile/SonyCameraMediaStreamRecordingProfile.m

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
#import "SonyCameraManager.h"
1313
#import "RemoteApiList.h"
1414

15+
/*!
16+
@brief ターゲットIDを定義.
17+
*/
18+
#define SONY_TARGET_ID @"sonycamera"
19+
20+
/*!
21+
@brief ターゲット名を定義.
22+
*/
23+
#define SONY_TARGET_NAME @"Sony Camera"
24+
1525
@implementation SonyCameraMediaStreamRecordingProfile
1626

1727
- (instancetype) init {
@@ -96,10 +106,10 @@ - (BOOL) didReceivedGetMediaRecorderRequest:(DConnectRequestMessage *)request re
96106
[manager getCameraState:^(NSString *state, int width, int height) {
97107
if (state) {
98108
DConnectMessage *recorder = [DConnectMessage message];
99-
[DConnectMediaStreamRecordingProfile setRecorderId:@"SonyCamera" target:recorder];
100-
[DConnectMediaStreamRecordingProfile setRecorderName:@"SonyCamera" target:recorder];
109+
[DConnectMediaStreamRecordingProfile setRecorderId:SONY_TARGET_ID target:recorder];
110+
[DConnectMediaStreamRecordingProfile setRecorderName:SONY_TARGET_NAME target:recorder];
101111
[DConnectMediaStreamRecordingProfile setRecorderState:state target:recorder];
102-
[DConnectMediaStreamRecordingProfile setRecorderMIMEType:@"image/png" target:recorder];
112+
[DConnectMediaStreamRecordingProfile setRecorderMIMEType:@"image/jpg" target:recorder];
103113
if (width > 0 && height > 0) {
104114
[DConnectMediaStreamRecordingProfile setRecorderImageWidth:width target:recorder];
105115
[DConnectMediaStreamRecordingProfile setRecorderImageHeight:height target:recorder];
@@ -133,7 +143,7 @@ - (BOOL) didReceivePostTakePhotoRequest:(DConnectRequestMessage *)request respon
133143
}
134144

135145
// ターゲットチェック
136-
if (target && ![target isEqualToString:@"SonyCamera"]) {
146+
if (target && ![target isEqualToString:SONY_TARGET_ID]) {
137147
[response setErrorToInvalidRequestParameterWithMessage:@"target is invalid."];
138148
return YES;
139149
}
@@ -178,7 +188,7 @@ - (BOOL) didReceivePostRecordRequest:(DConnectRequestMessage *)request response:
178188
}
179189

180190
// ターゲットチェック
181-
if (target && ![target isEqualToString:@"SonyCamera"]) {
191+
if (target && ![target isEqualToString:SONY_TARGET_ID]) {
182192
[response setErrorToInvalidRequestParameterWithMessage:@"target is invalid."];
183193
return YES;
184194
}
@@ -222,7 +232,7 @@ - (BOOL) didReceivePutStopRequest:(DConnectRequestMessage *)request response:(DC
222232
}
223233

224234
// ターゲットチェック
225-
if (target && ![target isEqualToString:@"SonyCamera"]) {
235+
if (target && ![target isEqualToString:SONY_TARGET_ID]) {
226236
[response setErrorToInvalidRequestParameterWithMessage:@"target is invalid."];
227237
return YES;
228238
}
@@ -265,7 +275,7 @@ - (BOOL) didReceivePutOnPhotoRequest:(DConnectRequestMessage *)request response:
265275
}
266276

267277
// ターゲットチェック
268-
if (target && ![target isEqualToString:@"SonyCamera"]) {
278+
if (target && ![target isEqualToString:SONY_TARGET_ID]) {
269279
[response setErrorToInvalidRequestParameterWithMessage:@"target is invalid."];
270280
return YES;
271281
}
@@ -296,7 +306,7 @@ - (BOOL) didReceiveDeleteOnPhotoRequest:(DConnectRequestMessage *)request respon
296306
}
297307

298308
// ターゲットチェック
299-
if (target && ![target isEqualToString:@"SonyCamera"]) {
309+
if (target && ![target isEqualToString:SONY_TARGET_ID]) {
300310
[response setErrorToInvalidRequestParameterWithMessage:@"target is invalid."];
301311
return YES;
302312
}
@@ -329,7 +339,7 @@ - (BOOL) didReceivePutPreviewRequest:(DConnectRequestMessage *)request response:
329339
}
330340

331341
// ターゲットチェック
332-
if (target && ![target isEqualToString:@"SonyCamera"]) {
342+
if (target && ![target isEqualToString:SONY_TARGET_ID]) {
333343
[response setErrorToInvalidRequestParameterWithMessage:@"target is invalid."];
334344
return YES;
335345
}
@@ -361,7 +371,7 @@ - (BOOL) didReceiveDeletePreviewRequest:(DConnectRequestMessage *)request respon
361371
}
362372

363373
// ターゲットチェック
364-
if (target && ![target isEqualToString:@"SonyCamera"]) {
374+
if (target && ![target isEqualToString:SONY_TARGET_ID]) {
365375
[response setErrorToInvalidRequestParameterWithMessage:@"target is invalid."];
366376
return YES;
367377
}

dConnectSDK/dConnectSDKForIOS/DConnectSDK/Classes/profile/DConnectMediaStreamRecordingProfile.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#import "DConnectMediaStreamRecordingProfile.h"
1111

1212
NSString *const DConnectMediaStreamRecordingProfileName = @"mediastreamRecording";
13-
NSString *const DConnectMediaStreamRecordingProfileAttrMediaRecorder = @"mediarecorder";
13+
NSString *const DConnectMediaStreamRecordingProfileAttrMediaRecorder = @"recorder";
1414
NSString *const DConnectMediaStreamRecordingProfileAttrTakePhoto = @"takephoto";
1515
NSString *const DConnectMediaStreamRecordingProfileAttrRecord = @"record";
1616
NSString *const DConnectMediaStreamRecordingProfileAttrPause = @"pause";

0 commit comments

Comments
 (0)