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 "media/base/bind_to_current_loop.h" | 11 #include "media/base/bind_to_current_loop.h" |
12 #include "media/capture/webm_muxer.h" | 12 #include "media/capture/webm_muxer.h" |
| 13 #include "third_party/WebKit/public/platform/WebMediaRecorderHandlerClient.h" |
13 #include "third_party/WebKit/public/platform/WebString.h" | 14 #include "third_party/WebKit/public/platform/WebString.h" |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 | 17 |
17 MediaRecorderHandler::MediaRecorderHandler() | 18 MediaRecorderHandler::MediaRecorderHandler() |
18 : recording_(false), client_(nullptr), weak_factory_(this) { | 19 : recording_(false), client_(nullptr), weak_factory_(this) { |
19 DVLOG(3) << __FUNCTION__; | 20 DVLOG(3) << __FUNCTION__; |
20 } | 21 } |
21 | 22 |
22 MediaRecorderHandler::~MediaRecorderHandler() { | 23 MediaRecorderHandler::~MediaRecorderHandler() { |
23 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 24 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
24 // Send a |last_in_slice| to our |client_|. | 25 // Send a |last_in_slice| to our |client_|. |
25 if (client_) | 26 if (client_) |
26 client_->writeData(nullptr, 0u, true); | 27 client_->writeData(nullptr, 0u, true); |
27 } | 28 } |
28 | 29 |
29 bool MediaRecorderHandler::canSupportMimeType( | 30 bool MediaRecorderHandler::canSupportMimeType( |
30 const blink::WebString& mimeType) { | 31 const blink::WebString& mimeType) { |
31 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 32 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
32 // TODO(mcasas): For the time being only "video/vp8" is supported. | 33 // TODO(mcasas): For the time being only empty or "video/vp8" are supported. |
33 return mimeType.utf8().compare("video/vp8") == 0; | 34 return mimeType.isEmpty() || mimeType.utf8().compare("video/vp8") == 0; |
34 } | 35 } |
35 | 36 |
36 bool MediaRecorderHandler::initialize( | 37 bool MediaRecorderHandler::initialize( |
37 blink::WebMediaRecorderHandlerClient* client, | 38 blink::WebMediaRecorderHandlerClient* client, |
38 const blink::WebMediaStream& media_stream, | 39 const blink::WebMediaStream& media_stream, |
39 const blink::WebString& mimeType) { | 40 const blink::WebString& mimeType) { |
40 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 41 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
41 if (!canSupportMimeType(mimeType)) { | 42 if (!canSupportMimeType(mimeType)) { |
42 DLOG(ERROR) << "Can't support type " << mimeType.utf8(); | 43 DLOG(ERROR) << "Can't support type " << mimeType.utf8(); |
43 return false; | 44 return false; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 123 } |
123 | 124 |
124 void MediaRecorderHandler::OnVideoFrameForTesting( | 125 void MediaRecorderHandler::OnVideoFrameForTesting( |
125 const scoped_refptr<media::VideoFrame>& frame, | 126 const scoped_refptr<media::VideoFrame>& frame, |
126 const base::TimeTicks& timestamp) { | 127 const base::TimeTicks& timestamp) { |
127 for (auto* recorder : video_recorders_) | 128 for (auto* recorder : video_recorders_) |
128 recorder->OnVideoFrameForTesting(frame, timestamp); | 129 recorder->OnVideoFrameForTesting(frame, timestamp); |
129 } | 130 } |
130 | 131 |
131 } // namespace content | 132 } // namespace content |
OLD | NEW |