android_frameworks_base/media/jni/android_media_Utils.h
Jaesung Chung 8409c0691f Enable reading a thumbnail from RAW image files in MtpDatabase
Also introduce new supported RAW image file formats, PEF and SRW.

RAW image file formats are not defined in PTP 1.2 specification except
for DNG. They are mostly built on top of TIFF or TIFF/EP. (Fuji's RAF
is the exception).

In this CL, image file formats are classified newly as below:

DNG: dng
TIFF: cr2, nrw, arw, rw2, orf, pef, srw
TIFF/EP: nef
Unknown Image Formats(FORMAT_DEFINED): wbmap, webp, raf

I referred to the following documents for defining MTP formats of RAW
images:

* http://www.rags-int-inc.com/PhotoTechStuff/RawStandards/RawSummary.html
* https://en.wikipedia.org/wiki/Raw_image_format

Bug: 26552863, Bug: 26626825
Change-Id: Ia218f6320c4c1ff051a23ca0060ceac46134b0d7
2016-01-27 18:40:36 +09:00

74 lines
2.4 KiB
C++

/*
* Copyright 2011, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _ANDROID_MEDIA_UTILS_H_
#define _ANDROID_MEDIA_UTILS_H_
#include "src/piex_types.h"
#include "src/piex.h"
#include <android_runtime/AndroidRuntime.h>
#include <jni.h>
#include <JNIHelp.h>
#include <utils/KeyedVector.h>
#include <utils/String8.h>
namespace android {
class FileStream : public piex::StreamInterface {
private:
FILE *mFile;
size_t mPosition;
size_t mSize;
public:
FileStream(const String8 filename);
~FileStream();
// Reads 'length' amount of bytes from 'offset' to 'data'. The 'data' buffer
// provided by the caller, guaranteed to be at least "length" bytes long.
// On 'kOk' the 'data' pointer contains 'length' valid bytes beginning at
// 'offset' bytes from the start of the stream.
// Returns 'kFail' if 'offset' + 'length' exceeds the stream and does not
// change the contents of 'data'.
piex::Error GetData(
const size_t offset, const size_t length, std::uint8_t* data) override;
bool exists() const;
size_t size() const;
};
// Reads EXIF metadata from a given raw image via piex.
// And returns true if the operation is successful; otherwise, false.
bool GetExifFromRawImage(
FileStream* stream, const String8& filename, piex::PreviewImageData& image_data);
// Returns true if the conversion is successful; otherwise, false.
bool ConvertKeyValueArraysToKeyedVector(
JNIEnv *env, jobjectArray keys, jobjectArray values,
KeyedVector<String8, String8>* vector);
struct AMessage;
status_t ConvertMessageToMap(
JNIEnv *env, const sp<AMessage> &msg, jobject *map);
status_t ConvertKeyValueArraysToMessage(
JNIEnv *env, jobjectArray keys, jobjectArray values,
sp<AMessage> *msg);
}; // namespace android
#endif // _ANDROID_MEDIA_UTILS_H_