| 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/macros.h" | 10 #include "base/macros.h" | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 36 // of this class. | 36 // of this class. | 
| 37 class AudioDirectiveHandlerImpl final : public AudioDirectiveHandler { | 37 class AudioDirectiveHandlerImpl final : public AudioDirectiveHandler { | 
| 38  public: | 38  public: | 
| 39   AudioDirectiveHandlerImpl(); | 39   AudioDirectiveHandlerImpl(); | 
| 40   AudioDirectiveHandlerImpl(scoped_ptr<AudioManager> audio_manager, | 40   AudioDirectiveHandlerImpl(scoped_ptr<AudioManager> audio_manager, | 
| 41                             scoped_ptr<base::Timer> timer, | 41                             scoped_ptr<base::Timer> timer, | 
| 42                             const scoped_refptr<TickClockRefCounted>& clock); | 42                             const scoped_refptr<TickClockRefCounted>& clock); | 
| 43 | 43 | 
| 44   ~AudioDirectiveHandlerImpl(); | 44   ~AudioDirectiveHandlerImpl(); | 
| 45 | 45 | 
| 46   // Do not use this class before calling this. | 46   // AudioDirectiveHandler overrides: | 
| 47   void Initialize(const AudioManager::DecodeSamplesCallback& decode_cb, | 47   void Initialize(WhispernetClient* whispernet_client, | 
| 48                   const AudioManager::EncodeTokenCallback& encode_cb) override; | 48                   const TokensCallback& tokens_cb) override; | 
| 49 |  | 
| 50   // Adds an instruction to our handler. The instruction will execute and be |  | 
| 51   // removed after the ttl expires. |  | 
| 52   void AddInstruction(const copresence::TokenInstruction& instruction, | 49   void AddInstruction(const copresence::TokenInstruction& instruction, | 
| 53                       const std::string& op_id, | 50                       const std::string& op_id, | 
| 54                       base::TimeDelta ttl_ms) override; | 51                       base::TimeDelta ttl_ms) override; | 
| 55 |  | 
| 56   // Removes all instructions associated with this operation id. |  | 
| 57   void RemoveInstructions(const std::string& op_id) override; | 52   void RemoveInstructions(const std::string& op_id) override; | 
| 58 |  | 
| 59   // Returns the currently playing token. |  | 
| 60   const std::string PlayingToken(AudioType type) const override; | 53   const std::string PlayingToken(AudioType type) const override; | 
|  | 54   bool IsPlayingTokenHeard(AudioType type) const override; | 
| 61 | 55 | 
| 62  private: | 56  private: | 
| 63   // Processes the next active instruction, | 57   // Processes the next active instruction, | 
| 64   // updating our audio manager state accordingly. | 58   // updating our audio manager state accordingly. | 
| 65   void ProcessNextInstruction(); | 59   void ProcessNextInstruction(); | 
| 66 | 60 | 
| 67   // Returns the time that an instruction expires at. This will always return | 61   // Returns the time that an instruction expires at. This will always return | 
| 68   // the earliest expiry time among all the active receive and transmit | 62   // the earliest expiry time among all the active receive and transmit | 
| 69   // instructions. If we don't have any active instructions, returns false. | 63   // instructions. If we don't have any active instructions, returns false. | 
| 70   bool GetNextInstructionExpiry(base::TimeTicks* next_event); | 64   bool GetNextInstructionExpiry(base::TimeTicks* next_event); | 
| 71 | 65 | 
| 72   scoped_ptr<AudioManager> audio_manager_; | 66   scoped_ptr<AudioManager> audio_manager_; | 
| 73 | 67 | 
| 74   scoped_ptr<base::Timer> audio_event_timer_; | 68   scoped_ptr<base::Timer> audio_event_timer_; | 
| 75   scoped_refptr<TickClockRefCounted> clock_; | 69   scoped_refptr<TickClockRefCounted> clock_; | 
| 76 | 70 | 
| 77   // Lists of transmits and receives, for both audible and inaudible tokens. | 71   // Lists of transmits and receives, for both audible and inaudible tokens. | 
| 78   // AUDIBLE = element 0, INAUDIBLE = element 1 (see copresence_constants.h). | 72   // AUDIBLE = element 0, INAUDIBLE = element 1 (see copresence_constants.h). | 
| 79   ScopedVector<AudioDirectiveList> transmits_lists_; | 73   ScopedVector<AudioDirectiveList> transmits_lists_; | 
| 80   ScopedVector<AudioDirectiveList> receives_lists_; | 74   ScopedVector<AudioDirectiveList> receives_lists_; | 
| 81 | 75 | 
| 82 | 76 | 
| 83   DISALLOW_COPY_AND_ASSIGN(AudioDirectiveHandlerImpl); | 77   DISALLOW_COPY_AND_ASSIGN(AudioDirectiveHandlerImpl); | 
| 84 }; | 78 }; | 
| 85 | 79 | 
| 86 }  // namespace copresence | 80 }  // namespace copresence | 
| 87 | 81 | 
| 88 #endif  // COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_HANDLER_IMPL_H_ | 82 #endif  // COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_HANDLER_IMPL_H_ | 
| OLD | NEW | 
|---|