|
|
@ -21,36 +21,36 @@ uint32_t start_time; |
|
|
|
|
|
|
|
|
|
|
|
AudioStream *audioStream = 0; |
|
|
|
AudioStream *audioStream = 0; |
|
|
|
|
|
|
|
|
|
|
|
//子线程回调给Java需要用到JavaVM
|
|
|
|
//use to get thread's JNIEnv
|
|
|
|
JavaVM *javaVM; |
|
|
|
JavaVM *javaVM; |
|
|
|
//调用类
|
|
|
|
//callback object
|
|
|
|
jobject jobject_error; |
|
|
|
jobject jobject_error; |
|
|
|
|
|
|
|
|
|
|
|
/***************与Java层对应**************/ |
|
|
|
/***************relative to Java**************/ |
|
|
|
//视频编码器打开失败
|
|
|
|
//error code for opening video encoder
|
|
|
|
const int ERROR_VIDEO_ENCODER_OPEN = 0x01; |
|
|
|
const int ERROR_VIDEO_ENCODER_OPEN = 0x01; |
|
|
|
//视频帧编码失败
|
|
|
|
//error code for video encoding
|
|
|
|
const int ERROR_VIDEO_ENCODE = 0x02; |
|
|
|
const int ERROR_VIDEO_ENCODE = 0x02; |
|
|
|
//音频编码器打开失败
|
|
|
|
//error code for opening audio encoder
|
|
|
|
const int ERROR_AUDIO_ENCODER_OPEN = 0x03; |
|
|
|
const int ERROR_AUDIO_ENCODER_OPEN = 0x03; |
|
|
|
//音频帧编码失败
|
|
|
|
//error code for audio encoding
|
|
|
|
const int ERROR_AUDIO_ENCODE = 0x04; |
|
|
|
const int ERROR_AUDIO_ENCODE = 0x04; |
|
|
|
//RTMP连接失败
|
|
|
|
//error code for RTMP connecting
|
|
|
|
const int ERROR_RTMP_CONNECT = 0x05; |
|
|
|
const int ERROR_RTMP_CONNECT = 0x05; |
|
|
|
//RTMP连接流失败
|
|
|
|
//error code for connecting stream
|
|
|
|
const int ERROR_RTMP_CONNECT_STREAM = 0x06; |
|
|
|
const int ERROR_RTMP_CONNECT_STREAM = 0x06; |
|
|
|
//RTMP发送数据包失败
|
|
|
|
//error code for sending packet
|
|
|
|
const int ERROR_RTMP_SEND_PACKET = 0x07; |
|
|
|
const int ERROR_RTMP_SEND_PACKET = 0x07; |
|
|
|
|
|
|
|
|
|
|
|
/***************与Java层对应**************/ |
|
|
|
/***************relative to Java**************/ |
|
|
|
|
|
|
|
|
|
|
|
//当调用System.loadLibrary时,会回调这个方法
|
|
|
|
//when calling System.loadLibrary, will callback it
|
|
|
|
jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { |
|
|
|
jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { |
|
|
|
javaVM = vm; |
|
|
|
javaVM = vm; |
|
|
|
return JNI_VERSION_1_6; |
|
|
|
return JNI_VERSION_1_6; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//回调异常给java
|
|
|
|
//callback error to java
|
|
|
|
void throwErrToJava(int error_code) { |
|
|
|
void throwErrToJava(int error_code) { |
|
|
|
JNIEnv *env; |
|
|
|
JNIEnv *env; |
|
|
|
javaVM->AttachCurrentThread(&env, NULL); |
|
|
|
javaVM->AttachCurrentThread(&env, NULL); |
|
|
@ -90,7 +90,7 @@ void *start(void *args) { |
|
|
|
LOGE("RTMP_SetupURL:%s", url); |
|
|
|
LOGE("RTMP_SetupURL:%s", url); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
//超时时间
|
|
|
|
//timeout
|
|
|
|
rtmp->Link.timeout = 5; |
|
|
|
rtmp->Link.timeout = 5; |
|
|
|
RTMP_EnableWrite(rtmp); |
|
|
|
RTMP_EnableWrite(rtmp); |
|
|
|
ret = RTMP_Connect(rtmp, 0); |
|
|
|
ret = RTMP_Connect(rtmp, 0); |
|
|
@ -105,9 +105,9 @@ void *start(void *args) { |
|
|
|
throwErrToJava(ERROR_RTMP_CONNECT_STREAM); |
|
|
|
throwErrToJava(ERROR_RTMP_CONNECT_STREAM); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
//开始时间
|
|
|
|
//start time
|
|
|
|
start_time = RTMP_GetTime(); |
|
|
|
start_time = RTMP_GetTime(); |
|
|
|
//开始推流
|
|
|
|
//start pushing
|
|
|
|
readyPushing = 1; |
|
|
|
readyPushing = 1; |
|
|
|
packets.setWork(1); |
|
|
|
packets.setWork(1); |
|
|
|
callback(audioStream->getAudioTag()); |
|
|
|
callback(audioStream->getAudioTag()); |
|
|
|