-
Notifications
You must be signed in to change notification settings - Fork 731
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
Replace ffmpeg-kit with libopus and libopusenc #6208
Replace ffmpeg-kit with libopus and libopusenc #6208
Conversation
@@ -0,0 +1,55 @@ | |||
/* | |||
* Copyright (c) 2022 New Vector Ltd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should keep the original copyright.
Also, maybe create a doc to explain where does this code come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I wrote this file I guess that's the original copyright? I just changed if from 'written by Jorge Martín on dd/MM' to the vector copyright, since it wasn't applied automatically and I didn't notice before uploading it.
Docs are a good idea, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, sorry. If you are the author, this is the correct copyright.
837640b
to
2c56b21
Compare
Please note that there's no need to review the files in the |
recordingJob = recorderScope.launch { | ||
while (audioRecorder?.state != AudioRecord.STATE_INITIALIZED) { | ||
// If the recorder is not ready let's give it some extra time | ||
delay(10L) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a reported problem about this or can you reproduce an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I ran into this before, but I can't seem to trigger this situation again. It should always be STATE_INITIALIZED
at this point, so I'll just remove it.
* Sampling rate of the input signal in Hz. | ||
*/ | ||
sealed class SampleRate private constructor(val value: Int) { | ||
object _8khz : SampleRate(8000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Starting with _
prefix is not allowed by lint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly can't find a better way to name these and keep the numbers. Any suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the end I went with a Rate
prefix. It's a bit weird, but it should fix the issue.
Code Quality Checks failed, did you check it ? :) |
Yes, it's related to this: #6208 (comment) |
2c56b21
to
1162700
Compare
What is the impact on the APK size? I think it will be good, can you check please? Thanks! |
With FFMPEG-kit:
Without FFMPEG-kit, using libopus:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with:
Emulator API 31 and Element Web : OK 👍
Emulator API 30 and Emulator API 30: Ok 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvement. LGTM, there are merge conflicts to resolve.
1162700
to
fd4276f
Compare
3aa7d7d
to
d1f9c0f
Compare
dependencies.gradle
Outdated
@@ -29,7 +29,7 @@ def jjwt = "0.11.5" | |||
def vanniktechEmoji = "0.15.0" | |||
|
|||
// Testing | |||
def mockk = "1.12.4" | |||
def mockk = "1.12.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to downgrade here? If yes, please add a comment above this line, else Dependabot will change this line again and we will have some trouble.
vector/build.gradle
Outdated
@@ -337,6 +337,9 @@ android { | |||
} | |||
|
|||
dependencies { | |||
implementation fileTree(dir: "libs", include: ["*.aar", "*.jar"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to add this line? I prefer to add explicit dependencies one by one if any
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, sorry, this was added to test some pre-built libs and I completely forgot to delete it.
d1f9c0f
to
c204f41
Compare
SonarCloud Quality Gate failed. |
Type of change
Content
This replaces ffmpeg-kit, which was used to convert audio files to and from ogg files with opus codec with libopus and a JNI wrapper. This change is only noticeable on devices with Android version < 10, as >= 10 can use Android's own implementation. This also removes the need for converting these files in the first place, as received audio files will already be in ogg format and the ones recorded will be encoded on-the-fly, with no need for post-processing.
Motivation and context
Fixes #6203. It's done mainly to get rid of a dependency and licensing issues for customers.
Tests
Ideally, we should test this on phones or emulators in versions < 10 and >= 10, both recording and playing and on both ARM and x86 archs.
Tested devices
Checklist