Home | History | Annotate | Download | only in video_engine
      1 /*
      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 "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"
     19 
     20 namespace webrtc {
     21 
     22 ViESharedData::ViESharedData(const Config& config)
     23     : 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)),
     27       module_process_thread_(ProcessThread::CreateProcessThread()),
     28       last_error_(0) {
     29   Trace::CreateTrace();
     30   channel_manager_->SetModuleProcessThread(module_process_thread_);
     31   input_manager_->SetModuleProcessThread(module_process_thread_);
     32   module_process_thread_->Start();
     33 }
     34 
     35 ViESharedData::~ViESharedData() {
     36   // Release these ones before the process thread and the trace.
     37   input_manager_.reset();
     38   channel_manager_.reset();
     39   render_manager_.reset();
     40 
     41   module_process_thread_->Stop();
     42   ProcessThread::DestroyProcessThread(module_process_thread_);
     43   Trace::ReturnTrace();
     44 }
     45 
     46 void ViESharedData::SetLastError(const int error) const {
     47   last_error_ = error;
     48 }
     49 
     50 int ViESharedData::LastErrorInternal() const {
     51   int error = last_error_;
     52   last_error_ = 0;
     53   return error;
     54 }
     55 
     56 int ViESharedData::NumberOfCores() const {
     57   return number_cores_;
     58 }
     59 
     60 }  // namespace webrtc
     61