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..e080ae3858bd267ee9d35dc1a599d2d005f23fbc |
| --- /dev/null |
| +++ b/components/copresence/handlers/audio/audio_directive_handler.h |
| @@ -0,0 +1,71 @@ |
| +// 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_ |
| +#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" |
| +#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; |
| + |
| +class AudioDirectiveHandler { |
| + public: |
| + AudioDirectiveHandler( |
| + const AudioRecorder::DecodeSamplesCallback& decode_cb, |
| + const AudioDirectiveList::EncodeTokenCallback& encode_cb); |
| + // Use this constructor ONLY for testing. |
| + explicit AudioDirectiveHandler( |
|
xiyuan
2014/07/25 21:02:09
nit: If we only want to expose it for testing, may
Daniel Erat
2014/07/25 23:09:01
what about just having a single c'tor and document
rkc
2014/07/28 21:02:01
Made this protected, so only the Mock that overrid
rkc
2014/07/28 21:02:01
Keeping a separate constructor makes it explicit t
|
| + const AudioDirectiveList::EncodeTokenCallback& encode_cb); |
| + virtual ~AudioDirectiveHandler(); |
| + |
| + void AddInstruction(const copresence::TokenInstruction& instruction, |
|
Daniel Erat
2014/07/25 23:09:01
document what this does
rkc
2014/07/28 21:02:01
Done.
|
| + base::TimeDelta ttl_ms); |
| + |
| + protected: |
| + virtual void PlayAudio( |
|
xiyuan
2014/07/25 21:02:09
It seems that these are made "virtual" because we
rkc
2014/07/28 21:02:01
Done.
|
| + const scoped_refptr<media::AudioBusRefCounted>& samples, |
| + base::TimeDelta duration); |
|
xiyuan
2014/07/25 21:02:09
nit: const base::TimeDelta& ?
Daniel Erat
2014/07/25 23:09:01
(not really necessary; time structs are just int64
rkc
2014/07/28 21:02:02
time.h specifies that these can be efficiently pas
rkc
2014/07/28 21:02:02
Acknowledged.
|
| + virtual void RecordAudio(base::TimeDelta duration); |
|
xiyuan
2014/07/25 21:02:09
nit: const base::TimeDelta& ?
rkc
2014/07/28 21:02:02
ditto.
|
| + |
| + virtual void StopPlayback(); |
| + virtual void StopRecording(); |
| + |
| + // For testing, we want to override base::Time::Now(). |
| + base::Time Now(); |
|
Daniel Erat
2014/07/25 23:09:01
i don't think you define this anywhere
rkc
2014/07/28 21:02:01
Leftover code, removed.
Done.
|
| + |
| + private: |
| + void ExecuteNextTransmit(); |
|
Daniel Erat
2014/07/25 23:09:01
add a comment documenting what these do
rkc
2014/07/28 21:02:01
Done.
|
| + void ExecuteNextReceive(); |
| + |
| + AudioDirectiveList directive_list_; |
| + |
| + AudioPlayer* player_; |
|
Daniel Erat
2014/07/25 23:09:01
document that these are owned by this class but de
rkc
2014/07/28 21:02:01
These objects delete themselves on the audio threa
|
| + 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_ |