diff --git a/Live/src/main/cpp/AudioStream.cpp b/Live/src/main/cpp/AudioStream.cpp index 74025a6..6d3c6eb 100644 --- a/Live/src/main/cpp/AudioStream.cpp +++ b/Live/src/main/cpp/AudioStream.cpp @@ -11,7 +11,7 @@ AudioStream::~AudioStream() { DELETE(buffer); if (audioCodec) { faacEncClose(audioCodec); - audioCodec = 0; + audioCodec = nullptr; } } @@ -48,7 +48,7 @@ RTMPPacket *AudioStream::getAudioTag() { u_long len; faacEncGetDecoderSpecificInfo(audioCodec, &buf, &len); int bodySize = static_cast(2 + len); - RTMPPacket *packet = new RTMPPacket; + auto *packet = new RTMPPacket; RTMPPacket_Alloc(packet, bodySize); //channel layout: stereo packet->m_body[0] = 0xAF; @@ -75,7 +75,7 @@ void AudioStream::encodeData(int8_t *data) { static_cast(maxOutputBytes)); if (byteLen > 0) { int bodySize = 2 + byteLen; - RTMPPacket *packet = new RTMPPacket; + auto *packet = new RTMPPacket; RTMPPacket_Alloc(packet, bodySize); //stereo packet->m_body[0] = 0xAF; diff --git a/Live/src/main/cpp/RtmpPusher.cpp b/Live/src/main/cpp/RtmpPusher.cpp index 95b59a0..041efde 100644 --- a/Live/src/main/cpp/RtmpPusher.cpp +++ b/Live/src/main/cpp/RtmpPusher.cpp @@ -11,14 +11,14 @@ (JNIEnv *env, jobject instance, ##__VA_ARGS__)\ SafeQueue packets; -VideoStream *videoStream = 0; +VideoStream *videoStream = nullptr; int isStart = 0; pthread_t pid; int readyPushing = 0; uint32_t start_time; -AudioStream *audioStream = 0; +AudioStream *audioStream = nullptr; //use to get thread's JNIEnv JavaVM *javaVM; @@ -52,7 +52,7 @@ jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { //callback error to java void throwErrToJava(int error_code) { JNIEnv *env; - javaVM->AttachCurrentThread(&env, NULL); + javaVM->AttachCurrentThread(&env, nullptr); jclass classErr = env->GetObjectClass(jobject_error); jmethodID methodErr = env->GetMethodID(classErr, "errorFromNative", "(I)V"); env->CallVoidMethod(jobject_error, methodErr, error_code); @@ -76,7 +76,7 @@ void releasePackets(RTMPPacket *&packet) { void *start(void *args) { char *url = static_cast(args); - RTMP *rtmp = 0; + RTMP *rtmp = nullptr; do { rtmp = RTMP_Alloc(); if (!rtmp) { @@ -92,7 +92,7 @@ void *start(void *args) { //timeout rtmp->Link.timeout = 5; RTMP_EnableWrite(rtmp); - ret = RTMP_Connect(rtmp, 0); + ret = RTMP_Connect(rtmp, nullptr); if (!ret) { LOGE("RTMP_Connect:%s", url); throwErrToJava(ERROR_RTMP_CONNECT); @@ -110,7 +110,7 @@ void *start(void *args) { readyPushing = 1; packets.setWork(1); callback(audioStream->getAudioTag()); - RTMPPacket *packet = 0; + RTMPPacket *packet = nullptr; while (readyPushing) { packets.pop(packet); if (!readyPushing) { @@ -140,7 +140,7 @@ void *start(void *args) { RTMP_Free(rtmp); } delete (url); - return 0; + return nullptr; } RTMP_PUSHER_FUNC(void, native_1init) { @@ -166,10 +166,10 @@ RTMP_PUSHER_FUNC(void, native_1start, jstring path_) { return; } isStart = 1; - const char *path = env->GetStringUTFChars(path_, 0); + const char *path = env->GetStringUTFChars(path_, nullptr); char *url = new char[strlen(path) + 1]; strcpy(url, path); - pthread_create(&pid, 0, start, url); + pthread_create(&pid, nullptr, start, url); env->ReleaseStringUTFChars(path_, path); } @@ -177,7 +177,7 @@ RTMP_PUSHER_FUNC(void, native_1pushVideo, jbyteArray data_) { if (!videoStream || !readyPushing) { return; } - jbyte *data = env->GetByteArrayElements(data_, NULL); + jbyte *data = env->GetByteArrayElements(data_, nullptr); videoStream->encodeData(data); env->ReleaseByteArrayElements(data_, data, 0); } @@ -186,9 +186,9 @@ RTMP_PUSHER_FUNC(void, native_1pushVideoNew, jbyteArray y, jbyteArray u, jbyteAr if (!videoStream || !readyPushing) { return; } - jbyte *y_plane = env->GetByteArrayElements(y, NULL); - jbyte *u_plane = env->GetByteArrayElements(u, NULL); - jbyte *v_plane = env->GetByteArrayElements(v, NULL); + jbyte *y_plane = env->GetByteArrayElements(y, nullptr); + jbyte *u_plane = env->GetByteArrayElements(u, nullptr); + jbyte *v_plane = env->GetByteArrayElements(v, nullptr); videoStream->encodeDataNew(y_plane, u_plane, v_plane); env->ReleaseByteArrayElements(y, y_plane, 0); env->ReleaseByteArrayElements(u, u_plane, 0); @@ -212,7 +212,7 @@ RTMP_PUSHER_FUNC(void, native_1pushAudio, jbyteArray data_) { if (!audioStream || !readyPushing) { return; } - jbyte *data = env->GetByteArrayElements(data_, NULL); + jbyte *data = env->GetByteArrayElements(data_, nullptr); audioStream->encodeData(data); env->ReleaseByteArrayElements(data_, data, 0); } @@ -221,7 +221,7 @@ RTMP_PUSHER_FUNC(void, native_1stop) { LOGI("native stop..."); readyPushing = 0; packets.setWork(0); - pthread_join(pid, 0); + pthread_join(pid, nullptr); } RTMP_PUSHER_FUNC(void, native_1release) { diff --git a/Live/src/main/cpp/VideoStream.cpp b/Live/src/main/cpp/VideoStream.cpp index 4c0d560..84a0b66 100644 --- a/Live/src/main/cpp/VideoStream.cpp +++ b/Live/src/main/cpp/VideoStream.cpp @@ -5,14 +5,14 @@ #include "PushInterface.h" VideoStream::VideoStream() { - pthread_mutex_init(&mutex, 0); + pthread_mutex_init(&mutex, nullptr); } VideoStream::~VideoStream() { pthread_mutex_destroy(&mutex); if (videoCodec) { x264_encoder_close(videoCodec); - videoCodec = 0; + videoCodec = nullptr; } if (pic_in) { x264_picture_clean(pic_in); @@ -30,7 +30,7 @@ void VideoStream::setVideoEncInfo(int width, int height, int fps, int bitrate) { uvSize = ySize / 4; if (videoCodec) { x264_encoder_close(videoCodec); - videoCodec = 0; + videoCodec = nullptr; } if (pic_in) { x264_picture_clean(pic_in); @@ -147,7 +147,7 @@ void VideoStream::encodeDataNew(int8_t *y_plane, int8_t *u_plane, int8_t *v_plan void VideoStream::sendSpsPps(uint8_t *sps, uint8_t *pps, int sps_len, int pps_len) { int bodySize = 13 + sps_len + 3 + pps_len; - RTMPPacket *packet = new RTMPPacket; + auto *packet = new RTMPPacket; RTMPPacket_Alloc(packet, bodySize); int i = 0; //start code @@ -200,7 +200,7 @@ void VideoStream::sendFrame(int type, uint8_t *payload, int i_payload) { payload += 3; } int bodySize = 9 + i_payload; - RTMPPacket *packet = new RTMPPacket; + auto *packet = new RTMPPacket; RTMPPacket_Alloc(packet, bodySize); packet->m_body[0] = 0x27;