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
3 // found in the LICENSE file.
5 #ifndef MEDIA_BASE_ANDROID_MEDIA_PLAYER_MANAGER_H_
6 #define MEDIA_BASE_ANDROID_MEDIA_PLAYER_MANAGER_H_
11 #include "base/basictypes.h"
12 #include "base/time/time.h"
13 #include "media/base/android/demuxer_stream_player_params.h"
14 #include "media/base/media_export.h"
15 #include "media/base/media_keys.h"
20 class MediaPlayerAndroid
;
21 class MediaResourceGetter
;
23 // This class is responsible for managing active MediaPlayerAndroid objects.
24 class MEDIA_EXPORT MediaPlayerManager
{
26 virtual ~MediaPlayerManager() {}
28 // Called by a MediaPlayerAndroid object when it is going to decode
29 // media streams. This helps the manager object maintain an array
30 // of active MediaPlayerAndroid objects and release the resources
32 virtual void RequestMediaResources(int player_id
) = 0;
34 // Called when a MediaPlayerAndroid object releases all its decoding
36 virtual void ReleaseMediaResources(int player_id
) = 0;
38 // Return a pointer to the MediaResourceGetter object.
39 virtual MediaResourceGetter
* GetMediaResourceGetter() = 0;
41 // Called when time update messages need to be sent. Args: player ID,
43 virtual void OnTimeUpdate(int player_id
, base::TimeDelta current_time
) = 0;
45 // Called when media metadata changed. Args: player ID, duration of the
46 // media, width, height, whether the metadata is successfully extracted.
47 virtual void OnMediaMetadataChanged(
49 base::TimeDelta duration
,
54 // Called when playback completed. Args: player ID.
55 virtual void OnPlaybackComplete(int player_id
) = 0;
57 // Called when media download was interrupted. Args: player ID.
58 virtual void OnMediaInterrupted(int player_id
) = 0;
60 // Called when buffering has changed. Args: player ID, percentage
62 virtual void OnBufferingUpdate(int player_id
, int percentage
) = 0;
64 // Called when seek completed. Args: player ID, current time.
65 virtual void OnSeekComplete(
67 const base::TimeDelta
& current_time
) = 0;
69 // Called when error happens. Args: player ID, error type.
70 virtual void OnError(int player_id
, int error
) = 0;
72 // Called when video size has changed. Args: player ID, width, height.
73 virtual void OnVideoSizeChanged(int player_id
, int width
, int height
) = 0;
75 // Returns the player that's in the fullscreen mode currently.
76 virtual MediaPlayerAndroid
* GetFullscreenPlayer() = 0;
78 // Returns the player with the specified id.
79 virtual MediaPlayerAndroid
* GetPlayer(int player_id
) = 0;
81 // Release all the players managed by this object.
82 virtual void DestroyAllMediaPlayers() = 0;
84 // Get the MediaDrmBridge object for the given media key Id.
85 virtual media::MediaDrmBridge
* GetDrmBridge(int media_keys_id
) = 0;
87 // Called by the player to get a hardware protected surface.
88 virtual void OnProtectedSurfaceRequested(int player_id
) = 0;
90 // TODO(xhwang): The following three methods needs to be decoupled from
91 // MediaPlayerManager to support the W3C Working Draft version of the EME
94 // Called when MediaDrmBridge wants to send a KeyAdded.
95 virtual void OnKeyAdded(int media_keys_id
,
96 const std::string
& session_id
) = 0;
98 // Called when MediaDrmBridge wants to send a KeyError.
99 virtual void OnKeyError(int media_keys_id
,
100 const std::string
& session_id
,
101 media::MediaKeys::KeyError error_code
,
102 int system_code
) = 0;
104 // Called when MediaDrmBridge wants to send a KeyMessage.
105 virtual void OnKeyMessage(int media_keys_id
,
106 const std::string
& session_id
,
107 const std::vector
<uint8
>& message
,
108 const std::string
& destination_url
) = 0;
113 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_MANAGER_H_