OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/renderer/media/media_recorder_handler.h" | 5 #include "content/renderer/media/media_recorder_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "content/renderer/media/video_track_recorder.h" | 10 #include "content/renderer/media/video_track_recorder.h" |
| 11 #include "content/renderer/media/webrtc_uma_histograms.h" |
11 #include "media/base/bind_to_current_loop.h" | 12 #include "media/base/bind_to_current_loop.h" |
12 #include "media/base/video_frame.h" | 13 #include "media/base/video_frame.h" |
13 #include "media/capture/webm_muxer.h" | 14 #include "media/capture/webm_muxer.h" |
14 #include "third_party/WebKit/public/platform/WebMediaRecorderHandlerClient.h" | 15 #include "third_party/WebKit/public/platform/WebMediaRecorderHandlerClient.h" |
15 #include "third_party/WebKit/public/platform/WebString.h" | 16 #include "third_party/WebKit/public/platform/WebString.h" |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
19 MediaRecorderHandler::MediaRecorderHandler() | 20 MediaRecorderHandler::MediaRecorderHandler() |
20 : recording_(false), client_(nullptr), weak_factory_(this) { | 21 : recording_(false), client_(nullptr), weak_factory_(this) { |
(...skipping 12 matching lines...) Expand all Loading... |
33 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 34 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
34 // TODO(mcasas): For the time being only empty or "video/vp8" are supported. | 35 // TODO(mcasas): For the time being only empty or "video/vp8" are supported. |
35 return mimeType.isEmpty() || mimeType.utf8().compare("video/vp8") == 0; | 36 return mimeType.isEmpty() || mimeType.utf8().compare("video/vp8") == 0; |
36 } | 37 } |
37 | 38 |
38 bool MediaRecorderHandler::initialize( | 39 bool MediaRecorderHandler::initialize( |
39 blink::WebMediaRecorderHandlerClient* client, | 40 blink::WebMediaRecorderHandlerClient* client, |
40 const blink::WebMediaStream& media_stream, | 41 const blink::WebMediaStream& media_stream, |
41 const blink::WebString& mimeType) { | 42 const blink::WebString& mimeType) { |
42 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 43 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
| 44 // Save histogram data so we can see how much MediaStream Recorder is used. |
| 45 // The histogram counts the number of calls to the JS API. |
| 46 UpdateWebRTCMethodCount(WEBKIT_MEDIA_STREAM_RECORDER); |
| 47 |
43 if (!canSupportMimeType(mimeType)) { | 48 if (!canSupportMimeType(mimeType)) { |
44 DLOG(ERROR) << "Can't support type " << mimeType.utf8(); | 49 DLOG(ERROR) << "Can't support type " << mimeType.utf8(); |
45 return false; | 50 return false; |
46 } | 51 } |
47 media_stream_ = media_stream; | 52 media_stream_ = media_stream; |
48 DCHECK(client); | 53 DCHECK(client); |
49 client_ = client; | 54 client_ = client; |
50 | 55 |
51 return true; | 56 return true; |
52 } | 57 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 141 } |
137 | 142 |
138 void MediaRecorderHandler::OnVideoFrameForTesting( | 143 void MediaRecorderHandler::OnVideoFrameForTesting( |
139 const scoped_refptr<media::VideoFrame>& frame, | 144 const scoped_refptr<media::VideoFrame>& frame, |
140 const base::TimeTicks& timestamp) { | 145 const base::TimeTicks& timestamp) { |
141 for (auto* recorder : video_recorders_) | 146 for (auto* recorder : video_recorders_) |
142 recorder->OnVideoFrameForTesting(frame, timestamp); | 147 recorder->OnVideoFrameForTesting(frame, timestamp); |
143 } | 148 } |
144 | 149 |
145 } // namespace content | 150 } // namespace content |
OLD | NEW |