OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... | |
25 #ifdef HAVE_SCTP | 25 #ifdef HAVE_SCTP |
26 #include "webrtc/media/sctp/sctpdataengine.h" | 26 #include "webrtc/media/sctp/sctpdataengine.h" |
27 #endif | 27 #endif |
28 #include "webrtc/pc/srtpfilter.h" | 28 #include "webrtc/pc/srtpfilter.h" |
29 | 29 |
30 namespace cricket { | 30 namespace cricket { |
31 | 31 |
32 | 32 |
33 using rtc::Bind; | 33 using rtc::Bind; |
34 | 34 |
35 static const int kNotSetOutputVolume = -1; | |
36 | |
37 static DataEngineInterface* ConstructDataEngine() { | 35 static DataEngineInterface* ConstructDataEngine() { |
38 #ifdef HAVE_SCTP | 36 #ifdef HAVE_SCTP |
39 return new HybridDataEngine(new RtpDataEngine(), new SctpDataEngine()); | 37 return new HybridDataEngine(new RtpDataEngine(), new SctpDataEngine()); |
40 #else | 38 #else |
41 return new RtpDataEngine(); | 39 return new RtpDataEngine(); |
42 #endif | 40 #endif |
43 } | 41 } |
44 | 42 |
45 ChannelManager::ChannelManager(MediaEngineInterface* me, | 43 ChannelManager::ChannelManager(MediaEngineInterface* me, |
46 DataEngineInterface* dme, | 44 DataEngineInterface* dme, |
(...skipping 10 matching lines...) Expand all Loading... | |
57 void ChannelManager::Construct(MediaEngineInterface* me, | 55 void ChannelManager::Construct(MediaEngineInterface* me, |
58 DataEngineInterface* dme, | 56 DataEngineInterface* dme, |
59 rtc::Thread* worker_thread, | 57 rtc::Thread* worker_thread, |
60 rtc::Thread* network_thread) { | 58 rtc::Thread* network_thread) { |
61 media_engine_.reset(me); | 59 media_engine_.reset(me); |
62 data_media_engine_.reset(dme); | 60 data_media_engine_.reset(dme); |
63 initialized_ = false; | 61 initialized_ = false; |
64 main_thread_ = rtc::Thread::Current(); | 62 main_thread_ = rtc::Thread::Current(); |
65 worker_thread_ = worker_thread; | 63 worker_thread_ = worker_thread; |
66 network_thread_ = network_thread; | 64 network_thread_ = network_thread; |
67 audio_output_volume_ = kNotSetOutputVolume; | |
68 capturing_ = false; | 65 capturing_ = false; |
69 enable_rtx_ = false; | 66 enable_rtx_ = false; |
70 } | 67 } |
71 | 68 |
72 ChannelManager::~ChannelManager() { | 69 ChannelManager::~ChannelManager() { |
73 if (initialized_) { | 70 if (initialized_) { |
74 Terminate(); | 71 Terminate(); |
75 // If srtp is initialized (done by the Channel) then we must call | 72 // If srtp is initialized (done by the Channel) then we must call |
76 // srtp_shutdown to free all crypto kernel lists. But we need to make sure | 73 // srtp_shutdown to free all crypto kernel lists. But we need to make sure |
77 // shutdown always called at the end, after channels are destroyed. | 74 // shutdown always called at the end, after channels are destroyed. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 if (!network_thread_->IsCurrent()) { | 147 if (!network_thread_->IsCurrent()) { |
151 // Do not allow invoking calls to other threads on the network thread. | 148 // Do not allow invoking calls to other threads on the network thread. |
152 network_thread_->Invoke<bool>( | 149 network_thread_->Invoke<bool>( |
153 RTC_FROM_HERE, | 150 RTC_FROM_HERE, |
154 rtc::Bind(&rtc::Thread::SetAllowBlockingCalls, network_thread_, false)); | 151 rtc::Bind(&rtc::Thread::SetAllowBlockingCalls, network_thread_, false)); |
155 } | 152 } |
156 | 153 |
157 initialized_ = worker_thread_->Invoke<bool>( | 154 initialized_ = worker_thread_->Invoke<bool>( |
158 RTC_FROM_HERE, Bind(&ChannelManager::InitMediaEngine_w, this)); | 155 RTC_FROM_HERE, Bind(&ChannelManager::InitMediaEngine_w, this)); |
159 ASSERT(initialized_); | 156 ASSERT(initialized_); |
160 if (!initialized_) { | |
161 return false; | |
162 } | |
163 | |
164 // If audio_output_volume_ has been set via SetOutputVolume(), set the | |
165 // audio output volume of the engine. | |
166 if (kNotSetOutputVolume != audio_output_volume_ && | |
167 !SetOutputVolume(audio_output_volume_)) { | |
168 LOG(LS_WARNING) << "Failed to SetOutputVolume to " | |
169 << audio_output_volume_; | |
170 } | |
171 | |
172 return initialized_; | 157 return initialized_; |
173 } | 158 } |
174 | 159 |
175 bool ChannelManager::InitMediaEngine_w() { | 160 bool ChannelManager::InitMediaEngine_w() { |
176 ASSERT(worker_thread_ == rtc::Thread::Current()); | 161 ASSERT(worker_thread_ == rtc::Thread::Current()); |
177 return media_engine_->Init(); | 162 return media_engine_->Init(); |
178 } | 163 } |
179 | 164 |
180 void ChannelManager::Terminate() { | 165 void ChannelManager::Terminate() { |
181 ASSERT(initialized_); | 166 ASSERT(initialized_); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 DataChannels::iterator it = std::find(data_channels_.begin(), | 370 DataChannels::iterator it = std::find(data_channels_.begin(), |
386 data_channels_.end(), data_channel); | 371 data_channels_.end(), data_channel); |
387 ASSERT(it != data_channels_.end()); | 372 ASSERT(it != data_channels_.end()); |
388 if (it == data_channels_.end()) | 373 if (it == data_channels_.end()) |
389 return; | 374 return; |
390 | 375 |
391 data_channels_.erase(it); | 376 data_channels_.erase(it); |
392 delete data_channel; | 377 delete data_channel; |
393 } | 378 } |
394 | 379 |
395 bool ChannelManager::GetOutputVolume(int* level) { | |
396 if (!initialized_) { | |
397 return false; | |
398 } | |
399 return worker_thread_->Invoke<bool>( | |
400 RTC_FROM_HERE, | |
401 Bind(&MediaEngineInterface::GetOutputVolume, media_engine_.get(), level)); | |
402 } | |
403 | |
404 bool ChannelManager::SetOutputVolume(int level) { | |
405 bool ret = level >= 0 && level <= 255; | |
406 if (initialized_) { | |
407 ret &= worker_thread_->Invoke<bool>( | |
tommi
2016/06/14 14:38:07
I'm especially happy to see one of these go away :
| |
408 RTC_FROM_HERE, Bind(&MediaEngineInterface::SetOutputVolume, | |
409 media_engine_.get(), level)); | |
410 } | |
411 | |
412 if (ret) { | |
413 audio_output_volume_ = level; | |
414 } | |
415 | |
416 return ret; | |
417 } | |
418 | |
419 | |
420 bool ChannelManager::StartAecDump(rtc::PlatformFile file, | 380 bool ChannelManager::StartAecDump(rtc::PlatformFile file, |
421 int64_t max_size_bytes) { | 381 int64_t max_size_bytes) { |
422 return worker_thread_->Invoke<bool>( | 382 return worker_thread_->Invoke<bool>( |
423 RTC_FROM_HERE, Bind(&MediaEngineInterface::StartAecDump, | 383 RTC_FROM_HERE, Bind(&MediaEngineInterface::StartAecDump, |
424 media_engine_.get(), file, max_size_bytes)); | 384 media_engine_.get(), file, max_size_bytes)); |
425 } | 385 } |
426 | 386 |
427 void ChannelManager::StopAecDump() { | 387 void ChannelManager::StopAecDump() { |
428 worker_thread_->Invoke<void>( | 388 worker_thread_->Invoke<void>( |
429 RTC_FROM_HERE, | 389 RTC_FROM_HERE, |
430 Bind(&MediaEngineInterface::StopAecDump, media_engine_.get())); | 390 Bind(&MediaEngineInterface::StopAecDump, media_engine_.get())); |
431 } | 391 } |
432 | 392 |
433 bool ChannelManager::StartRtcEventLog(rtc::PlatformFile file, | 393 bool ChannelManager::StartRtcEventLog(rtc::PlatformFile file, |
434 int64_t max_size_bytes) { | 394 int64_t max_size_bytes) { |
435 return worker_thread_->Invoke<bool>( | 395 return worker_thread_->Invoke<bool>( |
436 RTC_FROM_HERE, Bind(&MediaEngineInterface::StartRtcEventLog, | 396 RTC_FROM_HERE, Bind(&MediaEngineInterface::StartRtcEventLog, |
437 media_engine_.get(), file, max_size_bytes)); | 397 media_engine_.get(), file, max_size_bytes)); |
438 } | 398 } |
439 | 399 |
440 void ChannelManager::StopRtcEventLog() { | 400 void ChannelManager::StopRtcEventLog() { |
441 worker_thread_->Invoke<void>( | 401 worker_thread_->Invoke<void>( |
442 RTC_FROM_HERE, | 402 RTC_FROM_HERE, |
443 Bind(&MediaEngineInterface::StopRtcEventLog, media_engine_.get())); | 403 Bind(&MediaEngineInterface::StopRtcEventLog, media_engine_.get())); |
444 } | 404 } |
445 | 405 |
446 } // namespace cricket | 406 } // namespace cricket |
OLD | NEW |