blob: 11f136ba59fdbc872c2f9270ab43718ec7d1eb5a [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
mflodman@webrtc.org8baed512012-06-21 12:11:50 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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.orgf5d4cb12013-05-17 13:44:48 +000011#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"
niklase@google.com470e71d2011-07-07 08:21:25 +000019
20namespace webrtc {
21
andresp@webrtc.org7707d062013-05-13 10:50:50 +000022ViESharedData::ViESharedData(const Config& config)
mflodman@webrtc.org4dee3092013-05-16 11:13:18 +000023 : 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)),
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000027 module_process_thread_(ProcessThread::CreateProcessThread()),
28 last_error_(0) {
29 Trace::CreateTrace();
mflodman@webrtc.org4dee3092013-05-16 11:13:18 +000030 channel_manager_->SetModuleProcessThread(module_process_thread_);
31 input_manager_->SetModuleProcessThread(module_process_thread_);
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000032 module_process_thread_->Start();
niklase@google.com470e71d2011-07-07 08:21:25 +000033}
34
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000035ViESharedData::~ViESharedData() {
mflodman@webrtc.org4dee3092013-05-16 11:13:18 +000036 // Release these ones before the process thread and the trace.
37 input_manager_.reset();
38 channel_manager_.reset();
39 render_manager_.reset();
niklase@google.com470e71d2011-07-07 08:21:25 +000040
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000041 module_process_thread_->Stop();
42 ProcessThread::DestroyProcessThread(module_process_thread_);
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000043 Trace::ReturnTrace();
niklase@google.com470e71d2011-07-07 08:21:25 +000044}
45
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000046void ViESharedData::SetLastError(const int error) const {
47 last_error_ = error;
niklase@google.com470e71d2011-07-07 08:21:25 +000048}
49
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000050int ViESharedData::LastErrorInternal() const {
51 int error = last_error_;
52 last_error_ = 0;
53 return error;
niklase@google.com470e71d2011-07-07 08:21:25 +000054}
55
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000056int ViESharedData::NumberOfCores() const {
57 return number_cores_;
niklase@google.com470e71d2011-07-07 08:21:25 +000058}
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000059
60} // namespace webrtc