andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
pbos@webrtc.org | 281cff8 | 2013-05-17 13:44:48 +0000 | [diff] [blame] | 11 | #include "webrtc/modules/utility/interface/process_thread.h" |
| 12 | #include "webrtc/system_wrappers/interface/cpu_info.h" |
| 13 | #include "webrtc/system_wrappers/interface/trace.h" |
| 14 | #include "webrtc/video_engine/vie_channel_manager.h" |
| 15 | #include "webrtc/video_engine/vie_defines.h" |
| 16 | #include "webrtc/video_engine/vie_input_manager.h" |
| 17 | #include "webrtc/video_engine/vie_render_manager.h" |
| 18 | #include "webrtc/video_engine/vie_shared_data.h" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 19 | |
| 20 | namespace webrtc { |
| 21 | |
andresp@webrtc.org | ac6d919 | 2013-05-13 10:50:50 +0000 | [diff] [blame] | 22 | ViESharedData::ViESharedData(const Config& config) |
mflodman@webrtc.org | 7645e4d | 2013-05-16 11:13:18 +0000 | [diff] [blame] | 23 | : number_cores_(CpuInfo::DetectNumberOfCores()), |
| 24 | channel_manager_(new ViEChannelManager(0, number_cores_, config)), |
| 25 | input_manager_(new ViEInputManager(0, config)), |
| 26 | render_manager_(new ViERenderManager(0)), |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 27 | module_process_thread_(ProcessThread::CreateProcessThread()), |
| 28 | last_error_(0) { |
| 29 | Trace::CreateTrace(); |
mflodman@webrtc.org | 7645e4d | 2013-05-16 11:13:18 +0000 | [diff] [blame] | 30 | channel_manager_->SetModuleProcessThread(module_process_thread_); |
| 31 | input_manager_->SetModuleProcessThread(module_process_thread_); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 32 | module_process_thread_->Start(); |
| 33 | } |
| 34 | |
| 35 | ViESharedData::~ViESharedData() { |
mflodman@webrtc.org | 7645e4d | 2013-05-16 11:13:18 +0000 | [diff] [blame] | 36 | // Release these ones before the process thread and the trace. |
| 37 | input_manager_.reset(); |
| 38 | channel_manager_.reset(); |
| 39 | render_manager_.reset(); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 40 | |
| 41 | module_process_thread_->Stop(); |
| 42 | ProcessThread::DestroyProcessThread(module_process_thread_); |
| 43 | Trace::ReturnTrace(); |
| 44 | } |
| 45 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 46 | void ViESharedData::SetLastError(const int error) const { |
| 47 | last_error_ = error; |
| 48 | } |
| 49 | |
| 50 | int ViESharedData::LastErrorInternal() const { |
| 51 | int error = last_error_; |
| 52 | last_error_ = 0; |
| 53 | return error; |
| 54 | } |
| 55 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 56 | int ViESharedData::NumberOfCores() const { |
| 57 | return number_cores_; |
| 58 | } |
| 59 | |
| 60 | } // namespace webrtc |