From 6d778cc76d61af7d418943004afcac644d65d06d Mon Sep 17 00:00:00 2001 From: xufuji456 <839789740@qq.com> Date: Sun, 21 Feb 2021 00:00:44 +0800 Subject: [PATCH] change packet_queue.c to cpp --- app/CMakeLists.txt | 2 +- app/src/main/cpp/media_player.c | 2 +- .../cpp/{AVpacket_queue.c => packet_queue.cpp} | 6 +++--- .../main/cpp/{AVpacket_queue.h => packet_queue.h} | 14 +++++++++++--- 4 files changed, 16 insertions(+), 8 deletions(-) rename app/src/main/cpp/{AVpacket_queue.c => packet_queue.cpp} (88%) rename app/src/main/cpp/{AVpacket_queue.h => packet_queue.h} (79%) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index fc82582..d5755a7 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -29,7 +29,7 @@ add_library( # Sets the name of the library. src/main/cpp/openSL_audio_player.c src/main/cpp/video_player.c src/main/cpp/ffmpeg_pusher.cpp - src/main/cpp/AVpacket_queue.c + src/main/cpp/packet_queue.cpp src/main/cpp/media_player.c src/main/cpp/video_filter.c src/main/cpp/fast_start.c diff --git a/app/src/main/cpp/media_player.c b/app/src/main/cpp/media_player.c index 9fc39ba..bcf5ca6 100644 --- a/app/src/main/cpp/media_player.c +++ b/app/src/main/cpp/media_player.c @@ -5,7 +5,7 @@ #include "libavformat/avformat.h" #include "libswscale/swscale.h" #include "libswresample/swresample.h" -#include "AVpacket_queue.h" +#include "packet_queue.h" #include #include #include diff --git a/app/src/main/cpp/AVpacket_queue.c b/app/src/main/cpp/packet_queue.cpp similarity index 88% rename from app/src/main/cpp/AVpacket_queue.c rename to app/src/main/cpp/packet_queue.cpp index 74d9627..0df07d6 100644 --- a/app/src/main/cpp/AVpacket_queue.c +++ b/app/src/main/cpp/packet_queue.cpp @@ -1,18 +1,18 @@ // // Created by frank on 2018/2/3. // -#include "AVpacket_queue.h" +#include "packet_queue.h" #include #include AVPacketQueue *queue_init(int size) { - AVPacketQueue *queue = malloc(sizeof(AVPacketQueue)); + AVPacketQueue *queue = static_cast(malloc(sizeof(AVPacketQueue))); queue->size = size; queue->next_to_read = 0; queue->next_to_write = 0; int i; - queue->packets = malloc(sizeof(*queue->packets) * size); + queue->packets = static_cast(malloc(sizeof(*queue->packets) * size)); for (i = 0; i < size; i++) { queue->packets[i] = malloc(sizeof(AVPacket)); } diff --git a/app/src/main/cpp/AVpacket_queue.h b/app/src/main/cpp/packet_queue.h similarity index 79% rename from app/src/main/cpp/AVpacket_queue.h rename to app/src/main/cpp/packet_queue.h index 1497a7d..10b578b 100644 --- a/app/src/main/cpp/AVpacket_queue.h +++ b/app/src/main/cpp/packet_queue.h @@ -2,11 +2,15 @@ // Created by frank on 2018/2/3. // -#ifndef VIDEOPLAYER_AVPACKET_QUEUE_H -#define VIDEOPLAYER_AVPACKET_QUEUE_H +#ifndef PACKET_QUEUE_H +#define PACKET_QUEUE_H #include +#ifdef __cplusplus +extern "C" { +#endif + typedef struct AVPacketQueue { //the size of queue int size; @@ -26,4 +30,8 @@ void *queue_push(AVPacketQueue *queue, pthread_mutex_t *mutex, pthread_cond_t *c void *queue_pop(AVPacketQueue *queue, pthread_mutex_t *mutex, pthread_cond_t *cond); -#endif //VIDEOPLAYER_AVPACKET_QUEUE_H \ No newline at end of file +#endif //PACKET_QUEUE_H + +#ifdef __cplusplus +} +#endif \ No newline at end of file