update 2016-11-08 b1
1. resolved decoder for Android build
This commit is contained in:
@@ -9,19 +9,88 @@ Revision log:
|
||||
* 2016-03-21: created by strawmanbobi
|
||||
**************************************************************************************************/
|
||||
#include <jni.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "include/irda_decode_jni.h"
|
||||
#include "irda_defs.h"
|
||||
#include "irda_decode.h"
|
||||
#include <errno.h>
|
||||
#include "./include/irda_decode_jni.h"
|
||||
#include "./include/irda_defs.h"
|
||||
#include "./include/irda_decode.h"
|
||||
|
||||
// function declaration
|
||||
void FillBCCommandValuesToJni(JNIEnv* env, jobject j_bc_command, jclass bccommand_class, t_bc_command bc_command);
|
||||
// global variable definition
|
||||
UINT16 binary_length = 0;
|
||||
UINT8 *binary_content = NULL;
|
||||
|
||||
INT8 irda_ac_file_open(const char* file_name)
|
||||
{
|
||||
FILE *stream = fopen(file_name, "rb");
|
||||
if (NULL == stream)
|
||||
{
|
||||
IR_PRINTF("\nfile open failed : %d\n", errno);
|
||||
return IR_DECODE_FAILED;
|
||||
}
|
||||
|
||||
fseek(stream, 0, SEEK_END);
|
||||
binary_length = ftell(stream);
|
||||
binary_content = (UINT8*) irda_malloc(binary_length);
|
||||
|
||||
if (NULL == binary_content)
|
||||
{
|
||||
IR_PRINTF("\nfailed to alloc memory for binary\n");
|
||||
return IR_DECODE_FAILED;
|
||||
}
|
||||
|
||||
fseek(stream, 0, SEEK_SET);
|
||||
fread(binary_content, binary_length, 1, stream);
|
||||
fclose(stream);
|
||||
|
||||
if (IR_DECODE_FAILED == irda_ac_lib_open(binary_content, binary_length))
|
||||
{
|
||||
irda_free(binary_content);
|
||||
binary_length = 0;
|
||||
return IR_DECODE_FAILED;
|
||||
}
|
||||
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
|
||||
INT8 irda_tv_file_open(const char* file_name)
|
||||
{
|
||||
int print_index = 0;
|
||||
FILE *stream = fopen(file_name, "rb");
|
||||
|
||||
IR_PRINTF("file name = %s\n", file_name);
|
||||
|
||||
if (stream == NULL)
|
||||
{
|
||||
IR_PRINTF("\nfile open failed : %d\n", errno);
|
||||
return IR_DECODE_FAILED;
|
||||
}
|
||||
|
||||
fseek(stream, 0, SEEK_END);
|
||||
binary_length = ftell(stream);
|
||||
IR_PRINTF("length of binary = %d\n", binary_length);
|
||||
|
||||
binary_content = (UINT8*) irda_malloc(binary_length);
|
||||
|
||||
fseek(stream, 0, SEEK_SET);
|
||||
fread(binary_content, binary_length, 1, stream);
|
||||
fclose(stream);
|
||||
|
||||
if (IR_DECODE_FAILED == irda_tv_lib_open(binary_content, binary_length))
|
||||
{
|
||||
irda_free(binary_content);
|
||||
binary_length = 0;
|
||||
return IR_DECODE_FAILED;
|
||||
}
|
||||
|
||||
return IR_DECODE_SUCCEEDED;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaACLibOpen
|
||||
(JNIEnv *env, jobject this_obj, jstring file_name)
|
||||
{
|
||||
const char *n_file_name = (*env)->GetStringUTFChars(env, file_name, 0);
|
||||
if (IR_DECODE_FAILED == irda_ac_lib_open(n_file_name))
|
||||
if (IR_DECODE_FAILED == irda_ac_file_open(n_file_name))
|
||||
{
|
||||
irda_ac_lib_close();
|
||||
(*env)->ReleaseStringUTFChars(env, file_name, n_file_name);
|
||||
@@ -167,7 +236,7 @@ JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaTVLibOpen
|
||||
{
|
||||
const char *n_file_name = (*env)->GetStringUTFChars(env, file_name, 0);
|
||||
|
||||
if (IR_DECODE_FAILED == irda_tv_lib_open(n_file_name))
|
||||
if (IR_DECODE_FAILED == irda_tv_file_open(n_file_name))
|
||||
{
|
||||
(*env)->ReleaseStringUTFChars(env, file_name, n_file_name);
|
||||
return IR_DECODE_FAILED;
|
||||
|
||||
Reference in New Issue
Block a user