andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 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 | |
andresp@webrtc.org | ac6d919 | 2013-05-13 10:50:50 | [diff] [blame] | 11 | #include "webrtc/video_engine/vie_impl.h" |
| 12 | |
| 13 | #include "webrtc/common.h" |
pbos@webrtc.org | 3468f20 | 2014-05-14 08:02:22 | [diff] [blame] | 14 | #include "webrtc/system_wrappers/interface/logging.h" |
andresp@webrtc.org | ac6d919 | 2013-05-13 10:50:50 | [diff] [blame] | 15 | #include "webrtc/system_wrappers/interface/trace.h" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 16 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 17 | namespace webrtc { |
| 18 | |
andresp@webrtc.org | 90f05ed | 2013-05-08 19:20:23 | [diff] [blame] | 19 | enum { kModuleId = 0 }; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 20 | |
| 21 | VideoEngine* VideoEngine::Create() { |
andresp@webrtc.org | ac6d919 | 2013-05-13 10:50:50 | [diff] [blame] | 22 | return new VideoEngineImpl(new Config(), true /* owns_config */); |
| 23 | } |
| 24 | |
| 25 | VideoEngine* VideoEngine::Create(const Config& config) { |
| 26 | return new VideoEngineImpl(&config, false /* owns_config */); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | bool VideoEngine::Delete(VideoEngine*& video_engine) { |
pbos@webrtc.org | 3468f20 | 2014-05-14 08:02:22 | [diff] [blame] | 30 | if (!video_engine) |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 31 | return false; |
pbos@webrtc.org | 3468f20 | 2014-05-14 08:02:22 | [diff] [blame] | 32 | |
| 33 | LOG_F(LS_INFO); |
andrew@webrtc.org | 7ab7268 | 2013-05-09 02:12:07 | [diff] [blame] | 34 | VideoEngineImpl* vie_impl = static_cast<VideoEngineImpl*>(video_engine); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 35 | |
| 36 | // Check all reference counters. |
| 37 | ViEBaseImpl* vie_base = vie_impl; |
| 38 | if (vie_base->GetCount() > 0) { |
pbos@webrtc.org | 3468f20 | 2014-05-14 08:02:22 | [diff] [blame] | 39 | LOG(LS_ERROR) << "ViEBase ref count > 0: " << vie_base->GetCount(); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 40 | return false; |
| 41 | } |
| 42 | #ifdef WEBRTC_VIDEO_ENGINE_CAPTURE_API |
| 43 | ViECaptureImpl* vie_capture = vie_impl; |
| 44 | if (vie_capture->GetCount() > 0) { |
pbos@webrtc.org | 3468f20 | 2014-05-14 08:02:22 | [diff] [blame] | 45 | LOG(LS_ERROR) << "ViECapture ref count > 0: " << vie_capture->GetCount(); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 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) { |
pbos@webrtc.org | 3468f20 | 2014-05-14 08:02:22 | [diff] [blame] | 52 | LOG(LS_ERROR) << "ViECodec ref count > 0: " << vie_codec->GetCount(); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 53 | return false; |
| 54 | } |
| 55 | #endif |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 56 | #ifdef WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API |
| 57 | ViEExternalCodecImpl* vie_external_codec = vie_impl; |
| 58 | if (vie_external_codec->GetCount() > 0) { |
pbos@webrtc.org | 3468f20 | 2014-05-14 08:02:22 | [diff] [blame] | 59 | LOG(LS_ERROR) << "ViEExternalCodec ref count > 0: " |
| 60 | << vie_external_codec->GetCount(); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 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) { |
pbos@webrtc.org | 3468f20 | 2014-05-14 08:02:22 | [diff] [blame] | 67 | LOG(LS_ERROR) << "ViEFile ref count > 0: " << vie_file->GetCount(); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 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) { |
pbos@webrtc.org | 3468f20 | 2014-05-14 08:02:22 | [diff] [blame] | 74 | LOG(LS_ERROR) << "ViEImageProcess ref count > 0: " |
| 75 | << vie_image_process->GetCount(); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 76 | return false; |
| 77 | } |
| 78 | #endif |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 79 | ViENetworkImpl* vie_network = vie_impl; |
| 80 | if (vie_network->GetCount() > 0) { |
pbos@webrtc.org | 3468f20 | 2014-05-14 08:02:22 | [diff] [blame] | 81 | LOG(LS_ERROR) << "ViENetwork ref count > 0: " << vie_network->GetCount(); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 82 | return false; |
| 83 | } |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 84 | #ifdef WEBRTC_VIDEO_ENGINE_RENDER_API |
| 85 | ViERenderImpl* vie_render = vie_impl; |
| 86 | if (vie_render->GetCount() > 0) { |
pbos@webrtc.org | 3468f20 | 2014-05-14 08:02:22 | [diff] [blame] | 87 | LOG(LS_ERROR) << "ViERender ref count > 0: " << vie_render->GetCount(); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 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) { |
pbos@webrtc.org | 3468f20 | 2014-05-14 08:02:22 | [diff] [blame] | 94 | LOG(LS_ERROR) << "ViERTP_RTCP ref count > 0: " << vie_rtp_rtcp->GetCount(); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 95 | return false; |
| 96 | } |
| 97 | #endif |
| 98 | |
| 99 | delete vie_impl; |
| 100 | vie_impl = NULL; |
| 101 | video_engine = NULL; |
| 102 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 103 | return true; |
| 104 | } |
| 105 | |
| 106 | int 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 | } |
pbos@webrtc.org | 3468f20 | 2014-05-14 08:02:22 | [diff] [blame] | 114 | LOG_F(LS_INFO) << "filename: " << file_nameUTF8 |
| 115 | << " add_file_counter: " << (add_file_counter ? "yes" : "no"); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 116 | return 0; |
| 117 | } |
| 118 | |
| 119 | int VideoEngine::SetTraceFilter(const unsigned int filter) { |
andrew@webrtc.org | 06eaa54 | 2013-09-05 16:40:43 | [diff] [blame] | 120 | uint32_t old_filter = Trace::level_filter(); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 121 | |
| 122 | if (filter == kTraceNone && old_filter != kTraceNone) { |
| 123 | // Do the logging before turning it off. |
pbos@webrtc.org | 3468f20 | 2014-05-14 08:02:22 | [diff] [blame] | 124 | LOG_F(LS_INFO) << "filter: " << filter; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 125 | } |
| 126 | |
andrew@webrtc.org | 06eaa54 | 2013-09-05 16:40:43 | [diff] [blame] | 127 | Trace::set_level_filter(filter); |
pbos@webrtc.org | 3468f20 | 2014-05-14 08:02:22 | [diff] [blame] | 128 | LOG_F(LS_INFO) << "filter: " << filter; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 129 | return 0; |
| 130 | } |
| 131 | |
| 132 | int VideoEngine::SetTraceCallback(TraceCallback* callback) { |
pbos@webrtc.org | 3468f20 | 2014-05-14 08:02:22 | [diff] [blame] | 133 | LOG_F(LS_INFO); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 134 | return Trace::SetTraceCallback(callback); |
| 135 | } |
| 136 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 137 | } // namespace webrtc |