Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(667)

Side by Side Diff: remoting/webapp/crd/js/video_frame_recorder.js

Issue 803653004: Update Chromoting to use /third_party/closure_compiler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * Class implement the video frame recorder extension client. 7 * Class implement the video frame recorder extension client.
8 */ 8 */
9 9
10 'use strict'; 10 'use strict';
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 console.log("Received frame but have no writer"); 71 console.log("Received frame but have no writer");
72 return true; 72 return true;
73 } 73 }
74 if (!messageData) { 74 if (!messageData) {
75 console.log("Finished receiving frames"); 75 console.log("Finished receiving frames");
76 this.fileWriter_ = null; 76 this.fileWriter_ = null;
77 return true; 77 return true;
78 } 78 }
79 79
80 console.log("Received frame"); 80 console.log("Received frame");
81 /* jscompile gets confused if you refer to this as just atob(). */ 81 var videoPacketString = window.atob(messageData);
82 var videoPacketString = /** @type {string?} */ window.atob(messageData);
83 82
84 console.log("Converted from Base64 - length:" + videoPacketString.length); 83 console.log("Converted from Base64 - length:" + videoPacketString.length);
85 var byteArrays = []; 84 var byteArrays = [];
86 85
87 for (var offset = 0; offset < videoPacketString.length; offset += 512) { 86 for (var offset = 0; offset < videoPacketString.length; offset += 512) {
88 var slice = videoPacketString.slice(offset, offset + 512); 87 var slice = videoPacketString.slice(offset, offset + 512);
89 var byteNumbers = new Array(slice.length); 88 var byteNumbers = new Array(slice.length);
90 for (var i = 0; i < slice.length; i++) { 89 for (var i = 0; i < slice.length; i++) {
91 byteNumbers[i] = slice.charCodeAt(i); 90 byteNumbers[i] = slice.charCodeAt(i);
92 } 91 }
93 var byteArray = new Uint8Array(byteNumbers); 92 var byteArray = new Uint8Array(byteNumbers);
94 byteArrays.push(byteArray); 93 byteArrays.push(byteArray);
95 } 94 }
96 95
97 console.log("Writing frame"); 96 console.log("Writing frame");
98 videoPacketString = null; 97 videoPacketString = null;
99 /** 98 /**
100 * Our current compiler toolchain only understands the old (deprecated)
101 * Blob constructor, which does not accept any parameters.
102 * TODO(wez): Remove this when compiler is updated (see crbug.com/405298).
103 * @suppress {checkTypes}
104 * @param {Array} parts 99 * @param {Array} parts
105 * @return {Blob} 100 * @return {Blob}
106 */ 101 */
107 var makeBlob = function(parts) { 102 var makeBlob = function(parts) {
108 return new Blob(parts); 103 return new Blob(parts);
109 } 104 }
110 var videoPacketBlob = makeBlob(byteArrays); 105 var videoPacketBlob = makeBlob(byteArrays);
111 byteArrays = null; 106 byteArrays = null;
112 107
113 this.fileWriter_.write(videoPacketBlob); 108 this.fileWriter_.write(videoPacketBlob);
114 109
115 return true; 110 return true;
116 } 111 }
117 112
118 console.log("Unrecognized message: " + messageType); 113 console.log("Unrecognized message: " + messageType);
119 return true; 114 return true;
120 } 115 }
121 116
122 /** @param {FileEntry} fileEntry */ 117 /**
123 remoting.VideoFrameRecorder.prototype.onFileChosen_ = function(fileEntry) { 118 * @param {Entry} entry The single file entry if multiple files are not allowed.
124 if (!fileEntry) { 119 * @param {Array.<FileEntry>} fileEntries List of file entries if multiple files
120 * are allowed.
121 */
122 remoting.VideoFrameRecorder.prototype.onFileChosen_ = function(
123 entry, fileEntries) {
124 if (!entry) {
125 console.log("Cancelled save of video frames."); 125 console.log("Cancelled save of video frames.");
126 } else { 126 } else {
127 /** @type {function(string):void} */ 127 chrome.fileSystem.getDisplayPath(entry, function(path) {
128 chrome.fileSystem.getDisplayPath(fileEntry, function(path) {
129 console.log("Saving video frames to:" + path); 128 console.log("Saving video frames to:" + path);
130 }); 129 });
131 fileEntry.createWriter(this.onFileWriter_.bind(this)); 130 entry.createWriter(this.onFileWriter_.bind(this));
132 } 131 }
133 } 132 }
134 133
135 /** @param {FileWriter} fileWriter */ 134 /** @param {FileWriter} fileWriter */
136 remoting.VideoFrameRecorder.prototype.onFileWriter_ = function(fileWriter) { 135 remoting.VideoFrameRecorder.prototype.onFileWriter_ = function(fileWriter) {
137 console.log("Obtained FileWriter for video frame write"); 136 console.log("Obtained FileWriter for video frame write");
138 fileWriter.onwriteend = this.onWriteComplete_.bind(this); 137 fileWriter.onwriteend = this.onWriteComplete_.bind(this);
139 this.fileWriter_ = fileWriter; 138 this.fileWriter_ = fileWriter;
140 this.fetchNextFrame_(); 139 this.fetchNextFrame_();
141 } 140 }
142 141
143 remoting.VideoFrameRecorder.prototype.onWriteComplete_ = function(e) { 142 remoting.VideoFrameRecorder.prototype.onWriteComplete_ = function(e) {
144 console.log("Video frame write complete"); 143 console.log("Video frame write complete");
145 this.fetchNextFrame_(); 144 this.fetchNextFrame_();
146 } 145 }
147 146
148 remoting.VideoFrameRecorder.prototype.fetchNextFrame_ = function() { 147 remoting.VideoFrameRecorder.prototype.fetchNextFrame_ = function() {
149 console.log("Request next video frame"); 148 console.log("Request next video frame");
150 var data = { type: 'next-frame' } 149 var data = { type: 'next-frame' }
151 this.plugin_.sendClientMessage('video-recorder', JSON.stringify(data)); 150 this.plugin_.sendClientMessage('video-recorder', JSON.stringify(data));
152 } 151 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698