Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(680)

Side by Side Diff: chromecast/media/cma/backend/media_pipeline_backend_manager.h

Issue 1858803002: [chromecast] Pass media task runner to MediaPipelineBackendManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Resolved comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
14 #include "base/single_thread_task_runner.h"
13 #include "chromecast/public/media/media_pipeline_backend.h" 15 #include "chromecast/public/media/media_pipeline_backend.h"
14 #include "chromecast/public/media/media_pipeline_device_params.h" 16 #include "chromecast/public/media/media_pipeline_device_params.h"
15 17
16 namespace base {
17 template <typename T>
18 struct DefaultLazyInstanceTraits;
19 } // namespace base
20
21 namespace chromecast { 18 namespace chromecast {
22 namespace media { 19 namespace media {
23 20
24 // This class manages created media pipelines, and provides volume control by 21 // This class manages created media pipelines, and provides volume control by
25 // stream type. 22 // stream type.
26 // All functions in this class should be called on the media thread. 23 // All functions in this class should be called on the media thread.
27 class MediaPipelineBackendManager { 24 class MediaPipelineBackendManager {
28 public: 25 public:
26 explicit MediaPipelineBackendManager(
27 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner);
28 ~MediaPipelineBackendManager();
29
29 // Create media pipeline backend. 30 // Create media pipeline backend.
30 static MediaPipelineBackend* CreateMediaPipelineBackend( 31 scoped_ptr<MediaPipelineBackend> CreateMediaPipelineBackend(
31 const MediaPipelineDeviceParams& params); 32 const MediaPipelineDeviceParams& params);
32 33
33 // Create media pipeline backend with a specific stream_type. 34 // Create media pipeline backend with a specific stream_type.
34 static MediaPipelineBackend* CreateMediaPipelineBackend( 35 scoped_ptr<MediaPipelineBackend> CreateMediaPipelineBackend(
35 const MediaPipelineDeviceParams& params, 36 const MediaPipelineDeviceParams& params,
36 int stream_type); 37 int stream_type);
37 38
38 // Internal clean up when a new media pipeline backend is destroyed. 39 // Internal clean up when a new media pipeline backend is destroyed.
39 static void OnMediaPipelineBackendDestroyed( 40 void OnMediaPipelineBackendDestroyed(const MediaPipelineBackend* backend);
alokp 2016/04/05 20:35:46 This should not be a public member function. You s
tianyuwang1 2016/04/05 22:24:04 Done in this patch.
40 const MediaPipelineBackend* backend);
41 41
42 // Sets the relative volume for a specified stream type, 42 // Sets the relative volume for a specified stream type,
43 // with range [0.0, 1.0] inclusive. If |multiplier| is outside the 43 // with range [0.0, 1.0] inclusive. If |multiplier| is outside the
44 // range [0.0, 1.0], it is clamped to that range. 44 // range [0.0, 1.0], it is clamped to that range.
45 // TODO(tianyuwang): change stream_type to use a enum. 45 // TODO(tianyuwang): change stream_type to use a enum.
46 static void SetVolumeMultiplier(int stream_type, float volume); 46 void SetVolumeMultiplier(int stream_type, float volume);
47
48 scoped_refptr<base::SingleThreadTaskRunner> task_runner() const {
alokp 2016/04/05 20:35:46 This should return a raw pointer.
tianyuwang1 2016/04/05 22:24:04 Done.
49 return media_task_runner_;
50 }
47 51
48 private: 52 private:
49 friend struct base::DefaultLazyInstanceTraits<MediaPipelineBackendManager>; 53 float GetVolumeMultiplier(int stream_type);
50 54
51 // Returns a pointer to a singleton instance of the 55 const scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
52 // MediaPipelineBackendManager.
53 static MediaPipelineBackendManager* Get();
54
55 MediaPipelineBackendManager();
56 ~MediaPipelineBackendManager();
57
58 float GetVolumeMultiplier(int stream_type);
59 56
60 // A vector that stores all of the existing media_pipeline_backends_. 57 // A vector that stores all of the existing media_pipeline_backends_.
61 std::vector<MediaPipelineBackend*> media_pipeline_backends_; 58 std::vector<MediaPipelineBackend*> media_pipeline_backends_;
62 59
63 // Volume multiplier for each type of audio streams. 60 // Volume multiplier for each type of audio streams.
64 std::map<int, float> volume_by_stream_type_; 61 std::map<int, float> volume_by_stream_type_;
65 62
66 DISALLOW_COPY_AND_ASSIGN(MediaPipelineBackendManager); 63 DISALLOW_COPY_AND_ASSIGN(MediaPipelineBackendManager);
67 }; 64 };
68 65
69 } // namespace media 66 } // namespace media
70 } // namespace chromecast 67 } // namespace chromecast
71 68
72 #endif // CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_PIPELINE_BACKEND_MANAGER_H_ 69 #endif // CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_PIPELINE_BACKEND_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698