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/video_engine/vie_impl.h" 12 13#include "webrtc/common.h" 14#include "webrtc/system_wrappers/interface/logging.h" 15#include "webrtc/system_wrappers/interface/trace.h" 16 17namespace webrtc { 18 19enum { kModuleId = 0 }; 20 21VideoEngine* VideoEngine::Create() { 22 return new VideoEngineImpl(new Config(), true /* owns_config */); 23} 24 25VideoEngine* VideoEngine::Create(const Config& config) { 26 return new VideoEngineImpl(&config, false /* owns_config */); 27} 28 29bool VideoEngine::Delete(VideoEngine*& video_engine) { 30 if (!video_engine) 31 return false; 32 33 LOG_F(LS_INFO); 34 VideoEngineImpl* vie_impl = static_cast<VideoEngineImpl*>(video_engine); 35 36 // Check all reference counters. 37 ViEBaseImpl* vie_base = vie_impl; 38 if (vie_base->GetCount() > 0) { 39 LOG(LS_ERROR) << "ViEBase ref count > 0: " << vie_base->GetCount(); 40 return false; 41 } 42#ifdef WEBRTC_VIDEO_ENGINE_CAPTURE_API 43 ViECaptureImpl* vie_capture = vie_impl; 44 if (vie_capture->GetCount() > 0) { 45 LOG(LS_ERROR) << "ViECapture ref count > 0: " << vie_capture->GetCount(); 46 return false; 47 } 48#endif 49#ifdef WEBRTC_VIDEO_ENGINE_CODEC_API 50 ViECodecImpl* vie_codec = vie_impl; 51 if (vie_codec->GetCount() > 0) { 52 LOG(LS_ERROR) << "ViECodec ref count > 0: " << vie_codec->GetCount(); 53 return false; 54 } 55#endif 56#ifdef WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API 57 ViEExternalCodecImpl* vie_external_codec = vie_impl; 58 if (vie_external_codec->GetCount() > 0) { 59 LOG(LS_ERROR) << "ViEExternalCodec ref count > 0: " 60 << vie_external_codec->GetCount(); 61 return false; 62 } 63#endif 64#ifdef WEBRTC_VIDEO_ENGINE_FILE_API 65 ViEFileImpl* vie_file = vie_impl; 66 if (vie_file->GetCount() > 0) { 67 LOG(LS_ERROR) << "ViEFile ref count > 0: " << vie_file->GetCount(); 68 return false; 69 } 70#endif 71#ifdef WEBRTC_VIDEO_ENGINE_IMAGE_PROCESS_API 72 ViEImageProcessImpl* vie_image_process = vie_impl; 73 if (vie_image_process->GetCount() > 0) { 74 LOG(LS_ERROR) << "ViEImageProcess ref count > 0: " 75 << vie_image_process->GetCount(); 76 return false; 77 } 78#endif 79 ViENetworkImpl* vie_network = vie_impl; 80 if (vie_network->GetCount() > 0) { 81 LOG(LS_ERROR) << "ViENetwork ref count > 0: " << vie_network->GetCount(); 82 return false; 83 } 84#ifdef WEBRTC_VIDEO_ENGINE_RENDER_API 85 ViERenderImpl* vie_render = vie_impl; 86 if (vie_render->GetCount() > 0) { 87 LOG(LS_ERROR) << "ViERender ref count > 0: " << vie_render->GetCount(); 88 return false; 89 } 90#endif 91#ifdef WEBRTC_VIDEO_ENGINE_RTP_RTCP_API 92 ViERTP_RTCPImpl* vie_rtp_rtcp = vie_impl; 93 if (vie_rtp_rtcp->GetCount() > 0) { 94 LOG(LS_ERROR) << "ViERTP_RTCP ref count > 0: " << vie_rtp_rtcp->GetCount(); 95 return false; 96 } 97#endif 98 99 delete vie_impl; 100 vie_impl = NULL; 101 video_engine = NULL; 102 103 return true; 104} 105 106int VideoEngine::SetTraceFile(const char* file_nameUTF8, 107 const bool add_file_counter) { 108 if (!file_nameUTF8) { 109 return -1; 110 } 111 if (Trace::SetTraceFile(file_nameUTF8, add_file_counter) == -1) { 112 return -1; 113 } 114 LOG_F(LS_INFO) << "filename: " << file_nameUTF8 115 << " add_file_counter: " << (add_file_counter ? "yes" : "no"); 116 return 0; 117} 118 119int VideoEngine::SetTraceFilter(const unsigned int filter) { 120 uint32_t old_filter = Trace::level_filter(); 121 122 if (filter == kTraceNone && old_filter != kTraceNone) { 123 // Do the logging before turning it off. 124 LOG_F(LS_INFO) << "filter: " << filter; 125 } 126 127 Trace::set_level_filter(filter); 128 LOG_F(LS_INFO) << "filter: " << filter; 129 return 0; 130} 131 132int VideoEngine::SetTraceCallback(TraceCallback* callback) { 133 LOG_F(LS_INFO); 134 return Trace::SetTraceCallback(callback); 135} 136 137} // namespace webrtc 138