Feature: rename ffmpeg pusher

pull/221/head
xufuji456 3 years ago
parent 3f9d652e23
commit 5ae1646fb2
  1. 2
      app/src/main/cpp/CMakeLists.txt
  2. 8
      app/src/main/cpp/ff_rtmp_pusher.cpp
  3. 8
      app/src/main/cpp/ff_rtmp_pusher.h
  4. 10
      app/src/main/cpp/ffmpeg_pusher_jni.cpp

@ -45,7 +45,7 @@ add_library( # Sets the name of the library.
common_media_jni.cpp common_media_jni.cpp
ff_audio_player.cpp ff_audio_player.cpp
audio_player_jni.cpp audio_player_jni.cpp
ff_http_pusher.cpp ff_rtmp_pusher.cpp
ffmpeg_pusher_jni.cpp ffmpeg_pusher_jni.cpp
) )

@ -2,11 +2,11 @@
// Created by xu fulong on 2022/9/9. // Created by xu fulong on 2022/9/9.
// //
#include "ff_http_pusher.h" #include "ff_rtmp_pusher.h"
#define PUSH_TAG "HttpPusher" #define PUSH_TAG "HttpPusher"
int FFHttpPusher::open(const char *inputPath, const char *outputPath) { int FFRtmpPusher::open(const char *inputPath, const char *outputPath) {
int ret; int ret;
avformat_network_init(); avformat_network_init();
@ -69,7 +69,7 @@ void rescale(AVFormatContext *in_format_ctx, AVFormatContext *out_format_ctx, AV
packet->pos = -1; packet->pos = -1;
} }
int FFHttpPusher::push() { int FFRtmpPusher::push() {
int ret; int ret;
int64_t startTime = av_gettime(); int64_t startTime = av_gettime();
@ -105,7 +105,7 @@ int FFHttpPusher::push() {
return ret; return ret;
} }
void FFHttpPusher::close() { void FFRtmpPusher::close() {
if (outFormatCtx) { if (outFormatCtx) {
av_write_trailer(outFormatCtx); av_write_trailer(outFormatCtx);
avformat_close_input(&outFormatCtx); avformat_close_input(&outFormatCtx);

@ -2,8 +2,8 @@
// Created by xu fulong on 2022/9/9. // Created by xu fulong on 2022/9/9.
// //
#ifndef FF_HTTP_PUSHER_H #ifndef FF_RTMP_PUSHER_H
#define FF_HTTP_PUSHER_H #define FF_RTMP_PUSHER_H
#include "ffmpeg_jni_define.h" #include "ffmpeg_jni_define.h"
@ -17,7 +17,7 @@ extern "C" {
} }
#endif #endif
class FFHttpPusher { class FFRtmpPusher {
private: private:
AVFormatContext *inFormatCtx; AVFormatContext *inFormatCtx;
AVFormatContext *outFormatCtx; AVFormatContext *outFormatCtx;
@ -36,4 +36,4 @@ public:
}; };
#endif //FF_HTTP_PUSHER_H #endif //FF_RTMP_PUSHER_H

@ -3,21 +3,21 @@
// //
#include <jni.h> #include <jni.h>
#include "ff_http_pusher.h" #include "ff_rtmp_pusher.h"
PUSHER_FUNC(int, pushStream, jstring inputPath, jstring outputPath) { PUSHER_FUNC(int, pushStream, jstring inputPath, jstring outputPath) {
int ret; int ret;
const char *input_path = env->GetStringUTFChars(inputPath, JNI_FALSE); const char *input_path = env->GetStringUTFChars(inputPath, JNI_FALSE);
const char *output_path = env->GetStringUTFChars(outputPath, JNI_FALSE); const char *output_path = env->GetStringUTFChars(outputPath, JNI_FALSE);
auto *httpPusher = new FFHttpPusher(); auto *rtmpPusher = new FFRtmpPusher();
ret = httpPusher->open(input_path, output_path); ret = rtmpPusher->open(input_path, output_path);
if (ret < 0) { if (ret < 0) {
LOGE("HttpPusher", "open error=%d", ret); LOGE("HttpPusher", "open error=%d", ret);
return ret; return ret;
} }
ret = httpPusher->push(); ret = rtmpPusher->push();
httpPusher->close(); rtmpPusher->close();
env->ReleaseStringUTFChars(inputPath, input_path); env->ReleaseStringUTFChars(inputPath, input_path);
env->ReleaseStringUTFChars(outputPath, output_path); env->ReleaseStringUTFChars(outputPath, output_path);

Loading…
Cancel
Save