8000 Add Unified-Plan API. by cloudwebrtc · Pull Request #359 · flutter-webrtc/flutter-webrtc · GitHub
[go: up one dir, main page]

Skip to content

Add Unified-Plan API. #359

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

Merged
merged 28 commits into from
Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
41291c6
Add API and files for unified-plan.
cloudwebrtc Sep 28, 2020
e82f8f6
Add more.
cloudwebrtc Oct 2, 2020
930a297
Add more.
cloudwebrtc Oct 6, 2020
fe320c1
Update.
cloudwebrtc Oct 6, 2020
2b404f8
Fix bug.
cloudwebrtc Oct 8, 2020
2812cba
Update.
cloudwebrtc Oct 8, 2020
48403c6
Fix the kind parameter in RTCRTPCodec.
cloudwebrtc Oct 8, 2020
7cb1918
Add PeerConnectionState and add RTCTrackEvent.
cloudwebrtc Oct 9, 2020
cb1a950
Add example for unified-plan.
cloudwebrtc Oct 11, 2020
fa42f01
Update.
cloudwebrtc Oct 11, 2020
a55a1ac
Reduce code.
cloudwebrtc Oct 11, 2020
c9e143c
Fix simulcast.
cloudwebrtc Oct 12, 2020
45c27ff
Fix RtpSender.replaceTrack.
cloudwebrtc Oct 12, 2020
3a36cd4
More.
cloudwebrtc Oct 12, 2020
490be78
Add support for iOS.
cloudwebrtc Oct 12, 2020
587f10f
Optimized code.
cloudwebrtc Oct 12, 2020
6fad3fb
Fix simulcast for iOS.
cloudwebrtc Oct 12, 2020
7464f92
Update.
cloudwebrtc Oct 12, 2020
7bc2c5e
Upgrade GoogleWebRTC@android to 1.0.32006.
cloudwebrtc Oct 12, 2020
a6b639e
Update.
cloudwebrtc Oct 12, 2020
7cd1c9c
Merge changes from master.
cloudwebrtc Oct 13, 2020
4f3bd8f
Merge branch 'master' into feature/unified-plan
cloudwebrtc Oct 13, 2020
3e07885
Update.
cloudwebrtc Oct 13, 2020
c75a621
Update README.md
cloudwebrtc Oct 13, 2020
07f6b8f
Update.
cloudwebrtc Oct 13, 2020
cad7730
Merge branch 'feature/unified-plan' of https://github.com/flutter-web…
cloudwebrtc Oct 13, 2020
09fd6a0
Use shared code in iOS and macOS.
cloudwebrtc Oct 13, 2020
61ef49c
Update rtc_peerconnection_impl.dart
cloudwebrtc Oct 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ WebRTC plugin for Flutter Mobile/Desktop/Web
| Audio/Video | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | [WIP] | [WIP] | |
| Data Channel | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | [WIP] | [WIP] | |
| Screen Capture | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | | | |
| Unified-Plan | | | | | | | |
| Unified-Plan | :heavy_check_mark: | :heavy_check_mark: | | :heavy_check_mark: | | | |
| MediaRecorder| :warning: | :warning: | :heavy_check_mark: | | | | |

## Usage
Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ android {
compileSdkVersion 28

defaultConfig {
minSdkVersion 18
minSdkVersion 21
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'proguard-rules.pro'
}
Expand All @@ -41,6 +41,6 @@ android {
}

dependencies {
api 'org.webrtc:google-webrtc:1.0.30039'
api 'org.webrtc:google-webrtc:1.0.32006'
implementation "androidx.annotation:annotation:1.1.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,10 @@ private void setVideoTrack(VideoTrack videoTrack) {
this.videoTrack = videoTrack;

if (videoTrack != null) {
Log.w(TAG, "FlutterRTCVideoRenderer.setVideoTrack, set video track to " + videoTrack.id());
tryAddRendererToVideoTrack();
} else {
Log.w(TAG, "VideoTrack is null");
Log.w(TAG, "FlutterRTCVideoRenderer.setVideoTrack, set video track to null");
}
}
}
Expand Down
47 changes: 22 additions & 25 deletions android/src/main/java/com/cloudwebrtc/webrtc/GetUserMediaImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ public void onResume() {
this.applicationContext = applicationContext;
}

static private void resultError(String method, String error, Result result) {
String errorMsg = method + "(): " + error;
result.error(method, errorMsg,null);
Log.d(TAG, errorMsg);
}

/**
* Includes default constraints set for the audio media type.
*
Expand Down Expand Up @@ -396,7 +402,7 @@ void getUserMedia(
// requestedMediaTypes is the empty set, the method invocation fails
// with a TypeError.
if (requestPermissions.isEmpty()) {
result.error("TypeError", "constraints requests no media types", null);
resultError("getUserMedia", "TypeError, constraints requests no media types", result);
return;
}

Expand All @@ -423,7 +429,7 @@ public void invoke(Object... args) {
// getUserMedia() algorithm, if the user has denied
// permission, fail "with a new DOMException object whose
// name attribute has the value NotAllowedError."
result.error("DOMException", "NotAllowedError", null);
resultError("getUserMedia", "DOMException, NotAllowedError", result);
}
});
}
Expand Down Expand Up @@ -453,7 +459,7 @@ protected void onReceiveResult(int requestCode, Bundle resultData) {
Intent mediaProjectionData = resultData.getParcelable(PROJECTION_DATA);

if (resultCode != Activity.RESULT_OK) {
result.error(null, "User didn't give permission to capture the screen.", null);
resultError("screenRequestPremissions", "User didn't give permission to capture the screen.", result);
return;
}

Expand All @@ -465,13 +471,11 @@ protected void onReceiveResult(int requestCode, Bundle resultData) {
new MediaProjection.Callback() {
@Override
public void onStop() {
Log.e(TAG, "User revoked permission to capture the screen.");
result.error(null, "User revoked permission to capture the screen.", null);
resultError("MediaProjection.Callback()", "User revoked permission to capture the screen.", result);
}
});
if (videoCapturer == null) {
result.error(
/* type */ "GetDisplayMediaFailed", "Failed to create new VideoCapturer!", null);
resultError("screenRequestPremissions", "GetDisplayMediaFailed, User revoked permission to capture the screen.", result);
return;
}

