| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 REMOTING_CLIENT_AUDIO_PLAYER_H_ | 5 #ifndef REMOTING_CLIENT_AUDIO_PLAYER_H_ |
| 6 #define REMOTING_CLIENT_AUDIO_PLAYER_H_ | 6 #define REMOTING_CLIENT_AUDIO_PLAYER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <list> | 11 #include <list> |
| 12 #include <memory> | 12 #include <memory> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
| 16 #include "remoting/client/audio_consumer.h" |
| 16 #include "remoting/proto/audio.pb.h" | 17 #include "remoting/proto/audio.pb.h" |
| 17 | 18 |
| 18 namespace remoting { | 19 namespace remoting { |
| 19 | 20 |
| 20 class AudioPlayer { | 21 class AudioPlayer : public AudioConsumer { |
| 21 public: | 22 public: |
| 22 // The number of channels in the audio stream (only supporting stereo audio | 23 // The number of channels in the audio stream (only supporting stereo audio |
| 23 // for now). | 24 // for now). |
| 24 static const int kChannels = 2; | 25 static const int kChannels = 2; |
| 25 static const int kSampleSizeBytes = 2; | 26 static const int kSampleSizeBytes = 2; |
| 26 | 27 |
| 27 virtual ~AudioPlayer(); | 28 ~AudioPlayer() override; |
| 28 | 29 |
| 29 void ProcessAudioPacket(std::unique_ptr<AudioPacket> packet); | 30 void ProcessAudioPacket(std::unique_ptr<AudioPacket> packet); |
| 30 | 31 |
| 32 // AudioConsumer implementation. |
| 33 void AddAudioPacket(std::unique_ptr<AudioPacket> packet) override; |
| 34 |
| 31 protected: | 35 protected: |
| 32 AudioPlayer(); | 36 AudioPlayer(); |
| 33 | 37 |
| 34 // Return the recommended number of samples to include in a frame. | 38 // Return the recommended number of samples to include in a frame. |
| 35 virtual uint32_t GetSamplesPerFrame() = 0; | 39 virtual uint32_t GetSamplesPerFrame() = 0; |
| 36 | 40 |
| 37 // Resets the audio player and starts playback. | 41 // Resets the audio player and starts playback. |
| 38 // Returns true on success. | 42 // Returns true on success. |
| 39 virtual bool ResetAudioPlayer(AudioPacket::SamplingRate sampling_rate) = 0; | 43 virtual bool ResetAudioPlayer(AudioPacket::SamplingRate sampling_rate) = 0; |
| 40 | 44 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 68 | 72 |
| 69 // The number of bytes from |queued_packets_| that have been consumed. | 73 // The number of bytes from |queued_packets_| that have been consumed. |
| 70 size_t bytes_consumed_; | 74 size_t bytes_consumed_; |
| 71 | 75 |
| 72 DISALLOW_COPY_AND_ASSIGN(AudioPlayer); | 76 DISALLOW_COPY_AND_ASSIGN(AudioPlayer); |
| 73 }; | 77 }; |
| 74 | 78 |
| 75 } // namespace remoting | 79 } // namespace remoting |
| 76 | 80 |
| 77 #endif // REMOTING_CLIENT_AUDIO_PLAYER_H_ | 81 #endif // REMOTING_CLIENT_AUDIO_PLAYER_H_ |
| OLD | NEW |