| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" | 5 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 #include "media/base/android/media_codec_bridge.h" | 58 #include "media/base/android/media_codec_bridge.h" |
| 59 #endif | 59 #endif |
| 60 | 60 |
| 61 namespace content { | 61 namespace content { |
| 62 | 62 |
| 63 // Map of corresponding media constraints and platform effects. | 63 // Map of corresponding media constraints and platform effects. |
| 64 struct { | 64 struct { |
| 65 const char* constraint; | 65 const char* constraint; |
| 66 const media::AudioParameters::PlatformEffectsMask effect; | 66 const media::AudioParameters::PlatformEffectsMask effect; |
| 67 } const kConstraintEffectMap[] = { | 67 } const kConstraintEffectMap[] = { |
| 68 { content::kMediaStreamAudioDucking, | |
| 69 media::AudioParameters::DUCKING }, | |
| 70 { webrtc::MediaConstraintsInterface::kGoogEchoCancellation, | 68 { webrtc::MediaConstraintsInterface::kGoogEchoCancellation, |
| 71 media::AudioParameters::ECHO_CANCELLER }, | 69 media::AudioParameters::ECHO_CANCELLER }, |
| 72 }; | 70 }; |
| 73 | 71 |
| 74 // If any platform effects are available, check them against the constraints. | 72 // If any platform effects are available, check them against the constraints. |
| 75 // Disable effects to match false constraints, but if a constraint is true, set | 73 // Disable effects to match false constraints, but if a constraint is true, set |
| 76 // the constraint to false to later disable the software effect. | 74 // the constraint to false to later disable the software effect. |
| 77 // | 75 // |
| 78 // This function may modify both |constraints| and |effects|. | 76 // This function may modify both |constraints| and |effects|. |
| 79 void HarmonizeConstraintsAndEffects(RTCMediaConstraints* constraints, | 77 void HarmonizeConstraintsAndEffects(RTCMediaConstraints* constraints, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 96 // set the constraint to false to later disable the software effect. | 94 // set the constraint to false to later disable the software effect. |
| 97 if (is_mandatory) { | 95 if (is_mandatory) { |
| 98 constraints->AddMandatory(kConstraintEffectMap[i].constraint, | 96 constraints->AddMandatory(kConstraintEffectMap[i].constraint, |
| 99 webrtc::MediaConstraintsInterface::kValueFalse, true); | 97 webrtc::MediaConstraintsInterface::kValueFalse, true); |
| 100 } else { | 98 } else { |
| 101 constraints->AddOptional(kConstraintEffectMap[i].constraint, | 99 constraints->AddOptional(kConstraintEffectMap[i].constraint, |
| 102 webrtc::MediaConstraintsInterface::kValueFalse, true); | 100 webrtc::MediaConstraintsInterface::kValueFalse, true); |
| 103 } | 101 } |
| 104 DVLOG(1) << "Disabling constraint: " | 102 DVLOG(1) << "Disabling constraint: " |
| 105 << kConstraintEffectMap[i].constraint; | 103 << kConstraintEffectMap[i].constraint; |
| 106 } else if (kConstraintEffectMap[i].effect == | |
| 107 media::AudioParameters::DUCKING && value && !is_mandatory) { | |
| 108 // Special handling of the DUCKING flag that sets the optional | |
| 109 // constraint to |false| to match what the device will support. | |
| 110 constraints->AddOptional(kConstraintEffectMap[i].constraint, | |
| 111 webrtc::MediaConstraintsInterface::kValueFalse, true); | |
| 112 // No need to modify |effects| since the ducking flag is already off. | |
| 113 DCHECK((*effects & media::AudioParameters::DUCKING) == 0); | |
| 114 } | 104 } |
| 115 } | 105 } |
| 116 } | 106 } |
| 117 } | 107 } |
| 118 | 108 |
| 119 class P2PPortAllocatorFactory : public webrtc::PortAllocatorFactoryInterface { | 109 class P2PPortAllocatorFactory : public webrtc::PortAllocatorFactoryInterface { |
| 120 public: | 110 public: |
| 121 P2PPortAllocatorFactory(P2PSocketDispatcher* socket_dispatcher, | 111 P2PPortAllocatorFactory(P2PSocketDispatcher* socket_dispatcher, |
| 122 rtc::NetworkManager* network_manager, | 112 rtc::NetworkManager* network_manager, |
| 123 rtc::PacketSocketFactory* socket_factory, | 113 rtc::PacketSocketFactory* socket_factory, |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 } | 677 } |
| 688 | 678 |
| 689 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() { | 679 void PeerConnectionDependencyFactory::EnsureWebRtcAudioDeviceImpl() { |
| 690 if (audio_device_.get()) | 680 if (audio_device_.get()) |
| 691 return; | 681 return; |
| 692 | 682 |
| 693 audio_device_ = new WebRtcAudioDeviceImpl(); | 683 audio_device_ = new WebRtcAudioDeviceImpl(); |
| 694 } | 684 } |
| 695 | 685 |
| 696 } // namespace content | 686 } // namespace content |
| OLD | NEW |