OLD | NEW |
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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 int32_t IncomingVideoStream::Start() { | 131 int32_t IncomingVideoStream::Start() { |
132 CriticalSectionScoped csS(stream_critsect_.get()); | 132 CriticalSectionScoped csS(stream_critsect_.get()); |
133 if (running_) { | 133 if (running_) { |
134 return 0; | 134 return 0; |
135 } | 135 } |
136 | 136 |
137 if (!disable_prerenderer_smoothing_) { | 137 if (!disable_prerenderer_smoothing_) { |
138 CriticalSectionScoped csT(thread_critsect_.get()); | 138 CriticalSectionScoped csT(thread_critsect_.get()); |
139 assert(incoming_render_thread_ == NULL); | 139 assert(incoming_render_thread_ == NULL); |
140 | 140 |
141 incoming_render_thread_ = PlatformThread::CreateThread( | 141 incoming_render_thread_.reset(new rtc::PlatformThread( |
142 IncomingVideoStreamThreadFun, this, "IncomingVideoStreamThread"); | 142 IncomingVideoStreamThreadFun, this, "IncomingVideoStreamThread")); |
143 if (!incoming_render_thread_) { | 143 if (!incoming_render_thread_) { |
144 return -1; | 144 return -1; |
145 } | 145 } |
146 | 146 |
147 if (incoming_render_thread_->Start()) { | 147 incoming_render_thread_->Start(); |
148 } else { | 148 incoming_render_thread_->SetPriority(rtc::kRealtimePriority); |
149 return -1; | |
150 } | |
151 incoming_render_thread_->SetPriority(kRealtimePriority); | |
152 deliver_buffer_event_->StartTimer(false, kEventStartupTimeMs); | 149 deliver_buffer_event_->StartTimer(false, kEventStartupTimeMs); |
153 } | 150 } |
| 151 |
154 running_ = true; | 152 running_ = true; |
155 return 0; | 153 return 0; |
156 } | 154 } |
157 | 155 |
158 int32_t IncomingVideoStream::Stop() { | 156 int32_t IncomingVideoStream::Stop() { |
159 CriticalSectionScoped cs_stream(stream_critsect_.get()); | 157 CriticalSectionScoped cs_stream(stream_critsect_.get()); |
160 | 158 |
161 if (!running_) { | 159 if (!running_) { |
162 return 0; | 160 return 0; |
163 } | 161 } |
164 | 162 |
165 PlatformThread* thread = NULL; | 163 rtc::PlatformThread* thread = NULL; |
166 { | 164 { |
167 CriticalSectionScoped cs_thread(thread_critsect_.get()); | 165 CriticalSectionScoped cs_thread(thread_critsect_.get()); |
168 if (incoming_render_thread_) { | 166 if (incoming_render_thread_) { |
169 // Setting the incoming render thread to NULL marks that we're performing | 167 // Setting the incoming render thread to NULL marks that we're performing |
170 // a shutdown and will make IncomingVideoStreamProcess abort after wakeup. | 168 // a shutdown and will make IncomingVideoStreamProcess abort after wakeup. |
171 thread = incoming_render_thread_.release(); | 169 thread = incoming_render_thread_.release(); |
172 deliver_buffer_event_->StopTimer(); | 170 deliver_buffer_event_->StopTimer(); |
173 // Set the event to allow the thread to wake up and shut down without | 171 // Set the event to allow the thread to wake up and shut down without |
174 // waiting for a timeout. | 172 // waiting for a timeout. |
175 deliver_buffer_event_->Set(); | 173 deliver_buffer_event_->Set(); |
176 } | 174 } |
177 } | 175 } |
178 if (thread) { | 176 if (thread) { |
179 if (thread->Stop()) { | 177 thread->Stop(); |
180 delete thread; | 178 delete thread; |
181 } else { | |
182 assert(false); | |
183 } | |
184 } | 179 } |
185 running_ = false; | 180 running_ = false; |
186 return 0; | 181 return 0; |
187 } | 182 } |
188 | 183 |
189 int32_t IncomingVideoStream::Reset() { | 184 int32_t IncomingVideoStream::Reset() { |
190 CriticalSectionScoped cs_buffer(buffer_critsect_.get()); | 185 CriticalSectionScoped cs_buffer(buffer_critsect_.get()); |
191 render_buffers_->ReleaseAllFrames(); | 186 render_buffers_->ReleaseAllFrames(); |
192 return 0; | 187 return 0; |
193 } | 188 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 external_callback_->RenderFrame(stream_id_, video_frame); | 254 external_callback_->RenderFrame(stream_id_, video_frame); |
260 } else if (render_callback_) { | 255 } else if (render_callback_) { |
261 render_callback_->RenderFrame(stream_id_, video_frame); | 256 render_callback_->RenderFrame(stream_id_, video_frame); |
262 } | 257 } |
263 | 258 |
264 // We're done with this frame. | 259 // We're done with this frame. |
265 last_render_time_ms_ = video_frame.render_time_ms(); | 260 last_render_time_ms_ = video_frame.render_time_ms(); |
266 } | 261 } |
267 | 262 |
268 } // namespace webrtc | 263 } // namespace webrtc |
OLD | NEW |