Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_PIPELINE_BACKEND_MANAGER_H_ | 5 #ifndef CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_PIPELINE_BACKEND_MANAGER_H_ |
| 6 #define CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_PIPELINE_BACKEND_MANAGER_H_ | 6 #define CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_PIPELINE_BACKEND_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "chromecast/public/media/media_pipeline_backend.h" | 14 #include "chromecast/public/media/media_pipeline_backend.h" |
| 14 #include "chromecast/public/media/media_pipeline_device_params.h" | 15 #include "chromecast/public/media/media_pipeline_device_params.h" |
| 15 | 16 |
| 16 namespace base { | 17 namespace base { |
| 17 template <typename T> | 18 class SingleThreadTaskRunner; |
| 18 struct DefaultLazyInstanceTraits; | |
| 19 } // namespace base | 19 } // namespace base |
| 20 | 20 |
| 21 namespace chromecast { | 21 namespace chromecast { |
| 22 namespace media { | 22 namespace media { |
| 23 | 23 |
| 24 // This class manages created media pipelines, and provides volume control by | 24 // This class manages created media pipelines, and provides volume control by |
| 25 // stream type. | 25 // stream type. |
| 26 // All functions in this class should be called on the media thread. | 26 // All functions in this class should be called on the media thread. |
| 27 class MediaPipelineBackendManager { | 27 class MediaPipelineBackendManager { |
| 28 public: | 28 public: |
| 29 explicit MediaPipelineBackendManager( | |
| 30 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner); | |
| 31 ~MediaPipelineBackendManager(); | |
| 32 | |
| 29 // Create media pipeline backend. | 33 // Create media pipeline backend. |
| 30 static MediaPipelineBackend* CreateMediaPipelineBackend( | 34 MediaPipelineBackend* CreateMediaPipelineBackend( |
|
alokp
2016/03/31 04:37:24
scoped_ptr?
tianyuwang1
2016/03/31 18:14:53
Done.
| |
| 31 const MediaPipelineDeviceParams& params); | 35 const MediaPipelineDeviceParams& params); |
| 32 | 36 |
| 33 // Create media pipeline backend with a specific stream_type. | 37 // Create media pipeline backend with a specific stream_type. |
| 34 static MediaPipelineBackend* CreateMediaPipelineBackend( | 38 MediaPipelineBackend* CreateMediaPipelineBackend( |
|
alokp
2016/03/31 04:37:24
ditto
tianyuwang1
2016/03/31 18:14:54
Done.
| |
| 35 const MediaPipelineDeviceParams& params, | 39 const MediaPipelineDeviceParams& params, |
| 36 int stream_type); | 40 int stream_type); |
| 37 | 41 |
| 38 // Internal clean up when a new media pipeline backend is destroyed. | 42 // Internal clean up when a new media pipeline backend is destroyed. |
| 39 static void OnMediaPipelineBackendDestroyed( | 43 void OnMediaPipelineBackendDestroyed(const MediaPipelineBackend* backend); |
| 40 const MediaPipelineBackend* backend); | |
| 41 | 44 |
| 42 // Sets the relative volume for a specified stream type, | 45 // Sets the relative volume for a specified stream type, |
| 43 // with range [0.0, 1.0] inclusive. If |multiplier| is outside the | 46 // with range [0.0, 1.0] inclusive. If |multiplier| is outside the |
| 44 // range [0.0, 1.0], it is clamped to that range. | 47 // range [0.0, 1.0], it is clamped to that range. |
| 45 // TODO(tianyuwang): change stream_type to use a enum. | 48 // TODO(tianyuwang): change stream_type to use a enum. |
| 46 static void SetVolumeMultiplier(int stream_type, float volume); | 49 void SetVolumeMultiplier(int stream_type, float volume); |
| 47 | 50 |
| 48 private: | 51 private: |
| 49 friend struct base::DefaultLazyInstanceTraits<MediaPipelineBackendManager>; | |
| 50 | |
| 51 // Returns a pointer to a singleton instance of the | 52 // Returns a pointer to a singleton instance of the |
| 52 // MediaPipelineBackendManager. | 53 // MediaPipelineBackendManager. |
| 53 static MediaPipelineBackendManager* Get(); | 54 static MediaPipelineBackendManager* Get(); |
| 54 | 55 |
| 55 MediaPipelineBackendManager(); | 56 float GetVolumeMultiplier(int stream_type); |
| 56 ~MediaPipelineBackendManager(); | |
| 57 | 57 |
| 58 float GetVolumeMultiplier(int stream_type); | 58 const scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; |
| 59 | 59 |
| 60 // A vector that stores all of the existing media_pipeline_backends_. | 60 // A vector that stores all of the existing media_pipeline_backends_. |
| 61 std::vector<MediaPipelineBackend*> media_pipeline_backends_; | 61 std::vector<MediaPipelineBackend*> media_pipeline_backends_; |
| 62 | 62 |
| 63 // Volume multiplier for each type of audio streams. | 63 // Volume multiplier for each type of audio streams. |
| 64 std::map<int, float> volume_by_stream_type_; | 64 std::map<int, float> volume_by_stream_type_; |
| 65 | 65 |
| 66 DISALLOW_COPY_AND_ASSIGN(MediaPipelineBackendManager); | 66 DISALLOW_COPY_AND_ASSIGN(MediaPipelineBackendManager); |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 } // namespace media | 69 } // namespace media |
| 70 } // namespace chromecast | 70 } // namespace chromecast |
| 71 | 71 |
| 72 #endif // CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_PIPELINE_BACKEND_MANAGER_H_ | 72 #endif // CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_PIPELINE_BACKEND_MANAGER_H_ |
| OLD | NEW |