| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_MANAGER_ANDROID_H_ | 5 #ifndef WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_MANAGER_ANDROID_H_ |
| 6 #define WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_MANAGER_ANDROID_H_ | 6 #define WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_MANAGER_ANDROID_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <jni.h> | 9 #include <jni.h> |
| 10 #include <map> | 10 #include <map> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 | 13 |
| 14 namespace webkit_media { | 14 namespace webkit_media { |
| 15 | 15 |
| 16 class WebMediaPlayerAndroid; | 16 class WebMediaPlayerAndroid; |
| 17 | 17 |
| 18 // Class for managing all the WebMediaPlayerAndroid objects in a renderer | 18 // Class for managing all the WebMediaPlayerAndroid objects in a renderer |
| 19 // process. | 19 // process. |
| 20 class WebMediaPlayerManagerAndroid { | 20 class WebMediaPlayerManagerAndroid { |
| 21 public: | 21 public: |
| 22 WebMediaPlayerManagerAndroid(); | 22 WebMediaPlayerManagerAndroid(); |
| 23 ~WebMediaPlayerManagerAndroid(); | 23 ~WebMediaPlayerManagerAndroid(); |
| 24 | 24 |
| 25 // Register and unregister a WebMediaPlayerAndroid object. | 25 // Register and unregister a WebMediaPlayerAndroid object. |
| 26 int RegisterMediaPlayer(WebMediaPlayerAndroid* player); | 26 int RegisterMediaPlayer(WebMediaPlayerAndroid* player); |
| 27 void UnregisterMediaPlayer(int player_id); | 27 void UnregisterMediaPlayer(int player_id); |
| 28 | 28 |
| 29 // Called when a mediaplayer starts to decode media. If the number |
| 30 // of active decoders hits the limit, release some resources. |
| 31 // TODO(qinmin): we need to classify between video and audio decoders. |
| 32 // Audio decoders are inexpensive. And css animations often come with |
| 33 // lots of small audio files. |
| 34 void RequestMediaResources(int player_id); |
| 35 |
| 29 // Release all the media resources on the renderer process. | 36 // Release all the media resources on the renderer process. |
| 30 void ReleaseMediaResources(); | 37 void ReleaseMediaResources(); |
| 31 | 38 |
| 32 // Get the pointer to WebMediaPlayerAndroid given the |player_id|. | 39 // Get the pointer to WebMediaPlayerAndroid given the |player_id|. |
| 33 WebMediaPlayerAndroid* GetMediaPlayer(int player_id); | 40 WebMediaPlayerAndroid* GetMediaPlayer(int player_id); |
| 34 | 41 |
| 35 private: | 42 private: |
| 36 // Information needed to manage WebMediaPlayerAndroid. | 43 // Get the number of active players. |
| 37 // TODO(qinmin): more informations will be added here for resource management. | 44 int32 GetActivePlayerCount(); |
| 38 struct MediaPlayerInfo { | |
| 39 webkit_media::WebMediaPlayerAndroid* player; | |
| 40 }; | |
| 41 | 45 |
| 42 // Info for all available WebMediaPlayerAndroid on a page; kept so that | 46 // Info for all available WebMediaPlayerAndroid on a page; kept so that |
| 43 // we can enumerate them to send updates about tab focus and visibily. | 47 // we can enumerate them to send updates about tab focus and visibily. |
| 44 std::map<int32, MediaPlayerInfo> media_players_; | 48 std::map<int32, WebMediaPlayerAndroid*> media_players_; |
| 45 | 49 |
| 46 int32 next_media_player_id_; | 50 int32 next_media_player_id_; |
| 47 | 51 |
| 48 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerManagerAndroid); | 52 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerManagerAndroid); |
| 49 }; | 53 }; |
| 50 | 54 |
| 51 } // namespace webkit_media | 55 } // namespace webkit_media |
| 52 | 56 |
| 53 #endif // WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_MANAGER_ANDROID_H_ | 57 #endif // WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_MANAGER_ANDROID_H_ |
| OLD | NEW |