blob: 11f136ba59fdbc872c2f9270ab43718ec7d1eb5a [file] [log] [blame]
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +00001/*
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.org281cff82013-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"
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000019
20namespace webrtc {
21
andresp@webrtc.orgac6d9192013-05-13 10:50:50 +000022ViESharedData::ViESharedData(const Config& config)
mflodman@webrtc.org7645e4d2013-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)),
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000027 module_process_thread_(ProcessThread::CreateProcessThread()),
28 last_error_(0) {
29 Trace::CreateTrace();
mflodman@webrtc.org7645e4d2013-05-16 11:13:18 +000030 channel_manager_->SetModuleProcessThread(module_process_thread_);
31 input_manager_->SetModuleProcessThread(module_process_thread_);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000032 module_process_thread_->Start();
33}
34
35ViESharedData::~ViESharedData() {
mflodman@webrtc.org7645e4d2013-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();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000040
41 module_process_thread_->Stop();
42 ProcessThread::DestroyProcessThread(module_process_thread_);
43 Trace::ReturnTrace();
44}
45
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000046void ViESharedData::SetLastError(const int error) const {
47 last_error_ = error;
48}
49
50int ViESharedData::LastErrorInternal() const {
51 int error = last_error_;
52 last_error_ = 0;
53 return error;
54}
55
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000056int ViESharedData::NumberOfCores() const {
57 return number_cores_;
58}
59
60} // namespace webrtc