blob: 7cbc9728417666dfce4faa5a7b94fe8840c64591 [file] [log] [blame]
henrike@webrtc.orgf0488722014-05-13 18:00:26 +00001/*
2 * Copyright 2004 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/base/thread.h"
12
13#ifndef __has_feature
14#define __has_feature(x) 0 // Compatibility with non-clang or LLVM compilers.
15#endif // __has_feature
16
17#if defined(WEBRTC_WIN)
18#include <comdef.h>
19#elif defined(WEBRTC_POSIX)
20#include <time.h>
21#endif
22
23#include "webrtc/base/common.h"
24#include "webrtc/base/logging.h"
danilchapbebf54c2016-04-28 01:32:48 -070025#include "webrtc/base/nullsocketserver.h"
Tommiea14f0a2015-05-18 13:51:06 +020026#include "webrtc/base/platform_thread.h"
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000027#include "webrtc/base/stringutils.h"
28#include "webrtc/base/timeutils.h"
29
30#if !__has_feature(objc_arc) && (defined(WEBRTC_MAC))
31#include "webrtc/base/maccocoathreadhelper.h"
32#include "webrtc/base/scoped_autorelease_pool.h"
33#endif
34
tommi@webrtc.org7c64ed22015-03-17 14:25:37 +000035#include "webrtc/base/trace_event.h"
36
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000037namespace rtc {
38
39ThreadManager* ThreadManager::Instance() {
Andrew MacDonald469c2c02015-05-22 17:50:26 -070040 RTC_DEFINE_STATIC_LOCAL(ThreadManager, thread_manager, ());
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000041 return &thread_manager;
42}
43
44// static
45Thread* Thread::Current() {
46 return ThreadManager::Instance()->CurrentThread();
47}
48
49#if defined(WEBRTC_POSIX)
50ThreadManager::ThreadManager() {
51 pthread_key_create(&key_, NULL);
52#ifndef NO_MAIN_THREAD_WRAPPING
53 WrapCurrentThread();
54#endif
55#if !__has_feature(objc_arc) && (defined(WEBRTC_MAC))
56 // Under Automatic Reference Counting (ARC), you cannot use autorelease pools
57 // directly. Instead, you use @autoreleasepool blocks instead. Also, we are
58 // maintaining thread safety using immutability within context of GCD dispatch
59 // queues in this case.
60 InitCocoaMultiThreading();
61#endif
62}
63
64ThreadManager::~ThreadManager() {
65#if __has_feature(objc_arc)
66 @autoreleasepool
67#elif defined(WEBRTC_MAC)
68 // This is called during exit, at which point apparently no NSAutoreleasePools
69 // are available; but we might still need them to do cleanup (or we get the
70 // "no autoreleasepool in place, just leaking" warning when exiting).
71 ScopedAutoreleasePool pool;
72#endif
73 {
74 UnwrapCurrentThread();
75 pthread_key_delete(key_);
76 }
77}
78
79Thread *ThreadManager::CurrentThread() {
80 return static_cast<Thread *>(pthread_getspecific(key_));
81}
82
83void ThreadManager::SetCurrentThread(Thread *thread) {
84 pthread_setspecific(key_, thread);
85}
86#endif
87
88#if defined(WEBRTC_WIN)
89ThreadManager::ThreadManager() {
90 key_ = TlsAlloc();
91#ifndef NO_MAIN_THREAD_WRAPPING
92 WrapCurrentThread();
93#endif
94}
95
96ThreadManager::~ThreadManager() {
97 UnwrapCurrentThread();
98 TlsFree(key_);
99}
100
101Thread *ThreadManager::CurrentThread() {
102 return static_cast<Thread *>(TlsGetValue(key_));
103}
104
105void ThreadManager::SetCurrentThread(Thread *thread) {
106 TlsSetValue(key_, thread);
107}
108#endif
109
110Thread *ThreadManager::WrapCurrentThread() {
111 Thread* result = CurrentThread();
112 if (NULL == result) {
113 result = new Thread();
jiayl@webrtc.orgba737cb2014-09-18 16:45:21 +0000114 result->WrapCurrentWithThreadManager(this, true);
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000115 }
116 return result;
117}
118
119void ThreadManager::UnwrapCurrentThread() {
120 Thread* t = CurrentThread();
121 if (t && !(t->IsOwned())) {
122 t->UnwrapCurrent();
123 delete t;
124 }
125}
126
127struct ThreadInit {
128 Thread* thread;
129 Runnable* runnable;
130};
131
henrike@webrtc.org92a9bac2014-07-14 22:03:57 +0000132Thread::ScopedDisallowBlockingCalls::ScopedDisallowBlockingCalls()
133 : thread_(Thread::Current()),
134 previous_state_(thread_->SetAllowBlockingCalls(false)) {
135}
136
137Thread::ScopedDisallowBlockingCalls::~ScopedDisallowBlockingCalls() {
138 ASSERT(thread_->IsCurrent());
139 thread_->SetAllowBlockingCalls(previous_state_);
140}
141
danilchapbebf54c2016-04-28 01:32:48 -0700142Thread::Thread() : Thread(SocketServer::CreateDefault()) {}
143
144Thread::Thread(SocketServer* ss)
jbauch25d1f282016-02-05 00:25:02 -0800145 : MessageQueue(ss, false),
fischman@webrtc.orge5063b12014-05-23 17:28:50 +0000146 running_(true, false),
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000147#if defined(WEBRTC_WIN)
148 thread_(NULL),
149 thread_id_(0),
150#endif
henrike@webrtc.org92a9bac2014-07-14 22:03:57 +0000151 owned_(true),
152 blocking_calls_allowed_(true) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000153 SetName("Thread", this); // default name
danilchapbebf54c2016-04-28 01:32:48 -0700154 DoInit();
155}
156
157Thread::Thread(std::unique_ptr<SocketServer> ss)
158 : MessageQueue(std::move(ss), false),
159 running_(true, false),
160#if defined(WEBRTC_WIN)
161 thread_(NULL),
162 thread_id_(0),
163#endif
164 owned_(true),
165 blocking_calls_allowed_(true) {
166 SetName("Thread", this); // default name
167 DoInit();
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000168}
169
170Thread::~Thread() {
171 Stop();
jbauch25d1f282016-02-05 00:25:02 -0800172 DoDestroy();
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000173}
174
danilchapbebf54c2016-04-28 01:32:48 -0700175std::unique_ptr<Thread> Thread::CreateWithSocketServer() {
176 return std::unique_ptr<Thread>(new Thread(SocketServer::CreateDefault()));
177}
178
179std::unique_ptr<Thread> Thread::Create() {
180 return std::unique_ptr<Thread>(
181 new Thread(std::unique_ptr<SocketServer>(new NullSocketServer())));
182}
183
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000184bool Thread::SleepMs(int milliseconds) {
henrike@webrtc.org92a9bac2014-07-14 22:03:57 +0000185 AssertBlockingIsAllowedOnCurrentThread();
186
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000187#if defined(WEBRTC_WIN)
188 ::Sleep(milliseconds);
189 return true;
190#else
191 // POSIX has both a usleep() and a nanosleep(), but the former is deprecated,
192 // so we use nanosleep() even though it has greater precision than necessary.
193 struct timespec ts;
194 ts.tv_sec = milliseconds / 1000;
195 ts.tv_nsec = (milliseconds % 1000) * 1000000;
196 int ret = nanosleep(&ts, NULL);
197 if (ret != 0) {
198 LOG_ERR(LS_WARNING) << "nanosleep() returning early";
199 return false;
200 }
201 return true;
202#endif
203}
204
205bool Thread::SetName(const std::string& name, const void* obj) {
fischman@webrtc.orge5063b12014-05-23 17:28:50 +0000206 if (running()) return false;
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000207 name_ = name;
208 if (obj) {
209 char buf[16];
210 sprintfn(buf, sizeof(buf), " 0x%p", obj);
211 name_ += buf;
212 }
213 return true;
214}
215
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000216bool Thread::Start(Runnable* runnable) {
217 ASSERT(owned_);
218 if (!owned_) return false;
fischman@webrtc.orge5063b12014-05-23 17:28:50 +0000219 ASSERT(!running());
220 if (running()) return false;
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000221
222 Restart(); // reset fStop_ if the thread is being restarted
223
224 // Make sure that ThreadManager is created on the main thread before
225 // we start a new thread.
226 ThreadManager::Instance();
227
228 ThreadInit* init = new ThreadInit;
229 init->thread = this;
230 init->runnable = runnable;
231#if defined(WEBRTC_WIN)
Peter Boström8c38e8b2015-11-26 17:45:47 +0100232 thread_ = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PreRun, init, 0,
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000233 &thread_id_);
234 if (thread_) {
fischman@webrtc.orge5063b12014-05-23 17:28:50 +0000235 running_.Set();
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000236 } else {
237 return false;
238 }
239#elif defined(WEBRTC_POSIX)
240 pthread_attr_t attr;
241 pthread_attr_init(&attr);
242
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000243 int error_code = pthread_create(&thread_, &attr, PreRun, init);
244 if (0 != error_code) {
245 LOG(LS_ERROR) << "Unable to create pthread, error " << error_code;
246 return false;
247 }
fischman@webrtc.orge5063b12014-05-23 17:28:50 +0000248 running_.Set();
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000249#endif
250 return true;
251}
252
jiayl@webrtc.orgba737cb2014-09-18 16:45:21 +0000253bool Thread::WrapCurrent() {
254 return WrapCurrentWithThreadManager(ThreadManager::Instance(), true);
255}
256
257void Thread::UnwrapCurrent() {
258 // Clears the platform-specific thread-specific storage.
259 ThreadManager::Instance()->SetCurrentThread(NULL);
260#if defined(WEBRTC_WIN)
261 if (thread_ != NULL) {
262 if (!CloseHandle(thread_)) {
263 LOG_GLE(LS_ERROR) << "When unwrapping thread, failed to close handle.";
264 }
265 thread_ = NULL;
266 }
267#endif
268 running_.Reset();
269}
270
271void Thread::SafeWrapCurrent() {
272 WrapCurrentWithThreadManager(ThreadManager::Instance(), false);
273}
274
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000275void Thread::Join() {
fischman@webrtc.orge5063b12014-05-23 17:28:50 +0000276 if (running()) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000277 ASSERT(!IsCurrent());
jiayl@webrtc.org1fd362c2014-09-26 16:57:07 +0000278 if (Current() && !Current()->blocking_calls_allowed_) {
279 LOG(LS_WARNING) << "Waiting for the thread to join, "
280 << "but blocking calls have been disallowed";
281 }
282
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000283#if defined(WEBRTC_WIN)
jiayl@webrtc.orgba737cb2014-09-18 16:45:21 +0000284 ASSERT(thread_ != NULL);
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000285 WaitForSingleObject(thread_, INFINITE);
286 CloseHandle(thread_);
287 thread_ = NULL;
288 thread_id_ = 0;
289#elif defined(WEBRTC_POSIX)
290 void *pv;
291 pthread_join(thread_, &pv);
292#endif
fischman@webrtc.orge5063b12014-05-23 17:28:50 +0000293 running_.Reset();
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000294 }
295}
296
henrike@webrtc.org92a9bac2014-07-14 22:03:57 +0000297bool Thread::SetAllowBlockingCalls(bool allow) {
298 ASSERT(IsCurrent());
299 bool previous = blocking_calls_allowed_;
300 blocking_calls_allowed_ = allow;
301 return previous;
302}
303
304// static
305void Thread::AssertBlockingIsAllowedOnCurrentThread() {
tfarinaa41ab932015-10-30 16:08:48 -0700306#if !defined(NDEBUG)
henrike@webrtc.org92a9bac2014-07-14 22:03:57 +0000307 Thread* current = Thread::Current();
308 ASSERT(!current || current->blocking_calls_allowed_);
309#endif
310}
311
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000312void* Thread::PreRun(void* pv) {
313 ThreadInit* init = static_cast<ThreadInit*>(pv);
314 ThreadManager::Instance()->SetCurrentThread(init->thread);
Tommiea14f0a2015-05-18 13:51:06 +0200315 rtc::SetCurrentThreadName(init->thread->name_.c_str());
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000316#if __has_feature(objc_arc)
317 @autoreleasepool
318#elif defined(WEBRTC_MAC)
319 // Make sure the new thread has an autoreleasepool
320 ScopedAutoreleasePool pool;
321#endif
322 {
323 if (init->runnable) {
324 init->runnable->Run(init->thread);
325 } else {
326 init->thread->Run();
327 }
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000328 delete init;
329 return NULL;
330 }
331}
332
333void Thread::Run() {
334 ProcessMessages(kForever);
335}
336
337bool Thread::IsOwned() {
338 return owned_;
339}
340
341void Thread::Stop() {
342 MessageQueue::Quit();
343 Join();
344}
345
Peter Boström0c4e06b2015-10-07 12:23:21 +0200346void Thread::Send(MessageHandler* phandler, uint32_t id, MessageData* pdata) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000347 if (fStop_)
348 return;
349
350 // Sent messages are sent to the MessageHandler directly, in the context
351 // of "thread", like Win32 SendMessage. If in the right context,
352 // call the handler directly.
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000353 Message msg;
354 msg.phandler = phandler;
355 msg.message_id = id;
356 msg.pdata = pdata;
357 if (IsCurrent()) {
358 phandler->OnMessage(&msg);
359 return;
360 }
361
jiayl@webrtc.org3987b6d2014-09-24 17:14:05 +0000362 AssertBlockingIsAllowedOnCurrentThread();
363
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000364 AutoThread thread;
365 Thread *current_thread = Thread::Current();
366 ASSERT(current_thread != NULL); // AutoThread ensures this
367
368 bool ready = false;
369 {
370 CritScope cs(&crit_);
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000371 _SendMessage smsg;
372 smsg.thread = current_thread;
373 smsg.msg = msg;
374 smsg.ready = &ready;
375 sendlist_.push_back(smsg);
376 }
377
378 // Wait for a reply
jbauch9ccedc32016-02-25 01:14:56 -0800379 WakeUpSocketServer();
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000380
381 bool waited = false;
382 crit_.Enter();
383 while (!ready) {
384 crit_.Leave();
jiayl@webrtc.org3987b6d2014-09-24 17:14:05 +0000385 // We need to limit "ReceiveSends" to |this| thread to avoid an arbitrary
386 // thread invoking calls on the current thread.
387 current_thread->ReceiveSendsFromThread(this);
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000388 current_thread->socketserver()->Wait(kForever, false);
389 waited = true;
390 crit_.Enter();
391 }
392 crit_.Leave();
393
394 // Our Wait loop above may have consumed some WakeUp events for this
395 // MessageQueue, that weren't relevant to this Send. Losing these WakeUps can
396 // cause problems for some SocketServers.
397 //
398 // Concrete example:
399 // Win32SocketServer on thread A calls Send on thread B. While processing the
400 // message, thread B Posts a message to A. We consume the wakeup for that
401 // Post while waiting for the Send to complete, which means that when we exit
402 // this loop, we need to issue another WakeUp, or else the Posted message
403 // won't be processed in a timely manner.
404
405 if (waited) {
406 current_thread->socketserver()->WakeUp();
407 }
408}
409
410void Thread::ReceiveSends() {
jiayl@webrtc.org3987b6d2014-09-24 17:14:05 +0000411 ReceiveSendsFromThread(NULL);
412}
413
414void Thread::ReceiveSendsFromThread(const Thread* source) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000415 // Receive a sent message. Cleanup scenarios:
416 // - thread sending exits: We don't allow this, since thread can exit
417 // only via Join, so Send must complete.
418 // - thread receiving exits: Wakeup/set ready in Thread::Clear()
419 // - object target cleared: Wakeup/set ready in Thread::Clear()
jiayl@webrtc.org3987b6d2014-09-24 17:14:05 +0000420 _SendMessage smsg;
421
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000422 crit_.Enter();
jiayl@webrtc.org3987b6d2014-09-24 17:14:05 +0000423 while (PopSendMessageFromThread(source, &smsg)) {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000424 crit_.Leave();
jiayl@webrtc.org3987b6d2014-09-24 17:14:05 +0000425
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000426 smsg.msg.phandler->OnMessage(&smsg.msg);
jiayl@webrtc.org3987b6d2014-09-24 17:14:05 +0000427
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000428 crit_.Enter();
429 *smsg.ready = true;
430 smsg.thread->socketserver()->WakeUp();
431 }
432 crit_.Leave();
433}
434
jiayl@webrtc.org3987b6d2014-09-24 17:14:05 +0000435bool Thread::PopSendMessageFromThread(const Thread* source, _SendMessage* msg) {
436 for (std::list<_SendMessage>::iterator it = sendlist_.begin();
437 it != sendlist_.end(); ++it) {
438 if (it->thread == source || source == NULL) {
439 *msg = *it;
440 sendlist_.erase(it);
441 return true;
442 }
443 }
444 return false;
445}
446
tommi@webrtc.org7c64ed22015-03-17 14:25:37 +0000447void Thread::InvokeBegin() {
448 TRACE_EVENT_BEGIN0("webrtc", "Thread::Invoke");
449}
450
451void Thread::InvokeEnd() {
452 TRACE_EVENT_END0("webrtc", "Thread::Invoke");
453}
454
Peter Boström0c4e06b2015-10-07 12:23:21 +0200455void Thread::Clear(MessageHandler* phandler,
456 uint32_t id,
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000457 MessageList* removed) {
458 CritScope cs(&crit_);
459
460 // Remove messages on sendlist_ with phandler
461 // Object target cleared: remove from send list, wakeup/set ready
462 // if sender not NULL.
463
464 std::list<_SendMessage>::iterator iter = sendlist_.begin();
465 while (iter != sendlist_.end()) {
466 _SendMessage smsg = *iter;
467 if (smsg.msg.Match(phandler, id)) {
468 if (removed) {
469 removed->push_back(smsg.msg);
470 } else {
471 delete smsg.msg.pdata;
472 }
473 iter = sendlist_.erase(iter);
474 *smsg.ready = true;
475 smsg.thread->socketserver()->WakeUp();
476 continue;
477 }
478 ++iter;
479 }
480
481 MessageQueue::Clear(phandler, id, removed);
482}
483
484bool Thread::ProcessMessages(int cmsLoop) {
Peter Boström0c4e06b2015-10-07 12:23:21 +0200485 uint32_t msEnd = (kForever == cmsLoop) ? 0 : TimeAfter(cmsLoop);
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000486 int cmsNext = cmsLoop;
487
488 while (true) {
489#if __has_feature(objc_arc)
490 @autoreleasepool
491#elif defined(WEBRTC_MAC)
492 // see: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSAutoreleasePool_Class/Reference/Reference.html
493 // Each thread is supposed to have an autorelease pool. Also for event loops
494 // like this, autorelease pool needs to be created and drained/released
495 // for each cycle.
496 ScopedAutoreleasePool pool;
497#endif
498 {
499 Message msg;
500 if (!Get(&msg, cmsNext))
501 return !IsQuitting();
502 Dispatch(&msg);
503
504 if (cmsLoop != kForever) {
505 cmsNext = TimeUntil(msEnd);
506 if (cmsNext < 0)
507 return true;
508 }
509 }
510 }
511}
512
jiayl@webrtc.orgba737cb2014-09-18 16:45:21 +0000513bool Thread::WrapCurrentWithThreadManager(ThreadManager* thread_manager,
514 bool need_synchronize_access) {
fischman@webrtc.orge5063b12014-05-23 17:28:50 +0000515 if (running())
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000516 return false;
jiayl@webrtc.orgba737cb2014-09-18 16:45:21 +0000517
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000518#if defined(WEBRTC_WIN)
jiayl@webrtc.orgba737cb2014-09-18 16:45:21 +0000519 if (need_synchronize_access) {
520 // We explicitly ask for no rights other than synchronization.
521 // This gives us the best chance of succeeding.
522 thread_ = OpenThread(SYNCHRONIZE, FALSE, GetCurrentThreadId());
523 if (!thread_) {
524 LOG_GLE(LS_ERROR) << "Unable to get handle to thread.";
525 return false;
526 }
527 thread_id_ = GetCurrentThreadId();
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000528 }
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000529#elif defined(WEBRTC_POSIX)
530 thread_ = pthread_self();
531#endif
jiayl@webrtc.orgba737cb2014-09-18 16:45:21 +0000532
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000533 owned_ = false;
fischman@webrtc.orge5063b12014-05-23 17:28:50 +0000534 running_.Set();
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000535 thread_manager->SetCurrentThread(this);
536 return true;
537}
538
danilchapbebf54c2016-04-28 01:32:48 -0700539AutoThread::AutoThread() {
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000540 if (!ThreadManager::Instance()->CurrentThread()) {
541 ThreadManager::Instance()->SetCurrentThread(this);
542 }
543}
544
545AutoThread::~AutoThread() {
546 Stop();
547 if (ThreadManager::Instance()->CurrentThread() == this) {
548 ThreadManager::Instance()->SetCurrentThread(NULL);
549 }
550}
551
552#if defined(WEBRTC_WIN)
553void ComThread::Run() {
554 HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
555 ASSERT(SUCCEEDED(hr));
556 if (SUCCEEDED(hr)) {
557 Thread::Run();
558 CoUninitialize();
559 } else {
560 LOG(LS_ERROR) << "CoInitialize failed, hr=" << hr;
561 }
562}
563#endif
564
565} // namespace rtc