| 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 |
| 11 #include "webrtc/common_video/include/incoming_video_stream.h" | 11 #include "webrtc/common_video/include/incoming_video_stream.h" |
| 12 | 12 |
| 13 #include <assert.h> | 13 #include <assert.h> |
| 14 | 14 |
| 15 #if defined(_WIN32) | 15 #if defined(_WIN32) |
| 16 #include <windows.h> | 16 #include <windows.h> |
| 17 #elif defined(WEBRTC_LINUX) | 17 #elif defined(WEBRTC_LINUX) |
| 18 #include <sys/time.h> | 18 #include <sys/time.h> |
| 19 #include <time.h> | 19 #include <time.h> |
| 20 #else | 20 #else |
| 21 #include <sys/time.h> | 21 #include <sys/time.h> |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 #include "webrtc/base/platform_thread.h" |
| 24 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 25 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
| 25 #include "webrtc/common_video/video_render_frames.h" | 26 #include "webrtc/common_video/video_render_frames.h" |
| 26 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 27 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
| 27 #include "webrtc/system_wrappers/include/event_wrapper.h" | 28 #include "webrtc/system_wrappers/include/event_wrapper.h" |
| 28 #include "webrtc/system_wrappers/include/thread_wrapper.h" | |
| 29 #include "webrtc/system_wrappers/include/tick_util.h" | 29 #include "webrtc/system_wrappers/include/tick_util.h" |
| 30 #include "webrtc/system_wrappers/include/trace.h" | 30 #include "webrtc/system_wrappers/include/trace.h" |
| 31 | 31 |
| 32 namespace webrtc { | 32 namespace webrtc { |
| 33 | 33 |
| 34 IncomingVideoStream::IncomingVideoStream(uint32_t stream_id) | 34 IncomingVideoStream::IncomingVideoStream(uint32_t stream_id) |
| 35 : stream_id_(stream_id), | 35 : stream_id_(stream_id), |
| 36 stream_critsect_(CriticalSectionWrapper::CreateCriticalSection()), | 36 stream_critsect_(CriticalSectionWrapper::CreateCriticalSection()), |
| 37 thread_critsect_(CriticalSectionWrapper::CreateCriticalSection()), | 37 thread_critsect_(CriticalSectionWrapper::CreateCriticalSection()), |
| 38 buffer_critsect_(CriticalSectionWrapper::CreateCriticalSection()), | 38 buffer_critsect_(CriticalSectionWrapper::CreateCriticalSection()), |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 124 |
| 125 int32_t IncomingVideoStream::Start() { | 125 int32_t IncomingVideoStream::Start() { |
| 126 CriticalSectionScoped csS(stream_critsect_.get()); | 126 CriticalSectionScoped csS(stream_critsect_.get()); |
| 127 if (running_) { | 127 if (running_) { |
| 128 return 0; | 128 return 0; |
| 129 } | 129 } |
| 130 | 130 |
| 131 CriticalSectionScoped csT(thread_critsect_.get()); | 131 CriticalSectionScoped csT(thread_critsect_.get()); |
| 132 assert(incoming_render_thread_ == NULL); | 132 assert(incoming_render_thread_ == NULL); |
| 133 | 133 |
| 134 incoming_render_thread_ = ThreadWrapper::CreateThread( | 134 incoming_render_thread_ = PlatformThread::CreateThread( |
| 135 IncomingVideoStreamThreadFun, this, "IncomingVideoStreamThread"); | 135 IncomingVideoStreamThreadFun, this, "IncomingVideoStreamThread"); |
| 136 if (!incoming_render_thread_) { | 136 if (!incoming_render_thread_) { |
| 137 return -1; | 137 return -1; |
| 138 } | 138 } |
| 139 | 139 |
| 140 if (incoming_render_thread_->Start()) { | 140 if (incoming_render_thread_->Start()) { |
| 141 } else { | 141 } else { |
| 142 return -1; | 142 return -1; |
| 143 } | 143 } |
| 144 incoming_render_thread_->SetPriority(kRealtimePriority); | 144 incoming_render_thread_->SetPriority(kRealtimePriority); |
| 145 deliver_buffer_event_->StartTimer(false, kEventStartupTimeMs); | 145 deliver_buffer_event_->StartTimer(false, kEventStartupTimeMs); |
| 146 | 146 |
| 147 running_ = true; | 147 running_ = true; |
| 148 return 0; | 148 return 0; |
| 149 } | 149 } |
| 150 | 150 |
| 151 int32_t IncomingVideoStream::Stop() { | 151 int32_t IncomingVideoStream::Stop() { |
| 152 CriticalSectionScoped cs_stream(stream_critsect_.get()); | 152 CriticalSectionScoped cs_stream(stream_critsect_.get()); |
| 153 | 153 |
| 154 if (!running_) { | 154 if (!running_) { |
| 155 return 0; | 155 return 0; |
| 156 } | 156 } |
| 157 | 157 |
| 158 ThreadWrapper* thread = NULL; | 158 PlatformThread* thread = NULL; |
| 159 { | 159 { |
| 160 CriticalSectionScoped cs_thread(thread_critsect_.get()); | 160 CriticalSectionScoped cs_thread(thread_critsect_.get()); |
| 161 if (incoming_render_thread_) { | 161 if (incoming_render_thread_) { |
| 162 // Setting the incoming render thread to NULL marks that we're performing | 162 // Setting the incoming render thread to NULL marks that we're performing |
| 163 // a shutdown and will make IncomingVideoStreamProcess abort after wakeup. | 163 // a shutdown and will make IncomingVideoStreamProcess abort after wakeup. |
| 164 thread = incoming_render_thread_.release(); | 164 thread = incoming_render_thread_.release(); |
| 165 deliver_buffer_event_->StopTimer(); | 165 deliver_buffer_event_->StopTimer(); |
| 166 // Set the event to allow the thread to wake up and shut down without | 166 // Set the event to allow the thread to wake up and shut down without |
| 167 // waiting for a timeout. | 167 // waiting for a timeout. |
| 168 deliver_buffer_event_->Set(); | 168 deliver_buffer_event_->Set(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 } | 247 } |
| 248 | 248 |
| 249 // We're done with this frame. | 249 // We're done with this frame. |
| 250 if (!frame_to_render.IsZeroSize()) | 250 if (!frame_to_render.IsZeroSize()) |
| 251 last_render_time_ms_ = frame_to_render.render_time_ms(); | 251 last_render_time_ms_ = frame_to_render.render_time_ms(); |
| 252 } | 252 } |
| 253 return true; | 253 return true; |
| 254 } | 254 } |
| 255 | 255 |
| 256 } // namespace webrtc | 256 } // namespace webrtc |
| OLD | NEW |