Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement an FfmpegVideoRenderer #7132

Open
wants to merge 7 commits into
base: dev-v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use the appropriate method to link to Ffmpeg Library
  • Loading branch information
haohaozaici committed Apr 20, 2020
commit 37ef691a0d1f81c9100f5f86a79f2dae80587131
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ public final class FfmpegLibrary {

private static final String TAG = "FfmpegLibrary";

// TODO: Use appropriate compilation script.
private static final LibraryLoader LOADER =
new LibraryLoader("ffmpeg", "ffmpegJNI");
// new LibraryLoader("avutil", "swresample", "avcodec", "ffmpeg");
new LibraryLoader("avutil", "swresample", "avcodec", "ffmpegJNI");

private FfmpegLibrary() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
*/
public final class FfmpegVideoRenderer extends DecoderVideoRenderer {

private static final String TAG = "FfmpegVideoRenderer";

private static final int DEFAULT_NUM_OF_INPUT_BUFFERS = 4;
private static final int DEFAULT_NUM_OF_OUTPUT_BUFFERS = 4;
/* Default size based on 720p resolution video compressed by a factor of two. */
Expand Down
61 changes: 29 additions & 32 deletions extensions/ffmpeg/src/main/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,37 @@ set(CMAKE_CXX_STANDARD 11)

project(libffmpegJNI C CXX)

# Devices using armeabi-v7a are not required to support
# Neon which is why Neon is disabled by default for
# armeabi-v7a build. This flag enables it.
if(${ANDROID_ABI} MATCHES "armeabi-v7a")
add_compile_options("-mfpu=neon")
add_compile_options("-fPIC")
endif()

set(libgffmpeg_jni_root "${CMAKE_CURRENT_SOURCE_DIR}")
set(libgffmpeg_jni_build "${CMAKE_BINARY_DIR}")
set(libgffmpeg_jni_output_directory
${libgffmpeg_jni_root}/../libs/${ANDROID_ABI}/)

#set(libgffmpeg_root "${libgffmpeg_jni_root}/libgffmpeg")
#set(libgffmpeg_build "${libgffmpeg_jni_build}/libgffmpeg")

#set(cpu_features_root "${libgffmpeg_jni_root}/cpu_features")
#set(cpu_features_build "${libgffmpeg_jni_build}/cpu_features")

# Build cpu_features library.
#add_subdirectory("${cpu_features_root}"
# "${cpu_features_build}"
# EXCLUDE_FROM_ALL)

# Build libgffmpeg.
#add_subdirectory("${libgffmpeg_root}"
# "${libgffmpeg_build}"
# EXCLUDE_FROM_ALL)
add_library(ffmpeg
SHARED
IMPORTED)
set_target_properties(ffmpeg PROPERTIES
IMPORTED_LOCATION
${libgffmpeg_jni_output_directory}/libffmpeg.so)
add_library(
avutil
SHARED
IMPORTED)
set_target_properties(
avutil PROPERTIES
IMPORTED_LOCATION
${libgffmpeg_jni_output_directory}/libavutil.so)

add_library(
swresample
SHARED
IMPORTED)
set_target_properties(
swresample PROPERTIES
IMPORTED_LOCATION
${libgffmpeg_jni_output_directory}/libswresample.so)

add_library(
avcodec
SHARED
IMPORTED)
set_target_properties(
avcodec PROPERTIES
IMPORTED_LOCATION
${libgffmpeg_jni_output_directory}/libavcodec.so)

# Build libgffmpegJNI.
add_library(ffmpegJNI
Expand All @@ -53,9 +50,9 @@ find_library(android_log_lib log)
# Link libgffmpegJNI against used libraries.
target_link_libraries(ffmpegJNI
PRIVATE android
PRIVATE ffmpeg
# PRIVATE cpu_features
# PRIVATE libgffmpeg_static
PRIVATE avutil
PRIVATE swresample
PRIVATE avcodec
PRIVATE ${android_log_lib})

# Specify output directory for libgffmpegJNI.
Expand Down
2 changes: 0 additions & 2 deletions extensions/ffmpeg/src/main/jni/ffmpeg_jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ static const int AUDIO_DECODER_ERROR_INVALID_DATA = -1;
static const int AUDIO_DECODER_ERROR_OTHER = -2;
// LINT.ThenChange(../java/com/google/android/exoplayer2/ext/ffmpeg/FfmpegAudioDecoder.java)

// Error codes matching FfmpegVideoDecoder.java.

// LINT.IfChange
static const int VIDEO_DECODER_SUCCESS = 0;
static const int VIDEO_DECODER_ERROR_INVALID_DATA = -1;
Expand Down