OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_COPRESENCE_HANDLERS_AUDIO_DIRECTIVE_HANDLER_ | |
6 #define COMPONENTS_COPRESENCE_HANDLERS_AUDIO_DIRECTIVE_HANDLER_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/macros.h" | |
12 #include "base/memory/ref_counted.h" | |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/time/time.h" | |
15 #include "base/timer/timer.h" | |
16 #include "components/copresence/handlers/audio/audio_directive_list.h" | |
17 #include "components/copresence/mediums/audio/audio_recorder.h" | |
18 #include "components/copresence/proto/data.pb.h" | |
19 | |
20 namespace media { | |
21 class AudioBusRefCounted; | |
22 } | |
23 | |
24 namespace copresence { | |
25 | |
26 class AudioPlayer; | |
27 class AudioRecorder; | |
28 | |
29 class AudioDirectiveHandler { | |
30 public: | |
31 AudioDirectiveHandler( | |
32 const AudioRecorder::DecodeSamplesCallback& decode_cb, | |
33 const AudioDirectiveList::EncodeTokenCallback& encode_cb); | |
34 // Use this constructor ONLY for testing. | |
35 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
| |
36 const AudioDirectiveList::EncodeTokenCallback& encode_cb); | |
37 virtual ~AudioDirectiveHandler(); | |
38 | |
39 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.
| |
40 base::TimeDelta ttl_ms); | |
41 | |
42 protected: | |
43 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.
| |
44 const scoped_refptr<media::AudioBusRefCounted>& samples, | |
45 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.
| |
46 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.
| |
47 | |
48 virtual void StopPlayback(); | |
49 virtual void StopRecording(); | |
50 | |
51 // For testing, we want to override base::Time::Now(). | |
52 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.
| |
53 | |
54 private: | |
55 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.
| |
56 void ExecuteNextReceive(); | |
57 | |
58 AudioDirectiveList directive_list_; | |
59 | |
60 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
| |
61 AudioRecorder* recorder_; | |
62 | |
63 base::OneShotTimer<AudioDirectiveHandler> stop_playback_timer_; | |
64 base::OneShotTimer<AudioDirectiveHandler> stop_recording_timer_; | |
65 | |
66 DISALLOW_COPY_AND_ASSIGN(AudioDirectiveHandler); | |
67 }; | |
68 | |
69 } // namespace copresence | |
70 | |
71 #endif // COMPONENTS_COPRESENCE_HANDLERS_AUDIO_DIRECTIVE_HANDLER_ | |
OLD | NEW |