| 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(
|
| + const AudioDirectiveList::EncodeTokenCallback& encode_cb);
|
| + virtual ~AudioDirectiveHandler();
|
| +
|
| + void AddInstruction(const copresence::TokenInstruction& instruction,
|
| + base::TimeDelta ttl_ms);
|
| +
|
| + protected:
|
| + virtual void PlayAudio(
|
| + const scoped_refptr<media::AudioBusRefCounted>& samples,
|
| + base::TimeDelta duration);
|
| + virtual void RecordAudio(base::TimeDelta duration);
|
| +
|
| + virtual void StopPlayback();
|
| + virtual void StopRecording();
|
| +
|
| + // For testing, we want to override base::Time::Now().
|
| + base::Time Now();
|
| +
|
| + private:
|
| + void ExecuteNextTransmit();
|
| + 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_
|
|
|