OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 assert(vcm_->CaptureStarted()); | 52 assert(vcm_->CaptureStarted()); |
53 | 53 |
54 return true; | 54 return true; |
55 } | 55 } |
56 | 56 |
57 VcmCapturer* VcmCapturer::Create(VideoCaptureInput* input, | 57 VcmCapturer* VcmCapturer::Create(VideoCaptureInput* input, |
58 size_t width, | 58 size_t width, |
59 size_t height, | 59 size_t height, |
60 size_t target_fps) { | 60 size_t target_fps) { |
61 VcmCapturer* vcm__capturer = new VcmCapturer(input); | 61 VcmCapturer* vcm_capturer = new VcmCapturer(input); |
62 if (!vcm__capturer->Init(width, height, target_fps)) { | 62 if (!vcm_capturer->Init(width, height, target_fps)) { |
63 // TODO(pbos): Log a warning that this failed. | 63 // TODO(pbos): Log a warning that this failed. |
64 delete vcm__capturer; | 64 delete vcm_capturer; |
65 return NULL; | 65 return NULL; |
66 } | 66 } |
67 return vcm__capturer; | 67 return vcm_capturer; |
68 } | 68 } |
69 | 69 |
70 | 70 |
71 void VcmCapturer::Start() { started_ = true; } | 71 void VcmCapturer::Start() { |
| 72 rtc::CritScope lock(&crit_); |
| 73 started_ = true; |
| 74 } |
72 | 75 |
73 void VcmCapturer::Stop() { started_ = false; } | 76 void VcmCapturer::Stop() { |
| 77 rtc::CritScope lock(&crit_); |
| 78 started_ = false; |
| 79 } |
74 | 80 |
75 void VcmCapturer::Destroy() { | 81 void VcmCapturer::Destroy() { |
76 if (vcm_ == NULL) { | 82 if (vcm_ == NULL) { |
77 return; | 83 return; |
78 } | 84 } |
79 | 85 |
80 vcm_->StopCapture(); | 86 vcm_->StopCapture(); |
81 vcm_->DeRegisterCaptureDataCallback(); | 87 vcm_->DeRegisterCaptureDataCallback(); |
82 vcm_->Release(); | 88 vcm_->Release(); |
83 | 89 |
84 // TODO(pbos): How do I destroy the VideoCaptureModule? This still leaves | 90 // TODO(pbos): How do I destroy the VideoCaptureModule? This still leaves |
85 // non-freed memory. | 91 // non-freed memory. |
86 vcm_ = NULL; | 92 vcm_ = NULL; |
87 } | 93 } |
88 | 94 |
89 VcmCapturer::~VcmCapturer() { Destroy(); } | 95 VcmCapturer::~VcmCapturer() { Destroy(); } |
90 | 96 |
91 void VcmCapturer::OnIncomingCapturedFrame(const int32_t id, | 97 void VcmCapturer::OnIncomingCapturedFrame(const int32_t id, |
92 const VideoFrame& frame) { | 98 const VideoFrame& frame) { |
| 99 rtc::CritScope lock(&crit_); |
93 if (started_) | 100 if (started_) |
94 input_->IncomingCapturedFrame(frame); | 101 input_->IncomingCapturedFrame(frame); |
95 } | 102 } |
96 | 103 |
97 void VcmCapturer::OnCaptureDelayChanged(const int32_t id, const int32_t delay) { | 104 void VcmCapturer::OnCaptureDelayChanged(const int32_t id, const int32_t delay) { |
98 } | 105 } |
99 } // test | 106 } // test |
100 } // webrtc | 107 } // webrtc |
OLD | NEW |