Chromium Code Reviews| 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_LIST_ | 5 #ifndef COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_LIST_ |
| 6 #define COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_LIST_ | 6 #define COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_LIST_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 // samples associated with a audio transmit directives and expires directives | 48 // samples associated with a audio transmit directives and expires directives |
| 49 // that have outlived their TTL. | 49 // that have outlived their TTL. |
| 50 // TODO(rkc): Once we implement more token technologies, move reusable code | 50 // TODO(rkc): Once we implement more token technologies, move reusable code |
| 51 // from here to a base class and inherit various XxxxDirectiveList | 51 // from here to a base class and inherit various XxxxDirectiveList |
| 52 // classes from it. | 52 // classes from it. |
| 53 class AudioDirectiveList { | 53 class AudioDirectiveList { |
| 54 public: | 54 public: |
| 55 typedef base::Callback< | 55 typedef base::Callback< |
| 56 void(const std::string&, const scoped_refptr<media::AudioBusRefCounted>&)> | 56 void(const std::string&, const scoped_refptr<media::AudioBusRefCounted>&)> |
| 57 SamplesCallback; | 57 SamplesCallback; |
| 58 typedef base::Callback<void(const std::string&, const SamplesCallback&)> | 58 typedef base::Callback<void(const std::string&, bool, const SamplesCallback&)> |
| 59 EncodeTokenCallback; | 59 EncodeTokenCallback; |
| 60 | 60 |
| 61 AudioDirectiveList(const EncodeTokenCallback& encode_token_callback, | 61 AudioDirectiveList(const EncodeTokenCallback& encode_token_callback, |
| 62 const base::Closure& token_added_callback); | 62 const base::Closure& token_added_callback, |
| 63 bool use_audible_encoding); | |
| 63 virtual ~AudioDirectiveList(); | 64 virtual ~AudioDirectiveList(); |
| 64 | 65 |
| 65 // Adds a token to the token queue, after getting its corresponding samples | 66 // Adds a token to the token queue, after getting its corresponding samples |
| 66 // from whispernet. | 67 // from whispernet. |
| 67 void AddTransmitDirective(const std::string& token, | 68 void AddTransmitDirective(const std::string& token, |
| 68 const std::string& op_id, | 69 const std::string& op_id, |
| 69 base::TimeDelta ttl); | 70 base::TimeDelta ttl); |
| 70 | 71 |
| 71 void AddReceiveDirective(const std::string& op_id, base::TimeDelta ttl); | 72 void AddReceiveDirective(const std::string& op_id, base::TimeDelta ttl); |
| 72 | 73 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 99 scoped_ptr<AudioDirective> GetNextFromList(AudioDirectiveQueue* list); | 100 scoped_ptr<AudioDirective> GetNextFromList(AudioDirectiveQueue* list); |
| 100 | 101 |
| 101 // A map of tokens that are awaiting their samples before we can | 102 // A map of tokens that are awaiting their samples before we can |
| 102 // add them to the active transmit tokens list. | 103 // add them to the active transmit tokens list. |
| 103 std::map<std::string, AudioDirective> pending_transmit_tokens_; | 104 std::map<std::string, AudioDirective> pending_transmit_tokens_; |
| 104 | 105 |
| 105 AudioDirectiveQueue active_transmit_tokens_; | 106 AudioDirectiveQueue active_transmit_tokens_; |
| 106 AudioDirectiveQueue active_receive_tokens_; | 107 AudioDirectiveQueue active_receive_tokens_; |
| 107 | 108 |
| 108 EncodeTokenCallback encode_token_callback_; | 109 EncodeTokenCallback encode_token_callback_; |
| 109 | |
| 110 base::Closure token_added_callback_; | 110 base::Closure token_added_callback_; |
| 111 bool use_audible_encoding_; | |
|
xiyuan
2014/08/08 20:40:54
nit: const bool if |use_audible_encoding_| does no
rkc
2014/08/08 21:24:37
Done.
| |
| 111 | 112 |
| 112 // Cache that holds the encoded samples. After reaching its limit, the cache | 113 // Cache that holds the encoded samples. After reaching its limit, the cache |
| 113 // expires the oldest samples first. | 114 // expires the oldest samples first. |
| 114 SamplesMap samples_cache_; | 115 SamplesMap samples_cache_; |
| 115 | 116 |
| 116 DISALLOW_COPY_AND_ASSIGN(AudioDirectiveList); | 117 DISALLOW_COPY_AND_ASSIGN(AudioDirectiveList); |
| 117 }; | 118 }; |
| 118 | 119 |
| 119 } // namespace copresence | 120 } // namespace copresence |
| 120 | 121 |
| 121 #endif // COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_LIST_ | 122 #endif // COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_LIST_ |
| OLD | NEW |