| Index: components/copresence/handlers/directive_handler.cc
|
| diff --git a/components/copresence/handlers/directive_handler.cc b/components/copresence/handlers/directive_handler.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6964942bf59d484e26e4094058189ee53bffdd3d
|
| --- /dev/null
|
| +++ b/components/copresence/handlers/directive_handler.cc
|
| @@ -0,0 +1,37 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "components/copresence/handlers/directive_handler.h"
|
| +
|
| +#include "base/time/time.h"
|
| +#include "components/copresence/handlers/audio/audio_directive_handler.h"
|
| +#include "components/copresence/proto/data.pb.h"
|
| +
|
| +namespace copresence {
|
| +
|
| +DirectiveHandler::DirectiveHandler(
|
| + const AudioRecorder::DecodeSamplesCallback& decode_cb,
|
| + const AudioDirectiveList::EncodeTokenCallback& encode_cb)
|
| + : audio_handler_(new AudioDirectiveHandler(decode_cb, encode_cb)) {
|
| +}
|
| +
|
| +DirectiveHandler::~DirectiveHandler() {
|
| +}
|
| +
|
| +void DirectiveHandler::AddDirective(const copresence::Directive& directive) {
|
| + // We only handle Token directives; wifi/ble requests aren't implemented.
|
| + DCHECK_EQ(directive.instruction_type(), copresence::TOKEN);
|
| +
|
| + const copresence::TokenInstruction& ti = directive.token_instruction();
|
| + // We currently only support audio.
|
| + DCHECK_EQ(ti.medium(), copresence::AUDIO_ULTRASOUND_PASSBAND);
|
| + audio_handler_->AddInstruction(
|
| + ti, base::TimeDelta::FromMilliseconds(directive.ttl_millis()));
|
| +}
|
| +
|
| +void DirectiveHandler::RemoveDirectives(const std::string& /* op_id */) {
|
| + // TODO(rkc): Forward the remove directive call to all the directive handlers.
|
| +}
|
| +
|
| +} // namespace copresence
|
|
|