OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "content/browser/media/webrtc_internals.h" | 5 #include "content/browser/media/webrtc_internals.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "content/browser/media/webrtc_internals_ui_observer.h" | 8 #include "content/browser/media/webrtc_internals_ui_observer.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 #include "content/public/browser/child_process_data.h" | 10 #include "content/public/browser/child_process_data.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 log = new base::ListValue(); | 28 log = new base::ListValue(); |
29 if (log) | 29 if (log) |
30 dict->Set("log", log); | 30 dict->Set("log", log); |
31 } | 31 } |
32 return log; | 32 return log; |
33 } | 33 } |
34 | 34 |
35 } // namespace | 35 } // namespace |
36 | 36 |
37 WebRTCInternals::WebRTCInternals() | 37 WebRTCInternals::WebRTCInternals() |
38 : is_recording_rtp_(false), | 38 : aec_dump_enabled_(false) { |
39 aec_dump_enabled_(false) { | |
40 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 39 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
41 NotificationService::AllBrowserContextsAndSources()); | 40 NotificationService::AllBrowserContextsAndSources()); |
42 BrowserChildProcessObserver::Add(this); | 41 BrowserChildProcessObserver::Add(this); |
43 // TODO(grunell): Shouldn't all the webrtc_internals* files be excluded from the | 42 // TODO(grunell): Shouldn't all the webrtc_internals* files be excluded from the |
44 // build if WebRTC is disabled? | 43 // build if WebRTC is disabled? |
45 #if defined(ENABLE_WEBRTC) | 44 #if defined(ENABLE_WEBRTC) |
46 if (CommandLine::ForCurrentProcess()->HasSwitch( | 45 if (CommandLine::ForCurrentProcess()->HasSwitch( |
47 switches::kEnableWebRtcAecRecordings)) { | 46 switches::kEnableWebRtcAecRecordings)) { |
48 aec_dump_enabled_ = true; | 47 aec_dump_enabled_ = true; |
49 aec_dump_file_path_ = CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 48 aec_dump_file_path_ = CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 if (peer_connection_data_.GetSize() > 0) | 222 if (peer_connection_data_.GetSize() > 0) |
224 observer->OnUpdate("updateAllPeerConnections", &peer_connection_data_); | 223 observer->OnUpdate("updateAllPeerConnections", &peer_connection_data_); |
225 | 224 |
226 for (base::ListValue::iterator it = get_user_media_requests_.begin(); | 225 for (base::ListValue::iterator it = get_user_media_requests_.begin(); |
227 it != get_user_media_requests_.end(); | 226 it != get_user_media_requests_.end(); |
228 ++it) { | 227 ++it) { |
229 observer->OnUpdate("addGetUserMedia", *it); | 228 observer->OnUpdate("addGetUserMedia", *it); |
230 } | 229 } |
231 } | 230 } |
232 | 231 |
233 void WebRTCInternals::StartRtpRecording() { | |
234 if (!is_recording_rtp_) { | |
235 is_recording_rtp_ = true; | |
236 // TODO(justinlin): start RTP recording. | |
237 } | |
238 } | |
239 | |
240 void WebRTCInternals::StopRtpRecording() { | |
241 if (is_recording_rtp_) { | |
242 is_recording_rtp_ = false; | |
243 // TODO(justinlin): stop RTP recording. | |
244 } | |
245 } | |
246 | |
247 void WebRTCInternals::EnableAecDump(content::WebContents* web_contents) { | 232 void WebRTCInternals::EnableAecDump(content::WebContents* web_contents) { |
248 #if defined(ENABLE_WEBRTC) | 233 #if defined(ENABLE_WEBRTC) |
249 select_file_dialog_ = ui::SelectFileDialog::Create(this, NULL); | 234 select_file_dialog_ = ui::SelectFileDialog::Create(this, NULL); |
250 select_file_dialog_->SelectFile( | 235 select_file_dialog_->SelectFile( |
251 ui::SelectFileDialog::SELECT_SAVEAS_FILE, | 236 ui::SelectFileDialog::SELECT_SAVEAS_FILE, |
252 base::string16(), | 237 base::string16(), |
253 aec_dump_file_path_, | 238 aec_dump_file_path_, |
254 NULL, | 239 NULL, |
255 0, | 240 0, |
256 FILE_PATH_LITERAL(""), | 241 FILE_PATH_LITERAL(""), |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 } | 332 } |
348 } | 333 } |
349 | 334 |
350 if (found_any && observers_.might_have_observers()) { | 335 if (found_any && observers_.might_have_observers()) { |
351 base::DictionaryValue update; | 336 base::DictionaryValue update; |
352 update.SetInteger("rid", render_process_id); | 337 update.SetInteger("rid", render_process_id); |
353 SendUpdate("removeGetUserMediaForRenderer", &update); | 338 SendUpdate("removeGetUserMediaForRenderer", &update); |
354 } | 339 } |
355 } | 340 } |
356 | 341 |
357 // TODO(justlin): Calls this method as necessary to update the recording status | |
358 // UI. | |
359 void WebRTCInternals::SendRtpRecordingUpdate() { | |
360 DCHECK(is_recording_rtp_); | |
361 base::DictionaryValue update; | |
362 // TODO(justinlin): Fill in |update| with values as appropriate. | |
363 SendUpdate("updateDumpStatus", &update); | |
364 } | |
365 | |
366 void WebRTCInternals::ResetForTesting() { | 342 void WebRTCInternals::ResetForTesting() { |
367 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 343 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
368 observers_.Clear(); | 344 observers_.Clear(); |
369 peer_connection_data_.Clear(); | 345 peer_connection_data_.Clear(); |
370 get_user_media_requests_.Clear(); | 346 get_user_media_requests_.Clear(); |
371 is_recording_rtp_ = false; | |
372 aec_dump_enabled_ = false; | 347 aec_dump_enabled_ = false; |
373 } | 348 } |
374 | 349 |
375 } // namespace content | 350 } // namespace content |
OLD | NEW |