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

Unified Diff: components/copresence/handlers/directive_handler.cc

Issue 461803003: Stop playing/recording when not needed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months 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 side-by-side diff with in-line comments
Download patch
Index: components/copresence/handlers/directive_handler.cc
diff --git a/components/copresence/handlers/directive_handler.cc b/components/copresence/handlers/directive_handler.cc
index a7ca573ed4c13e901e1e535eb172d4a26fc0cda4..e76dde6fed26116274c1e57ef3403717f132d058 100644
--- a/components/copresence/handlers/directive_handler.cc
+++ b/components/copresence/handlers/directive_handler.cc
@@ -14,7 +14,7 @@ DirectiveHandler::DirectiveHandler() {}
void DirectiveHandler::Initialize(
const AudioRecorder::DecodeSamplesCallback& decode_cb,
- const AudioDirectiveList::EncodeTokenCallback& encode_cb) {
+ const AudioDirectiveHandler::EncodeTokenCallback& encode_cb) {
audio_handler_.reset(new AudioDirectiveHandler(decode_cb, encode_cb));
audio_handler_->Initialize();
}
@@ -26,6 +26,16 @@ void DirectiveHandler::AddDirective(const Directive& directive) {
// We only handle Token directives; wifi/ble requests aren't implemented.
DCHECK_EQ(directive.instruction_type(), TOKEN);
+ std::string op_id;
+ if (directive.has_published_message_id()) {
+ op_id = directive.published_message_id();
+ } else if (directive.has_subscription_id()) {
+ op_id = directive.subscription_id();
+ } else {
+ NOTREACHED() << "No operation associated with directive!";
+ return;
+ }
+
const TokenInstruction& ti = directive.token_instruction();
DCHECK(audio_handler_.get()) << "Clients must call Initialize() before "
<< "any other DirectiveHandler methods.";
@@ -33,14 +43,22 @@ void DirectiveHandler::AddDirective(const Directive& directive) {
if (ti.medium() == AUDIO_ULTRASOUND_PASSBAND ||
ti.medium() == AUDIO_AUDIBLE_DTMF) {
audio_handler_->AddInstruction(
- ti, base::TimeDelta::FromMilliseconds(directive.ttl_millis()));
+ ti, op_id, 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.
+void DirectiveHandler::RemoveDirectives(const std::string& op_id) {
DCHECK(audio_handler_.get()) << "Clients must call Initialize() before "
<< "any other DirectiveHandler methods.";
+ audio_handler_->RemoveInstructions(op_id);
+}
+
+const std::string& DirectiveHandler::CurrentAudibleToken() const {
+ return audio_handler_->PlayingAudibleToken();
+}
+
+const std::string& DirectiveHandler::CurrentInaudibleToken() const {
+ return audio_handler_->PlayingInaudibleToken();
}
} // namespace copresence
« no previous file with comments | « components/copresence/handlers/directive_handler.h ('k') | components/copresence/mediums/audio/audio_player.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698