1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_RENDERERS_RENDERER_IMPL_FACTORY_H_
6 #define MEDIA_RENDERERS_RENDERER_IMPL_FACTORY_H_
11 #include "base/functional/callback.h"
12 #include "base/memory/raw_ptr.h"
13 #include "base/task/sequenced_task_runner.h"
14 #include "build/build_config.h"
15 #include "media/base/media_export.h"
16 #include "media/base/media_player_logging_id.h"
17 #include "media/base/renderer_factory.h"
19 #if !BUILDFLAG(IS_ANDROID)
20 #include "media/base/speech_recognition_client.h"
27 class AudioRendererSink;
29 class GpuVideoAcceleratorFactories;
32 class VideoRendererSink;
34 using CreateAudioDecodersCB =
35 base::RepeatingCallback<std::vector<std::unique_ptr<AudioDecoder>>()>;
36 using CreateVideoDecodersCB =
37 base::RepeatingCallback<std::vector<std::unique_ptr<VideoDecoder>>()>;
39 // The default factory class for creating RendererImpl.
40 class MEDIA_EXPORT RendererImplFactory final : public RendererFactory {
42 using GetGpuFactoriesCB =
43 base::RepeatingCallback<GpuVideoAcceleratorFactories*()>;
45 #if BUILDFLAG(IS_ANDROID)
46 RendererImplFactory(MediaLog* media_log,
47 DecoderFactory* decoder_factory,
48 const GetGpuFactoriesCB& get_gpu_factories_cb,
49 MediaPlayerLoggingID media_player_id);
53 DecoderFactory* decoder_factory,
54 const GetGpuFactoriesCB& get_gpu_factories_cb,
55 MediaPlayerLoggingID media_player_id,
56 std::unique_ptr<SpeechRecognitionClient> speech_recognition_client);
59 RendererImplFactory(const RendererImplFactory&) = delete;
60 RendererImplFactory& operator=(const RendererImplFactory&) = delete;
62 ~RendererImplFactory() final;
64 std::unique_ptr<Renderer> CreateRenderer(
65 const scoped_refptr<base::SequencedTaskRunner>& media_task_runner,
66 const scoped_refptr<base::TaskRunner>& worker_task_runner,
67 AudioRendererSink* audio_renderer_sink,
68 VideoRendererSink* video_renderer_sink,
69 RequestOverlayInfoCB request_overlay_info_cb,
70 const gfx::ColorSpace& target_color_space) final;
73 std::vector<std::unique_ptr<AudioDecoder>> CreateAudioDecoders(
74 const scoped_refptr<base::SequencedTaskRunner>& media_task_runner);
75 std::vector<std::unique_ptr<VideoDecoder>> CreateVideoDecoders(
76 const scoped_refptr<base::SequencedTaskRunner>& media_task_runner,
77 RequestOverlayInfoCB request_overlay_info_cb,
78 const gfx::ColorSpace& target_color_space,
79 GpuVideoAcceleratorFactories* gpu_factories);
81 raw_ptr<MediaLog> media_log_;
83 // Factory to create extra audio and video decoders.
84 // Could be nullptr if not extra decoders are available.
85 raw_ptr<DecoderFactory, DanglingUntriaged> decoder_factory_;
87 // Creates factories for supporting video accelerators. May be null.
88 GetGpuFactoriesCB get_gpu_factories_cb_;
90 // WebMediaPlayerImpl id.
91 MediaPlayerLoggingID media_player_id_;
93 #if !BUILDFLAG(IS_ANDROID)
94 std::unique_ptr<SpeechRecognitionClient> speech_recognition_client_;
100 #endif // MEDIA_RENDERERS_RENDERER_IMPL_FACTORY_H_