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 skeleton of native litr-muxers module #239

Merged
merged 1 commit into from
Jan 13, 2023

Conversation

IanDBird
Copy link
Contributor

Part of #235

This first PR does the following:

  • New module called litr-muxers to contain the native muxers module (based upon libavformat)
  • Build instructions and scripts to locally build the required libavformat (and dependencies)
  • Fallback support to binaries that are contained in the repo, if the consumer prefers not to build them themselves
  • Some basic headers that will be required as part of the native code.

@@ -49,9 +50,11 @@ class SharedMediaStoragePublisher @JvmOverloads constructor(
if (!file.exists()) return null

val newFileName = file.name
val extension = MimeTypeMap.getFileExtensionFromUrl(newFileName)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this issue when I tested muxing to mkv. It probably happens today if you mux to webm. This small change just means that we build a demo app filepath that has the correct extension. It only impacts the demo app.

# If locally built ffmpeg binaries are available, we will prioritise these. This is preferable as
# ensures they are built to match exactly what the consumer requires. However, we will allow the
# build to fallback to those bundled with the repository.
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ffmpeg")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@izzytwosheds - After our chat yesterday, I added this condition. If we detect locally built binaries, we will use them. However, I have included versions that i've built myself that it will fall back too. If you're happy with this, you may want to replace those bundled binaries with versions you've built yourself.

PRIVATE avformat
PRIVATE ${log-lib})

set_property(TARGET litr-muxers PROPERTY LINKER_LANGUAGE CXX)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added because after removing all the CPP files, cmake didn't know how to link :D

#ifndef LITR_FFMPEG_H
#define LITR_FFMPEG_H

extern "C" {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the code in this module will be C++, and libavformat (and deps) are C, I created this header to make it easy to import/include.

#include <android/log.h>

#define LOG_TAG "LiTrMuxers_JNI"
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging functions that can be used from C++ that will end up in Android's logcat.

ENABLED_DECODERS=("${@:4}")
JOBS=$(nproc 2> /dev/null || sysctl -n hw.ncpu 2> /dev/null || echo 4)
echo "Using $JOBS jobs for make"
COMMON_OPTIONS="
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script is based upon ExoPlayer's ffmpeg module, except with everything disabled. I've only enabled what is required to match the capabilities of Android's MediaMuxer, with the addition of segmented support.

@izzytwosheds izzytwosheds merged commit ccdd48a into linkedin:main Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants