Chromium Code Reviews| Index: components/copresence/handlers/audio/audio_directive_handler.h |
| diff --git a/components/copresence/handlers/audio/audio_directive_handler.h b/components/copresence/handlers/audio/audio_directive_handler.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f71699332fa007dabcfc861ad9491f882beb1f83 |
| --- /dev/null |
| +++ b/components/copresence/handlers/audio/audio_directive_handler.h |
| @@ -0,0 +1,74 @@ |
| +// 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. |
| + |
| +#ifndef COMPONENTS_COPRESENCE_HANDLERS_AUDIO_DIRECTIVE_HANDLER_ |
|
Daniel Erat
2014/07/31 22:31:14
update header guard to match path
rkc
2014/08/01 21:08:56
Done.
|
| +#define COMPONENTS_COPRESENCE_HANDLERS_AUDIO_DIRECTIVE_HANDLER_ |
| + |
| +#include <vector> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
|
Daniel Erat
2014/07/31 22:31:15
i don't think you use this
rkc
2014/08/01 21:08:56
Done.
|
| +#include "base/time/time.h" |
| +#include "base/timer/timer.h" |
| +#include "components/copresence/handlers/audio/audio_directive_list.h" |
| +#include "components/copresence/mediums/audio/audio_recorder.h" |
| +#include "components/copresence/proto/data.pb.h" |
| + |
| +namespace media { |
| +class AudioBusRefCounted; |
| +} |
| + |
| +namespace copresence { |
| + |
| +class AudioPlayer; |
| +class AudioRecorder; |
|
Daniel Erat
2014/07/31 22:31:14
you don't need to forward-declare this; you're alr
rkc
2014/08/01 21:08:56
Done.
|
| + |
| +class AudioDirectiveHandler { |
| + public: |
| + AudioDirectiveHandler( |
| + const AudioRecorder::DecodeSamplesCallback& decode_cb, |
| + const AudioDirectiveList::EncodeTokenCallback& encode_cb); |
| + virtual ~AudioDirectiveHandler(); |
| + |
| + // Adds in instruction to our handler. The instruction will execute and be |
| + // removed after the ttl expires. |
| + void AddInstruction(const copresence::TokenInstruction& instruction, |
| + base::TimeDelta ttl_ms); |
| + |
| + protected: |
| + // Use this constructor ONLY for testing. |
| + explicit AudioDirectiveHandler( |
| + const AudioDirectiveList::EncodeTokenCallback& encode_cb); |
|
Daniel Erat
2014/07/31 22:31:15
add an Init() method here too and set_player_for_t
rkc
2014/08/01 21:08:56
Added the init method. Don't need the set methods
|
| + |
| + // Protected and virtual since we want to be able to mock these out. |
| + virtual void PlayAudio( |
| + const scoped_refptr<media::AudioBusRefCounted>& samples, |
| + base::TimeDelta duration); |
| + virtual void RecordAudio(base::TimeDelta duration); |
| + |
| + private: |
| + void StopPlayback(); |
| + void StopRecording(); |
| + |
| + // Execute the next active transmit instruction. |
| + void ExecuteNextTransmit(); |
| + // Execute the next active receive instruction. |
| + void ExecuteNextReceive(); |
| + |
| + AudioDirectiveList directive_list_; |
| + |
| + AudioPlayer* player_; |
| + AudioRecorder* recorder_; |
| + |
| + base::OneShotTimer<AudioDirectiveHandler> stop_playback_timer_; |
| + base::OneShotTimer<AudioDirectiveHandler> stop_recording_timer_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AudioDirectiveHandler); |
| +}; |
| + |
| +} // namespace copresence |
| + |
| +#endif // COMPONENTS_COPRESENCE_HANDLERS_AUDIO_DIRECTIVE_HANDLER_ |
|
Daniel Erat
2014/07/31 22:31:15
update path
|