Skip to content

Commit

Permalink
Merge pull request #73 from ricohapi/dev/1.8.0
Browse files Browse the repository at this point in the history
Dev/1.8.0
  • Loading branch information
simago authored Apr 3, 2024
2 parents bc2ba21 + ebaad52 commit 0bc25be
Show file tree
Hide file tree
Showing 78 changed files with 1,617 additions and 323 deletions.
19 changes: 10 additions & 9 deletions demos/demo-android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,25 @@ android {
namespace 'com.ricoh360.thetaclient.thetaClientDemo'
}


dependencies {
def lifecycle_version = "2.7.0"

implementation 'androidx.core:core-ktx:1.12.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2'
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.6.2'
implementation 'androidx.activity:activity-compose:1.8.0'
implementation "androidx.navigation:navigation-compose:2.7.5"
implementation 'androidx.webkit:webkit:1.8.0'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
implementation 'androidx.activity:activity-compose:1.8.2'
implementation "androidx.navigation:navigation-compose:2.7.7"
implementation 'androidx.webkit:webkit:1.10.0'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0'
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0'
implementation 'com.jakewharton.timber:timber:5.0.1'
implementation 'io.coil-kt:coil-compose:2.2.2'
implementation "io.ktor:ktor-client-cio:2.1.3"
implementation "com.ricoh360.thetaclient:theta-client:1.7.1"
implementation "com.ricoh360.thetaclient:theta-client:1.8.0"

testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0'
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"
Expand Down
1 change: 1 addition & 0 deletions demos/demo-android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.ThetaSdkSampleApp"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".MainActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import io.ktor.utils.io.streams.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import timber.log.Timber

/**
Expand All @@ -31,7 +32,7 @@ class ThetaViewModel(
val thetaFilesState: StateFlow<ThetaRepository.ThetaFiles?> = _thetaFilesState

private val _previewFlow = MutableStateFlow<Bitmap?>(null)
val previewFlow: StateFlow<Bitmap?> = _previewFlow
val previewFlow: StateFlow<Bitmap?> = _previewFlow.asStateFlow()
private var previewJob: Job? = null

init {
Expand Down Expand Up @@ -70,11 +71,24 @@ class ThetaViewModel(
}
previewJob = viewModelScope.launch(ioDispatcher) {
kotlin.runCatching {
var beforeBitmap: Bitmap? = null
thetaRepository.getLivePreview()
.collect { byteReadPacket ->
ensureActive()
byteReadPacket.inputStream().use {
_previewFlow.emit(BitmapFactory.decodeStream(it))
val options = BitmapFactory.Options()
options.inMutable = true
val bitmap = BitmapFactory.decodeStream(it, null, options)
_previewFlow.emit(bitmap)
// Explicitly release the bitmap since it may not be released by the cpu load.
viewModelScope.launch(Dispatchers.Main) {
beforeBitmap?.let {
if (!it.isRecycled) {
it.recycle()
}
}
beforeBitmap = bitmap
}
}
byteReadPacket.release()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal class ThetaViewModelTest {
@Test
fun shootingTest() = runTest {
class TakenCallback : PhotoCapture.TakePictureCallback {
override fun onSuccess(fileUrl: String) {
override fun onSuccess(fileUrl: String?) {
assertTrue(true, fileUrl)
}

Expand Down
4 changes: 2 additions & 2 deletions demos/demo-android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
buildscript {
ext {
compose_version = '1.5.3' // depends on Kotlin 1.7.10
compose_version = '1.5.3' // depends on Kotlin 1.9.10
kotlin_version = '1.9.10'
coroutines_version = '1.6.4'
coroutines_version = '1.7.3'
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
Expand Down
2 changes: 0 additions & 2 deletions demos/demo-flutter/android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@

-keep class com.ricoh360.thetaclient.** { *; }
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.7.1'
pod 'THETAClient', '1.8.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.7.1",
"theta-client-react-native": "1.8.0",
"react": "18.2.0",
"react-native": "0.71.14",
"react-native-safe-area-context": "^4.4.1",
Expand Down
24 changes: 23 additions & 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.7.1"
implementation "com.ricoh360.thetaclient:theta-client:1.8.0"
```
- 本 SDK を使用したアプリケーションが動作するスマートフォンと THETA を無線 LAN 接続しておきます。

Expand Down Expand Up @@ -109,6 +109,28 @@ thetaRepository.getPhotoCaptureBuilder()
- ISO 上限 (THETA V ファームウェア v2.50.1 以前、THETA S、THETA SC では指定しても無視される)
- 200, 250, 320, 400, 500, 640, 800, 1000, 1250, 1600, 2000, 2500, 3200

#### 静止画撮影でビットレートの数値を設定する場合(THETA X)

THETA X では静止画撮影のビットレートの数値を設定することができます([api-spec](https://github.com/ricohapi/theta-api-specs/blob/main/theta-web-api-v2.1/options/_bitrate.md)参照)。
THETA Client でこの値を設定する際は、以下の手順が必要です:

1. `PhotoCapture`オブジェクトを生成
1. `setOptions()``bitrate`を設定
1. `takePicture()`で撮影

この手順が必要な理由は、`PhotoCapture.Builder.build()`内で`captureMode`の値が`image`にセットされる際に、
カメラ側の`bitrate`の値がリセットされるためです。

```kotlin
val photoCapture = thetaRepository.getPhotoCaptureBuilder().build()

val options = ThetaRepository.Options()
options.bitrate = ThetaRepository.BitrateNumber(1048576)
thetaRepository.setOptions(options)

photoCapture.takePicture(TakenCallback())
```

## 動画を撮影する

まず`VideoCapture.Builder`を使って撮影設定を行い、`VideoCapture`オブジェクトを生成します。
Expand Down
25 changes: 23 additions & 2 deletions docs/tutorial-android.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# THETA client tutorial for Android
# THETA client tutorial for Android

## Advance preparation

- Add following descriptions to the `dependencies` of your module's `build.gradle`.

```
implementation "com.ricoh360.thetaclient:theta-client:1.7.1"
implementation "com.ricoh360.thetaclient:theta-client:1.8.0"
```

- Connect the wireless LAN between THETA and the smartphone that runs on the application using this SDK.
Expand Down Expand Up @@ -98,6 +98,27 @@ See [Display a preview](#preview) for instructions on how to view preview.
- ISO upper limit (THETA V firmware v2.50.1 or earlier, ignored even if specified in THETA S or THETA SC)
- 200, 250, 320, 400, 500, 640, 800, 1000, 1250, 1600, 2000, 2500, 3200

#### Set the bitrate value for still image capture (THETA X)

The bitrate value for still image capture can be set in THETA X(see [api-spec](https://github.com/ricohapi/theta-api-specs/blob/main/theta-web-api-v2.1/options/_bitrate.md)).
To set this value with THETA Client, follow the steps below.

1. Create a `PhotoCapture` object
1. Call `setOptions()` to set the `bitrate` value
1. Call `takePicture()`

The reason this step is necessary is that the `bitrate` value on the camera is reset when the `captureMode` value is set to `image` in `PhotoCapture.Builder.build()`.

```kotlin
val photoCapture = thetaRepository.getPhotoCaptureBuilder().build()

val options = ThetaRepository.Options()
options.bitrate = ThetaRepository.BitrateNumber(1048576)
thetaRepository.setOptions(options)

photoCapture.takePicture(TakenCallback())
```

## Shoot a video

First, shooting settings are performed using `VideoCapture.Builder` to create `VideoCapture` objects.
Expand Down
33 changes: 33 additions & 0 deletions docs/tutorial-flutter.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,39 @@ _thetaClientFlutter.getPhotoCaptureBuilder()
| colorTemperature | CT settings (specified by the colorTemperature option) | RICOH THETA S firmware v01.82 or later and RICOH THETA SC firmware v01.10 or later |
| underwater | Underwater | RICOH THETA V firmware v3.21.1 or later |

#### 静止画撮影でビットレートの数値を設定する場合(THETA X)

THETA X では静止画撮影のビットレートの数値を設定することができます([api-spec](https://github.com/ricohapi/theta-api-specs/blob/main/theta-web-api-v2.1/options/_bitrate.md)参照)。
THETA Client でこの値を設定する際は、以下の手順が必要です:

1. `PhotoCapture`オブジェクトを生成
1. `setOptions()``bitrate`を設定
1. `takePicture()`で撮影

この手順が必要な理由は、`PhotoCaptureBuilder.build()`内で`captureMode`の値が`image`にセットされる際に、
カメラに設定された`bitrate`の値がリセットされるためです。

```dart
_thetaClientFlutter.getPhotoCaptureBuilder()
.build()
.then((photoCapture) {
// success build photoCapture
})
.onError((error, stackTrace) {
// handle error
});
final options = Options();
options.bitrate = BitrateNumber(1048576);
await _thetaClientFlutter.setOptions(options);
photoCapture.takePicture((fileUrl) {
// send HTTP GET request for fileUrl and receive JPEG file
}, (exception) {
// catch error while take picture
});
```

## 動画を撮影する

まず`getVideoCaptureBuilder()`を使って撮影設定を行い、`VideoCapture`オブジェクトを生成します。
Expand Down
34 changes: 33 additions & 1 deletion docs/tutorial-flutter.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# THETA Client Tutorial for Flutter
# THETA Client Tutorial for Flutter

## Create a Flutter Project

Expand Down Expand Up @@ -152,6 +152,38 @@ Next, we call `PhotoCapture.takePicture()` to shoot still pictures.
});
```

#### Set the bitrate value for still image capture (THETA X)

The bitrate value for still image capture can be set in THETA X(see [api-spec](https://github.com/ricohapi/theta-api-specs/blob/main/theta-web-api-v2.1/options/_bitrate.md)).
To set this value with THETA Client, follow the steps below.

1. Create a `PhotoCapture` object
1. Call `setOptions()` to set the `bitrate` value
1. Call `takePicture()`

The reason this step is necessary is that the `bitrate` value on the camera is reset when the `captureMode` value is set to `image` in `PhotoCaptureBuilder.build()`.

```dart
_thetaClientFlutter.getPhotoCaptureBuilder()
.build()
.then((photoCapture) {
// success build photoCapture
})
.onError((error, stackTrace) {
// handle error
});
final options = Options();
options.bitrate = BitrateNumber(1048576);
await _thetaClientFlutter.setOptions(options);
photoCapture.takePicture((fileUrl) {
// send HTTP GET request for fileUrl and receive JPEG file
}, (exception) {
// catch error while take picture
});
```

## Shoot a video

First, you set up shooting using `getVideoCaptureBuilder()` and create `VideoCapture` objects.
Expand Down
37 changes: 37 additions & 0 deletions docs/tutorial-ios.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,43 @@ do {
| colorTemperature | CT settings (specified by the colorTemperature option) | RICOH THETA S firmware v01.82 or later and RICOH THETA SC firmware v01.10 or later |
| underwater | Underwater | RICOH THETA V firmware v3.21.1 or later |

#### 静止画撮影でビットレートの数値を設定する場合(THETA X)

THETA X では静止画撮影のビットレートの数値を設定することができます([api-spec](https://github.com/ricohapi/theta-api-specs/blob/main/theta-web-api-v2.1/options/_bitrate.md)参照)。
THETA Client でこの値を設定する際は、以下の手順が必要です:

1. `PhotoCapture`オブジェクトを生成
1. `setOptions()``bitrate`を設定
1. `takePicture()`で撮影

この手順が必要な理由は、`PhotoCapture.Builder.build()`内で`captureMode`の値が`image`にセットされる際に、
カメラに設定された`bitrate`の値がリセットされるためです。

```swift
let photoCapture: PhotoCapture = try await withCheckedThrowingContinuation { continuation in
thetaRepository!.getPhotoCaptureBuilder().build { capture, error in
...
}
}
try await withCheckedThrowingContinuation { continuation in
let options = ThetaRepository.Options()
options.bitrate = ThetaRepository.BitrateNumber(value: 1048576)
thetaRepository!.setOptions(options: options) { error in
...
}
}
class Callback: PhotoCaptureTakePictureCallback {
...
}
let photoUrl: String? = try await withCheckedThrowingContinuation { continuation in
photoCapture.takePicture(
callback: Callback { fileUrl, error in
...
}
)
}
```

## 動画を撮影する

まず`ThetaRepository.getVideoCaptureBuilder()`を使って撮影設定を行い、`VideoCapture`オブジェクトを生成します。
Expand Down
38 changes: 37 additions & 1 deletion docs/tutorial-ios.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# THETA CLient Tutorial for iOS
# THETA CLient Tutorial for iOS

## Available models

Expand Down Expand Up @@ -304,6 +304,42 @@ GpsInfo shall be prepared as follows:
| colorTemperature | CT settings (specified by the colorTemperature option) | RICOH THETA S firmware v01.82 or later and RICOH THETA SC firmware v01.10 or later |
| underwater | Underwater | RICOH THETA V firmware v3.21.1 or later |

#### Set the bitrate value for still image capture (THETA X)

The bitrate value for still image capture can be set in THETA X(see [api-spec](https://github.com/ricohapi/theta-api-specs/blob/main/theta-web-api-v2.1/options/_bitrate.md)).
To set this value with THETA Client, follow the steps below.

1. Create a `PhotoCapture` object
1. Call `setOptions()` to set the `_bitrate` value
1. Call `takePicture()`

The reason this step is necessary is that the `bitrate` value on the camera is reset when the `captureMode` value is set to `image` in `PhotoCapture.Builder.build()`.

```swift
let photoCapture: PhotoCapture = try await withCheckedThrowingContinuation { continuation in
thetaRepository!.getPhotoCaptureBuilder().build { capture, error in
...
}
}
try await withCheckedThrowingContinuation { continuation in
let options = ThetaRepository.Options()
options.bitrate = ThetaRepository.BitrateNumber(value: 1048576)
thetaRepository!.setOptions(options: options) { error in
...
}
}
class Callback: PhotoCaptureTakePictureCallback {
...
}
let photoUrl: String? = try await withCheckedThrowingContinuation { continuation in
photoCapture.takePicture(
callback: Callback { fileUrl, error in
...
}
)
}
```

## Shoot a video

First, use the `ThetaRepository.getVideoCaptureBuilder()` to set the shooting and create the `VideoCapture` object.
Expand Down
Loading

0 comments on commit 0bc25be

Please sign in to comment.