Feature: remove macro define

pull/221/head
xufuji456 2 years ago
parent 23d4263c71
commit f48e4c2332
  1. 5
      Live/src/main/cpp/AudioStream.cpp
  2. 2
      Live/src/main/cpp/AudioStream.h
  3. 12
      Live/src/main/cpp/PacketQueue.h
  4. 2
      Live/src/main/cpp/PushInterface.h
  5. 13
      Live/src/main/cpp/RtmpPusher.cpp
  6. 11
      Live/src/main/cpp/VideoStream.cpp
  7. 2
      Live/src/main/cpp/VideoStream.h

@ -8,7 +8,8 @@ AudioStream::AudioStream() {
}
AudioStream::~AudioStream() {
DELETE(buffer);
delete buffer;
buffer = nullptr;
if (audioCodec) {
faacEncClose(audioCodec);
audioCodec = nullptr;
@ -39,7 +40,7 @@ void AudioStream::setAudioEncInfo(int samplesInHZ, int channels) {
buffer = new u_char[maxOutputBytes];
}
int AudioStream::getInputSamples() {
int AudioStream::getInputSamples() const {
return static_cast<int>(inputSamples);
}

@ -18,7 +18,7 @@ public:
void setAudioCallback(AudioCallback audioCallback);
int getInputSamples();
int getInputSamples() const;
void encodeData(int8_t *data);

@ -12,7 +12,7 @@ class PacketQueue {
public:
void push(T new_value) {
std::lock_guard<std::mutex> lk(m_mutex);
std::lock_guard<std::mutex> lock(m_mutex);
if (m_running) {
m_queue.push(new_value);
m_cond.notify_one();
@ -21,7 +21,7 @@ public:
int pop(T &value) {
int ret = 0;
std::unique_lock<std::mutex> lk(m_mutex);
std::unique_lock<std::mutex> lock(m_mutex);
if (!m_running) {
return ret;
}
@ -34,22 +34,22 @@ public:
}
void setRunning(bool run) {
std::lock_guard<std::mutex> lk(m_mutex);
std::lock_guard<std::mutex> lock(m_mutex);
m_running = run;
}
int empty() {
std::lock_guard<std::mutex> lk(m_mutex);
std::lock_guard<std::mutex> lock(m_mutex);
return m_queue.empty();
}
int size() {
std::lock_guard<std::mutex> lk(m_mutex);
std::lock_guard<std::mutex> lock(m_mutex);
return static_cast<int>(m_queue.size());
}
void clear() {
std::lock_guard<std::mutex> lk(m_mutex);
std::lock_guard<std::mutex> lock(m_mutex);
int size = m_queue.size();
for (int i = 0; i < size; ++i) {
T value = m_queue.front();

@ -7,6 +7,4 @@
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,"FrankLive",__VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,"FrankLive",__VA_ARGS__)
#define DELETE(obj) if(obj){ delete obj; obj = 0; }
#endif

@ -12,7 +12,6 @@
PacketQueue<RTMPPacket *> packets;
VideoStream *videoStream = nullptr;
int isStart = 0;
pthread_t pid;
std::atomic<bool> isPushing;
@ -76,7 +75,7 @@ void releasePackets(RTMPPacket *&packet) {
void *start(void *args) {
char *url = static_cast<char *>(args);
RTMP *rtmp = nullptr;
RTMP *rtmp;
do {
rtmp = RTMP_Alloc();
if (!rtmp) {
@ -131,7 +130,6 @@ void *start(void *args) {
}
releasePackets(packet);
} while (0);
isStart = 0;
isPushing = false;
packets.setRunning(false);
packets.clear();
@ -162,10 +160,9 @@ RTMP_PUSHER_FUNC(void, native_1setVideoCodecInfo,
RTMP_PUSHER_FUNC(void, native_1start, jstring path_) {
LOGI("native start...");
if (isStart) {
if (isPushing) {
return;
}
isStart = 1;
const char *path = env->GetStringUTFChars(path_, nullptr);
char *url = new char[strlen(path) + 1];
strcpy(url, path);
@ -214,6 +211,8 @@ RTMP_PUSHER_FUNC(void, native_1stop) {
RTMP_PUSHER_FUNC(void, native_1release) {
LOGI("native release...");
env->DeleteGlobalRef(jobject_error);
DELETE(videoStream);
DELETE(audioStream);
delete videoStream;
videoStream = nullptr;
delete audioStream;
audioStream = nullptr;
}

@ -18,7 +18,8 @@ VideoStream::~VideoStream() {
}
if (pic_in) {
x264_picture_clean(pic_in);
DELETE(pic_in);
delete pic_in;
pic_in = nullptr;
}
}
@ -31,7 +32,8 @@ void VideoStream::setVideoEncInfo(int width, int height, int fps, int bitrate) {
}
if (pic_in) {
x264_picture_clean(pic_in);
DELETE(pic_in);
delete pic_in;
pic_in = nullptr;
}
//setting x264 params
@ -79,9 +81,12 @@ void VideoStream::setVideoCallback(VideoCallback callback) {
this->videoCallback = callback;
}
void VideoStream::encodeVideo(int8_t *data, int8_t camera_type) {
void VideoStream::encodeVideo(int8_t *data, int camera_type) {
pthread_mutex_lock(&mutex);
if (!pic_in)
return;
if (camera_type == 1) {
memcpy(pic_in->img.plane[0], data, m_frameLen); // y
for (int i = 0; i < m_frameLen/4; ++i) {

@ -17,7 +17,7 @@ public:
void setVideoEncInfo(int width, int height, int fps, int bitrate);
void encodeVideo(int8_t *data, int8_t camera_type);
void encodeVideo(int8_t *data, int camera_type);
void setVideoCallback(VideoCallback videoCallback);

Loading…
Cancel
Save