blob: 4e6ebcc00c1323c4815b46fd636bc8b54bf1b6cd [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
mflodman@webrtc.orgab2610f2012-06-29 10:05:28 +000011#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"
niklase@google.com470e71d2011-07-07 08:21:25 +000019
20namespace webrtc {
21
22// Active instance counter
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000023int ViESharedData::instance_counter_ = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000024
andresp@webrtc.org7707d062013-05-13 10:50:50 +000025ViESharedData::ViESharedData(const Config& config)
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000026 : instance_id_(++instance_counter_),
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000027 initialized_(false),
28 number_cores_(CpuInfo::DetectNumberOfCores()),
astor@webrtc.orgbd7aeba2012-06-26 10:47:04 +000029 over_use_detector_options_(),
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000030 channel_manager_(*new ViEChannelManager(instance_id_, number_cores_,
andresp@webrtc.org7707d062013-05-13 10:50:50 +000031 over_use_detector_options_,
32 config)),
33 input_manager_(*new ViEInputManager(instance_id_, config)),
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000034 render_manager_(*new ViERenderManager(instance_id_)),
35 module_process_thread_(ProcessThread::CreateProcessThread()),
36 last_error_(0) {
37 Trace::CreateTrace();
mflodman@webrtc.orgab2610f2012-06-29 10:05:28 +000038 channel_manager_.SetModuleProcessThread(module_process_thread_);
mflodman@webrtc.org8baed512012-06-21 12:11:50 +000039 input_manager_.SetModuleProcessThread(module_process_thread_);
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000040 module_process_thread_->Start();
niklase@google.com470e71d2011-07-07 08:21:25 +000041}
42
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000043ViESharedData::~ViESharedData() {
44 delete &input_manager_;
45 delete &channel_manager_;
46 delete &render_manager_;
niklase@google.com470e71d2011-07-07 08:21:25 +000047
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000048 module_process_thread_->Stop();
49 ProcessThread::DestroyProcessThread(module_process_thread_);
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000050 Trace::ReturnTrace();
niklase@google.com470e71d2011-07-07 08:21:25 +000051}
52
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000053bool ViESharedData::Initialized() const {
54 return initialized_;
niklase@google.com470e71d2011-07-07 08:21:25 +000055}
56
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000057int ViESharedData::SetInitialized() {
58 initialized_ = true;
59 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000060}
61
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000062int ViESharedData::SetUnInitialized() {
63 initialized_ = false;
64 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000065}
66
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000067void ViESharedData::SetLastError(const int error) const {
68 last_error_ = error;
niklase@google.com470e71d2011-07-07 08:21:25 +000069}
70
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000071int ViESharedData::LastErrorInternal() const {
72 int error = last_error_;
73 last_error_ = 0;
74 return error;
niklase@google.com470e71d2011-07-07 08:21:25 +000075}
76
astor@webrtc.orgc0496e62012-08-10 10:14:43 +000077void ViESharedData::SetOverUseDetectorOptions(
78 const OverUseDetectorOptions& options) {
79 over_use_detector_options_ = options;
80}
81
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000082int ViESharedData::NumberOfCores() const {
83 return number_cores_;
niklase@google.com470e71d2011-07-07 08:21:25 +000084}
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000085
86} // namespace webrtc