-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cloned video MediaStreamTrack has another resolution than original track
https://bugs.webkit.org/show_bug.cgi?id=261329 rdar://115551680 Reviewed by Jean-Yves Avenard. When cloning a track, we are adding a new SourceProxy as obserer of the underlying source. This works fine for video tracks in case the SourceProxy is not resizing/reducing frame rate of the source via addVideoFrameObserver size/frame rate parameters. This resizing may happen for instance if the application wants a resolution that is not directly supported by the camera. Before the patch, the clone would register itself via addVideoFrameObserver without parameters, which would trigger no resizing/reducing frame rate. After the patch, we first copy the settings from the original source to the cloned source. We then call addVideoFrameObserver with the right parameters. Covered by added test. * LayoutTests/webrtc/video-clone-track-expected.txt: Added. * LayoutTests/webrtc/video-clone-track.html: Added. * Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp: (WebKit::UserMediaCaptureManagerProxy::SourceProxy::SourceProxy): (WebKit::UserMediaCaptureManagerProxy::SourceProxy::~SourceProxy): (WebKit::UserMediaCaptureManagerProxy::SourceProxy::observeMedia): (WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints): (WebKit::UserMediaCaptureManagerProxy::clone): Canonical link: https://commits.webkit.org/268307@main
- Loading branch information
Showing
4 changed files
with
55 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
|
||
PASS Ensure cloned track gets the expected width and height | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<script src="../resources/testharness.js"></script> | ||
<script src="../resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<video id="video" autoplay=""></video> | ||
<script src ="routines.js"></script> | ||
<script> | ||
promise_test(async (test) => { | ||
const localStream = await navigator.mediaDevices.getUserMedia({video: {width:640, height:360 }}); | ||
const localStream2 = localStream.clone(); | ||
const stream = await new Promise((resolve, reject) => { | ||
createConnections((firstConnection) => { | ||
const sender = firstConnection.addTrack(localStream2.getVideoTracks()[0], localStream2); | ||
}, (secondConnection) => { | ||
secondConnection.ontrack = (trackEvent) => { | ||
resolve(trackEvent.streams[0]); | ||
}; | ||
}); | ||
setTimeout(() => reject("Test timed out"), 5000); | ||
}); | ||
|
||
video.srcObject = stream; | ||
await video.play(); | ||
|
||
assert_equals(video.videoWidth, 640); | ||
assert_equals(video.videoHeight, 360); | ||
}, "Ensure cloned track gets the expected width and height"); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters