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