Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(566)

Side by Side Diff: media/base/android/media_player_android.h

Issue 643353002: Listen to the audio focus event for MSE/EME (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_
6 #define MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ 6 #define MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/memory/weak_ptr.h"
12 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "media/base/android/media_player_listener.h"
13 #include "media/base/media_export.h" 15 #include "media/base/media_export.h"
14 #include "ui/gl/android/scoped_java_surface.h" 16 #include "ui/gl/android/scoped_java_surface.h"
15 #include "url/gurl.h" 17 #include "url/gurl.h"
16 18
17 namespace media { 19 namespace media {
18 20
19 class BrowserCdm; 21 class BrowserCdm;
20 class MediaPlayerManager; 22 class MediaPlayerManager;
21 23
22 // This class serves as the base class for different media player 24 // This class serves as the base class for different media player
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 int player_id() { return player_id_; } 81 int player_id() { return player_id_; }
80 82
81 GURL frame_url() { return frame_url_; } 83 GURL frame_url() { return frame_url_; }
82 84
83 protected: 85 protected:
84 MediaPlayerAndroid(int player_id, 86 MediaPlayerAndroid(int player_id,
85 MediaPlayerManager* manager, 87 MediaPlayerManager* manager,
86 const RequestMediaResourcesCB& request_media_resources_cb, 88 const RequestMediaResourcesCB& request_media_resources_cb,
87 const GURL& frame_url); 89 const GURL& frame_url);
88 90
91 // TODO(qinmin): Simplify the MediaPlayerListener class to only listen to
92 // media interrupt events. And have a separate child class to listen to all
93 // the events needed by MediaPlayerBridge. http://crbug.com/422597.
94 // MediaPlayerListener callbacks.
95 virtual void OnVideoSizeChanged(int width, int height);
96 virtual void OnMediaError(int error_type);
97 virtual void OnBufferingUpdate(int percent);
98 virtual void OnPlaybackComplete();
99 virtual void OnMediaInterrupted();
100 virtual void OnSeekComplete();
101 virtual void OnMediaPrepared();
102
103 // Attach/Detaches |listener_| for listening to all the events.
104 void AttachListener(jobject j_media_player);
xhwang 2014/10/14 18:23:30 It seems |j_media_player| can be NULL here. What d
qinmin 2014/10/14 21:55:51 Done.
105 void DetachListener();
106
89 MediaPlayerManager* manager() { return manager_; } 107 MediaPlayerManager* manager() { return manager_; }
90 108
91 RequestMediaResourcesCB request_media_resources_cb_; 109 RequestMediaResourcesCB request_media_resources_cb_;
92 110
93 private: 111 private:
112 friend class MediaPlayerListener;
113
94 // Player ID assigned to this player. 114 // Player ID assigned to this player.
95 int player_id_; 115 int player_id_;
96 116
97 // Resource manager for all the media players. 117 // Resource manager for all the media players.
98 MediaPlayerManager* manager_; 118 MediaPlayerManager* manager_;
99 119
100 // Url for the frame that contains this player. 120 // Url for the frame that contains this player.
101 GURL frame_url_; 121 GURL frame_url_;
102 122
123 // Listener object that listens to all the media player events.
124 scoped_ptr<MediaPlayerListener> listener_;
125
126 // Weak pointer passed to |listener_| for callbacks.
127 // NOTE: Weak pointers must be invalidated before all other member variables.
128 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_;
129
103 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); 130 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid);
104 }; 131 };
105 132
106 } // namespace media 133 } // namespace media
107 134
108 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ 135 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698