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

Side by Side Diff: webrtc/test/frame_generator_capturer.cc

Issue 1476453002: Clean up PlatformThread. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: IsRunning DCHECK Created 5 years 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/test/frame_generator_capturer.h ('k') | webrtc/video/rampup_tests.h » ('j') | 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) 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 FrameGeneratorCapturer::FrameGeneratorCapturer(Clock* clock, 60 FrameGeneratorCapturer::FrameGeneratorCapturer(Clock* clock,
61 VideoCaptureInput* input, 61 VideoCaptureInput* input,
62 FrameGenerator* frame_generator, 62 FrameGenerator* frame_generator,
63 int target_fps) 63 int target_fps)
64 : VideoCapturer(input), 64 : VideoCapturer(input),
65 clock_(clock), 65 clock_(clock),
66 sending_(false), 66 sending_(false),
67 tick_(EventTimerWrapper::Create()), 67 tick_(EventTimerWrapper::Create()),
68 thread_(FrameGeneratorCapturer::Run, this, "FrameGeneratorCapturer"),
68 frame_generator_(frame_generator), 69 frame_generator_(frame_generator),
69 target_fps_(target_fps), 70 target_fps_(target_fps),
70 first_frame_capture_time_(-1) { 71 first_frame_capture_time_(-1) {
71 assert(input != NULL); 72 assert(input != NULL);
72 assert(frame_generator != NULL); 73 assert(frame_generator != NULL);
73 assert(target_fps > 0); 74 assert(target_fps > 0);
74 } 75 }
75 76
76 FrameGeneratorCapturer::~FrameGeneratorCapturer() { 77 FrameGeneratorCapturer::~FrameGeneratorCapturer() {
77 Stop(); 78 Stop();
78 79
79 if (thread_.get() != NULL) 80 thread_.Stop();
80 thread_->Stop();
81 } 81 }
82 82
83 bool FrameGeneratorCapturer::Init() { 83 bool FrameGeneratorCapturer::Init() {
84 // This check is added because frame_generator_ might be file based and should 84 // This check is added because frame_generator_ might be file based and should
85 // not crash because a file moved. 85 // not crash because a file moved.
86 if (frame_generator_.get() == NULL) 86 if (frame_generator_.get() == NULL)
87 return false; 87 return false;
88 88
89 if (!tick_->StartTimer(true, 1000 / target_fps_)) 89 if (!tick_->StartTimer(true, 1000 / target_fps_))
90 return false; 90 return false;
91 thread_ = PlatformThread::CreateThread(FrameGeneratorCapturer::Run, this, 91 thread_.Start();
92 "FrameGeneratorCapturer"); 92 thread_.SetPriority(rtc::kHighPriority);
93 if (thread_.get() == NULL)
94 return false;
95 if (!thread_->Start()) {
96 thread_.reset();
97 return false;
98 }
99 thread_->SetPriority(webrtc::kHighPriority);
100 return true; 93 return true;
101 } 94 }
102 95
103 bool FrameGeneratorCapturer::Run(void* obj) { 96 bool FrameGeneratorCapturer::Run(void* obj) {
104 static_cast<FrameGeneratorCapturer*>(obj)->InsertFrame(); 97 static_cast<FrameGeneratorCapturer*>(obj)->InsertFrame();
105 return true; 98 return true;
106 } 99 }
107 100
108 void FrameGeneratorCapturer::InsertFrame() { 101 void FrameGeneratorCapturer::InsertFrame() {
109 { 102 {
(...skipping 18 matching lines...) Expand all
128 void FrameGeneratorCapturer::Stop() { 121 void FrameGeneratorCapturer::Stop() {
129 rtc::CritScope cs(&lock_); 122 rtc::CritScope cs(&lock_);
130 sending_ = false; 123 sending_ = false;
131 } 124 }
132 125
133 void FrameGeneratorCapturer::ForceFrame() { 126 void FrameGeneratorCapturer::ForceFrame() {
134 tick_->Set(); 127 tick_->Set();
135 } 128 }
136 } // test 129 } // test
137 } // webrtc 130 } // webrtc
OLDNEW
« no previous file with comments | « webrtc/test/frame_generator_capturer.h ('k') | webrtc/video/rampup_tests.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698