diff --git a/app/src/main/cpp/audio_player.cpp b/app/src/main/cpp/audio_player.cpp index 739fc8e..abeb005 100644 --- a/app/src/main/cpp/audio_player.cpp +++ b/app/src/main/cpp/audio_player.cpp @@ -41,7 +41,7 @@ int init_volume_filter(AVFilterGraph **graph, AVFilterContext **src, AVFilterCon const AVFilter *volume; AVFilterContext *buffersink_ctx; const AVFilter *buffersink; - AVDictionary *options_dict = NULL; + AVDictionary *options_dict = nullptr; uint8_t ch_layout[64]; int ret; @@ -68,7 +68,7 @@ int init_volume_filter(AVFilterGraph **graph, AVFilterContext **src, AVFilterCon av_opt_set (buffer_ctx, "sample_fmt", av_get_sample_fmt_name(inputFormat), AV_OPT_SEARCH_CHILDREN); av_opt_set_q (buffer_ctx, "time_base", (AVRational){ 1, sample_rate }, AV_OPT_SEARCH_CHILDREN); av_opt_set_int(buffer_ctx, "sample_rate", sample_rate, AV_OPT_SEARCH_CHILDREN); - ret = avfilter_init_str(buffer_ctx, NULL); + ret = avfilter_init_str(buffer_ctx, nullptr); if (ret < 0) { LOGE(TAG, "Could not initialize the buffer filter:%d", ret); return ret; @@ -105,7 +105,7 @@ int init_volume_filter(AVFilterGraph **graph, AVFilterContext **src, AVFilterCon LOGE(TAG, "Could not allocate the abuffersink instance..."); return AVERROR(ENOMEM); } - ret = avfilter_init_str(buffersink_ctx, NULL); + ret = avfilter_init_str(buffersink_ctx, nullptr); if (ret < 0) { LOGE(TAG, "Could not initialize the abuffersink instance:%d", ret); return ret; @@ -119,7 +119,7 @@ int init_volume_filter(AVFilterGraph **graph, AVFilterContext **src, AVFilterCon return ret; } /* Configure the graph. */ - ret = avfilter_graph_config(filter_graph, NULL); + ret = avfilter_graph_config(filter_graph, nullptr); if (ret < 0) { LOGE(TAG, "Error configuring the filter graph:%d", ret); return ret; @@ -158,14 +158,14 @@ int init_equalizer_filter(const char *filter_desc, AVCodecContext *codecCtx, AVF av_get_sample_fmt_name(codecCtx->sample_fmt), codecCtx->channel_layout); ret = avfilter_graph_create_filter(&buffersrc_ctx, buffersrc, "in", - args, NULL, filter_graph); + args, nullptr, filter_graph); if (ret < 0) { LOGE(TAG, "Cannot create buffer source:%d", ret); goto end; } /* buffer audio sink: to terminate the filter chain. */ ret = avfilter_graph_create_filter(&buffersink_ctx, buffersink, "out", - NULL, NULL, filter_graph); + nullptr, nullptr, filter_graph); if (ret < 0) { LOGE(TAG, "Cannot create buffer sink:%d", ret); goto end; @@ -174,18 +174,18 @@ int init_equalizer_filter(const char *filter_desc, AVCodecContext *codecCtx, AVF outputs->name = av_strdup("in"); outputs->filter_ctx = buffersrc_ctx; outputs->pad_idx = 0; - outputs->next = NULL; + outputs->next = nullptr; inputs->name = av_strdup("out"); inputs->filter_ctx = buffersink_ctx; inputs->pad_idx = 0; - inputs->next = NULL; + inputs->next = nullptr; if ((ret = avfilter_graph_parse_ptr(filter_graph, filter_desc, - &inputs, &outputs, NULL)) < 0) { + &inputs, &outputs, nullptr)) < 0) { LOGE(TAG, "avfilter_graph_parse_ptr error:%d", ret); goto end; } - if ((ret = avfilter_graph_config(filter_graph, NULL)) < 0) { + if ((ret = avfilter_graph_config(filter_graph, nullptr)) < 0) { LOGE(TAG, "avfilter_graph_config error:%d", ret); goto end; } @@ -204,17 +204,17 @@ AUDIO_PLAYER_FUNC(void, play, jstring input_jstr, jstring filter_jstr) { AVFilterContext *audioSrcContext; AVFilterContext *audioSinkContext; - const char *input_cstr = env->GetStringUTFChars(input_jstr, NULL); + const char *input_cstr = env->GetStringUTFChars(input_jstr, nullptr); LOGI(TAG, "input url=%s", input_cstr); - filter_desc = env->GetStringUTFChars(filter_jstr, NULL); + filter_desc = env->GetStringUTFChars(filter_jstr, nullptr); LOGE(TAG, "filter_desc=%s", filter_desc); av_register_all(); AVFormatContext *pFormatCtx = avformat_alloc_context(); - if (avformat_open_input(&pFormatCtx, input_cstr, NULL, NULL) != 0) { + if (avformat_open_input(&pFormatCtx, input_cstr, nullptr, nullptr) != 0) { LOGE(TAG, "Couldn't open the audio file!"); return; } - if (avformat_find_stream_info(pFormatCtx, NULL) < 0) { + if (avformat_find_stream_info(pFormatCtx, nullptr) < 0) { LOGE(TAG, "Couldn't find stream info!"); return; } @@ -231,7 +231,7 @@ AUDIO_PLAYER_FUNC(void, play, jstring input_jstr, jstring filter_jstr) { LOGE(TAG, "Couldn't find audio decoder!"); return; } - if (avcodec_open2(codecCtx, codec, NULL) < 0) { + if (avcodec_open2(codecCtx, codec, nullptr) < 0) { LOGE(TAG, "Couldn't open audio decoder"); return; } @@ -247,8 +247,7 @@ AUDIO_PLAYER_FUNC(void, play, jstring input_jstr, jstring filter_jstr) { swr_alloc_set_opts(swrCtx, out_ch_layout, out_sample_fmt, out_sample_rate, - in_ch_layout, in_sample_fmt, in_sample_rate, - 0, NULL); + in_ch_layout, in_sample_fmt, in_sample_rate, 0, nullptr); swr_init(swrCtx); int out_channel = av_get_channel_layout_nb_channels(out_ch_layout); jclass player_class = env->GetObjectClass(thiz); @@ -316,11 +315,11 @@ AUDIO_PLAYER_FUNC(void, play, jstring input_jstr, jstring filter_jstr) { //convert audio format swr_convert(swrCtx, &out_buffer, MAX_AUDIO_FRAME_SIZE, (const uint8_t **) /*frame*/filter_frame->data, /*frame*/filter_frame->nb_samples); - int out_buffer_size = av_samples_get_buffer_size(NULL, out_channel, + int out_buffer_size = av_samples_get_buffer_size(nullptr, out_channel, /*frame*/filter_frame->nb_samples, out_sample_fmt, 1); jbyteArray audio_sample_array = env->NewByteArray(out_buffer_size); - jbyte *sample_byte_array = env->GetByteArrayElements(audio_sample_array, NULL); + jbyte *sample_byte_array = env->GetByteArrayElements(audio_sample_array, nullptr); memcpy(sample_byte_array, out_buffer, (size_t) out_buffer_size); env->ReleaseByteArrayElements(audio_sample_array, sample_byte_array, 0); //call write method to play @@ -353,7 +352,7 @@ end: AUDIO_PLAYER_FUNC(void, again, jstring filter_jstr) { if (!filter_jstr) return; filter_again = 1; - filter_desc = env->GetStringUTFChars(filter_jstr, NULL); + filter_desc = env->GetStringUTFChars(filter_jstr, nullptr); } AUDIO_PLAYER_FUNC(void, release) { diff --git a/app/src/main/cpp/ffmpeg_pusher.cpp b/app/src/main/cpp/ffmpeg_pusher.cpp index 6717d5c..80268e0 100644 --- a/app/src/main/cpp/ffmpeg_pusher.cpp +++ b/app/src/main/cpp/ffmpeg_pusher.cpp @@ -18,7 +18,7 @@ extern "C" { PUSHER_FUNC(jint, pushStream, jstring filePath, jstring liveUrl) { - AVFormatContext *in_format = NULL, *out_format = NULL; + AVFormatContext *in_format = nullptr, *out_format = nullptr; AVPacket packet; const char *file_path, *live_url; int video_index = -1; @@ -26,8 +26,8 @@ PUSHER_FUNC(jint, pushStream, jstring filePath, jstring liveUrl) { int frame_index = 0; int64_t start_time = 0; - file_path = env->GetStringUTFChars(filePath, NULL); - live_url = env->GetStringUTFChars(liveUrl, NULL); + file_path = env->GetStringUTFChars(filePath, nullptr); + live_url = env->GetStringUTFChars(liveUrl, nullptr); LOGE(TAG, "file_path=%s", file_path); LOGE(TAG, "live_url=%s", live_url); @@ -49,7 +49,7 @@ PUSHER_FUNC(jint, pushStream, jstring filePath, jstring liveUrl) { } } av_dump_format(in_format, 0, file_path, 0); - avformat_alloc_output_context2(&out_format, NULL, "flv", live_url); + avformat_alloc_output_context2(&out_format, nullptr, "flv", live_url); if (!out_format) { LOGE(TAG, "could not alloc output context..."); ret = AVERROR_UNKNOWN; @@ -84,7 +84,7 @@ PUSHER_FUNC(jint, pushStream, jstring filePath, jstring liveUrl) { } } //Write header - ret = avformat_write_header(out_format, NULL); + ret = avformat_write_header(out_format, nullptr); if (ret < 0) { LOGE(TAG, "could not write header..."); goto end; diff --git a/app/src/main/cpp/media_player.cpp b/app/src/main/cpp/media_player.cpp index b6ca446..aab5ced 100644 --- a/app/src/main/cpp/media_player.cpp +++ b/app/src/main/cpp/media_player.cpp @@ -85,12 +85,12 @@ int init_input_format_context(MediaPlayer* player, const char* file_name){ //alloc format context player->format_context = avformat_alloc_context(); //open the input file - if(avformat_open_input(&player->format_context, file_name, NULL, NULL)!=0) { + if(avformat_open_input(&player->format_context, file_name, nullptr, nullptr)!=0) { LOGE(TAG, "Couldn't open file:%s\n", file_name); return -1; } //find the info of all streams - if(avformat_find_stream_info(player->format_context, NULL)<0) { + if(avformat_find_stream_info(player->format_context, nullptr)<0) { LOGE(TAG, "Couldn't find stream information."); return -1; } @@ -126,21 +126,21 @@ int init_codec_context(MediaPlayer* player){ player->video_codec_context = player->format_context->streams[player->video_stream_index]->codec; //find audio and video decoder player->video_codec = avcodec_find_decoder(player->video_codec_context->codec_id); - if(player->video_codec == NULL) { + if(player->video_codec == nullptr) { LOGE(TAG, "couldn't find video Codec."); return -1; } - if(avcodec_open2(player->video_codec_context, player->video_codec, NULL) < 0) { + if(avcodec_open2(player->video_codec_context, player->video_codec, nullptr) < 0) { LOGE(TAG, "Couldn't open video codec."); return -1; } player->audio_codec_context = player->format_context->streams[player->audio_stream_index]->codec; player->audio_codec = avcodec_find_decoder(player->audio_codec_context->codec_id); - if( player->audio_codec == NULL) { + if( player->audio_codec == nullptr) { LOGE(TAG, "couldn't find audio Codec."); return -1; } - if(avcodec_open2(player->audio_codec_context, player->audio_codec, NULL) < 0) { + if(avcodec_open2(player->audio_codec_context, player->audio_codec, nullptr) < 0) { LOGE(TAG, "Couldn't open audio codec."); return -1; } @@ -188,7 +188,7 @@ void player_wait_for_frame(MediaPlayer *player, int64_t stream_time) { //TODO: waiting util time out // pthread_cond_timeout_np(&player->cond, &player->mutex, // (unsigned int) (sleep_time / 1000ll)); - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); timeout.tv_sec = now.tv_sec; timeout.tv_nsec = static_cast((now.tv_usec + sleep_time) * 1000); pthread_cond_timedwait(&player->cond, &player->mutex, &timeout); @@ -204,7 +204,7 @@ int decode_video(MediaPlayer* player, AVPacket* packet){ ANativeWindow_Buffer windowBuffer; player->yuv_frame = av_frame_alloc(); player->rgba_frame = av_frame_alloc(); - if(player->rgba_frame == NULL || player->yuv_frame == NULL) { + if(player->rgba_frame == nullptr || player->yuv_frame == nullptr) { LOGE(TAG, "Couldn't allocate video frame."); return -1; } @@ -224,9 +224,9 @@ int decode_video(MediaPlayer* player, AVPacket* packet){ player->video_height, AV_PIX_FMT_RGBA, SWS_BILINEAR, - NULL, - NULL, - NULL); + nullptr, + nullptr, + nullptr); int frameFinished; //decode video frame @@ -285,7 +285,7 @@ void audio_decoder_prepare(MediaPlayer* player) { swr_alloc_set_opts(player->swrContext, out_ch_layout, player->out_sample_fmt, player->out_sample_rate, in_ch_layout, in_sample_fmt, in_sample_rate, - 0, NULL); + 0, nullptr); swr_init(player->swrContext); player->out_channel_nb = av_get_channel_layout_nb_channels(out_ch_layout); } @@ -332,7 +332,7 @@ int decode_audio(MediaPlayer* player, AVPacket* packet){ MAX_AUDIO_FRAME_SIZE, (const uint8_t **)player->audio_frame->data, player->audio_frame->nb_samples); - int out_buffer_size = av_samples_get_buffer_size(NULL, + int out_buffer_size = av_samples_get_buffer_size(nullptr, player->out_channel_nb, player->audio_frame->nb_samples, player->out_sample_fmt, @@ -346,11 +346,11 @@ int decode_audio(MediaPlayer* player, AVPacket* packet){ player_wait_for_frame(player, player->audio_clock + AUDIO_TIME_ADJUST_US); } - if(javaVM != NULL){ + if(javaVM != nullptr){ JNIEnv * env; - javaVM->AttachCurrentThread(&env, NULL); + javaVM->AttachCurrentThread(&env, nullptr); jbyteArray audio_sample_array = env->NewByteArray(out_buffer_size); - jbyte* sample_byte_array = env->GetByteArrayElements(audio_sample_array,NULL); + jbyte* sample_byte_array = env->GetByteArrayElements(audio_sample_array, nullptr); memcpy(sample_byte_array, player->audio_buffer, (size_t) out_buffer_size); env->ReleaseByteArrayElements(audio_sample_array,sample_byte_array,0); //call write method of AudioTrack to play @@ -432,7 +432,7 @@ MEDIA_PLAYER_FUNC(jint, setup, jstring filePath, jobject surface){ const char *file_name = env->GetStringUTFChars(filePath, JNI_FALSE); int ret; player = static_cast(malloc(sizeof(MediaPlayer))); - if(player == NULL){ + if(player == nullptr){ return -1; } ret = init_input_format_context(player, file_name); @@ -456,23 +456,23 @@ MEDIA_PLAYER_FUNC(jint, setup, jstring filePath, jobject surface){ } MEDIA_PLAYER_FUNC(jint, play){ - pthread_mutex_init(&player->mutex, NULL); - pthread_cond_init(&player->cond, NULL); + pthread_mutex_init(&player->mutex, nullptr); + pthread_cond_init(&player->cond, nullptr); - pthread_create(&player->write_thread, NULL, write_packet_to_queue, (void*)player); + pthread_create(&player->write_thread, nullptr, write_packet_to_queue, (void*)player); sleep(1); player->start_time = 0; Decoder data1 = {player, player->video_stream_index}, *decoder_data1 = &data1; - pthread_create(&player->video_thread, NULL, decode_func, (void*)decoder_data1); + pthread_create(&player->video_thread, nullptr, decode_func, (void*)decoder_data1); Decoder data2 = {player, player->audio_stream_index}, *decoder_data2 = &data2; - pthread_create(&player->audio_thread,NULL,decode_func,(void*)decoder_data2); + pthread_create(&player->audio_thread, nullptr, decode_func, (void*)decoder_data2); - pthread_join(player->write_thread, NULL); - pthread_join(player->video_thread, NULL); - pthread_join(player->audio_thread, NULL); + pthread_join(player->write_thread, nullptr); + pthread_join(player->video_thread, nullptr); + pthread_join(player->audio_thread, nullptr); return 0; } diff --git a/app/src/main/cpp/openSL_audio_player.cpp b/app/src/main/cpp/openSL_audio_player.cpp index 0236b69..c1cf8f1 100644 --- a/app/src/main/cpp/openSL_audio_player.cpp +++ b/app/src/main/cpp/openSL_audio_player.cpp @@ -24,15 +24,15 @@ extern "C" { #define TAG "OpenSLPlayer" //object of engine -SLObjectItf engineObject = NULL; +SLObjectItf engineObject = nullptr; SLEngineItf engineEngine; //object of mixer -SLObjectItf outputMixObject = NULL; -SLEnvironmentalReverbItf outputMixEnvironmentalReverb = NULL; +SLObjectItf outputMixObject = nullptr; +SLEnvironmentalReverbItf outputMixEnvironmentalReverb = nullptr; //object of buffer -SLObjectItf bqPlayerObject = NULL; +SLObjectItf bqPlayerObject = nullptr; SLPlayItf bqPlayerPlay; SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue; SLEffectSendItf bqPlayerEffectSend; @@ -63,7 +63,7 @@ int getPCM(void **pcm, size_t *pcmSize); void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bufferQueueItf, void *context) { bufferSize = 0; getPCM(&openBuffer, &bufferSize); - if (NULL != openBuffer && 0 != bufferSize) { + if (nullptr != openBuffer && 0 != bufferSize) { SLresult result; result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, openBuffer, bufferSize); if (result < 0) { @@ -77,7 +77,7 @@ void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bufferQueueItf, void *contex //create the engine of OpenSLES void createEngine() { SLresult result; - result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL); + result = slCreateEngine(&engineObject, 0, nullptr, 0, nullptr, nullptr); LOGI(TAG, "slCreateEngine=%d", result); result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE); LOGI(TAG, "engineObject->Realize=%d", result); @@ -118,7 +118,7 @@ void createBufferQueueAudioPlayer(int rate, int channel, int bitsPerSample) { SLDataSource audioSrc = {&buffer_queue, &format_pcm}; SLDataLocator_OutputMix loc_outmix = {SL_DATALOCATOR_OUTPUTMIX, outputMixObject}; - SLDataSink audioSnk = {&loc_outmix, NULL}; + SLDataSink audioSnk = {&loc_outmix, nullptr}; const SLInterfaceID ids[3] = {SL_IID_BUFFERQUEUE, SL_IID_EFFECTSEND, SL_IID_VOLUME}; const SLboolean req[3] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE}; @@ -136,7 +136,7 @@ void createBufferQueueAudioPlayer(int rate, int channel, int bitsPerSample) { &bqPlayerBufferQueue); LOGI(TAG, "GetInterface bqPlayerBufferQueue=%d", result); - result = (*bqPlayerBufferQueue)->RegisterCallback(bqPlayerBufferQueue, bqPlayerCallback, NULL); + result = (*bqPlayerBufferQueue)->RegisterCallback(bqPlayerBufferQueue, bqPlayerCallback, nullptr); LOGI(TAG, "RegisterCallback=%d", result); result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_EFFECTSEND, @@ -155,12 +155,12 @@ int createAudioPlayer(int *rate, int *channel, const char *file_name) { av_register_all(); aFormatCtx = avformat_alloc_context(); - if (avformat_open_input(&aFormatCtx, file_name, NULL, NULL) != 0) { + if (avformat_open_input(&aFormatCtx, file_name, nullptr, nullptr) != 0) { LOGE(TAG, "Couldn't open file:%s\n", file_name); return -1; } - if (avformat_find_stream_info(aFormatCtx, NULL) < 0) { + if (avformat_find_stream_info(aFormatCtx, nullptr) < 0) { LOGE(TAG, "Couldn't find stream information."); return -1; } @@ -184,7 +184,7 @@ int createAudioPlayer(int *rate, int *channel, const char *file_name) { fprintf(stderr, "Unsupported codec!\n"); return -1; } - if (avcodec_open2(aCodecCtx, aCodec, NULL) < 0) { + if (avcodec_open2(aCodecCtx, aCodec, nullptr) < 0) { LOGE(TAG, "Could not open codec."); return -1; } @@ -248,35 +248,35 @@ int releaseAudioPlayer() { AUDIO_PLAYER_FUNC(void, playAudio, jstring filePath) { int rate, channel; - const char *file_name = env->GetStringUTFChars(filePath, NULL); + const char *file_name = env->GetStringUTFChars(filePath, nullptr); LOGI(TAG, "file_name=%s", file_name); createAudioPlayer(&rate, &channel, file_name); createEngine(); createBufferQueueAudioPlayer(rate, channel, SL_PCMSAMPLEFORMAT_FIXED_16); - bqPlayerCallback(bqPlayerBufferQueue, NULL); + bqPlayerCallback(bqPlayerBufferQueue, nullptr); } AUDIO_PLAYER_FUNC(void, stop) { - if (bqPlayerObject != NULL) { + if (bqPlayerObject != nullptr) { (*bqPlayerObject)->Destroy(bqPlayerObject); - bqPlayerObject = NULL; - bqPlayerPlay = NULL; - bqPlayerBufferQueue = NULL; - bqPlayerEffectSend = NULL; - bqPlayerVolume = NULL; + bqPlayerObject = nullptr; + bqPlayerPlay = nullptr; + bqPlayerBufferQueue = nullptr; + bqPlayerEffectSend = nullptr; + bqPlayerVolume = nullptr; } - if (outputMixObject != NULL) { + if (outputMixObject != nullptr) { (*outputMixObject)->Destroy(outputMixObject); - outputMixObject = NULL; - outputMixEnvironmentalReverb = NULL; + outputMixObject = nullptr; + outputMixEnvironmentalReverb = nullptr; } - if (engineObject != NULL) { + if (engineObject != nullptr) { (*engineObject)->Destroy(engineObject); - engineObject = NULL; - engineEngine = NULL; + engineObject = nullptr; + engineEngine = nullptr; } releaseAudioPlayer(); diff --git a/app/src/main/cpp/video_player.cpp b/app/src/main/cpp/video_player.cpp index c8a356f..cf378a9 100644 --- a/app/src/main/cpp/video_player.cpp +++ b/app/src/main/cpp/video_player.cpp @@ -29,11 +29,11 @@ VIDEO_PLAYER_FUNC(jint, play, jstring filePath, jobject surface) { LOGE(TAG, "open file:%s\n", file_name); av_register_all(); AVFormatContext *pFormatCtx = avformat_alloc_context(); - if (avformat_open_input(&pFormatCtx, file_name, NULL, NULL) != 0) { + if (avformat_open_input(&pFormatCtx, file_name, nullptr, nullptr) != 0) { LOGE(TAG, "Couldn't open file:%s\n", file_name); return -1; } - if (avformat_find_stream_info(pFormatCtx, NULL) < 0) { + if (avformat_find_stream_info(pFormatCtx, nullptr) < 0) { LOGE(TAG, "Couldn't find stream information."); return -1; } @@ -57,11 +57,11 @@ VIDEO_PLAYER_FUNC(jint, play, jstring filePath, jobject surface) { AVCodecContext *pCodecCtx = pFormatCtx->streams[videoStream]->codec; AVCodec *pCodec = avcodec_find_decoder(pCodecCtx->codec_id); - if (pCodec == NULL) { + if (pCodec == nullptr) { LOGE(TAG, "couldn't find Codec."); return -1; } - if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0) { + if (avcodec_open2(pCodecCtx, pCodec, nullptr) < 0) { LOGE(TAG, "Couldn't open codec."); return -1; } @@ -72,13 +72,13 @@ VIDEO_PLAYER_FUNC(jint, play, jstring filePath, jobject surface) { ANativeWindow_setBuffersGeometry(nativeWindow, videoWidth, videoHeight, WINDOW_FORMAT_RGBA_8888); ANativeWindow_Buffer windowBuffer; - if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0) { + if (avcodec_open2(pCodecCtx, pCodec, nullptr) < 0) { LOGE(TAG, "Couldn't open codec."); return -1; } AVFrame *pFrame = av_frame_alloc(); AVFrame *pFrameRGBA = av_frame_alloc(); - if (pFrameRGBA == NULL || pFrame == NULL) { + if (pFrameRGBA == nullptr || pFrame == nullptr) { LOGE(TAG, "Couldn't allocate video frame."); return -1; } @@ -96,9 +96,9 @@ VIDEO_PLAYER_FUNC(jint, play, jstring filePath, jobject surface) { pCodecCtx->height, AV_PIX_FMT_RGBA, SWS_BILINEAR, - NULL, - NULL, - NULL); + nullptr, + nullptr, + nullptr); int frameFinished; AVPacket packet;