Skip to content

Commit

Permalink
Merge pull request #6 from ricohapi/feature/#4
Browse files Browse the repository at this point in the history
Modify "Add Exif support/ THETA Z1 support"
  • Loading branch information
j-takashima authored Oct 28, 2019
2 parents 5c32f0a + b012a17 commit 6468e68
Show file tree
Hide file tree
Showing 22 changed files with 349 additions and 255 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
Expand Down Expand Up @@ -430,32 +426,4 @@ public void notificationError(String message) {
public void notificationErrorOccured() {
sendBroadcast(new Intent(Constants.ACTION_ERROR_OCCURED));
}

/**
* Get THETA model name
*
* @return THETA ModelName (eg. You can get the model name like "RICOH THETA *")
*/
public String getThetaModel() {
return Build.MODEL;
}

/**
* Get the firmwareversion of THETA
*
* @return THETA FirmwareVersion
*/
public String getFirmwareVersion() {
try {
PackageInfo packageInfo = getPackageManager()
.getPackageInfo(Constants.RECEPTOR, PackageManager.GET_META_DATA);
if (packageInfo != null) {
return packageInfo.versionName;
}
} catch (NameNotFoundException e) {
e.printStackTrace();
}

return "0.00.0";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.theta360.pluginlibrary.activity;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Arrays;

public class ThetaInfo {
private static final String PROP_A_PATH = "/param/adj/Prop_A.bin";

/**
* Get THETA model name
*
* @return THETA ModelName (eg. You can get the model name like "RICOH THETA *")
*/
public static String getThetaModelName() {
return Build.MODEL;
}

/**
* Get the THETA firmwareversion
*
* @return THETA FirmwareVersion
*/
public static String getThetaFirmwareVersion(Context context) {
try {
PackageInfo packageInfo = context.getPackageManager()
.getPackageInfo(Constants.RECEPTOR, PackageManager.GET_META_DATA);
if (packageInfo != null) {
return packageInfo.versionName;
}
} catch (NameNotFoundException e) {
e.printStackTrace();
}

return ".";
}

/**
* Get the THETA SerialNumber
*
* @return THETA SerialNumber
*/
public static long getThetaSerialNumber() {
long serial = 0;
try {
File file = new File(PROP_A_PATH);
if(file != null && file.exists()) {
// int(符号付き)をlong(正の整数)へ変換する
// 単純に(long)キャストすると 0x87654321 → 0xFFFFFFFF87654321になってしまう
serial = readFile4byte(file, "cameraSerialNumber", 4) & 0x00000000FFFFFFFFL;
}
} catch (IOException e) {
e.printStackTrace();
}
return serial;
}

private static int readFile4byte(File adjFile, String member, int start) throws IOException {
int result = 0;

FileInputStream fin = new FileInputStream(adjFile);
byte[] dates = new byte[120];
fin.read(dates);
fin.close();

byte[] bytes = Arrays.copyOfRange(dates, start, start + 4);
result = ByteBuffer.wrap(bytes).getInt();

return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,11 @@ public void write() {
readTimestamp();
shiftTimezone();

String model = MovieSettings.getModel();
String model = CameraSettings.getThetaModel().toString();
byte[] bAmod = model.getBytes();

byte[] bAswr = null;
String firmwareVersion = MovieSettings.getFirmwareVersion();
String firmwareVersion = CameraSettings.getThetaFirmwareVersion();
bAswr = getVersionFullName(model, firmwareVersion).getBytes();

byte[] bAday = null;
Expand All @@ -339,7 +339,7 @@ public void write() {

byte[] bAxyz = new AXYZ().getData();

String manufacturer = MovieSettings.getManufacturer();
String manufacturer = CameraSettings.getManufacturer();
byte[] bAmak = manufacturer.getBytes();

byte[] bManu = new byte[6];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.theta360.pluginlibrary.exif;

import com.theta360.pluginlibrary.values.ThetaModel;
import java.util.Date;
import android.hardware.Camera;
import android.support.annotation.NonNull;
Expand Down Expand Up @@ -43,6 +44,16 @@
* CameraSettings class
*/
public class CameraSettings {
private static final String DEFAULT_MANUFACTURER = "RICOH";
private static final String DEFAULT_FIRMWARE_VERSION = ".";

private static String mManufacturer = null;
private static ThetaModel mThetaModel = null;
private static long mThetaSerialNumber = -1;
private static String mThetaFirmwareVersion = null;
private static GpsInfo mGpsInfo = null;
private static SensorValues mSensorValues = null;

private static ExposureProgram mExposureProgram = null;
private static Aperture mAperture = null;
private static ShutterSpeed mShutterSpeed = null;
Expand All @@ -62,6 +73,13 @@ public class CameraSettings {
* Initialize the camera settings held by the object.
*/
public static void initialize() {
mManufacturer = DEFAULT_MANUFACTURER;
mThetaModel = ThetaModel.THETA_DEF;
mThetaSerialNumber = 0;
mThetaFirmwareVersion = DEFAULT_FIRMWARE_VERSION;
mGpsInfo = new GpsInfo();
mSensorValues = new SensorValues();

mFilter = Filter.OFF;
mExposureProgram = ExposureProgram.NORMAL_PROGRAM;
mAperture = Aperture.APERTURE_2_0;
Expand All @@ -77,6 +95,117 @@ public static void initialize() {
mZenithCorrection = ZenithCorrection.RIC_ZENITH_CORRECTION_OFF;
mDngOutput = false;
}

/**
* Returns the manufacturer name that is held
*
* @return manufacturer name("RICOH")
*/
public static String getManufacturer() {
return (mManufacturer != null) ? mManufacturer : DEFAULT_MANUFACTURER;
}

/**
* Hold the manufacturer name
*
* @param manufacturer manufacturer name("RICOH")
*/
public static void setManufacturer(String manufacturer) {
mManufacturer = manufacturer;
}

/**
* Returns the THETA serial number that is held
*
* @return serialNumber
*/
public static long getThetaSerialNumber() {
return mThetaSerialNumber;
}

/**
* Hold the THETA serial number
*/
public static void setThetaSerialNumber(long serialNumber) {
mThetaSerialNumber = serialNumber;
}

/**
* Returns the THETA model that is held
*
* @return ThetaModel
*/
public static ThetaModel getThetaModel() {
return (mThetaModel != null) ? mThetaModel : ThetaModel.THETA_DEF;
}

/**
* Returns the THETA model that is held
*
* @param model ThetaModel
*/
public static void setThetaModel(ThetaModel model) {
mThetaModel = model;
}

/**
* Returns the THETA firmware version that is held
*
* @return firmwareVersion
*/
public static String getThetaFirmwareVersion() {
return (mThetaFirmwareVersion != null) ? mThetaFirmwareVersion : DEFAULT_FIRMWARE_VERSION;
}

/**
* Hold the THETA firmware version
*/
public static void setThetaFirmwareVersion(String firmwareVersion) {
mThetaFirmwareVersion = firmwareVersion;
}

/**
* Returns the GPS information that is held
*
* @return GPS information
*/
public static GpsInfo getGpsInfo() {
if (mGpsInfo == null) {
mGpsInfo = new GpsInfo();
}
return mGpsInfo;
}

/**
* Hold the GPS information
*
* @param gpsInfo GPS information
*/
public static void setGpsInfo(GpsInfo gpsInfo) {
mGpsInfo = gpsInfo;
}

/**
* Returns the sensor information that is held
*
* @return sensor information
*/
public static SensorValues getSensorValues() {
if (mSensorValues == null) {
mSensorValues = new SensorValues();
}
return mSensorValues;
}

/**
* Hold the sensor information
*
* @param sensorValues sensor information
*/
public static void setSensorValues(SensorValues sensorValues) {
mSensorValues = sensorValues;
}

/**
* Update the camera setting value held by the object based on the setting value of Camera.Parameters.
*
Expand Down Expand Up @@ -451,16 +580,25 @@ static ExposureProgram getExposureProgram(@NonNull Camera.Parameters parameters)

static Aperture getAperture(@NonNull Camera.Parameters parameters) {
String apertureIndex = parameters.get(KEY_RIC_MANUAL_EXPOSURE_AV_REAR);
if (apertureIndex == null) {
apertureIndex = parameters.get(KEY_RIC_MANUAL_EXPOSURE_AV_FRONT);
}
return (apertureIndex != null) ? Aperture.getValueFromIndex(Integer.parseInt(apertureIndex)) : Aperture.APERTURE_2_0;
}

static ShutterSpeed getShutterSpeed(@NonNull Camera.Parameters parameters) {
String shutterSpeed = parameters.get(KEY_RIC_MANUAL_EXPOSURE_PRIMARY);
if (shutterSpeed == null) {
shutterSpeed = parameters.get(KEY_RIC_MANUAL_EXPOSURE_SECONDARY);
}
return (shutterSpeed != null) ? ShutterSpeed.getValueFromIndex(Integer.parseInt(shutterSpeed)) : ShutterSpeed.SHUTTER_SPEED_AUTO;
}

static Iso getIso(@NonNull Camera.Parameters parameters) {
String iso = parameters.get(KEY_RIC_MANUAL_EXPOSURE_ISO_PRIMARY);
if (iso == null) {
iso = parameters.get(KEY_RIC_MANUAL_EXPOSURE_ISO_SECONDARY);
}
return (iso != null) ? Iso.getValueFromIndex(Integer.parseInt(iso)) : Iso.ISO_AUTO;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public DngExif(@NonNull byte[] data, boolean dataBeforeModify) {
* Set zenith correction disabled in DNG file metadata
*/
@Override
public void setExifSphere(@NonNull SensorValues sensorValues) {
setExifSphere(sensorValues, false);
public void setExifSphere() {
setExifSphere(false);
}

@Override
Expand Down
Loading

0 comments on commit 6468e68

Please sign in to comment.