|
|
@ -1,7 +1,5 @@
|
|
|
|
package com.yinuo.library.vlc.encoder;
|
|
|
|
package com.yinuo.library.vlc.encoder;
|
|
|
|
|
|
|
|
|
|
|
|
import static com.common.commonlib.utils.StorageUtilsKt.NVME_KEYWORDS;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.annotation.TargetApi;
|
|
|
|
import android.annotation.TargetApi;
|
|
|
|
import android.app.Activity;
|
|
|
|
import android.app.Activity;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Context;
|
|
|
@ -14,6 +12,7 @@ import android.view.Surface;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
|
|
|
|
|
|
|
import com.common.commonlib.CommonApplication;
|
|
|
|
import com.common.commonlib.CommonApplication;
|
|
|
|
|
|
|
|
import com.common.commonlib.utils.LogUtils;
|
|
|
|
import com.common.commonlib.utils.StorageUtils;
|
|
|
|
import com.common.commonlib.utils.StorageUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.File;
|
|
|
@ -189,8 +188,7 @@ public class CameraHelper {
|
|
|
|
* Creates a media file in the {@code Environment.DIRECTORY_PICTURES} directory. The directory
|
|
|
|
* Creates a media file in the {@code Environment.DIRECTORY_PICTURES} directory. The directory
|
|
|
|
* is persistent and available to other applications like gallery.
|
|
|
|
* is persistent and available to other applications like gallery.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param type Media type. Can be video or image.
|
|
|
|
* @param type Media type. Can be video or image.
|
|
|
|
* @param defaultRecordDuration
|
|
|
|
|
|
|
|
* @return A file object pointing to the newly created file.
|
|
|
|
* @return A file object pointing to the newly created file.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static File getOutputMediaFile(int type, long time, long duration) {
|
|
|
|
public static File getOutputMediaFile(int type, long time, long duration) {
|
|
|
@ -199,6 +197,11 @@ public class CameraHelper {
|
|
|
|
File mediaStorageDir = getMediaStorageDir();
|
|
|
|
File mediaStorageDir = getMediaStorageDir();
|
|
|
|
if (mediaStorageDir == null) return null;
|
|
|
|
if (mediaStorageDir == null) return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Float availableSizeSizeInGB = StorageUtils.INSTANCE.getAvailableSizeSizeInGB(mediaStorageDir.getAbsolutePath());
|
|
|
|
|
|
|
|
if (availableSizeSizeInGB < 1f) {
|
|
|
|
|
|
|
|
LogUtils.e("存储空间即将耗尽");
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
// Create a media file name
|
|
|
|
// Create a media file name
|
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA);
|
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA);
|
|
|
|
String timeStamp = format.format(time);
|
|
|
|
String timeStamp = format.format(time);
|
|
|
@ -221,7 +224,7 @@ public class CameraHelper {
|
|
|
|
private static File getMediaStorageDir() {
|
|
|
|
private static File getMediaStorageDir() {
|
|
|
|
Context context = CommonApplication.Companion.getContext();
|
|
|
|
Context context = CommonApplication.Companion.getContext();
|
|
|
|
if (context != null) {
|
|
|
|
if (context != null) {
|
|
|
|
String nvmePath = StorageUtils.INSTANCE.getStoragePath(context, NVME_KEYWORDS);
|
|
|
|
String nvmePath = StorageUtils.INSTANCE.getStoragePath(context, false);
|
|
|
|
if (!TextUtils.isEmpty(nvmePath)) {
|
|
|
|
if (!TextUtils.isEmpty(nvmePath)) {
|
|
|
|
File mediaStorageDir = new File(nvmePath + File.separator + "video");
|
|
|
|
File mediaStorageDir = new File(nvmePath + File.separator + "video");
|
|
|
|
if (!mediaStorageDir.exists() && !mediaStorageDir.mkdirs()) {
|
|
|
|
if (!mediaStorageDir.exists() && !mediaStorageDir.mkdirs()) {
|
|
|
|