blob: 79f033b4e15c2df6291470d9f93104955cabafa8 [file] [log] [blame]
andrew@webrtc.orgb015cbe2012-10-22 18:19:231/*
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.orgac6d9192013-05-13 10:50:5011#include "webrtc/video_engine/vie_impl.h"
12
13#include "webrtc/common.h"
pbos@webrtc.org3468f202014-05-14 08:02:2214#include "webrtc/system_wrappers/interface/logging.h"
andresp@webrtc.orgac6d9192013-05-13 10:50:5015#include "webrtc/system_wrappers/interface/trace.h"
andrew@webrtc.orgb015cbe2012-10-22 18:19:2316
andrew@webrtc.orgb015cbe2012-10-22 18:19:2317namespace webrtc {
18
andresp@webrtc.org90f05ed2013-05-08 19:20:2319enum { kModuleId = 0 };
andrew@webrtc.orgb015cbe2012-10-22 18:19:2320
21VideoEngine* VideoEngine::Create() {
andresp@webrtc.orgac6d9192013-05-13 10:50:5022 return new VideoEngineImpl(new Config(), true /* owns_config */);
23}
24
25VideoEngine* VideoEngine::Create(const Config& config) {
26 return new VideoEngineImpl(&config, false /* owns_config */);
andrew@webrtc.orgb015cbe2012-10-22 18:19:2327}
28
29bool VideoEngine::Delete(VideoEngine*& video_engine) {
pbos@webrtc.org3468f202014-05-14 08:02:2230 if (!video_engine)
andrew@webrtc.orgb015cbe2012-10-22 18:19:2331 return false;
pbos@webrtc.org3468f202014-05-14 08:02:2232
33 LOG_F(LS_INFO);
andrew@webrtc.org7ab72682013-05-09 02:12:0734 VideoEngineImpl* vie_impl = static_cast<VideoEngineImpl*>(video_engine);
andrew@webrtc.orgb015cbe2012-10-22 18:19:2335
36 // Check all reference counters.
37 ViEBaseImpl* vie_base = vie_impl;
38 if (vie_base->GetCount() > 0) {
pbos@webrtc.org3468f202014-05-14 08:02:2239 LOG(LS_ERROR) << "ViEBase ref count > 0: " << vie_base->GetCount();
andrew@webrtc.orgb015cbe2012-10-22 18:19:2340 return false;
41 }
42#ifdef WEBRTC_VIDEO_ENGINE_CAPTURE_API
43 ViECaptureImpl* vie_capture = vie_impl;
44 if (vie_capture->GetCount() > 0) {
pbos@webrtc.org3468f202014-05-14 08:02:2245 LOG(LS_ERROR) << "ViECapture ref count > 0: " << vie_capture->GetCount();
andrew@webrtc.orgb015cbe2012-10-22 18:19:2346 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.org3468f202014-05-14 08:02:2252 LOG(LS_ERROR) << "ViECodec ref count > 0: " << vie_codec->GetCount();
andrew@webrtc.orgb015cbe2012-10-22 18:19:2353 return false;
54 }
55#endif
andrew@webrtc.orgb015cbe2012-10-22 18:19:2356#ifdef WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API
57 ViEExternalCodecImpl* vie_external_codec = vie_impl;
58 if (vie_external_codec->GetCount() > 0) {
pbos@webrtc.org3468f202014-05-14 08:02:2259 LOG(LS_ERROR) << "ViEExternalCodec ref count > 0: "
60 << vie_external_codec->GetCount();
andrew@webrtc.orgb015cbe2012-10-22 18:19:2361 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.org3468f202014-05-14 08:02:2267 LOG(LS_ERROR) << "ViEFile ref count > 0: " << vie_file->GetCount();
andrew@webrtc.orgb015cbe2012-10-22 18:19:2368 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.org3468f202014-05-14 08:02:2274 LOG(LS_ERROR) << "ViEImageProcess ref count > 0: "
75 << vie_image_process->GetCount();
andrew@webrtc.orgb015cbe2012-10-22 18:19:2376 return false;
77 }
78#endif
andrew@webrtc.orgb015cbe2012-10-22 18:19:2379 ViENetworkImpl* vie_network = vie_impl;
80 if (vie_network->GetCount() > 0) {
pbos@webrtc.org3468f202014-05-14 08:02:2281 LOG(LS_ERROR) << "ViENetwork ref count > 0: " << vie_network->GetCount();
andrew@webrtc.orgb015cbe2012-10-22 18:19:2382 return false;
83 }
andrew@webrtc.orgb015cbe2012-10-22 18:19:2384#ifdef WEBRTC_VIDEO_ENGINE_RENDER_API
85 ViERenderImpl* vie_render = vie_impl;
86 if (vie_render->GetCount() > 0) {
pbos@webrtc.org3468f202014-05-14 08:02:2287 LOG(LS_ERROR) << "ViERender ref count > 0: " << vie_render->GetCount();
andrew@webrtc.orgb015cbe2012-10-22 18:19:2388 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.org3468f202014-05-14 08:02:2294 LOG(LS_ERROR) << "ViERTP_RTCP ref count > 0: " << vie_rtp_rtcp->GetCount();
andrew@webrtc.orgb015cbe2012-10-22 18:19:2395 return false;
96 }
97#endif
98
99 delete vie_impl;
100 vie_impl = NULL;
101 video_engine = NULL;
102
andrew@webrtc.orgb015cbe2012-10-22 18:19:23103 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 }
pbos@webrtc.org3468f202014-05-14 08:02:22114 LOG_F(LS_INFO) << "filename: " << file_nameUTF8
115 << " add_file_counter: " << (add_file_counter ? "yes" : "no");
andrew@webrtc.orgb015cbe2012-10-22 18:19:23116 return 0;
117}
118
119int VideoEngine::SetTraceFilter(const unsigned int filter) {
andrew@webrtc.org06eaa542013-09-05 16:40:43120 uint32_t old_filter = Trace::level_filter();
andrew@webrtc.orgb015cbe2012-10-22 18:19:23121
122 if (filter == kTraceNone && old_filter != kTraceNone) {
123 // Do the logging before turning it off.
pbos@webrtc.org3468f202014-05-14 08:02:22124 LOG_F(LS_INFO) << "filter: " << filter;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23125 }
126
andrew@webrtc.org06eaa542013-09-05 16:40:43127 Trace::set_level_filter(filter);
pbos@webrtc.org3468f202014-05-14 08:02:22128 LOG_F(LS_INFO) << "filter: " << filter;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23129 return 0;
130}
131
132int VideoEngine::SetTraceCallback(TraceCallback* callback) {
pbos@webrtc.org3468f202014-05-14 08:02:22133 LOG_F(LS_INFO);
andrew@webrtc.orgb015cbe2012-10-22 18:19:23134 return Trace::SetTraceCallback(callback);
135}
136
andrew@webrtc.orgb015cbe2012-10-22 18:19:23137} // namespace webrtc