ffmpeg_pusher_jni.cpp 702 B

12345678910111213141516171819202122232425
  1. //
  2. // Created by xu fulong on 2022/9/9.
  3. //
  4. #include <jni.h>
  5. #include "ff_rtmp_pusher.h"
  6. PUSHER_FUNC(int, pushStream, jstring inputPath, jstring outputPath) {
  7. int ret;
  8. const char *input_path = env->GetStringUTFChars(inputPath, JNI_FALSE);
  9. const char *output_path = env->GetStringUTFChars(outputPath, JNI_FALSE);
  10. auto *rtmpPusher = new FFRtmpPusher();
  11. ret = rtmpPusher->open(input_path, output_path);
  12. if (ret < 0) {
  13. LOGE("HttpPusher", "open error=%d", ret);
  14. return ret;
  15. }
  16. ret = rtmpPusher->push();
  17. rtmpPusher->close();
  18. env->ReleaseStringUTFChars(inputPath, input_path);
  19. env->ReleaseStringUTFChars(outputPath, output_path);
  20. return ret;
  21. }