Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: talk/app/webrtc/localaudiosource.cc

Issue 1430433004: Replace rtc::cricket::Settable with rtc::Maybe (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | talk/app/webrtc/localaudiosource_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // Convert constraints to audio options. Return false if constraints are 42 // Convert constraints to audio options. Return false if constraints are
43 // invalid. 43 // invalid.
44 void FromConstraints(const MediaConstraintsInterface::Constraints& constraints, 44 void FromConstraints(const MediaConstraintsInterface::Constraints& constraints,
45 cricket::AudioOptions* options) { 45 cricket::AudioOptions* options) {
46 // This design relies on the fact that all the audio constraints are actually 46 // This design relies on the fact that all the audio constraints are actually
47 // "options", i.e. boolean-valued and always satisfiable. If the constraints 47 // "options", i.e. boolean-valued and always satisfiable. If the constraints
48 // are extended to include non-boolean values or actual format constraints, 48 // are extended to include non-boolean values or actual format constraints,
49 // a different algorithm will be required. 49 // a different algorithm will be required.
50 struct { 50 struct {
51 const char* name; 51 const char* name;
52 cricket::Settable<bool>& value; 52 rtc::Maybe<bool>& value;
53 } key_to_value[] = { 53 } key_to_value[] = {
54 {MediaConstraintsInterface::kGoogEchoCancellation, 54 {MediaConstraintsInterface::kGoogEchoCancellation,
55 options->echo_cancellation}, 55 options->echo_cancellation},
56 {MediaConstraintsInterface::kExtendedFilterEchoCancellation, 56 {MediaConstraintsInterface::kExtendedFilterEchoCancellation,
57 options->extended_filter_aec}, 57 options->extended_filter_aec},
58 {MediaConstraintsInterface::kDAEchoCancellation, 58 {MediaConstraintsInterface::kDAEchoCancellation,
59 options->delay_agnostic_aec}, 59 options->delay_agnostic_aec},
60 {MediaConstraintsInterface::kAutoGainControl, options->auto_gain_control}, 60 {MediaConstraintsInterface::kAutoGainControl, options->auto_gain_control},
61 {MediaConstraintsInterface::kExperimentalAutoGainControl, 61 {MediaConstraintsInterface::kExperimentalAutoGainControl,
62 options->experimental_agc}, 62 options->experimental_agc},
63 {MediaConstraintsInterface::kNoiseSuppression, 63 {MediaConstraintsInterface::kNoiseSuppression,
64 options->noise_suppression}, 64 options->noise_suppression},
65 {MediaConstraintsInterface::kExperimentalNoiseSuppression, 65 {MediaConstraintsInterface::kExperimentalNoiseSuppression,
66 options->experimental_ns}, 66 options->experimental_ns},
67 {MediaConstraintsInterface::kHighpassFilter, options->highpass_filter}, 67 {MediaConstraintsInterface::kHighpassFilter, options->highpass_filter},
68 {MediaConstraintsInterface::kTypingNoiseDetection, 68 {MediaConstraintsInterface::kTypingNoiseDetection,
69 options->typing_detection}, 69 options->typing_detection},
70 {MediaConstraintsInterface::kAudioMirroring, options->stereo_swapping}, 70 {MediaConstraintsInterface::kAudioMirroring, options->stereo_swapping},
71 {MediaConstraintsInterface::kAecDump, options->aec_dump} 71 {MediaConstraintsInterface::kAecDump, options->aec_dump}
72 }; 72 };
73 73
74 for (const auto& constraint : constraints) { 74 for (const auto& constraint : constraints) {
75 bool value = false; 75 bool value = false;
76 if (!rtc::FromString(constraint.value, &value)) 76 if (!rtc::FromString(constraint.value, &value))
77 continue; 77 continue;
78 78
79 for (auto& entry : key_to_value) { 79 for (auto& entry : key_to_value) {
80 if (constraint.key.compare(entry.name) == 0) 80 if (constraint.key.compare(entry.name) == 0)
81 entry.value.Set(value); 81 entry.value = rtc::Maybe<bool>(value);
82 } 82 }
83 } 83 }
84 } 84 }
85 85
86 } // namespace 86 } // namespace
87 87
88 rtc::scoped_refptr<LocalAudioSource> LocalAudioSource::Create( 88 rtc::scoped_refptr<LocalAudioSource> LocalAudioSource::Create(
89 const PeerConnectionFactoryInterface::Options& options, 89 const PeerConnectionFactoryInterface::Options& options,
90 const MediaConstraintsInterface* constraints) { 90 const MediaConstraintsInterface* constraints) {
91 rtc::scoped_refptr<LocalAudioSource> source( 91 rtc::scoped_refptr<LocalAudioSource> source(
(...skipping 12 matching lines...) Expand all
104 // constraints. 104 // constraints.
105 FromConstraints(constraints->GetOptional(), &options_); 105 FromConstraints(constraints->GetOptional(), &options_);
106 106
107 cricket::AudioOptions mandatory_options; 107 cricket::AudioOptions mandatory_options;
108 FromConstraints(constraints->GetMandatory(), &mandatory_options); 108 FromConstraints(constraints->GetMandatory(), &mandatory_options);
109 options_.SetAll(mandatory_options); 109 options_.SetAll(mandatory_options);
110 source_state_ = kLive; 110 source_state_ = kLive;
111 } 111 }
112 112
113 } // namespace webrtc 113 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | talk/app/webrtc/localaudiosource_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698