OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/copresence/handlers/directive_handler.h" |
| 6 |
| 7 #include "base/time/time.h" |
| 8 #include "components/copresence/handlers/audio/audio_directive_handler.h" |
| 9 #include "components/copresence/proto/data.pb.h" |
| 10 |
| 11 namespace copresence { |
| 12 |
| 13 DirectiveHandler::DirectiveHandler( |
| 14 const AudioRecorder::DecodeSamplesCallback& decode_cb, |
| 15 const AudioDirectiveList::EncodeTokenCallback& encode_cb) |
| 16 : audio_handler_(new AudioDirectiveHandler(decode_cb, encode_cb)) { |
| 17 } |
| 18 |
| 19 DirectiveHandler::~DirectiveHandler() { |
| 20 } |
| 21 |
| 22 void DirectiveHandler::AddDirective(const Directive& directive) { |
| 23 // We only handle Token directives; wifi/ble requests aren't implemented. |
| 24 DCHECK_EQ(directive.instruction_type(), TOKEN); |
| 25 |
| 26 const TokenInstruction& ti = directive.token_instruction(); |
| 27 // We currently only support audio. |
| 28 DCHECK_EQ(ti.medium(), AUDIO_ULTRASOUND_PASSBAND); |
| 29 audio_handler_->AddInstruction( |
| 30 ti, base::TimeDelta::FromMilliseconds(directive.ttl_millis())); |
| 31 } |
| 32 |
| 33 void DirectiveHandler::RemoveDirectives(const std::string& /* op_id */) { |
| 34 // TODO(rkc): Forward the remove directive call to all the directive handlers. |
| 35 } |
| 36 |
| 37 } // namespace copresence |
OLD | NEW |