链接地址:http://download.csdn.net/detail/yuanchunsi/9895103
// x264.c
// jni
//
//
// create by yuanchunsi.
#include <jni.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <stdbool.h>
#include <pthread.h>
#include "stdint.h"
#include "utils_jni.h"
#include "utils/log.h"
#include "utils/queue.h"
#if defined ( __cplusplus)
extern "C"
{
#include "x264.h"
};
#else
#include "x264.h"
#endif
typedef struct _Encoder{
x264_param_t * param;
x264_t *handle;
x264_picture_t * picture;
x264_nal_t *nal;
} Encoder;
typedef struct _packet{
char *in;
int insize;
} packet_t;
Encoder * encoder = NULL;
static queue_t * queue = NULL;
static pthread_t encoder_id;
static bool encoder_stop ;
static FILE* fp_dst = NULL;
static void* encoder_run(void *data) {
int ret;
int y_size;
//int i,j;
//int iNal = -1;
//int frame_num = 0;
pthread_detach(pthread_self());
pthread_t thid;
struct sched_param param;
thid = pthread_self();
param.sched_priority = sched_get_priority_max(SCHED_RR);
pthread_setschedparam(thid,SCHED_RR,¶m);
Encoder *en = (Encoder*)data;
if (NULL == en) {
ERROR("Invaid data\n");
return NULL;
}
//fp_ds