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 // Return a pointer to the MediaResourceGetter object.
29 virtual MediaResourceGetter
* GetMediaResourceGetter() = 0;
31 // Called when time update messages need to be sent. Args: player ID,
33 virtual void OnTimeUpdate(int player_id
, base::TimeDelta current_time
) = 0;
35 // Called when media metadata changed. Args: player ID, duration of the
36 // media, width, height, whether the metadata is successfully extracted.
37 virtual void OnMediaMetadataChanged(
39 base::TimeDelta duration
,
44 // Called when playback completed. Args: player ID.
45 virtual void OnPlaybackComplete(int player_id
) = 0;
47 // Called when media download was interrupted. Args: player ID.
48 virtual void OnMediaInterrupted(int player_id
) = 0;
50 // Called when buffering has changed. Args: player ID, percentage
52 virtual void OnBufferingUpdate(int player_id
, int percentage
) = 0;
54 // Called when seek completed. Args: player ID, current time.
55 virtual void OnSeekComplete(
57 const base::TimeDelta
& current_time
) = 0;
59 // Called when error happens. Args: player ID, error type.
60 virtual void OnError(int player_id
, int error
) = 0;
62 // Called when video size has changed. Args: player ID, width, height.
63 virtual void OnVideoSizeChanged(int player_id
, int width
, int height
) = 0;
65 // Returns the player that's in the fullscreen mode currently.
66 virtual MediaPlayerAndroid
* GetFullscreenPlayer() = 0;
68 // Returns the player with the specified id.
69 virtual MediaPlayerAndroid
* GetPlayer(int player_id
) = 0;
71 // Release all the players managed by this object.
72 virtual void DestroyAllMediaPlayers() = 0;
74 // Get the MediaDrmBridge object for the given media key Id.
75 virtual media::MediaDrmBridge
* GetDrmBridge(int cdm_id
) = 0;
77 // Called by the player to get a hardware protected surface.
78 virtual void RequestFullScreen(int player_id
) = 0;
80 // The following five methods are related to EME.
81 // TODO(xhwang): These methods needs to be decoupled from MediaPlayerManager
82 // to support the W3C Working Draft version of the EME spec.
83 // http://crbug.com/315312
85 // Called when MediaDrmBridge determines a SessionId.
86 virtual void OnSessionCreated(int cdm_id
,
88 const std::string
& web_session_id
) = 0;
90 // Called when MediaDrmBridge wants to send a Message event.
91 virtual void OnSessionMessage(int cdm_id
,
93 const std::vector
<uint8
>& message
,
94 const GURL
& destination_url
) = 0;
96 // Called when MediaDrmBridge wants to send a Ready event.
97 virtual void OnSessionReady(int cdm_id
, uint32 session_id
) = 0;
99 // Called when MediaDrmBridge wants to send a Closed event.
100 virtual void OnSessionClosed(int cdm_id
, uint32 session_id
) = 0;
102 // Called when MediaDrmBridge wants to send an Error event.
103 virtual void OnSessionError(int cdm_id
,
105 media::MediaKeys::KeyError error_code
,
106 uint32 system_code
) = 0;
111 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_MANAGER_H_