Compare commits

...

4 Commits

Author SHA1 Message Date
Gleidson Daniel 84db57e405 organize the code 2022-11-09 16:40:22 -03:00
Gleidson Daniel Silva a73afa9494
Merge branch 'develop' into encode-audio 2022-11-09 14:16:04 -03:00
Gleidson Daniel 36677622e0 update pods 2022-11-09 14:15:32 -03:00
Gleidson Daniel 6d70253766 use ffmpeg-kit-react-native to encode audios 2022-11-09 14:05:55 -03:00
9 changed files with 82 additions and 9 deletions

View File

@ -11,7 +11,7 @@ buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 23
minSdkVersion = 24
compileSdkVersion = 31
targetSdkVersion = 31
if (System.properties['os.arch'] == "aarch64") {
@ -28,6 +28,7 @@ buildscript {
libre_build = !(isPlay.toBoolean())
jitsi_url = "https://github.com/RocketChat/jitsi-maven-repository/raw/master/releases"
jitsi_version = "3.7.0"
ffmpegKitPackage = "audio"
}
repositories {

View File

@ -8,9 +8,10 @@ import { activateKeepAwake, deactivateKeepAwake } from 'expo-keep-awake';
import styles from './styles';
import I18n from '../../i18n';
import { themes } from '../../lib/constants';
import { CustomIcon } from '../CustomIcon';
import { encodeAudio } from '../../lib/methods/audioFile';
import { events, logEvent } from '../../lib/methods/helpers/log';
import { TSupportedThemes } from '../../theme';
import { CustomIcon } from '../CustomIcon';
interface IMessageBoxRecordAudioProps {
theme: TSupportedThemes;
@ -157,16 +158,16 @@ export default class RecordAudio extends React.PureComponent<IMessageBoxRecordAu
await this.recording.stopAndUnloadAsync();
const fileURI = this.recording.getURI();
const fileData = await getInfoAsync(fileURI as string);
const audioEncodedPath = await encodeAudio(fileURI!);
const fileData = await getInfoAsync(audioEncodedPath);
const fileInfo = {
name: `${Date.now()}.m4a`,
mime: 'audio/aac',
type: 'audio/aac',
name: `${Date.now()}.mp3`,
mime: 'audio/mpeg',
type: 'audio/mpeg',
store: 'Uploads',
path: fileURI,
path: fileData.uri,
size: fileData.size
};
onFinish(fileInfo);
} catch (error) {
logEvent(events.ROOM_AUDIO_FINISH_F);

View File

@ -1,4 +1,5 @@
import * as FileSystem from 'expo-file-system';
import { FFmpegKit, ReturnCode } from 'ffmpeg-kit-react-native';
import { sanitizeLikeString } from '../database/utils';
import { store } from '../store/auxStore';
@ -52,3 +53,19 @@ export const deleteAllAudioFiles = async (serverUrl: string): Promise<void> => {
log(error);
}
};
export const encodeAudio = (fileURI: string): Promise<string> =>
new Promise((resolve, reject) => {
const fileName = sanitizeString(fileURI.substring(fileURI.lastIndexOf('/') + 1).split('.')[0]);
const newFilePath = `${FileSystem.cacheDirectory}${fileName}.mp3`;
const ffmpegCommand = `-hide_banner -y -i ${fileURI} -c:a libmp3lame -qscale:a 2 ${newFilePath}`;
FFmpegKit.execute(ffmpegCommand).then(async session => {
const returnCode = await session.getReturnCode();
if (ReturnCode.isSuccess(returnCode)) {
return resolve(newFilePath);
}
if (ReturnCode.isCancel(returnCode)) {
return reject();
}
});
});

View File

@ -9,6 +9,7 @@ def all_pods
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi', :modular_headers => true
pod 'simdjson', path: '../node_modules/@nozbe/simdjson'
pod 'ReactNativeUiLib', :path => '../node_modules/react-native-ui-lib/lib'
pod 'ffmpeg-kit-react-native', :subspecs => ['audio'], :podspec => '../node_modules/ffmpeg-kit-react-native/ffmpeg-kit-react-native.podspec'
$RNFirebaseAnalyticsWithoutAdIdSupport = true
config = use_native_modules!

View File

@ -34,6 +34,10 @@ PODS:
- React-Core (= 0.68.2)
- React-jsi (= 0.68.2)
- ReactCommon/turbomodule/core (= 0.68.2)
- ffmpeg-kit-ios-audio (5.1)
- ffmpeg-kit-react-native/audio (5.1.0):
- ffmpeg-kit-ios-audio (= 5.1)
- React-Core
- Firebase/AnalyticsWithoutAdIdSupport (8.15.0):
- Firebase/CoreOnly
- FirebaseAnalytics/WithoutAdIdSupport (~> 8.15.0)
@ -600,6 +604,7 @@ DEPENDENCIES:
- EXVideoThumbnails (from `../node_modules/expo-video-thumbnails/ios`)
- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
- FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`)
- ffmpeg-kit-react-native/audio (from `../node_modules/ffmpeg-kit-react-native/ffmpeg-kit-react-native.podspec`)
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
- hermes-engine (~> 0.11.0)
- JitsiMeetSDK (from `https://github.com/RocketChat/jitsi-meet-ios-sdk-releases.git`)
@ -680,6 +685,7 @@ DEPENDENCIES:
SPEC REPOS:
trunk:
- ffmpeg-kit-ios-audio
- Firebase
- FirebaseAnalytics
- FirebaseCore
@ -734,6 +740,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/Libraries/FBLazyVector"
FBReactNativeSpec:
:path: "../node_modules/react-native/React/FBReactNativeSpec"
ffmpeg-kit-react-native:
:podspec: "../node_modules/ffmpeg-kit-react-native/ffmpeg-kit-react-native.podspec"
glog:
:podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec"
JitsiMeetSDK:
@ -902,6 +910,8 @@ SPEC CHECKSUMS:
EXVideoThumbnails: 19e055dc3245b53c536da9e0ef9c618fd2118297
FBLazyVector: a7a655862f6b09625d11c772296b01cd5164b648
FBReactNativeSpec: 66b5770d86bfee27d67b850416dbc7123c4f6311
ffmpeg-kit-ios-audio: 6eaf5a3c4249b767328502747a08bfd901a86d3d
ffmpeg-kit-react-native: 56ecfcd21536379dd123eade87c3b6fd55f12030
Firebase: 5f8193dff4b5b7c5d5ef72ae54bb76c08e2b841d
FirebaseAnalytics: 7761cbadb00a717d8d0939363eb46041526474fa
FirebaseCore: 5743c5785c074a794d35f2fff7ecc254a91e08b1
@ -998,6 +1008,6 @@ SPEC CHECKSUMS:
WatermelonDB: 577c61fceff16e9f9103b59d14aee4850c0307b6
Yoga: 99652481fcd320aefa4a7ef90095b95acd181952
PODFILE CHECKSUM: 052cbf741847405abc3b902c9e107c1ebb48b252
PODFILE CHECKSUM: fa943eef52304cbca92070cf5ab4be1008650d23
COCOAPODS: 1.11.3

View File

@ -1046,6 +1046,14 @@
"${PODS_XCFRAMEWORKS_BUILD_DIR}/JitsiMeetSDK/JitsiMeetSDK.framework/JitsiMeetSDK",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/JitsiMeetSDK/WebRTC.framework/WebRTC",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal/OpenSSL.framework/OpenSSL",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-audio/ffmpegkit.framework/ffmpegkit",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-audio/libavcodec.framework/libavcodec",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-audio/libavdevice.framework/libavdevice",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-audio/libavfilter.framework/libavfilter",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-audio/libavformat.framework/libavformat",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-audio/libavutil.framework/libavutil",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-audio/libswresample.framework/libswresample",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-audio/libswscale.framework/libswscale",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/hermes-engine/hermes.framework/hermes",
);
name = "[CP] Embed Pods Frameworks";
@ -1053,6 +1061,14 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/JitsiMeetSDK.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/WebRTC.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OpenSSL.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ffmpegkit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libavcodec.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libavdevice.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libavfilter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libavformat.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libavutil.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libswresample.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libswscale.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/hermes.framework",
);
runOnlyForDeploymentPostprocessing = 0;
@ -1070,6 +1086,14 @@
"${PODS_XCFRAMEWORKS_BUILD_DIR}/JitsiMeetSDK/JitsiMeetSDK.framework/JitsiMeetSDK",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/JitsiMeetSDK/WebRTC.framework/WebRTC",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal/OpenSSL.framework/OpenSSL",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-audio/ffmpegkit.framework/ffmpegkit",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-audio/libavcodec.framework/libavcodec",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-audio/libavdevice.framework/libavdevice",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-audio/libavfilter.framework/libavfilter",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-audio/libavformat.framework/libavformat",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-audio/libavutil.framework/libavutil",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-audio/libswresample.framework/libswresample",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-audio/libswscale.framework/libswscale",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/hermes-engine/hermes.framework/hermes",
);
name = "[CP] Embed Pods Frameworks";
@ -1077,6 +1101,14 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/JitsiMeetSDK.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/WebRTC.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OpenSSL.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ffmpegkit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libavcodec.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libavdevice.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libavfilter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libavformat.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libavutil.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libswresample.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libswscale.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/hermes.framework",
);
runOnlyForDeploymentPostprocessing = 0;

