Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync Brotli Native code with Upstream #87

Merged
merged 4 commits into from
Feb 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Include decoder_jni.h
hyperxpro committed Feb 19, 2023

Verified

This commit was signed with the committer’s verified signature.
hyperxpro Aayush Atharva
commit 51c265868b4844c4aab4abb7f6ec9953e004e2c0
75 changes: 75 additions & 0 deletions natives/src/main/cpp/decoder_jni.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/* Copyright 2017 Google Inc. All Rights Reserved.

Distributed under MIT license.
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/

#ifndef BROTLI_WRAPPER_DEC_DECODER_JNI_H_
#define BROTLI_WRAPPER_DEC_DECODER_JNI_H_

#include <jni.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* Creates a new Decoder.
*
* Cookie to address created decoder is stored in out_cookie. In case of failure
* cookie is 0.
*
* @param ctx {out_cookie, in_directBufferSize} tuple
* @returns direct ByteBuffer if directBufferSize is not 0; otherwise null
*/
JNIEXPORT jobject JNICALL
Java_com_aayushatharva_brotli4j_decoder_DecoderJNI_nativeCreate(
JNIEnv* env, jobject /*jobj*/, jlongArray ctx);

/**
* Push data to decoder.
*
* status codes:
* - 0 error happened
* - 1 stream is finished, no more input / output expected
* - 2 needs more input to process further
* - 3 needs more output to process further
* - 4 ok, can proceed further without additional input
*
* @param ctx {in_cookie, out_status} tuple
* @param input_length number of bytes provided in input or direct input;
* 0 to process further previous input
*/
JNIEXPORT void JNICALL
Java_com_aayushatharva_brotli4j_decoder_DecoderJNI_nativePush(
JNIEnv* env, jobject /*jobj*/, jlongArray ctx, jint input_length);

/**
* Pull decompressed data from decoder.
*
* @param ctx {in_cookie, out_status} tuple
* @returns direct ByteBuffer; all the produced data MUST be consumed before
* any further invocation; null in case of error
*/
JNIEXPORT jobject JNICALL
Java_com_aayushatharva_brotli4j_decoder_DecoderJNI_nativePull(
JNIEnv* env, jobject /*jobj*/, jlongArray ctx);

/**
* Releases all used resources.
*
* @param ctx {in_cookie} tuple
*/
JNIEXPORT void JNICALL
Java_com_aayushatharva_brotli4j_decoder_DecoderJNI_nativeDestroy(
JNIEnv* env, jobject /*jobj*/, jlongArray ctx);

JNIEXPORT jboolean JNICALL
Java_com_aayushatharva_brotli4j_decoder_DecoderJNI_nativeAttachDictionary(
JNIEnv* env, jobject /*jobj*/, jlongArray ctx, jobject dictionary);

#ifdef __cplusplus
}
#endif

#endif // BROTLI_WRAPPER_DEC_DECODER_JNI_H_