8000 Revert "Media Recorder implementation Android and iOS (#1810)" · flutter-webrtc/flutter-webrtc@e34f296 · GitHub
[go: up one dir, main page]

Skip to content

Commit e34f296

Browse files
authored
Revert "Media Recorder implementation Android and iOS (#1810)"
This reverts commit 04ccd08.
1 parent 9291302 commit e34f296

28 files changed

+60
-797
lines changed

android/src/main/java/com/cloudwebrtc/webrtc/GetUserMediaImpl.java

+14-62
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import android.app.Activity;
55
import android.app.Fragment;
66
import android.app.FragmentTransaction;
7-
import android.content.ContentResolver;
87
import android.content.ContentValues;
98
import android.content.Context;
109
import android.content.Intent;
@@ -14,14 +13,12 @@
1413
import android.media.AudioDeviceInfo;
1514
import android.media.projection.MediaProjection;
1615
import android.media.projection.MediaProjectionManager;
17-
import android.net.Uri;
1816
import android.os.Build;
1917
import android.os.Build.VERSION;
2018
import android.os.Build.VERSION_CODES;
2119
import android.os.Bundle;
2220
import android.os.Handler;
2321
import android.os.Looper;
24-
import android.os.ParcelFileDescriptor;
2522
import android.os.ResultReceiver;
2623
import android.provider.MediaStore;
2724
import android.util.Log;
@@ -72,9 +69,6 @@
7269
import org.webrtc.audio.JavaAudioDeviceModule;
7370

7471
import java.io.File;
75-
import java.io.FileInputStream;
76-
import java.io.FileOutputStream;
77-
import java.io.InputStream;
7872
import java.util.ArrayList;
7973
import java.util.HashMap;
8074
import java.util.List;
@@ -969,64 +963,22 @@ void startRecordingToFile(
969963
mediaRecorders.append(id, mediaRecorder);
970964
}
971965

972-
void stopRecording(Integer id, String albumName) {
973-
try {
974-
MediaRecorderImpl mediaRecorder = mediaRecorders.get(id);
975-
628C if (mediaRecorder != null) {
976-
mediaRecorder.stopRecording();
977-
mediaRecorders.remove(id);
978-
File file = mediaRecorder.getRecordFile();
979-
Uri collection;
980-
981-
if (file != null) {
982-
ContentValues values = new ContentValues();
983-
values.put(MediaStore.Video.Media.TITLE, file.getName());
984-
values.put(MediaStore.Video.Media.DISPLAY_NAME, file.getName());
985-
values.put(MediaStore.Video.Media.ALBUM, albumName);
986-
values.put(MediaStore.Video.Media.MIME_TYPE, "video/mp4");
987-
values.put(MediaStore.Video.Media.DATE_ADDED, System.currentTimeMillis() / 1000);
988-
values.put(MediaStore.Video.Media.DATE_TAKEN, System.currentTimeMillis());
989-
990-
//Android version above 9 MediaStore uses RELATIVE_PATH
991-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
992-
values.put(MediaStore.Video.Media.RELATIVE_PATH, "Movies/" + albumName);
993-
values.put(MediaStore.Video.Media.IS_PENDING, 1);
994-
995-
collection = MediaStore.Video.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY);
996-
} else {
997-
//Android version 9 and below MediaStore uses DATA
998-
values.put(MediaStore.Video.Media.DATA, "/storage/emulated/0/Movies/" + albumName + "/" + file.getName());
999-
1000-
collection = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
1001-
}
1002-
1003-
ContentResolver resolver = applicationContext.getContentResolver();
1004-
Uri uriSavedMedia = resolver.insert(collection, values);
1005-
1006-
assert uriSavedMedia != null;
1007-
ParcelFileDescriptor pfd = resolver.openFileDescriptor(uriSavedMedia, "w");
1008-
assert pfd != null;
1009-
FileOutputStream out = new FileOutputStream(pfd.getFileDescriptor());
1010-
1011-
InputStream in = new FileInputStream(file);
1012-
1013-
byte[] buf = new byte[8192];
1014-
int len;
1015-
1016-
while ((len = in.read(buf)) > 0) {
1017-
out.write(buf, 0, len);
1018-
}
1019-
1020-
out.close();
1021-
in.close();
1022-
pfd.close();
1023-
values.clear();
1024-
}
966+
void stopRecording(Integer id) {
967+
MediaRecorderImpl mediaRecorder = mediaRecorders.get(id);
968+
if (mediaRecorder != null) {
969+
mediaRecorder.stopRecording();
970+
mediaRecorders.remove(id);
971+
File file = mediaRecorder.getRecordFile();
972+
if (file != null) {
973+
ContentValues values = new ContentValues(3);
974+
values.put(MediaStore.Video.Media.TITLE, file.getName());
975+
values.put(MediaStore.Video.Media.MIME_TYPE, "video/mp4");
976+
values.put(MediaStore.Video.Media.DATA, file.getAbsolutePath());
977+
applicationContext
978+
.getContentResolver()
979+
.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, values);
1025980
}
1026-
} catch(Exception e){
1027-
1028981
}
1029-
1030982
}
1031983

1032984

android/src/main/java/com/cloudwebrtc/webrtc/MethodCallHandlerImpl.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,7 @@ public void onMethodCall(MethodCall call, @NonNull Result notSafeResult) {
770770
break;
771771
case "stopRecordToFile":
772772
Integer recorderId = call.argument("recorderId");
773-
String albumName = call.argument("albumName");
774-
getUserMediaImpl.stopRecording(recorderId, albumName);
773+
getUserMediaImpl.stopRecording(recorderId);
775774
result.success(null);
776775
break;
777776
case "captureFrame": {

common/darwin/Classes/FlutterRTCAudioSink-Interface.h

-6
This file was deleted.

common/darwin/Classes/FlutterRTCAudioSink.h

-14
This file was deleted.

common/darwin/Classes/FlutterRTCAudioSink.mm

-67
This file was deleted.

common/darwin/Classes/FlutterRTCFrameCapturer.h

-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@
1212
toPath:(NSString*)path
1313
result:(FlutterResult)result;
1414

15-
+ (CVPixelBufferRef)convertToCVPixelBuffer:(RTCVideoFrame *) frame;
16-
1715
@end

common/darwin/Classes/FlutterRTCFrameCapturer.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ - (void)renderFrame:(nullable RTCVideoFrame*)frame {
4141
CVPixelBufferRef pixelBufferRef;
4242
bool shouldRelease;
4343
if (![buffer isKindOfClass:[RTCCVPixelBuffer class]]) {
44-
pixelBufferRef = [FlutterRTCFrameCapturer convertToCVPixelBuffer:frame];
44+
pixelBufferRef = [self convertToCVPixelBuffer:frame];
4545
shouldRelease = true;
4646
} else {
4747
pixelBufferRef = ((RTCCVPixelBuffer*)buffer).pixelBuffer;
@@ -108,7 +108,7 @@ - (void)renderFrame:(nullable RTCVideoFrame*)frame {
108108
});
109109
}
110110

111-
+ (CVPixelBufferRef)convertToCVPixelBuffer:(RTCVideoFrame*)frame {
111+
- (CVPixelBufferRef)convertToCVPixelBuffer:(RTCVideoFrame*)frame {
112112
id<RTCI420Buffer> i420Buffer = [frame.buffer toI420];
113113
CVPixelBufferRef outputPixelBuffer;
114114
size_t w = (size_t)roundf(i420Buffer.width);

common/darwin/Classes/FlutterRTCMediaRecorder.h

-24
This file was deleted.

0 commit comments

Comments
 (0)
0