• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef MEDIA_BASE_ANDROID_MEDIA_PLAYER_MANAGER_H_
6 #define MEDIA_BASE_ANDROID_MEDIA_PLAYER_MANAGER_H_
7 
8 #include <string>
9 #include <vector>
10 
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"
16 
17 namespace media {
18 
19 class MediaDrmBridge;
20 class MediaPlayerAndroid;
21 class MediaResourceGetter;
22 
23 // This class is responsible for managing active MediaPlayerAndroid objects.
24 class MEDIA_EXPORT MediaPlayerManager {
25  public:
~MediaPlayerManager()26   virtual ~MediaPlayerManager() {}
27 
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
31   // when needed.
32   virtual void RequestMediaResources(int player_id) = 0;
33 
34   // Called when a MediaPlayerAndroid object releases all its decoding
35   // resources.
36   virtual void ReleaseMediaResources(int player_id) = 0;
37 
38   // Return a pointer to the MediaResourceGetter object.
39   virtual MediaResourceGetter* GetMediaResourceGetter() = 0;
40 
41   // Called when time update messages need to be sent. Args: player ID,
42   // current time.
43   virtual void OnTimeUpdate(int player_id, base::TimeDelta current_time) = 0;
44 
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(
48       int player_id,
49       base::TimeDelta duration,
50       int width,
51       int height,
52       bool success) = 0;
53 
54   // Called when playback completed. Args: player ID.
55   virtual void OnPlaybackComplete(int player_id) = 0;
56 
57   // Called when media download was interrupted. Args: player ID.
58   virtual void OnMediaInterrupted(int player_id) = 0;
59 
60   // Called when buffering has changed. Args: player ID, percentage
61   // of the media.
62   virtual void OnBufferingUpdate(int player_id, int percentage) = 0;
63 
64   // Called when seek completed. Args: player ID, current time.
65   virtual void OnSeekComplete(
66       int player_id,
67       const base::TimeDelta& current_time) = 0;
68 
69   // Called when error happens. Args: player ID, error type.
70   virtual void OnError(int player_id, int error) = 0;
71 
72   // Called when video size has changed. Args: player ID, width, height.
73   virtual void OnVideoSizeChanged(int player_id, int width, int height) = 0;
74 
75   // Returns the player that's in the fullscreen mode currently.
76   virtual MediaPlayerAndroid* GetFullscreenPlayer() = 0;
77 
78   // Returns the player with the specified id.
79   virtual MediaPlayerAndroid* GetPlayer(int player_id) = 0;
80 
81   // Release all the players managed by this object.
82   virtual void DestroyAllMediaPlayers() = 0;
83 
84   // Get the MediaDrmBridge object for the given media key Id.
85   virtual media::MediaDrmBridge* GetDrmBridge(int media_keys_id) = 0;
86 
87   // Called by the player to get a hardware protected surface.
88   virtual void OnProtectedSurfaceRequested(int player_id) = 0;
89 
90   // The following five methods are related to EME.
91   // TODO(xhwang): These methods needs to be decoupled from MediaPlayerManager
92   // to support the W3C Working Draft version of the EME spec.
93   // http://crbug.com/315312
94 
95   // Called when MediaDrmBridge determines a SessionId.
96   virtual void OnSessionCreated(int media_keys_id,
97                                 uint32 session_id,
98                                 const std::string& web_session_id) = 0;
99 
100   // Called when MediaDrmBridge wants to send a Message event.
101   virtual void OnSessionMessage(int media_keys_id,
102                                 uint32 session_id,
103                                 const std::vector<uint8>& message,
104                                 const std::string& destination_url) = 0;
105 
106   // Called when MediaDrmBridge wants to send a Ready event.
107   virtual void OnSessionReady(int media_keys_id, uint32 session_id) = 0;
108 
109   // Called when MediaDrmBridge wants to send a Closed event.
110   virtual void OnSessionClosed(int media_keys_id, uint32 session_id) = 0;
111 
112   // Called when MediaDrmBridge wants to send an Error event.
113   virtual void OnSessionError(int media_keys_id,
114                               uint32 session_id,
115                               media::MediaKeys::KeyError error_code,
116                               int system_code) = 0;
117 };
118 
119 }  // namespace media
120 
121 #endif  // MEDIA_BASE_ANDROID_MEDIA_PLAYER_MANAGER_H_
122