blob: b9271448846764712aea4b461e767e5a2e307f8a [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
25ViESharedData::ViESharedData()
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 vie_performance_monitor_(ViEPerformanceMonitor(instance_id_)),
31 channel_manager_(*new ViEChannelManager(instance_id_, number_cores_,
mflodman@webrtc.orgab2610f2012-06-29 10:05:28 +000032 &vie_performance_monitor_,
astor@webrtc.orgbd7aeba2012-06-26 10:47:04 +000033 over_use_detector_options_)),
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000034 input_manager_(*new ViEInputManager(instance_id_)),
35 render_manager_(*new ViERenderManager(instance_id_)),
36 module_process_thread_(ProcessThread::CreateProcessThread()),
37 last_error_(0) {
38 Trace::CreateTrace();
mflodman@webrtc.orgab2610f2012-06-29 10:05:28 +000039 channel_manager_.SetModuleProcessThread(module_process_thread_);
mflodman@webrtc.org8baed512012-06-21 12:11:50 +000040 input_manager_.SetModuleProcessThread(module_process_thread_);
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000041 module_process_thread_->Start();
niklase@google.com470e71d2011-07-07 08:21:25 +000042}
43
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000044ViESharedData::~ViESharedData() {
45 delete &input_manager_;
46 delete &channel_manager_;
47 delete &render_manager_;
niklase@google.com470e71d2011-07-07 08:21:25 +000048
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000049 module_process_thread_->Stop();
50 ProcessThread::DestroyProcessThread(module_process_thread_);
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000051 Trace::ReturnTrace();
niklase@google.com470e71d2011-07-07 08:21:25 +000052}
53
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000054bool ViESharedData::Initialized() const {
55 return initialized_;
niklase@google.com470e71d2011-07-07 08:21:25 +000056}
57
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000058int ViESharedData::SetInitialized() {
59 initialized_ = true;
60 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000061}
62
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000063int ViESharedData::SetUnInitialized() {
64 initialized_ = false;
65 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000066}
67
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000068void ViESharedData::SetLastError(const int error) const {
69 last_error_ = error;
niklase@google.com470e71d2011-07-07 08:21:25 +000070}
71
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000072int ViESharedData::LastErrorInternal() const {
73 int error = last_error_;
74 last_error_ = 0;
75 return error;
niklase@google.com470e71d2011-07-07 08:21:25 +000076}
77
astor@webrtc.orgc0496e62012-08-10 10:14:43 +000078void ViESharedData::SetOverUseDetectorOptions(
79 const OverUseDetectorOptions& options) {
80 over_use_detector_options_ = options;
81}
82
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000083int ViESharedData::NumberOfCores() const {
84 return number_cores_;
niklase@google.com470e71d2011-07-07 08:21:25 +000085}
mflodman@webrtc.org471e83e2011-11-24 15:16:00 +000086
87} // namespace webrtc