OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 CHROMECAST_MEDIA_AUDIO_CHROMECAST_DEVICE_AUDIO_OUTPUT_STREAM_H_ |
| 6 #define CHROMECAST_MEDIA_AUDIO_CHROMECAST_DEVICE_AUDIO_OUTPUT_STREAM_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "chromecast/media/audio/cast_audio_manager.h" |
| 10 #include "chromecast/public/media/cast_audio_output_stream.h" |
| 11 #include "media/audio/audio_io.h" |
| 12 #include "media/base/media_export.h" |
| 13 |
| 14 namespace chromecast { |
| 15 namespace media { |
| 16 |
| 17 struct AudioParameters; |
| 18 |
| 19 // An implementation of ::media::AudioOutputStream for any Chromecast device. |
| 20 // This passes control requests and data to an instance of the platform- |
| 21 // independent chromecast::CastAudioOutputStream interface. |
| 22 class ChromecastDeviceAudioOutputStream |
| 23 : private CastAudioOutputStream::AudioSourceCallback, |
| 24 public ::media::AudioOutputStream { |
| 25 public: |
| 26 // |output_stream| is provided and owned by the global instance of |
| 27 // CastAudioOutputDevice. This class does not take ownership. This |
| 28 // implementation currently supports the following types for audio samples: |
| 29 // uint8_t, int16_t, int32_t |
| 30 // |params|.bits_per_sample must hold 8, 16, or 32, respectively. |
| 31 ChromecastDeviceAudioOutputStream(CastAudioOutputStream* output_stream, |
| 32 const AudioParameters& params, |
| 33 CastAudioManager* manager); |
| 34 ~ChromecastDeviceAudioOutputStream() override; |
| 35 |
| 36 // ::media::AudioOutputStream implementation: |
| 37 bool Open() override; |
| 38 void Start( |
| 39 ::media::AudioOutputStream::AudioSourceCallback* callback) override; |
| 40 void Stop() override; |
| 41 void SetVolume(double volume) override; |
| 42 void GetVolume(double* volume) override; |
| 43 void Close() override; |
| 44 |
| 45 // chromecast::AudioSourceCallback implementation: |
| 46 int GetMoreData(void* dest, |
| 47 uint32_t len, |
| 48 int32_t frames, |
| 49 uint32_t total_bytes_delay) override; |
| 50 void OnError(CastAudioOutputStream* stream) override; |
| 51 |
| 52 private: |
| 53 // Calls to ::media::AudioOutputStream interface will be forwarded here. |
| 54 CastAudioOutputStream* output_stream_; |
| 55 |
| 56 // Calls to chromecast::AudioSourceCallback interface will be forwarded here. |
| 57 ::media::AudioOutputStream::AudioSourceCallback* callback_; |
| 58 |
| 59 // The parameters describing the stream. |
| 60 const AudioParameters params_; |
| 61 |
| 62 // The manager that owns this stream. Alert |manager_| when |this| closes. |
| 63 CastAudioManager* audio_manager_; |
| 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(ChromecastDeviceAudioOutputStream); |
| 66 }; |
| 67 |
| 68 } // namespace media |
| 69 } // namespace chromecast |
| 70 |
| 71 #endif // CHROMECAST_MEDIA_AUDIO_CHROMECAST_DEVICE_AUDIO_OUTPUT_STREAM_H_ |
OLD | NEW |