change packet_queue.c to cpp

pull/166/head
xufuji456 4 years ago
parent 7347333359
commit 6d778cc76d
  1. 2
      app/CMakeLists.txt
  2. 2
      app/src/main/cpp/media_player.c
  3. 6
      app/src/main/cpp/packet_queue.cpp
  4. 14
      app/src/main/cpp/packet_queue.h

@ -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

@ -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 <android/native_window.h>
#include <android/native_window_jni.h>
#include <stdio.h>

@ -1,18 +1,18 @@
//
// Created by frank on 2018/2/3.
//
#include "AVpacket_queue.h"
#include "packet_queue.h"
#include <stdlib.h>
#include <libavcodec/avcodec.h>
AVPacketQueue *queue_init(int size) {
AVPacketQueue *queue = malloc(sizeof(AVPacketQueue));
AVPacketQueue *queue = static_cast<AVPacketQueue *>(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<void **>(malloc(sizeof(*queue->packets) * size));
for (i = 0; i < size; i++) {
queue->packets[i] = malloc(sizeof(AVPacket));
}

@ -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 <pthread.h>
#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
#endif //PACKET_QUEUE_H
#ifdef __cplusplus
}
#endif
Loading…
Cancel
Save