OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_HANDLER_IMPL_H_ | 5 #ifndef COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_HANDLER_IMPL_H_ |
6 #define COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_HANDLER_IMPL_H_ | 6 #define COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_HANDLER_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
| 10 #include "base/callback.h" |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 15 #include "components/audio_modem/public/modem.h" |
14 #include "components/copresence/handlers/audio/audio_directive_handler.h" | 16 #include "components/copresence/handlers/audio/audio_directive_handler.h" |
15 #include "components/copresence/public/copresence_constants.h" | 17 #include "components/copresence/public/copresence_constants.h" |
16 | 18 |
17 namespace base { | 19 namespace base { |
18 class TimeTicks; | 20 class TimeTicks; |
19 class Timer; | 21 class Timer; |
20 } | 22 } |
21 | 23 |
22 namespace media { | 24 namespace media { |
23 class AudioBusRefCounted; | 25 class AudioBusRefCounted; |
(...skipping 10 matching lines...) Expand all Loading... |
34 // class. Investigate a better way to do this; a few options are abstracting | 36 // class. Investigate a better way to do this; a few options are abstracting |
35 // out token encoding to a separate class, or allowing whispernet to have | 37 // out token encoding to a separate class, or allowing whispernet to have |
36 // multiple callbacks for encoded tokens being sent back and have two versions | 38 // multiple callbacks for encoded tokens being sent back and have two versions |
37 // of this class. | 39 // of this class. |
38 class AudioDirectiveHandlerImpl final : public AudioDirectiveHandler { | 40 class AudioDirectiveHandlerImpl final : public AudioDirectiveHandler { |
39 public: | 41 public: |
40 explicit AudioDirectiveHandlerImpl( | 42 explicit AudioDirectiveHandlerImpl( |
41 const DirectivesCallback& update_directives_callback); | 43 const DirectivesCallback& update_directives_callback); |
42 AudioDirectiveHandlerImpl( | 44 AudioDirectiveHandlerImpl( |
43 const DirectivesCallback& update_directives_callback, | 45 const DirectivesCallback& update_directives_callback, |
44 scoped_ptr<AudioManager> audio_manager, | 46 scoped_ptr<audio_modem::Modem> audio_modem, |
45 scoped_ptr<base::Timer> timer, | 47 scoped_ptr<base::Timer> timer, |
46 const scoped_refptr<TickClockRefCounted>& clock); | 48 const scoped_refptr<TickClockRefCounted>& clock); |
47 | 49 |
48 ~AudioDirectiveHandlerImpl() override; | 50 ~AudioDirectiveHandlerImpl() override; |
49 | 51 |
50 // AudioDirectiveHandler overrides: | 52 // AudioDirectiveHandler overrides: |
51 void Initialize(WhispernetClient* whispernet_client, | 53 void Initialize(audio_modem::WhispernetClient* whispernet_client, |
52 const TokensCallback& tokens_cb) override; | 54 const audio_modem::TokensCallback& tokens_cb) override; |
53 void AddInstruction(const Directive& directive, | 55 void AddInstruction(const Directive& directive, |
54 const std::string& op_id) override; | 56 const std::string& op_id) override; |
55 void RemoveInstructions(const std::string& op_id) override; | 57 void RemoveInstructions(const std::string& op_id) override; |
56 const std::string PlayingToken(AudioType type) const override; | 58 const std::string PlayingToken(audio_modem::AudioType type) const override; |
57 bool IsPlayingTokenHeard(AudioType type) const override; | 59 bool IsPlayingTokenHeard(audio_modem::AudioType type) const override; |
58 | 60 |
59 private: | 61 private: |
60 // Processes the next active instruction, | 62 // Processes the next active instruction, |
61 // updating our audio manager state accordingly. | 63 // updating our audio manager state accordingly. |
62 void ProcessNextInstruction(); | 64 void ProcessNextInstruction(); |
63 | 65 |
64 // Returns the time that an instruction expires at. This will always return | 66 // Returns the time that an instruction expires at. This will always return |
65 // the earliest expiry time among all the active receive and transmit | 67 // the earliest expiry time among all the active receive and transmit |
66 // instructions. If we don't have any active instructions, returns false. | 68 // instructions. If we don't have any active instructions, returns false. |
67 bool GetNextInstructionExpiry(base::TimeTicks* next_event); | 69 bool GetNextInstructionExpiry(base::TimeTicks* next_event); |
68 | 70 |
69 DirectivesCallback update_directives_callback_; | 71 DirectivesCallback update_directives_callback_; |
70 scoped_ptr<AudioManager> audio_manager_; | 72 scoped_ptr<audio_modem::Modem> audio_modem_; |
71 scoped_ptr<base::Timer> audio_event_timer_; | 73 scoped_ptr<base::Timer> audio_event_timer_; |
72 scoped_refptr<TickClockRefCounted> clock_; | 74 scoped_refptr<TickClockRefCounted> clock_; |
73 | 75 |
74 // Lists of transmits and receives, for both audible and inaudible tokens. | 76 // Lists of transmits and receives, for both audible and inaudible tokens. |
75 // AUDIBLE = element 0, INAUDIBLE = element 1 (see copresence_constants.h). | 77 // AUDIBLE = element 0, INAUDIBLE = element 1 (see copresence_constants.h). |
76 ScopedVector<AudioDirectiveList> transmits_lists_; | 78 ScopedVector<AudioDirectiveList> transmits_lists_; |
77 ScopedVector<AudioDirectiveList> receives_lists_; | 79 ScopedVector<AudioDirectiveList> receives_lists_; |
78 | 80 |
79 DISALLOW_COPY_AND_ASSIGN(AudioDirectiveHandlerImpl); | 81 DISALLOW_COPY_AND_ASSIGN(AudioDirectiveHandlerImpl); |
80 }; | 82 }; |
81 | 83 |
82 } // namespace copresence | 84 } // namespace copresence |
83 | 85 |
84 #endif // COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_HANDLER_IMPL_H_ | 86 #endif // COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_HANDLER_IMPL_H_ |
OLD | NEW |