Expand Down Expand Up @@ -573,7 +577,7 @@ private void getUserMedia(
// specified by
// https://www.w3.org/TR/mediacapture-streams/#dom-mediadevices-getusermedia
// with respect to distinguishing the various causes of failure.
result.error(/* type */ "GetUserMediaFailed", "Failed to create new track", null);
resultError("getUserMedia", "Failed to create new track.", result);
return;
}

Expand Down Expand Up @@ -753,7 +757,7 @@ private void requestPermissions(
void switchCamera(String id, Result result) {
VideoCapturer videoCapturer = mVideoCapturers.get(id);
if (videoCapturer == null) {
result.error(null, "Video capturer not found for id: " + id, null);
resultError("switchCamera", "Video capturer not found for id: " + id, result);
return;
}

Expand All @@ -767,7 +771,7 @@ public void onCameraSwitchDone(boolean b) {

@Override
public void onCameraSwitchError(String s) {
result.error("Switching camera failed", s, null);
resultError("switchCamera", "Switching camera failed: " + id, result);
}
});
}
Expand Down Expand Up @@ -818,7 +822,7 @@ void stopRecording(Integer id) {
void hasTorch(String trackId, Result result) {
VideoCapturer videoCapturer = mVideoCapturers.get(trackId);
if (videoCapturer == null) {
result.error(null, "Video capturer not found for id: " + trackId, null);
resultError("hasTorch", "Video capturer not found for id: " + trackId, result);
return;
}

Expand All @@ -837,8 +841,7 @@ void hasTorch(String trackId, Result result) {
(CameraDevice) getPrivateProperty(session.getClass(), session, "cameraDevice");
} catch (NoSuchFieldWithNameException e) {
// Most likely the upstream Camera2Capturer class have changed
Log.e(TAG, "[TORCH] Failed to get `" + e.fieldName + "` from `" + e.className + "`");
result.error(null, "Failed to get `" + e.fieldName + "` from `" + e.className + "`", null);
resultError("hasTorch", "[TORCH] Failed to get `" + e.fieldName + "` from `" + e.className + "`", result);
return;
}

Expand Down Expand Up @@ -866,8 +869,7 @@ void hasTorch(String trackId, Result result) {
camera = (Camera) getPrivateProperty(session.getClass(), session, "camera");
} catch (NoSuchFieldWithNameException e) {
// Most likely the upstream Camera1Capturer class have changed
Log.e(TAG, "[TORCH] Failed to get `" + e.fieldName + "` from `" + e.className + "`");
result.error(null, "Failed to get `" + e.fieldName + "` from `" + e.className + "`", null);
resultError("hasTorch", "[TORCH] Failed to get `" + e.fieldName + "` from `" + e.className + "`", result);
return;
}

Expand All @@ -879,15 +881,14 @@ void hasTorch(String trackId, Result result) {
return;
}

Log.e(TAG, "[TORCH] Video capturer not compatible");
result.error(null, "Video capturer not compatible", null);
resultError("hasTorch", "[TORCH] Video capturer not compatible", result);
}

@RequiresApi(api = VERSION_CODES.LOLLIPOP)
void setTorch(String trackId, boolean torch, Result result) {
VideoCapturer videoCapturer = mVideoCapturers.get(trackId);
if (videoCapturer == null) {
result.error(null, "Video capturer not found for id: " + trackId, null);
resultError("setTorch", "Video capturer not found for id: " + trackId, result);
return;
}

Expand Down Expand Up @@ -919,8 +920,7 @@ void setTorch(String trackId, boolean torch, Result result) {
(Handler) getPrivateProperty(session.getClass(), session, "cameraThreadHandler");
} catch (NoSuchFieldWithNameException e) {
// Most likely the upstream Camera2Capturer class have changed
Log.e(TAG, "[TORCH] Failed to get `" + e.fieldName + "` from `" + e.className + "`");
result.error(null, "Failed to get `" + e.fieldName + "` from `" + e.className + "`", null);
resultError("setTorch", "[TORCH] Failed to get `" + e.fieldName + "` from `" + e.className + "`", result);
return;
}

Expand Down Expand Up @@ -959,8 +959,7 @@ void setTorch(String trackId, boolean torch, Result result) {
camera = (Camera) getPrivateProperty(session.getClass(), session, "camera");
} catch (NoSuchFieldWithNameException e) {
// Most likely the upstream Camera1Capturer class have changed
Log.e(TAG, "[TORCH] Failed to get `" + e.fieldName + "` from `" + e.className + "`");
result.error(null, "Failed to get `" + e.fieldName + "` from `" + e.className + "`", null);
resultError("setTorch", "[TORCH] Failed to get `" + e.fieldName + "` from `" + e.className + "`", result);
return;
< 2851 /td> }

Expand All @@ -972,9 +971,7 @@ void setTorch(String trackId, boolean torch, Result result) {
result.success(null);
return;
}

Log.e(TAG, "[TORCH] Video capturer not compatible");
result.error(null, "Video capturer not compatible", null);
resultError("setTorch", "[TORCH] Video capturer not compatible", result);
}

private Object getPrivateProperty(Class klass, Object object, String fieldName)
Expand Down
Loading
0