OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/rtc_video_capturer.h" | 5 #include "content/renderer/media/rtc_video_capturer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
(...skipping 19 matching lines...) Expand all Loading... |
30 DVLOG(1) << "Got a StartCapture when already started!!! "; | 30 DVLOG(1) << "Got a StartCapture when already started!!! "; |
31 return cricket::CS_FAILED; | 31 return cricket::CS_FAILED; |
32 } | 32 } |
33 | 33 |
34 media::VideoCaptureCapability cap; | 34 media::VideoCaptureCapability cap; |
35 cap.width = capture_format.width; | 35 cap.width = capture_format.width; |
36 cap.height = capture_format.height; | 36 cap.height = capture_format.height; |
37 cap.frame_rate = capture_format.framerate(); | 37 cap.frame_rate = capture_format.framerate(); |
38 cap.color = media::VideoCaptureCapability::kI420; | 38 cap.color = media::VideoCaptureCapability::kI420; |
39 | 39 |
| 40 SetCaptureFormat(&capture_format); |
| 41 |
40 state_ = VIDEO_CAPTURE_STATE_STARTED; | 42 state_ = VIDEO_CAPTURE_STATE_STARTED; |
41 start_time_ = base::Time::Now(); | 43 start_time_ = base::Time::Now(); |
42 delegate_->StartCapture(cap, | 44 delegate_->StartCapture(cap, |
43 base::Bind(&RtcVideoCapturer::OnFrameCaptured, base::Unretained(this)), | 45 base::Bind(&RtcVideoCapturer::OnFrameCaptured, base::Unretained(this)), |
44 base::Bind(&RtcVideoCapturer::OnStateChange, base::Unretained(this))); | 46 base::Bind(&RtcVideoCapturer::OnStateChange, base::Unretained(this))); |
45 // Update the desired aspect ratio so that later the video frame can be | 47 // Update the desired aspect ratio so that later the video frame can be |
46 // cropped to meet the requirement if the camera returns a different | 48 // cropped to meet the requirement if the camera returns a different |
47 // resolution than the |cap|. | 49 // resolution than the |cap|. |
48 UpdateAspectRatio(cap.width, cap.height); | 50 UpdateAspectRatio(cap.width, cap.height); |
49 return cricket::CS_STARTING; | 51 return cricket::CS_STARTING; |
50 } | 52 } |
51 | 53 |
52 void RtcVideoCapturer::Stop() { | 54 void RtcVideoCapturer::Stop() { |
53 DVLOG(3) << " RtcVideoCapturer::Stop "; | 55 DVLOG(3) << " RtcVideoCapturer::Stop "; |
54 if (state_ == VIDEO_CAPTURE_STATE_STOPPED) { | 56 if (state_ == VIDEO_CAPTURE_STATE_STOPPED) { |
55 DVLOG(1) << "Got a StopCapture while not started."; | 57 DVLOG(1) << "Got a StopCapture while not started."; |
56 return; | 58 return; |
57 } | 59 } |
| 60 |
| 61 SetCaptureFormat(NULL); |
58 state_ = VIDEO_CAPTURE_STATE_STOPPED; | 62 state_ = VIDEO_CAPTURE_STATE_STOPPED; |
59 delegate_->StopCapture(); | 63 delegate_->StopCapture(); |
60 SignalStateChange(this, cricket::CS_STOPPED); | 64 SignalStateChange(this, cricket::CS_STOPPED); |
61 } | 65 } |
62 | 66 |
63 bool RtcVideoCapturer::IsRunning() { | 67 bool RtcVideoCapturer::IsRunning() { |
64 return state_ == VIDEO_CAPTURE_STATE_STARTED; | 68 return state_ == VIDEO_CAPTURE_STATE_STARTED; |
65 } | 69 } |
66 | 70 |
67 bool RtcVideoCapturer::GetPreferredFourccs(std::vector<uint32>* fourccs) { | 71 bool RtcVideoCapturer::GetPreferredFourccs(std::vector<uint32>* fourccs) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 converted_state = cricket::CS_FAILED; | 144 converted_state = cricket::CS_FAILED; |
141 break; | 145 break; |
142 default: | 146 default: |
143 NOTREACHED(); | 147 NOTREACHED(); |
144 break; | 148 break; |
145 } | 149 } |
146 SignalStateChange(this, converted_state); | 150 SignalStateChange(this, converted_state); |
147 } | 151 } |
148 | 152 |
149 } // namespace content | 153 } // namespace content |
OLD | NEW |