Skip to content

Commit

Permalink
Merge pull request #102 from ricohapi/dev/1.12.0
Browse files Browse the repository at this point in the history
Dev/1.12.0
  • Loading branch information
LassicYM authored Feb 3, 2025
2 parents 3360fa8 + cceebf8 commit 889291a
Show file tree
Hide file tree
Showing 36 changed files with 465 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/buildAndTest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
arguments: publishToMavenLocal podPublishXCFramework testReleaseUnitTest
- name: Archive code coverage results
if: always()
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: kotlin-multiplatform/build/reports/tests/testReleaseUnitTest
2 changes: 1 addition & 1 deletion demos/demo-android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ dependencies {
implementation 'com.jakewharton.timber:timber:5.0.1'
implementation 'io.coil-kt:coil-compose:2.2.2'
implementation "io.ktor:ktor-client-cio:2.3.9"
implementation "com.ricoh360.thetaclient:theta-client:1.11.1"
implementation "com.ricoh360.thetaclient:theta-client:1.12.0"

testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0'
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"
Expand Down
2 changes: 1 addition & 1 deletion demos/demo-ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ target 'SdkSample' do
use_frameworks!

# Pods for SdkSample
pod 'THETAClient', '1.11.1'
pod 'THETAClient', '1.12.0'
end
2 changes: 1 addition & 1 deletion demos/demo-react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@react-navigation/native": "^6.1.0",
"@react-navigation/native-stack": "^6.9.5",
"theta-client-react-native": "1.11.1",
"theta-client-react-native": "1.12.0",
"react": "18.2.0",
"react-native": "0.71.14",
"react-native-safe-area-context": "^4.4.1",
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial-android.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- モジュールの`build.gradle``dependencies`に次を追加します。
```
implementation "com.ricoh360.thetaclient:theta-client:1.11.1"
implementation "com.ricoh360.thetaclient:theta-client:1.12.0"
```
- 本 SDK を使用したアプリケーションが動作するスマートフォンと THETA を無線 LAN 接続しておきます。

Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial-android.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- Add following descriptions to the `dependencies` of your module's `build.gradle`.

```
implementation "com.ricoh360.thetaclient:theta-client:1.11.1"
implementation "com.ricoh360.thetaclient:theta-client:1.12.0"
```

- Connect the wireless LAN between THETA and the smartphone that runs on the application using this SDK.
Expand Down
2 changes: 1 addition & 1 deletion flutter/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ dependencies {
implementation("io.ktor:ktor-serialization-kotlinx-json:2.3.9")
implementation("com.soywiz.korlibs.krypto:krypto:4.0.10")

implementation("com.ricoh360.thetaclient:theta-client:1.11.1")
implementation("com.ricoh360.thetaclient:theta-client:1.12.0")
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class ThetaClientFlutterPlugin : FlutterPlugin, MethodCallHandler {
const val notifyIdVideoCaptureStopError = 10081
const val notifyIdVideoCaptureCapturing = 10082
const val notifyIdVideoCaptureStarted = 10083
const val notifyIdConvertVideoFormatsProgress = 10091
}

fun sendNotifyEvent(id: Int, params: Map<String, Any?>) {
Expand Down Expand Up @@ -1486,7 +1487,16 @@ class ThetaClientFlutterPlugin : FlutterPlugin, MethodCallHandler {
val fileUrl = call.argument<String>("fileUrl")!!
val toLowResolution = call.argument<Boolean>("toLowResolution")!!
val applyTopBottomCorrection = call.argument<Boolean>("applyTopBottomCorrection")!!
val response = thetaRepository!!.convertVideoFormats(fileUrl, toLowResolution, applyTopBottomCorrection)
val response = thetaRepository!!.convertVideoFormats(
fileUrl,
toLowResolution,
applyTopBottomCorrection
) { completion ->
sendNotifyEvent(
notifyIdConvertVideoFormatsProgress,
toCaptureProgressNotifyParam(completion)
)
}
result.success(response)
} catch (e: Exception) {
result.error(e.javaClass.simpleName, e.message, null)
Expand Down
11 changes: 9 additions & 2 deletions flutter/ios/Classes/SwiftThetaClientFlutterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ let NOTIFY_PHOTO_CAPTURING = 10071
let NOTIFY_VIDEO_CAPTURE_STOP_ERROR = 10081
let NOTIFY_VIDEO_CAPTURE_CAPTURING = 10082
let NOTIFY_VIDEO_CAPTURE_STARTED = 10083
let NOTIFY_CONVERT_VIDEO_FORMATS_PROGRESS = 10091

public class SwiftThetaClientFlutterPlugin: NSObject, FlutterPlugin, FlutterStreamHandler {
public func onListen(withArguments _: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? {
Expand Down Expand Up @@ -1422,7 +1423,7 @@ public class SwiftThetaClientFlutterPlugin: NSObject, FlutterPlugin, FlutterStre
}

func convertVideoFormats(call: FlutterMethodCall, result: @escaping FlutterResult) {
if thetaRepository == nil {
guard let thetaRepository = thetaRepository else {
let flutterError = FlutterError(code: SwiftThetaClientFlutterPlugin.errorCode, message: SwiftThetaClientFlutterPlugin.messageNotInit, details: nil)
result(flutterError)
return
Expand All @@ -1431,7 +1432,13 @@ public class SwiftThetaClientFlutterPlugin: NSObject, FlutterPlugin, FlutterStre
let fileUrl = arguments["fileUrl"] as! String
let toLowResolution = arguments["toLowResolution"] as! Bool
let applyTopBottomCorrection = arguments["applyTopBottomCorrection"] as! Bool
thetaRepository!.convertVideoFormats(fileUrl: fileUrl, toLowResolution: toLowResolution, applyTopBottomCorrection: applyTopBottomCorrection) { response, error in
thetaRepository.convertVideoFormats(
fileUrl: fileUrl,
toLowResolution: toLowResolution,
applyTopBottomCorrection: applyTopBottomCorrection
) { completion in
self.sendNotifyEvent(id: NOTIFY_CONVERT_VIDEO_FORMATS_PROGRESS, params: toCaptureProgressNotifyParam(value: completion.floatValue))
} completionHandler: { response, error in
if let thetaError = error {
let flutterError = FlutterError(code: SwiftThetaClientFlutterPlugin.errorCode, message: thetaError.localizedDescription, details: nil)
result(flutterError)
Expand Down
4 changes: 2 additions & 2 deletions flutter/ios/theta_client_flutter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
Pod::Spec.new do |s|
s.name = 'theta_client_flutter'
s.version = '1.11.1'
s.version = '1.12.0'
s.summary = 'theta-client plugin project.'
s.description = <<-DESC
theta-client Flutter plugin project.
Expand All @@ -17,7 +17,7 @@ Pod::Spec.new do |s|
s.dependency 'Flutter'
s.platform = :ios, '15.0'

s.dependency 'THETAClient', '1.11.1'
s.dependency 'THETAClient', '1.12.0'

# Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
Expand Down
15 changes: 11 additions & 4 deletions flutter/lib/theta_client_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,15 @@ class ThetaClientFlutter {
/// - @param fileUrl URL of a saved movie file.
/// - @param toLowResolution If true generates lower resolution video, otherwise same resolution.
/// - @param applyTopBottomCorrection apply Top/bottom correction. This parameter is ignored on Theta X.
/// - @param onProgress the block for convertVideoFormats progress.
/// - @return URL of a converted movie file.
/// - @throws Command is currently disabled.
Future<String> convertVideoFormats(String fileUrl, bool toLowResolution,
[bool applyTopBottomCorrection = true]) {
Future<String> convertVideoFormats(String fileUrl,
bool toLowResolution,
[bool applyTopBottomCorrection = true,
void Function(double)? onProgress]) {
return ThetaClientFlutterPlatform.instance.convertVideoFormats(
fileUrl, toLowResolution, applyTopBottomCorrection);
fileUrl, toLowResolution, applyTopBottomCorrection, onProgress);
}

/// Cancels the movie format conversion.
Expand Down Expand Up @@ -2484,7 +2487,11 @@ enum PreviewFormatEnum {

/// For Theta S and SC
// ignore: constant_identifier_names
w640_h320_f10('W640_H320_F10');
w640_h320_f10('W640_H320_F10'),

/// For Theta X
// ignore: constant_identifier_names
w3840_h1920_f30('W3840_H1920_F30');

final String rawValue;

Expand Down
22 changes: 21 additions & 1 deletion flutter/lib/theta_client_flutter_method_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const notifyIdPhotoCapturing = 10071;
const notifyIdVideoCaptureStopError = 10081;
const notifyIdVideoCaptureCapturing = 10082;
const notifyIdVideoCaptureStarted = 10083;
const notifyIdConvertVideoFormatsProgress = 10091;

/// An implementation of [ThetaClientFlutterPlatform] that uses method channels.
class MethodChannelThetaClientFlutter extends ThetaClientFlutterPlatform {
Expand All @@ -45,6 +46,10 @@ class MethodChannelThetaClientFlutter extends ThetaClientFlutterPlatform {
notifyList[id] = callback;
}

bool existsNotify(int id) {
return notifyList.containsKey(id);
}

void removeNotify(int id) {
notifyList.remove(id);
}
Expand Down Expand Up @@ -891,9 +896,22 @@ class MethodChannelThetaClientFlutter extends ThetaClientFlutterPlatform {

@override
Future<String> convertVideoFormats(String fileUrl, bool toLowResolution,
bool applyTopBottomCorrection) async {
bool applyTopBottomCorrection, void Function(double)? onProgress) async {
var completer = Completer<String>();
if (existsNotify(notifyIdConvertVideoFormatsProgress)) {
completer.completeError(Exception('convertVideoFormats is running.'));
return completer.future;
}

try {
enableNotifyEventReceiver();
addNotify(notifyIdConvertVideoFormatsProgress, (params) {
final completion = params?['completion'] as double?;
if (onProgress != null && completion != null) {
onProgress(completion);
}
});

final Map params = <String, dynamic>{
'fileUrl': fileUrl,
'toLowResolution': toLowResolution,
Expand All @@ -904,6 +922,8 @@ class MethodChannelThetaClientFlutter extends ThetaClientFlutterPlatform {
completer.complete(result);
} catch (e) {
completer.completeError(e);
} finally {
removeNotify(notifyIdConvertVideoFormatsProgress);
}
return completer.future;
}
Expand Down
4 changes: 2 additions & 2 deletions flutter/lib/theta_client_flutter_platform_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ abstract class ThetaClientFlutterPlatform extends PlatformInterface {
throw UnimplementedError('stopSelfTimer() has not been implemented.');
}

Future<String> convertVideoFormats(
String fileUrl, bool toLowResolution, bool applyTopBottomCorrection) {
Future<String> convertVideoFormats(String fileUrl, bool toLowResolution,
bool applyTopBottomCorrection, void Function(double)? onProgress) {
throw UnimplementedError('convertVideoFormats() has not been implemented.');
}

Expand Down
2 changes: 1 addition & 1 deletion flutter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: theta_client_flutter
description: THETA Client Flutter plugin project.
version: 1.11.1
version: 1.12.0
homepage:

environment:
Expand Down
122 changes: 122 additions & 0 deletions flutter/test/commands/convert_video_formats_method_channel_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:theta_client_flutter/theta_client_flutter_method_channel.dart';

void main() {
MethodChannelThetaClientFlutter platform = MethodChannelThetaClientFlutter();
const MethodChannel channel = MethodChannel('theta_client_flutter');

TestWidgetsFlutterBinding.ensureInitialized();

setUp(() {
platform = MethodChannelThetaClientFlutter();
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, null);
});

tearDown(() {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, null);
});

test('convertVideoFormats', () async {
String fileUrl = 'http://dummy.MP4';
String result = 'http://dummy_result.MP4';
bool toLowResolution = true;
bool applyTopBottomCorrection = true;
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, (MethodCall methodCall) async {
expect(methodCall.method, 'convertVideoFormats');
expect(platform.notifyList.containsKey(10091), true,
reason: 'add notify progress');

var arguments = methodCall.arguments as Map<dynamic, dynamic>;
expect(arguments['fileUrl'], fileUrl);
expect(arguments['toLowResolution'], toLowResolution);
expect(arguments['applyTopBottomCorrection'], applyTopBottomCorrection);

// native event
platform.onNotify({
'id': 10091,
'params': {
'completion': 0.1,
},
});
await Future.delayed(const Duration(milliseconds: 10));
platform.onNotify({
'id': 10091,
'params': {
'completion': 0.2,
},
});
await Future.delayed(const Duration(milliseconds: 10));

return Future.value(result);
});

int progressCount = 0;
expect(
await platform.convertVideoFormats(
fileUrl, toLowResolution, applyTopBottomCorrection, (completion) {
progressCount += 1;
}),
result);
expect(progressCount, 2);
expect(platform.notifyList.length, 0);

expect(
await platform.convertVideoFormats(
fileUrl, toLowResolution, applyTopBottomCorrection, null),
result);
});

test('error call in running', () async {
String fileUrl = 'http://dummy.MP4';
String result = 'http://dummy_result.MP4';
bool toLowResolution = true;
bool applyTopBottomCorrection = true;
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, (MethodCall methodCall) async {
expect(methodCall.method, 'convertVideoFormats');
await Future.delayed(const Duration(milliseconds: 10));

return Future.value(result);
});

var future = platform.convertVideoFormats(
fileUrl, toLowResolution, applyTopBottomCorrection, (completion) {});

try {
await platform.convertVideoFormats(
fileUrl, toLowResolution, applyTopBottomCorrection, (completion) {});
expect(true, false, reason: 'not exception');
} catch (error) {
expect(
error.toString().contains('convertVideoFormats is running.'), true);
}
await future.then((value) {
expect(value, result);
});
expect(platform.notifyList.length, 0);
});

test('exception', () async {
String fileUrl = 'http://dummy.MP4';
bool toLowResolution = true;
bool applyTopBottomCorrection = true;
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, (MethodCall methodCall) async {
expect(methodCall.method, 'convertVideoFormats');
throw Exception('test error');
});

try {
await platform.convertVideoFormats(
fileUrl, toLowResolution, applyTopBottomCorrection, (completion) {});
expect(true, false, reason: 'not exception');
} catch (error) {
expect(error.toString().contains('test error'), true);
}
expect(platform.notifyList.length, 0);
});
}
1 change: 1 addition & 0 deletions flutter/test/enum_name_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,7 @@ void main() {
[PreviewFormatEnum.w640_h320_f30, 'W640_H320_F30'],
[PreviewFormatEnum.w640_h320_f8, 'W640_H320_F8'],
[PreviewFormatEnum.w640_h320_f10, 'W640_H320_F10'],
[PreviewFormatEnum.w3840_h1920_f30, 'W3840_H1920_F30'],
];
expect(data.length, PreviewFormatEnum.values.length, reason: 'enum count');
for (int i = 0; i < data.length; i++) {
Expand Down
21 changes: 0 additions & 21 deletions flutter/test/theta_client_flutter_method_channel_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1243,27 +1243,6 @@ void main() {
await platform.stopSelfTimer();
});

test('convertVideoFormats', () async {
String fileUrl = 'http://dummy.MP4';
String result = 'http://dummy_result.MP4';
bool toLowResolution = true;
bool applyTopBottomCorrection = true;
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, (MethodCall methodCall) async {
expect(methodCall.method, 'convertVideoFormats');

var arguments = methodCall.arguments as Map<dynamic, dynamic>;
expect(arguments['fileUrl'], fileUrl);
expect(arguments['toLowResolution'], toLowResolution);
expect(arguments['applyTopBottomCorrection'], applyTopBottomCorrection);
return Future.value(result);
});
expect(
await platform.convertVideoFormats(
fileUrl, toLowResolution, applyTopBottomCorrection),
result);
});

test('cancelVideoConvert', () async {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, (MethodCall methodCall) async {
Expand Down
Loading

0 comments on commit 889291a

Please sign in to comment.