View File

@ -70,6 +70,7 @@
"expo-local-authentication": "12.2.0",
"expo-video-thumbnails": "6.3.0",
"expo-web-browser": "10.2.1",
"ffmpeg-kit-react-native": "^5.1.0",
"hoist-non-react-statics": "3.3.2",
"i18n-js": "3.9.2",
"js-base64": "3.6.1",

View File

@ -14,6 +14,11 @@ module.exports = {
platforms: {
android: null
}
},
'ffmpeg-kit-react-native': {
platforms: {
ios: null
}
}
}
};

View File

@ -10969,6 +10969,11 @@ fetch-retry@^4.1.1:
resolved "https://registry.yarnpkg.com/fetch-retry/-/fetch-retry-4.1.1.tgz#fafe0bb22b54f4d0a9c788dff6dd7f8673ca63f3"
integrity sha512-e6eB7zN6UBSwGVwrbWVH+gdLnkW9WwHhmq2YDK1Sh30pzx1onRVGBvogTlUeWxwTa+L86NYdo4hFkh7O8ZjSnA==
ffmpeg-kit-react-native@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/ffmpeg-kit-react-native/-/ffmpeg-kit-react-native-5.1.0.tgz#7aea05ee642b0b204777ba36994f41ed192ec4ca"
integrity sha512-WGuF7wm18vvhr1oCMLRfHIDCwKrmBezWgVtzim6Z3cbDiHeYvDjpm7KJwrvBMwOgekQtP4R4zI9W0ZByoXjMnQ==
figgy-pudding@^3.5.1:
version "3.5.2"
resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.2.tgz#b4eee8148abb01dcf1d1ac34367d59e12fa61d6e"