blob: 574aa9a422d8bef4db03a906b17277b4440031d7 [file] [log] [blame]
andrew@webrtc.orga7b57da2012-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
11#include "modules/utility/interface/process_thread.h"
12#include "system_wrappers/interface/cpu_info.h"
13#include "system_wrappers/interface/trace.h"
14#include "video_engine/vie_channel_manager.h"
15#include "video_engine/vie_defines.h"
16#include "video_engine/vie_input_manager.h"
17#include "video_engine/vie_render_manager.h"
18#include "video_engine/vie_shared_data.h"
19
20namespace webrtc {
21
22// Active instance counter
23int ViESharedData::instance_counter_ = 0;
24
25ViESharedData::ViESharedData()
26 : instance_id_(++instance_counter_),
27 initialized_(false),
28 number_cores_(CpuInfo::DetectNumberOfCores()),
29 over_use_detector_options_(),
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +000030 channel_manager_(*new ViEChannelManager(instance_id_, number_cores_,
andrew@webrtc.orga7b57da2012-10-22 18:19:23 +000031 over_use_detector_options_)),
32 input_manager_(*new ViEInputManager(instance_id_)),
33 render_manager_(*new ViERenderManager(instance_id_)),
34 module_process_thread_(ProcessThread::CreateProcessThread()),
35 last_error_(0) {
36 Trace::CreateTrace();
37 channel_manager_.SetModuleProcessThread(module_process_thread_);
38 input_manager_.SetModuleProcessThread(module_process_thread_);
39 module_process_thread_->Start();
40}
41
42ViESharedData::~ViESharedData() {
43 delete &input_manager_;
44 delete &channel_manager_;
45 delete &render_manager_;
46
47 module_process_thread_->Stop();
48 ProcessThread::DestroyProcessThread(module_process_thread_);
49 Trace::ReturnTrace();
50}
51
52bool ViESharedData::Initialized() const {
53 return initialized_;
54}
55
56int ViESharedData::SetInitialized() {
57 initialized_ = true;
58 return 0;
59}
60
61int ViESharedData::SetUnInitialized() {
62 initialized_ = false;
63 return 0;
64}
65
66void ViESharedData::SetLastError(const int error) const {
67 last_error_ = error;
68}
69
70int ViESharedData::LastErrorInternal() const {
71 int error = last_error_;
72 last_error_ = 0;
73 return error;
74}
75
76void ViESharedData::SetOverUseDetectorOptions(
77 const OverUseDetectorOptions& options) {
78 over_use_detector_options_ = options;
79}
80
81int ViESharedData::NumberOfCores() const {
82 return number_cores_;
83}
84
85} // namespace webrtc