Chromium Code Reviews| 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 MEDIA_MOJO_SERVICES_MOJO_AUDIO_OUTPUT_H_ | |
| 6 #define MEDIA_MOJO_SERVICES_MOJO_AUDIO_OUTPUT_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 | |
| 11 // This class handles IPC for single stream by delegating method calls to its | |
|
o1ka
2017/02/22 13:26:30
nit "audio output stream"
Max Morin
2017/03/02 23:11:32
Done.
| |
| 12 // AudioOutputDelegate. | |
| 13 | |
| 14 #include "base/threading/thread_checker.h" | |
| 15 #include "media/base/audio_output_delegate.h" | |
| 16 #include "media/mojo/interfaces/audio_output.mojom.h" | |
| 17 #include "mojo/public/cpp/bindings/binding.h" | |
| 18 | |
| 19 namespace media { | |
| 20 | |
| 21 class MojoAudioOutput : public mojom::AudioOutput, | |
| 22 public AudioOutputDelegate::EventHandler { | |
| 23 public: | |
| 24 using CreateDelegateCallback = | |
| 25 base::OnceCallback<std::unique_ptr<AudioOutputDelegate>( | |
| 26 AudioOutputDelegate::EventHandler*, | |
| 27 const AudioParameters&)>; | |
| 28 using FinishedCallback = base::OnceCallback<void(mojom::AudioOutput*)>; | |
| 29 | |
| 30 // |create_delegate_callback| is used to obtain an AudioOutputDelegate for the | |
| 31 // stream when it's started and |finished_callback| is called when this class | |
| 32 // should be removed (stream ended/error). | |
| 33 MojoAudioOutput(mojom::AudioOutputRequest request, | |
| 34 CreateDelegateCallback create_delegate_callback, | |
| 35 FinishedCallback finished_callback); | |
| 36 | |
| 37 ~MojoAudioOutput() override; | |
| 38 | |
| 39 private: | |
| 40 // mojom::AudioOutput implementation. | |
| 41 void Start(const AudioParameters& params, | |
| 42 const StartCallback& callback) override; | |
| 43 void Play() override; | |
| 44 void Pause() override; | |
| 45 void SetVolume(double volume) override; | |
| 46 | |
| 47 // AudioOutputDelegate::EventHandler implementation. | |
| 48 void OnStreamCreated(int stream_id, | |
| 49 base::SharedMemory* shared_memory, | |
| 50 base::CancelableSyncSocket* foreign_socket) override; | |
| 51 void OnStreamError(int stream_id) override; | |
| 52 | |
| 53 // Closes connection to client and notifies owner. | |
| 54 void OnError(); | |
| 55 | |
| 56 // The callback for the Start() must be stored until the response is ready. | |
| 57 StartCallback start_callback_; | |
| 58 | |
| 59 mojo::Binding<AudioOutput> binding_; | |
| 60 CreateDelegateCallback create_delegate_callback_; | |
| 61 FinishedCallback finished_callback_; | |
| 62 base::ThreadChecker thread_checker_; | |
| 63 std::unique_ptr<AudioOutputDelegate> delegate_; | |
| 64 | |
| 65 DISALLOW_COPY_AND_ASSIGN(MojoAudioOutput); | |
| 66 }; | |
| 67 | |
| 68 } // namespace media | |
| 69 | |
| 70 #endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_OUTPUT_H_ | |
| OLD | NEW |