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

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

Issue 2173593002: [Chromecast] Limit number of concurrent audio and video decoders (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 <memory> 9 #include <memory>
10 #include <vector>
11 10
12 #include "base/macros.h" 11 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
14 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
15 #include "chromecast/public/media/media_pipeline_backend.h" 14 #include "chromecast/public/media/media_pipeline_backend.h"
16 #include "chromecast/public/media/media_pipeline_device_params.h" 15 #include "chromecast/public/media/media_pipeline_device_params.h"
17 16
18 namespace chromecast { 17 namespace chromecast {
19 namespace media { 18 namespace media {
20 19
(...skipping 21 matching lines...) Expand all
42 // TODO(tianyuwang): change stream_type to use a enum. 41 // TODO(tianyuwang): change stream_type to use a enum.
43 void SetVolumeMultiplier(int stream_type, float volume); 42 void SetVolumeMultiplier(int stream_type, float volume);
44 43
45 base::SingleThreadTaskRunner* task_runner() const { 44 base::SingleThreadTaskRunner* task_runner() const {
46 return media_task_runner_.get(); 45 return media_task_runner_.get();
47 } 46 }
48 47
49 private: 48 private:
50 friend class MediaPipelineBackendWrapper; 49 friend class MediaPipelineBackendWrapper;
51 50
51 struct BackendInfo {
52 int audio_decoder_count_ = 0;
53 int video_decoder_count_ = 0;
54 };
55
56 // MediaPipelineBackendWrapper instances must check with these functions
57 // before creating decoders, so the manager can enforce global limits.
58 // If these return true, the count is incremented (i.e. it's assumed that the
59 // wrapper will create one). It's decreased when backend is destroyed.
60 bool CanCreateAudioDecoder(MediaPipelineBackend* backend);
61 bool CanCreateVideoDecoder(MediaPipelineBackend* backend);
62
52 // Internal clean up when a new media pipeline backend is destroyed. 63 // Internal clean up when a new media pipeline backend is destroyed.
53 void OnMediaPipelineBackendDestroyed(const MediaPipelineBackend* backend); 64 void OnMediaPipelineBackendDestroyed(MediaPipelineBackend* backend);
54 65
55 float GetVolumeMultiplier(int stream_type); 66 float GetVolumeMultiplier(int stream_type);
56 67
57 const scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; 68 const scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
58 69
59 // A vector that stores all of the existing media_pipeline_backends_. 70 // Collection of all existing media_pipeline_backends_
60 std::vector<MediaPipelineBackend*> media_pipeline_backends_; 71 std::map<MediaPipelineBackend*, BackendInfo> media_pipeline_backends_;
72 int audio_decoder_count_;
73 int video_decoder_count_;
61 74
62 // Volume multiplier for each type of audio streams. 75 // Volume multiplier for each type of audio streams.
63 std::map<int, float> volume_by_stream_type_; 76 std::map<int, float> volume_by_stream_type_;
64 77
65 DISALLOW_COPY_AND_ASSIGN(MediaPipelineBackendManager); 78 DISALLOW_COPY_AND_ASSIGN(MediaPipelineBackendManager);
66 }; 79 };
67 80
68 } // namespace media 81 } // namespace media
69 } // namespace chromecast 82 } // namespace chromecast
70 83
71 #endif // CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_PIPELINE_BACKEND_MANAGER_H_ 84 #endif // CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_PIPELINE_BACKEND_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698