Skip to content

Commit

Permalink
Remove deprecated usage of URL.createObjectURL with MediaStream
Browse files Browse the repository at this point in the history
Only straightforward usage has been removed, identified with regexp
"URL.createObjectURL.*stream".

Bug: 800767
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I83d563080b2f534e7d9e3062b1633017dc9a01a8
Reviewed-on: https://chromium-review.googlesource.com/878741
Commit-Queue: Florent Castelli <orphis@chromium.org>
Reviewed-by: Guido Urdaneta <guidou@chromium.org>
Reviewed-by: Philip Jägenstedt <foolip@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555378}
  • Loading branch information
Orphis authored and Commit Bot committed May 2, 2018
1 parent 63ce1d9 commit 703cf3e
Show file tree
Hide file tree
Showing 23 changed files with 44 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ public boolean canceled() {
+ "var video = document.querySelector('video');"
+ "function successCallback(stream) {"
+ " window.document.title = 'grant';"
+ " if (window.URL) {"
+ " video.src = window.URL.createObjectURL(stream);"
+ " } else {"
+ " video.src = stream;"
+ " }"
+ " video.srcObject = stream;"
+ "}"
+ "function errorCallback(error){"
+ " window.document.title = 'deny';"
Expand Down
8 changes: 5 additions & 3 deletions chrome/browser/resources/chromeos/user_images_grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,11 @@ cr.define('options', function() {
stopCamera: function() {
this.cameraOnline = false;
if (this.cameraVideo_)
this.cameraVideo_.src = '';
if (this.cameraStream_)
this.cameraVideo_.srcObject = null;
if (this.cameraStream_) {
this.stopVideoTracks_(this.cameraStream_);
this.cameraStream_ = null;
}
// Cancel any pending getUserMedia() checks.
this.cameraStartInProgress_ = false;
},
Expand All @@ -258,7 +260,7 @@ cr.define('options', function() {
*/
handleCameraAvailable_: function(onAvailable, stream) {
if (this.cameraStartInProgress_ && onAvailable()) {
this.cameraVideo_.src = URL.createObjectURL(stream);
this.cameraVideo_.srcObject = stream;
this.cameraStream_ = stream;
} else {
this.stopVideoTracks_(stream);
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/resources/feedback/js/take_screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function takeScreenshot(callback) {
video, 0, 0, video.videoWidth, video.videoHeight);

video.pause();
video.src = '';
video.srcObject = null;

screenshotStream.getVideoTracks()[0].stop();
screenshotStream = null;
Expand All @@ -39,7 +39,7 @@ function takeScreenshot(callback) {
function(stream) {
if (stream) {
screenshotStream = stream;
video.src = window.URL.createObjectURL(screenshotStream);
video.srcObject = screenshotStream;
video.play();
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function shutdownReceiver() {
}

var player = document.getElementById('player');
player.src = '';
player.srcObject = null;
var tracks = window.currentStream.getTracks();
for (var i = 0; i < tracks.length; ++i) {
tracks[i].stop();
Expand All @@ -32,7 +32,7 @@ window.addEventListener('load', function() {
this.play();
});
player.setAttribute('controls', '1');
player.src = URL.createObjectURL(window.currentStream);
player.srcObject = window.currentStream;

// Add onended event listeners. This detects when tab capture was shut down by
// closing the tab being captured.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function waitForExpectedColors(colorDeviation) {
this.video.width = width;
this.video.height = height;
this.video.addEventListener("error", chrome.test.fail);
this.video.src = URL.createObjectURL(receiveStream);
this.video.srcObject = receiveStream;
this.video.play();

this.readbackCanvas = document.createElement("canvas");
Expand Down Expand Up @@ -144,7 +144,7 @@ function waitForExpectedColors(colorDeviation) {
// Destroy the video, which will disconnect the consumer of the
// MediaStream.
this.video.removeEventListener("error", chrome.test.fail);
this.video.src = '';
this.video.srcObject = null;
this.video = null;

// Wait one second, then execute the second round of testing. This tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function waitForAnExpectedColor(
// If not yet done, plug the LocalMediaStream into the video element.
if (!this.stream || this.stream != stream) {
this.stream = stream;
video.src = URL.createObjectURL(stream);
video.srcObject = stream;
video.play();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function connectToVideoAndRunTest(stream) {
var start_time = new Date().getTime();

// Play the LocalMediaStream in the video element.
video.src = URL.createObjectURL(stream);
video.srcObject = stream;
video.play();

var frame = 0;
Expand Down
4 changes: 2 additions & 2 deletions chrome/test/data/webrtc/webrtc-simulcast.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@

function gotStream(stream) {
trace('Received local stream');
localVideo.src = webkitURL.createObjectURL(stream);
localVideo.srcObject = stream;
localStream = stream;
pcClient.addStream(localStream);
renegotiateClient();
Expand Down Expand Up @@ -217,7 +217,7 @@
// html, otherwise we can't detect video in it.
throw 'Received video with unexpected id ' + e.stream.id;
}
remoteVideo.src = webkitURL.createObjectURL(e.stream);
remoteVideo.srcObject = e.stream;
}

function onClientIceCandidate(event) {
Expand Down
2 changes: 1 addition & 1 deletion content/test/data/media/canvas_capture_color.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
var canvas = document.getElementById('canvas-' + contextType);
var video = document.getElementById('canvas-' + contextType + '-local-view');
var stream = canvas.captureStream();
video.src = URL.createObjectURL(stream);
video.srcObject = stream;
video.load();
}

Expand Down
3 changes: 1 addition & 2 deletions content/test/data/media/getusermedia-depth-capture.html
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@
}

function attachMediaStream(stream, videoElement) {
var localStreamUrl = URL.createObjectURL(stream);
$(videoElement).src = localStreamUrl;
$(videoElement).srcObject = stream;
}

function detectVideoInLocalView1(stream) {
Expand Down
2 changes: 1 addition & 1 deletion content/test/data/media/getusermedia-real-webcam.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

function gotStreamCallback(stream) {
var localView = $('local-view');
localView.src = URL.createObjectURL(stream);
localView.srcObject = stream;
detectVideoPlaying('local-view').then(() => {
sendValueToTest(localView.videoWidth + 'x' + localView.videoHeight);
});
Expand Down
8 changes: 3 additions & 5 deletions content/test/data/media/mediarecorder_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@
}
};
remotePeerConnection.onaddstream = function(event) {
document.getElementById('remoteVideo').src = URL.createObjectURL(
event.stream);
document.getElementById('remoteVideo').srcObject = event.stream;
resolve(event.stream);
};

Expand All @@ -78,14 +77,13 @@
createAnswer(description);
}, function(error) { failTest(error.toString()); });

document.getElementById('video').src = URL.createObjectURL(
localStream);
document.getElementById('video').srcObject = localStream;
});
}

function createAndStartMediaRecorder(stream, mimeType, slice) {
return new Promise(function(resolve, reject) {
document.getElementById('video').src = URL.createObjectURL(stream);
document.getElementById('video').srcObject = stream;
var recorder = new MediaRecorder(stream, {'mimeType' : mimeType});
console.log('Recorder object created, mimeType = ' + mimeType);
if (slice != undefined) {
Expand Down
6 changes: 2 additions & 4 deletions content/test/data/media/peerconnection-call-audio.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@
}

function displayAndRemember(localStream) {
var localStreamUrl = URL.createObjectURL(localStream);
$('local-view').src = localStreamUrl;
$('local-view').srcObject = localStream;

gLocalStream = localStream;
}
Expand All @@ -195,9 +194,8 @@
function onRemoteStream(e, target) {
console.log("Receiving remote stream...");
gRemoteStreams[target] = e.stream;
var remoteStreamUrl = URL.createObjectURL(e.stream);
var remoteVideo = $(target);
remoteVideo.src = remoteStreamUrl;
remoteVideo.srcObject = e.stream;
}

</script>
Expand Down
6 changes: 2 additions & 4 deletions content/test/data/media/peerconnection-call-data.html
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@
}

function displayAndRemember(localStream) {
var localStreamUrl = URL.createObjectURL(localStream);
$('local-view').src = localStreamUrl;
$('local-view').srcObject = localStream;

gLocalStream = localStream;
}
Expand All @@ -261,9 +260,8 @@
function onRemoteStream(e, target) {
console.log("Receiving remote stream...");
gRemoteStreams[target] = e.stream;
var remoteStreamUrl = URL.createObjectURL(e.stream);
var remoteVideo = $(target);
remoteVideo.src = remoteStreamUrl;
remoteVideo.srcObject = e.stream;
}

function connectOnIceCandidate(caller, callee) {
Expand Down
8 changes: 3 additions & 5 deletions content/test/data/media/peerconnection-call.html
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
var videoElement = document.createElement('video');

// No crash for this operation.
videoElement.src = URL.createObjectURL(newStream);
videoElement.srcObject = newStream;
detectVideoPlaying('remote-view-2')
.then(reportTestSuccess);
})
Expand Down Expand Up @@ -516,8 +516,7 @@
}

function displayAndRemember(localStream) {
var localStreamUrl = URL.createObjectURL(localStream);
$('local-view').src = localStreamUrl;
$('local-view').srcObject = localStream;

gLocalStream = localStream;
}
Expand Down Expand Up @@ -655,9 +654,8 @@
e.stream.id + ' was received.');
}
gRemoteStreams[target] = e.stream;
var remoteStreamUrl = URL.createObjectURL(e.stream);
var remoteVideo = $(target);
remoteVideo.src = remoteStreamUrl;
remoteVideo.srcObject = e.stream;
}

// Check that applyConstraints() fails on remote tracks because there is
Expand Down
2 changes: 1 addition & 1 deletion content/test/data/media/video_capture_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

function gotStreamCallback(stream) {
var localView = $('local-view');
localView.src = URL.createObjectURL(stream);
localView.srcObject = stream;

var videoTracks = stream.getVideoTracks();
if (videoTracks.length == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
navigator.webkitGetUserMedia(
{ video: true, audio: true },
function(stream) {
video.src = window.URL.createObjectURL(stream);
video.srcObject = stream;
}, function(err) { window.console.log(err); }
);
}
Expand Down
2 changes: 1 addition & 1 deletion native_client_sdk/src/examples/api/video_encode/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function $(id) {
function success(stream) {
track = stream.getVideoTracks()[0];
var video = $('video')
video.src = URL.createObjectURL(stream);
video.srcObject = stream;
video.track = track;
video.play();

Expand Down
6 changes: 3 additions & 3 deletions ppapi/examples/video_effects/video_effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<script>
var getUserMedia = navigator.webkitGetUserMedia.bind(navigator);
var attachMediaStream = function(element, stream) {
element.src = URL.createObjectURL(stream);
element.srcObject = stream;
};
var startButton = document.getElementById('startButton');
var toggleEffectButton = document.getElementById('toggleEffectButton');
Expand Down Expand Up @@ -94,7 +94,7 @@
}

function onRegisterStreamDone() {
vidprocessedlocal.src = URL.createObjectURL(processedLocalstream);
vidprocessedlocal.srcObject = processedLocalstream;
toggleEffectButton.disabled = false;
}

Expand Down Expand Up @@ -176,7 +176,7 @@
}

function gotRemoteStream(e){
vidremote.src = URL.createObjectURL(e.stream);
vidremote.srcObject = e.stream;
trace("Received remote stream");
}

Expand Down
2 changes: 1 addition & 1 deletion ppapi/examples/video_encode/video_encode.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

function success(stream) {
track = stream.getVideoTracks()[0];
video.src = URL.createObjectURL(stream);
video.srcObject = stream;
video.play();

var list = $('profileList');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@
async_test(function(t) {
var video = document.querySelector("video");
navigator.webkitGetUserMedia({video:true}, function(stream) {
var previewURL = URL.createObjectURL(stream);

video.ontimeupdate = t.step_func(function() {
// restart preview.
video.src = previewURL;
video.srcObject = stream;
video.ontimeupdate = t.step_func_done();
});

//start preview.
video.src = previewURL;
video.srcObject = stream;
}, getStreamFailed);

function getStreamFailed(error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ <h1>Test Multichannel Audio Output for MediaStreamDestination</h1>
}

var audioElement = new Audio();
audioElement.src = URL.createObjectURL(mediaStreamDestination.stream);
audioElement.srcObject = mediaStreamDestination.stream;
audioElement.play();

// The ChannelMerger for the individual channel access.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Polymer({

var successCallback = function(stream) {
if (this.cameraStartInProgress_) {
this.$.cameraVideo.src = URL.createObjectURL(stream);
this.$.cameraVideo.srcObject = stream;
this.cameraStream_ = stream;
} else {
this.stopVideoTracks_(stream);
Expand All @@ -170,9 +170,11 @@ Polymer({
stopCamera: function() {
this.$.userImageStreamCrop.classList.remove('preview');
this.cameraOnline_ = false;
this.$.cameraVideo.src = '';
if (this.cameraStream_)
this.$.cameraVideo.srcObject = null;
if (this.cameraStream_) {
this.stopVideoTracks_(this.cameraStream_);
this.cameraStream_ = null;
}
// Cancel any pending getUserMedia() checks.
this.cameraStartInProgress_ = false;
},
Expand Down

0 comments on commit 703cf3e

Please sign in to comment.