2 * Copyright (C) 2013 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef LIBJPEG_HOOK_H_
18 #define LIBJPEG_HOOK_H_
26 #include "inputstream_wrapper.h"
27 #include "outputstream_wrapper.h"
32 * DestManager holds the libjpeg destination manager struct and
33 * a holder with a java OutputStream.
36 struct jpeg_destination_mgr mgr;
37 OutputStreamWrapper *outStream;
40 // Initializes the DestManager struct, sets up the jni refs
41 int32_t MakeDst(j_compress_ptr cinfo, JNIEnv *env, jobject outStream);
44 * Updates the jni env pointer. This should be called in the beginning of any
45 * JNI method in jpegstream.cpp before CleanDst or any of the libjpeg functions
46 * that can trigger a call to an OutputStreamWrapper method.
48 void UpdateDstEnv(j_compress_ptr cinfo, JNIEnv* env);
50 // Cleans the jni refs. To wipe the compress object call jpeg_destroy_compress
51 void CleanDst(j_compress_ptr cinfo);
54 * SourceManager holds the libjpeg source manager struct and a
55 * holder with a java InputStream.
58 struct jpeg_source_mgr mgr;
59 boolean start_of_file;
60 InputStreamWrapper *inStream;
63 // Initializes the SourceManager struct, sets up the jni refs
64 int32_t MakeSrc(j_decompress_ptr cinfo, JNIEnv *env, jobject inStream);
67 * Updates the jni env pointer. This should be called in the beginning of any
68 * JNI method in jpegstream.cpp before CleanSrc or any of the libjpeg functions
69 * that can trigger a call to an InputStreamWrapper method.
71 void UpdateSrcEnv(j_decompress_ptr cinfo, JNIEnv* env);
73 // Cleans the jni refs. To wipe the decompress object, call jpeg_destroy_decompress
74 void CleanSrc(j_decompress_ptr cinfo);
76 #endif // LIBJPEG_HOOK_H_