Chromium Code Reviews| Index: content/browser/renderer_host/media/renderer_audio_output_stream_factory_context_impl.h |
| diff --git a/content/browser/renderer_host/media/renderer_audio_output_stream_factory_context_impl.h b/content/browser/renderer_host/media/renderer_audio_output_stream_factory_context_impl.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cab74c7bdaf97a215c18877241c7dea5563d6196 |
| --- /dev/null |
| +++ b/content/browser/renderer_host/media/renderer_audio_output_stream_factory_context_impl.h |
| @@ -0,0 +1,99 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_RENDERER_AUDIO_OUTPUT_STREAM_FACTORY_CONTEXT_IMPL_H_ |
| +#define CONTENT_BROWSER_RENDERER_HOST_MEDIA_RENDERER_AUDIO_OUTPUT_STREAM_FACTORY_CONTEXT_IMPL_H_ |
| + |
| +#include <memory> |
| +#include <string> |
| + |
| +#include "content/browser/renderer_host/media/renderer_audio_output_stream_factory_context.h" |
| +#include "content/common/media/renderer_audio_output_stream_factory.mojom.h" |
| +#include "mojo/public/cpp/bindings/interface_request.h" |
| +#include "mojo/public/cpp/bindings/strong_binding_set.h" |
| + |
| +namespace media { |
| +class AudioSystem; |
| +} // namespace media |
| + |
| +namespace content { |
| + |
| +class MediaStreamManager; |
| + |
| +// In addition to being a RendererAudioOutputStreamFactoryContext, this class |
| +// also handles requests for mojom::RendererAudioOutputStreamFactory instances. |
| +// |
| +// Ownership diagram for stream IPC classes (excluding interfaces): |
| +// RendererAudioOutputStreamFactoryContext |
| +// ^ |
| +// | owns (at most one per render frame in the process). |
| +// | |
| +// RenderFrameAudioOutputStreamFactory |
| +// ^ |
| +// | owns (one per stream for the frame). |
| +// | |
| +// media::MojoAudioOutputStreamProvider |
| +// ^ |
| +// | owns (one). |
| +// | |
| +// media::MojoAudioOutputStream |
|
o1ka
2017/03/29 08:13:48
Great, thanks! (an arrow is a bit confusing though
Max Morin
2017/03/30 12:48:50
Hopefully, the text clears it up :).
|
| + |
| +class CONTENT_EXPORT RendererAudioOutputStreamFactoryContextImpl |
| + : public RendererAudioOutputStreamFactoryContext { |
| + public: |
| + RendererAudioOutputStreamFactoryContextImpl( |
| + int render_process_id, |
| + media::AudioSystem* audio_system, |
| + MediaStreamManager* media_stream_manager, |
| + const std::string& salt); |
| + |
| + ~RendererAudioOutputStreamFactoryContextImpl() override; |
| + |
| + // Creates a factory and binds it to the request. Intended to be registered |
| + // in a RenderFrameHosts InterfaceRegistry. |
| + void CreateFactory( |
| + int frame_host_id, |
| + mojo::InterfaceRequest<mojom::RendererAudioOutputStreamFactory> request); |
| + |
| + // RendererAudioOutputStreamFactoryContext implementation. |
| + int GetRenderProcessId() const override; |
| + |
| + std::string GetHMACForDeviceId( |
| + const url::Origin& origin, |
| + const std::string& raw_device_id) const override; |
| + |
| + void RequestDeviceAuthorization( |
| + int render_frame_id, |
| + int session_id, |
| + const std::string& device_id, |
| + const url::Origin& security_origin, |
| + AuthorizationCompletedCallback cb) const override; |
| + |
| + std::unique_ptr<media::AudioOutputDelegate> CreateDelegate( |
| + const std::string& unique_device_id, |
| + int render_frame_id, |
| + const media::AudioParameters& params, |
| + media::AudioOutputDelegate::EventHandler* handler) override; |
| + |
| + private: |
| + // Used for hashing the device_id. |
| + const std::string salt_; |
| + const int render_process_id_; |
| + media::AudioSystem* const audio_system_; |
| + MediaStreamManager* const media_stream_manager_; |
| + const AudioOutputAuthorizationHandler authorization_handler_; |
| + |
| + // All streams requires ids for logging, so we keep a count for that. |
| + int next_stream_id_ = 0; |
| + |
| + // The factories created by |this| is kept here, so that we can make sure they |
| + // don't keep danging references to |this|. |
| + mojo::StrongBindingSet<mojom::RendererAudioOutputStreamFactory> factories_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(RendererAudioOutputStreamFactoryContextImpl); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_RENDERER_AUDIO_OUTPUT_STREAM_FACTORY_CONTEXT_IMPL_H_ |