OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 CONTENT_BROWSER_MEDIA_AUDIO_OUTPUT_STREAM_IMPL_H_ |
| 6 #define CONTENT_BROWSER_MEDIA_AUDIO_OUTPUT_STREAM_IMPL_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "content/browser/media/audio_output_impl.h" |
| 10 #include "content/browser/renderer_host/media/audio_renderer_host.h" |
| 11 #include "content/common/content_export.h" |
| 12 #include "media/mojo/interfaces/audio_output.mojom.h" |
| 13 #include "mojo/public/cpp/bindings/interface_request.h" |
| 14 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 15 |
| 16 namespace content { |
| 17 |
| 18 // This class implements AudioOutputStream Mojo interface. It will be used |
| 19 // by the AudioOutputClient to perform operations on audio output streams. |
| 20 // AudioOutputClient will perform operations remotely on the |
| 21 // AudioOutputStreamPtr and Mojo will transfer them to AudioOutputStreamImpl. |
| 22 // Owned by AudioOutputImpl. |
| 23 class CONTENT_EXPORT AudioOutputStreamImpl |
| 24 : public media::mojom::AudioOutputStream { |
| 25 public: |
| 26 AudioOutputStreamImpl(int stream_id, |
| 27 int render_frame_id, |
| 28 AudioOutputImpl* audio_output_impl, |
| 29 media::mojom::AudioOutputStreamRequest request); |
| 30 |
| 31 ~AudioOutputStreamImpl() override; |
| 32 |
| 33 int get_stream_id() const { return stream_id_; } |
| 34 |
| 35 private: |
| 36 FRIEND_TEST_ALL_PREFIXES(AudioOutputStreamImplTest, Close); |
| 37 // AudioOutputStream interface implementation. |
| 38 void Close() override; |
| 39 |
| 40 int stream_id_; |
| 41 int render_frame_id_; |
| 42 // AudioRendererHost is ref counted and AudioOutputImpl holds a reference to |
| 43 // it. And because all AudioOutputStreamImpl instances will be owned by |
| 44 // AudioOutputImpl too, it's safe to access AudioRendererHost from |
| 45 // AudioOutputStreamImpl. |
| 46 // The only issue that could happen is during AudioOutputStreamImpl |
| 47 // destructor. AudioRendererHost cannot access from there. |
| 48 AudioOutputImpl* audio_output_impl_; |
| 49 // Callback for media::mojom::AudioOutput::CreateStream. |
| 50 media::mojom::AudioOutput::CreateStreamCallback create_stream_callback_; |
| 51 mojo::Binding<media::mojom::AudioOutputStream> binding_; |
| 52 media::mojom::AudioOutputStreamPtr stream_ptr_; |
| 53 }; |
| 54 |
| 55 } // namespace content |
| 56 |
| 57 #endif // CONTENT_BROWSER_MEDIA_AUDIO_OUTPUT_STREAM_IMPL_H_ |
OLD | NEW |