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_handler_impl.h" | 5 #include "components/copresence/handlers/audio/audio_directive_handler_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 DCHECK(receives_lists_.empty()); | 69 DCHECK(receives_lists_.empty()); |
70 receives_lists_.push_back(new AudioDirectiveList(clock_)); | 70 receives_lists_.push_back(new AudioDirectiveList(clock_)); |
71 receives_lists_.push_back(new AudioDirectiveList(clock_)); | 71 receives_lists_.push_back(new AudioDirectiveList(clock_)); |
72 } | 72 } |
73 | 73 |
74 void AudioDirectiveHandlerImpl::AddInstruction( | 74 void AudioDirectiveHandlerImpl::AddInstruction( |
75 const TokenInstruction& instruction, | 75 const TokenInstruction& instruction, |
76 const std::string& op_id, | 76 const std::string& op_id, |
77 base::TimeDelta ttl) { | 77 base::TimeDelta ttl) { |
| 78 DCHECK(transmits_lists_.size() == 2u && receives_lists_.size() == 2u) |
| 79 << "Call Initialize() before other AudioDirectiveHandler methods"; |
| 80 |
78 switch (instruction.token_instruction_type()) { | 81 switch (instruction.token_instruction_type()) { |
79 case TRANSMIT: | 82 case TRANSMIT: |
80 DVLOG(2) << "Audio Transmit Directive received. Token: " | 83 DVLOG(2) << "Audio Transmit Directive received. Token: " |
81 << instruction.token_id() | 84 << instruction.token_id() |
82 << " with medium=" << instruction.medium() | 85 << " with medium=" << instruction.medium() |
83 << " with TTL=" << ttl.InMilliseconds(); | 86 << " with TTL=" << ttl.InMilliseconds(); |
84 switch (instruction.medium()) { | 87 switch (instruction.medium()) { |
85 case AUDIO_ULTRASOUND_PASSBAND: | 88 case AUDIO_ULTRASOUND_PASSBAND: |
86 transmits_lists_[INAUDIBLE]->AddDirective(op_id, ttl); | 89 transmits_lists_[INAUDIBLE]->AddDirective(op_id, ttl); |
87 audio_manager_->SetToken(INAUDIBLE, instruction.token_id()); | 90 audio_manager_->SetToken(INAUDIBLE, instruction.token_id()); |
(...skipping 23 matching lines...) Expand all Loading... |
111 break; | 114 break; |
112 case UNKNOWN_TOKEN_INSTRUCTION_TYPE: | 115 case UNKNOWN_TOKEN_INSTRUCTION_TYPE: |
113 default: | 116 default: |
114 LOG(WARNING) << "Unknown Audio Transmit Directive received. type = " | 117 LOG(WARNING) << "Unknown Audio Transmit Directive received. type = " |
115 << instruction.token_instruction_type(); | 118 << instruction.token_instruction_type(); |
116 } | 119 } |
117 ProcessNextInstruction(); | 120 ProcessNextInstruction(); |
118 } | 121 } |
119 | 122 |
120 void AudioDirectiveHandlerImpl::RemoveInstructions(const std::string& op_id) { | 123 void AudioDirectiveHandlerImpl::RemoveInstructions(const std::string& op_id) { |
| 124 DCHECK(transmits_lists_.size() == 2u && receives_lists_.size() == 2u) |
| 125 << "Call Initialize() before other AudioDirectiveHandler methods"; |
| 126 |
121 transmits_lists_[AUDIBLE]->RemoveDirective(op_id); | 127 transmits_lists_[AUDIBLE]->RemoveDirective(op_id); |
122 transmits_lists_[INAUDIBLE]->RemoveDirective(op_id); | 128 transmits_lists_[INAUDIBLE]->RemoveDirective(op_id); |
123 receives_lists_[AUDIBLE]->RemoveDirective(op_id); | 129 receives_lists_[AUDIBLE]->RemoveDirective(op_id); |
124 receives_lists_[INAUDIBLE]->RemoveDirective(op_id); | 130 receives_lists_[INAUDIBLE]->RemoveDirective(op_id); |
125 | 131 |
126 ProcessNextInstruction(); | 132 ProcessNextInstruction(); |
127 } | 133 } |
128 | 134 |
129 const std::string AudioDirectiveHandlerImpl::PlayingToken( | 135 const std::string AudioDirectiveHandlerImpl::PlayingToken( |
130 AudioType type) const { | 136 AudioType type) const { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 184 |
179 *expiry = GetEarliestEventTime(transmits_lists_[AUDIBLE], base::TimeTicks()); | 185 *expiry = GetEarliestEventTime(transmits_lists_[AUDIBLE], base::TimeTicks()); |
180 *expiry = GetEarliestEventTime(transmits_lists_[INAUDIBLE], *expiry); | 186 *expiry = GetEarliestEventTime(transmits_lists_[INAUDIBLE], *expiry); |
181 *expiry = GetEarliestEventTime(receives_lists_[AUDIBLE], *expiry); | 187 *expiry = GetEarliestEventTime(receives_lists_[AUDIBLE], *expiry); |
182 *expiry = GetEarliestEventTime(receives_lists_[INAUDIBLE], *expiry); | 188 *expiry = GetEarliestEventTime(receives_lists_[INAUDIBLE], *expiry); |
183 | 189 |
184 return !expiry->is_null(); | 190 return !expiry->is_null(); |
185 } | 191 } |
186 | 192 |
187 } // namespace copresence | 193 } // namespace copresence |
OLD | NEW |