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 "components/copresence/handlers/audio/audio_directive_list.h" | 5 #include "components/copresence/handlers/audio/audio_directive_list.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "media/base/audio_bus.h" | 10 #include "media/base/audio_bus.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 118 } |
119 | 119 |
120 if (list->empty()) | 120 if (list->empty()) |
121 return make_scoped_ptr<AudioDirective>(NULL); | 121 return make_scoped_ptr<AudioDirective>(NULL); |
122 | 122 |
123 return make_scoped_ptr(new AudioDirective(list->top())); | 123 return make_scoped_ptr(new AudioDirective(list->top())); |
124 } | 124 } |
125 | 125 |
126 void AudioDirectiveList::OnTokenEncoded( | 126 void AudioDirectiveList::OnTokenEncoded( |
127 const std::string& token, | 127 const std::string& token, |
| 128 bool /* audible */, |
128 const scoped_refptr<media::AudioBusRefCounted>& samples) { | 129 const scoped_refptr<media::AudioBusRefCounted>& samples) { |
129 // We shouldn't re-encode a token if it's already in the cache. | 130 // We shouldn't re-encode a token if it's already in the cache. |
130 DCHECK(!samples_cache_.HasKey(token)); | 131 DCHECK(!samples_cache_.HasKey(token)); |
131 DVLOG(3) << "Token: " << token << " encoded."; | 132 DVLOG(3) << "Token: " << token << " encoded."; |
132 samples_cache_.Add(token, samples); | 133 samples_cache_.Add(token, samples); |
133 | 134 |
134 // Copy the samples into their corresponding directive object and move | 135 // Copy the samples into their corresponding directive object and move |
135 // that object into the active queue. | 136 // that object into the active queue. |
136 std::map<std::string, AudioDirective>::iterator it = | 137 std::map<std::string, AudioDirective>::iterator it = |
137 pending_transmit_tokens_.find(token); | 138 pending_transmit_tokens_.find(token); |
138 | 139 |
139 it->second.samples = samples; | 140 it->second.samples = samples; |
140 active_transmit_tokens_.push(it->second); | 141 active_transmit_tokens_.push(it->second); |
141 pending_transmit_tokens_.erase(it); | 142 pending_transmit_tokens_.erase(it); |
142 | 143 |
143 if (!token_added_callback_.is_null()) | 144 if (!token_added_callback_.is_null()) |
144 token_added_callback_.Run(); | 145 token_added_callback_.Run(); |
145 } | 146 } |
146 | 147 |
147 } // namespace copresence | 148 } // namespace copresence |
OLD | NEW |