OSDN Git Service

Olympus PENのライブビュー機能搭載。
authorMRSa <mrsa@myad.jp>
Sat, 4 Jan 2020 05:56:27 +0000 (14:56 +0900)
committerMRSa <mrsa@myad.jp>
Sat, 4 Jan 2020 05:56:27 +0000 (14:56 +0900)
app/src/main/java/net/osdn/gokigen/a01d/camera/olympuspen/wrapper/OlympusPenLiveViewControl.java

index 4d5e1c4..3f88377 100644 (file)
@@ -34,6 +34,7 @@ public class OlympusPenLiveViewControl implements ILiveViewControl
 
     private Map<String, String> headerMap;
     private ByteArrayOutputStream receivedByteStream;
+    private byte[] rtpHeader;
 
     OlympusPenLiveViewControl()
     {
@@ -211,29 +212,23 @@ public class OlympusPenLiveViewControl implements ILiveViewControl
                 extensionLength = 16;
                 extensionLength = checkJpegStartPosition(receivedData, extensionLength) - position;
 
+                rtpHeader = Arrays.copyOf(receivedData, extensionLength);
+                System.gc();
             }
             else if (receivedData[1] == (byte) 0xe0)
             {
                 // 末尾パケット (RTPヘッダは 12bytes)
                 isFinished = true;
             }
-            //Log.v(TAG, "RECEIVED PACKET : " + dataLength + " [" + isFinished + "] ext : " + extensionLength);
 
             int offset = position + extensionLength;
             receivedByteStream.write(receivedData, (position + extensionLength), (dataLength - offset));
             if (isFinished)
             {
                 byte[] dataArray = receivedByteStream.toByteArray();
-/*
-                {
-                    byte[] start = Arrays.copyOfRange(dataArray, 0, 32);
-                    byte[] end = Arrays.copyOfRange(dataArray, (dataArray.length - 32), dataArray.length);
-                    dump_bytes(" ST ", start);
-                    dump_bytes(" ED ", end);
-                }
-*/
-                liveViewListener.onUpdateLiveView(Arrays.copyOf(dataArray, dataArray.length), null);
                 receivedByteStream.flush();
+                liveViewListener.onUpdateLiveView(Arrays.copyOf(dataArray, dataArray.length), null);
+                receivedByteStream.reset();
                 //System.gc();
             }
         }