OSDN Git Service

Ricoh Theta Vで動作するように修正。
authorMRSa <mrsa@myad.jp>
Thu, 10 Dec 2020 14:14:03 +0000 (23:14 +0900)
committerMRSa <mrsa@myad.jp>
Thu, 10 Dec 2020 14:14:03 +0000 (23:14 +0900)
app/build.gradle
app/src/main/java/net/osdn/gokigen/a01d/camera/theta/operation/ThetaSingleShotControl.java
app/src/main/java/net/osdn/gokigen/a01d/camera/theta/wrapper/ThetaLiveViewControl.java
app/src/main/java/net/osdn/gokigen/a01d/camera/theta/wrapper/connection/ThetaCameraConnectSequence.java
app/src/main/java/net/osdn/gokigen/a01d/camera/utils/SimpleLiveviewSlicer.java
build.gradle

index 47b95b9..0038469 100644 (file)
@@ -7,8 +7,8 @@ android {
         applicationId "net.osdn.gokigen.a01d"
         minSdkVersion 14
         targetSdkVersion 30
-        versionCode 10903
-        versionName "1.9.3"
+        versionCode 10904
+        versionName "1.9.4"
     }
     buildTypes {
         release {
@@ -21,7 +21,7 @@ android {
 dependencies {
     api fileTree(dir: 'libs', include: ['*.jar'])
     implementation 'androidx.appcompat:appcompat:1.2.0'
-    implementation 'androidx.exifinterface:exifinterface:1.3.1'
+    implementation 'androidx.exifinterface:exifinterface:1.3.2'
     implementation 'androidx.preference:preference-ktx:1.1.1'
     implementation 'com.google.android.material:material:1.2.1'
     implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
index 5d08419..559fb50 100644 (file)
@@ -60,7 +60,7 @@ public class ThetaSingleShotControl
                     {
                         String shootUrl = "http://192.168.1.1/osc/commands/execute";
                         String postData = (useThetaV21) ? "{\"name\":\"camera.takePicture\",\"parameters\":{\"timeout\":0}}" : "{\"name\":\"camera.takePicture\",\"parameters\":{\"sessionId\": \"" + sessionIdProvider.getSessionId() + "\"}}";
-                        String result = SimpleHttpClient.httpPost(shootUrl, postData, timeoutMs);
+                        String result = SimpleHttpClient.httpPostWithHeader(shootUrl, postData, null, "application/json;charset=utf-8", timeoutMs);
                         if ((result == null)||(result.length() < 1))
                         {
                             Log.v(TAG, "singleShot() reply is null.");
index 36c2174..22fc75e 100644 (file)
@@ -32,6 +32,7 @@ public class ThetaLiveViewControl implements ILiveViewControl
         {
             SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
             useOscV2 = preferences.getBoolean(IPreferencePropertyAccessor.USE_OSC_THETA_V21, false);
+            Log.v(TAG, " use OSC v2 : " + useOscV2);
         }
         catch (Exception e)
         {
@@ -112,7 +113,7 @@ public class ThetaLiveViewControl implements ILiveViewControl
 
                         // Create Slicer to open the stream and parse it.
                         slicer = new SimpleLiveviewSlicer();
-                        slicer.open(streamUrl, paramData);
+                        slicer.open(streamUrl, paramData, "application/json;charset=utf-8");
 
                         while (whileFetching)
                         {
index e2a7cb4..cc8799e 100644 (file)
@@ -135,24 +135,24 @@ public class ThetaCameraConnectSequence implements Runnable
 
         try
         {
-            String responseS = SimpleHttpClient.httpPost(commandsExecuteUrl, startSessionData, TIMEOUT_MS);
-            Log.v(TAG, " " + commandsExecuteUrl + " " + startSessionData + " " + responseS);
+            String responseS = SimpleHttpClient.httpPostWithHeader(commandsExecuteUrl, startSessionData, null, "application/json;charset=utf-8", TIMEOUT_MS);
+            Log.v(TAG, " [ " + commandsExecuteUrl + " ] " + startSessionData + " ::: " + responseS);
 
-            String response = SimpleHttpClient.httpPost(getStateUrl, "", TIMEOUT_MS);
-            Log.v(TAG, " " + getStateUrl + " " + response);
+            String response = SimpleHttpClient.httpPostWithHeader(getStateUrl, "", null, null, TIMEOUT_MS);
+            Log.v(TAG, " (" + getStateUrl + ") " + response);
             if (response.length() > 0)
             {
                 int apiLevel = 1;
                 String sessionId = null;
-               JSONObject object = new JSONObject(response);
-               try
-               {
-                   apiLevel = object.getJSONObject("state").getInt("_apiVersion");
-               }
-               catch (Exception e)
-               {
-                   e.printStackTrace();
-               }
+                JSONObject object = new JSONObject(response);
+                try
+                {
+                    apiLevel = object.getJSONObject("state").getInt("_apiVersion");
+                }
+                catch (Exception e)
+                {
+                    e.printStackTrace();
+                }
                 try
                 {
                     sessionId = object.getJSONObject("state").getString("sessionId");
@@ -162,12 +162,12 @@ public class ThetaCameraConnectSequence implements Runnable
                 {
                     e.printStackTrace();
                 }
-               if (apiLevel != 2)
-               {
-                   String setApiLevelData = "{\"name\":\"camera.setOptions\",\"parameters\":{" + "\"sessionId\" : \"" + sessionId + "\", \"options\":{ \"clientVersion\":2}}}";
-                   String response3 = SimpleHttpClient.httpPost(commandsExecuteUrl, setApiLevelData, TIMEOUT_MS);
-                   Log.v(TAG, " " + commandsExecuteUrl + " " + setApiLevelData + " " + response3);
-               }
+                if (apiLevel != 2)
+                {
+                    String setApiLevelData = "{\"name\":\"camera.setOptions\",\"parameters\":{" + "\"sessionId\" : \"" + sessionId + "\", \"options\":{ \"clientVersion\":2}}}";
+                    String response3 = SimpleHttpClient.httpPostWithHeader(commandsExecuteUrl, setApiLevelData, null, "application/json;charset=utf-8", TIMEOUT_MS);
+                    Log.v(TAG, " " + commandsExecuteUrl + " " + setApiLevelData + " " + response3);
+                }
                 onConnectNotify();
             }
             else
index ffa9d12..805f707 100644 (file)
@@ -55,7 +55,7 @@ public class SimpleLiveviewSlicer
     }
 */
 
-    public void open(String liveviewUrl, String postData)
+    public void open(String liveviewUrl, String postData, String contentType)
     {
         OutputStream outputStream = null;
         OutputStreamWriter writer = null;
@@ -71,6 +71,10 @@ public class SimpleLiveviewSlicer
             mHttpConn = (HttpURLConnection) urlObj.openConnection();
             mHttpConn.setRequestMethod("POST");
             mHttpConn.setConnectTimeout(CONNECTION_TIMEOUT);
+            if (contentType != null)
+            {
+                mHttpConn.setRequestProperty("Content-Type", contentType);
+            }
             {
                 mHttpConn.setDoInput(true);
                 mHttpConn.setDoOutput(true);
index 28d7982..2240f67 100644 (file)
@@ -1,13 +1,13 @@
 // Top-level build file where you can add configuration options common to all sub-projects/modules.
 
 buildscript {
-    ext.kotlin_version = '1.4.10'
+    ext.kotlin_version = '1.4.20'
     repositories {
         jcenter()
         google()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:4.1.0'
+        classpath 'com.android.tools.build:gradle:4.1.1'
         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
 
         // NOTE: Do not place your application dependencies here; they belong