Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(417)

Side by Side Diff: webrtc/video/video_capture_input.cc

Issue 1453093002: Revert of Create rtc::AtomicInt POD struct. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/video/video_capture_input.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 28 matching lines...) Expand all
39 : capture_cs_(CriticalSectionWrapper::CreateCriticalSection()), 39 : capture_cs_(CriticalSectionWrapper::CreateCriticalSection()),
40 module_process_thread_(module_process_thread), 40 module_process_thread_(module_process_thread),
41 frame_callback_(frame_callback), 41 frame_callback_(frame_callback),
42 local_renderer_(local_renderer), 42 local_renderer_(local_renderer),
43 stats_proxy_(stats_proxy), 43 stats_proxy_(stats_proxy),
44 incoming_frame_cs_(CriticalSectionWrapper::CreateCriticalSection()), 44 incoming_frame_cs_(CriticalSectionWrapper::CreateCriticalSection()),
45 encoder_thread_(ThreadWrapper::CreateThread(EncoderThreadFunction, 45 encoder_thread_(ThreadWrapper::CreateThread(EncoderThreadFunction,
46 this, 46 this,
47 "EncoderThread")), 47 "EncoderThread")),
48 capture_event_(EventWrapper::Create()), 48 capture_event_(EventWrapper::Create()),
49 stop_(0),
49 last_captured_timestamp_(0), 50 last_captured_timestamp_(0),
50 delta_ntp_internal_ms_( 51 delta_ntp_internal_ms_(
51 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds() - 52 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds() -
52 TickTime::MillisecondTimestamp()), 53 TickTime::MillisecondTimestamp()),
53 overuse_detector_(new OveruseFrameDetector(Clock::GetRealTimeClock(), 54 overuse_detector_(new OveruseFrameDetector(Clock::GetRealTimeClock(),
54 CpuOveruseOptions(), 55 CpuOveruseOptions(),
55 overuse_observer, 56 overuse_observer,
56 stats_proxy)), 57 stats_proxy)),
57 encoding_time_observer_(encoding_time_observer) { 58 encoding_time_observer_(encoding_time_observer) {
58 encoder_thread_->Start(); 59 encoder_thread_->Start();
59 encoder_thread_->SetPriority(kHighPriority); 60 encoder_thread_->SetPriority(kHighPriority);
60 module_process_thread_->RegisterModule(overuse_detector_.get()); 61 module_process_thread_->RegisterModule(overuse_detector_.get());
61 } 62 }
62 63
63 VideoCaptureInput::~VideoCaptureInput() { 64 VideoCaptureInput::~VideoCaptureInput() {
64 module_process_thread_->DeRegisterModule(overuse_detector_.get()); 65 module_process_thread_->DeRegisterModule(overuse_detector_.get());
65 66
66 // Stop the thread. 67 // Stop the thread.
67 rtc::AtomicInt::ReleaseStore(&stop_, 1); 68 rtc::AtomicOps::ReleaseStore(&stop_, 1);
68 capture_event_->Set(); 69 capture_event_->Set();
69 encoder_thread_->Stop(); 70 encoder_thread_->Stop();
70 } 71 }
71 72
72 void VideoCaptureInput::IncomingCapturedFrame(const VideoFrame& video_frame) { 73 void VideoCaptureInput::IncomingCapturedFrame(const VideoFrame& video_frame) {
73 // TODO(pbos): Remove local rendering, it should be handled by the client code 74 // TODO(pbos): Remove local rendering, it should be handled by the client code
74 // if required. 75 // if required.
75 if (local_renderer_) 76 if (local_renderer_)
76 local_renderer_->RenderFrame(video_frame, 0); 77 local_renderer_->RenderFrame(video_frame, 0);
77 78
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 122 }
122 123
123 bool VideoCaptureInput::EncoderThreadFunction(void* obj) { 124 bool VideoCaptureInput::EncoderThreadFunction(void* obj) {
124 return static_cast<VideoCaptureInput*>(obj)->EncoderProcess(); 125 return static_cast<VideoCaptureInput*>(obj)->EncoderProcess();
125 } 126 }
126 127
127 bool VideoCaptureInput::EncoderProcess() { 128 bool VideoCaptureInput::EncoderProcess() {
128 static const int kThreadWaitTimeMs = 100; 129 static const int kThreadWaitTimeMs = 100;
129 int64_t capture_time = -1; 130 int64_t capture_time = -1;
130 if (capture_event_->Wait(kThreadWaitTimeMs) == kEventSignaled) { 131 if (capture_event_->Wait(kThreadWaitTimeMs) == kEventSignaled) {
131 if (rtc::AtomicInt::AcquireLoad(&stop_)) 132 if (rtc::AtomicOps::AcquireLoad(&stop_))
132 return false; 133 return false;
133 134
134 int64_t encode_start_time = -1; 135 int64_t encode_start_time = -1;
135 VideoFrame deliver_frame; 136 VideoFrame deliver_frame;
136 { 137 {
137 CriticalSectionScoped cs(capture_cs_.get()); 138 CriticalSectionScoped cs(capture_cs_.get());
138 if (!captured_frame_.IsZeroSize()) { 139 if (!captured_frame_.IsZeroSize()) {
139 deliver_frame = captured_frame_; 140 deliver_frame = captured_frame_;
140 captured_frame_.Reset(); 141 captured_frame_.Reset();
141 } 142 }
(...skipping 17 matching lines...) Expand all
159 } 160 }
160 // We're done! 161 // We're done!
161 if (capture_time != -1) { 162 if (capture_time != -1) {
162 overuse_detector_->FrameSent(capture_time); 163 overuse_detector_->FrameSent(capture_time);
163 } 164 }
164 return true; 165 return true;
165 } 166 }
166 167
167 } // namespace internal 168 } // namespace internal
168 } // namespace webrtc 169 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/video_capture_input.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698