|
|
@ -12,13 +12,11 @@ |
|
|
|
|
|
|
|
|
|
|
|
PacketQueue<RTMPPacket *> packets; |
|
|
|
PacketQueue<RTMPPacket *> packets; |
|
|
|
VideoStream *videoStream = nullptr; |
|
|
|
VideoStream *videoStream = nullptr; |
|
|
|
pthread_t pid; |
|
|
|
AudioStream *audioStream = nullptr; |
|
|
|
|
|
|
|
|
|
|
|
std::atomic<bool> isPushing; |
|
|
|
std::atomic<bool> isPushing; |
|
|
|
uint32_t start_time; |
|
|
|
uint32_t start_time; |
|
|
|
|
|
|
|
|
|
|
|
AudioStream *audioStream = nullptr; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//use to get thread's JNIEnv
|
|
|
|
//use to get thread's JNIEnv
|
|
|
|
JavaVM *javaVM; |
|
|
|
JavaVM *javaVM; |
|
|
|
//callback object
|
|
|
|
//callback object
|
|
|
@ -143,9 +141,9 @@ void *start(void *args) { |
|
|
|
|
|
|
|
|
|
|
|
RTMP_PUSHER_FUNC(void, native_1init) { |
|
|
|
RTMP_PUSHER_FUNC(void, native_1init) { |
|
|
|
LOGI("native init..."); |
|
|
|
LOGI("native init..."); |
|
|
|
videoStream = new VideoStream; |
|
|
|
videoStream = new VideoStream(); |
|
|
|
videoStream->setVideoCallback(callback); |
|
|
|
videoStream->setVideoCallback(callback); |
|
|
|
audioStream = new AudioStream; |
|
|
|
audioStream = new AudioStream(); |
|
|
|
audioStream->setAudioCallback(callback); |
|
|
|
audioStream->setAudioCallback(callback); |
|
|
|
packets.setReleaseCallback(releasePackets); |
|
|
|
packets.setReleaseCallback(releasePackets); |
|
|
|
jobject_error = env->NewGlobalRef(instance); |
|
|
|
jobject_error = env->NewGlobalRef(instance); |
|
|
@ -166,7 +164,9 @@ RTMP_PUSHER_FUNC(void, native_1start, jstring path_) { |
|
|
|
const char *path = env->GetStringUTFChars(path_, nullptr); |
|
|
|
const char *path = env->GetStringUTFChars(path_, nullptr); |
|
|
|
char *url = new char[strlen(path) + 1]; |
|
|
|
char *url = new char[strlen(path) + 1]; |
|
|
|
strcpy(url, path); |
|
|
|
strcpy(url, path); |
|
|
|
pthread_create(&pid, nullptr, start, url); |
|
|
|
|
|
|
|
|
|
|
|
std::thread pushThread(start, url); |
|
|
|
|
|
|
|
pushThread.detach(); |
|
|
|
env->ReleaseStringUTFChars(path_, path); |
|
|
|
env->ReleaseStringUTFChars(path_, path); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -205,7 +205,6 @@ RTMP_PUSHER_FUNC(void, native_1stop) { |
|
|
|
LOGI("native stop..."); |
|
|
|
LOGI("native stop..."); |
|
|
|
isPushing = false; |
|
|
|
isPushing = false; |
|
|
|
packets.setRunning(false); |
|
|
|
packets.setRunning(false); |
|
|
|
pthread_join(pid, nullptr); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RTMP_PUSHER_FUNC(void, native_1release) { |
|
|
|
RTMP_PUSHER_FUNC(void, native_1release) { |
|
|
|