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

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

Issue 1128383003: Implementation of MediaCodecPlayer stage 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed some comments Created 5 years, 7 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/memory/weak_ptr.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "media/base/android/media_player_listener.h" 14 #include "media/base/android/media_player_listener.h"
15 #include "media/base/media_export.h" 15 #include "media/base/media_export.h"
16 #include "ui/gfx/geometry/size.h"
16 #include "ui/gl/android/scoped_java_surface.h" 17 #include "ui/gl/android/scoped_java_surface.h"
17 #include "url/gurl.h" 18 #include "url/gurl.h"
18 19
19 namespace media { 20 namespace media {
20 21
21 class BrowserCdm; 22 class BrowserCdm;
22 class MediaPlayerManager; 23 class MediaPlayerManager;
23 24
24 // This class serves as the base class for different media player 25 // This class serves as the base class for different media player
25 // implementations on Android. Subclasses need to provide their own 26 // implementations on Android. Subclasses need to provide their own
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 virtual bool IsPlayerReady() = 0; 73 virtual bool IsPlayerReady() = 0;
73 virtual bool CanPause() = 0; 74 virtual bool CanPause() = 0;
74 virtual bool CanSeekForward() = 0; 75 virtual bool CanSeekForward() = 0;
75 virtual bool CanSeekBackward() = 0; 76 virtual bool CanSeekBackward() = 0;
76 virtual GURL GetUrl(); 77 virtual GURL GetUrl();
77 virtual GURL GetFirstPartyForCookies(); 78 virtual GURL GetFirstPartyForCookies();
78 79
79 // Associates the |cdm| with this player. 80 // Associates the |cdm| with this player.
80 virtual void SetCdm(BrowserCdm* cdm); 81 virtual void SetCdm(BrowserCdm* cdm);
81 82
83 // Overridden in MediaCodecPlayer to pass data between threads.
84 virtual void OnMediaMetadataChanged(
85 base::TimeDelta duration, const gfx::Size& video_size) {}
86
82 int player_id() { return player_id_; } 87 int player_id() { return player_id_; }
83 88
84 GURL frame_url() { return frame_url_; } 89 GURL frame_url() { return frame_url_; }
85 90
91 // Attach/Detaches |listener_| for listening to all the media events. If
92 // |j_media_player| is NULL, |listener_| only listens to the system media
93 // events. Otherwise, it also listens to the events from |j_media_player|.
94 void AttachListener(jobject j_media_player);
95 void DetachListener();
96
86 protected: 97 protected:
87 MediaPlayerAndroid(int player_id, 98 MediaPlayerAndroid(int player_id,
88 MediaPlayerManager* manager, 99 MediaPlayerManager* manager,
89 const RequestMediaResourcesCB& request_media_resources_cb, 100 const RequestMediaResourcesCB& request_media_resources_cb,
90 const GURL& frame_url); 101 const GURL& frame_url);
91 102
92 // TODO(qinmin): Simplify the MediaPlayerListener class to only listen to 103 // TODO(qinmin): Simplify the MediaPlayerListener class to only listen to
93 // media interrupt events. And have a separate child class to listen to all 104 // media interrupt events. And have a separate child class to listen to all
94 // the events needed by MediaPlayerBridge. http://crbug.com/422597. 105 // the events needed by MediaPlayerBridge. http://crbug.com/422597.
95 // MediaPlayerListener callbacks. 106 // MediaPlayerListener callbacks.
96 virtual void OnVideoSizeChanged(int width, int height); 107 virtual void OnVideoSizeChanged(int width, int height);
97 virtual void OnMediaError(int error_type); 108 virtual void OnMediaError(int error_type);
98 virtual void OnBufferingUpdate(int percent); 109 virtual void OnBufferingUpdate(int percent);
99 virtual void OnPlaybackComplete(); 110 virtual void OnPlaybackComplete();
100 virtual void OnMediaInterrupted(); 111 virtual void OnMediaInterrupted();
101 virtual void OnSeekComplete(); 112 virtual void OnSeekComplete();
102 virtual void OnMediaPrepared(); 113 virtual void OnMediaPrepared();
103 114
104 // Attach/Detaches |listener_| for listening to all the media events. If
105 // |j_media_player| is NULL, |listener_| only listens to the system media
106 // events. Otherwise, it also listens to the events from |j_media_player|.
107 void AttachListener(jobject j_media_player);
108 void DetachListener();
109
110 // When destroying a subclassed object on a non-UI thread 115 // When destroying a subclassed object on a non-UI thread
111 // it is still required to destroy the |listener_| related stuff 116 // it is still required to destroy the |listener_| related stuff
112 // on the UI thread. 117 // on the UI thread.
113 void DestroyListenerOnUIThread(); 118 void DestroyListenerOnUIThread();
114 void SetAudible(bool is_audible); 119 void SetAudible(bool is_audible);
115 120
116 MediaPlayerManager* manager() { return manager_; } 121 MediaPlayerManager* manager() { return manager_; }
117 122
123 base::WeakPtr<MediaPlayerAndroid> WeakPtrForUIThread();
124
118 RequestMediaResourcesCB request_media_resources_cb_; 125 RequestMediaResourcesCB request_media_resources_cb_;
119 126
120 private: 127 private:
121 friend class MediaPlayerListener; 128 friend class MediaPlayerListener;
122 129
123 // Player ID assigned to this player. 130 // Player ID assigned to this player.
124 int player_id_; 131 int player_id_;
125 132
126 // Resource manager for all the media players. 133 // Resource manager for all the media players.
127 MediaPlayerManager* manager_; 134 MediaPlayerManager* manager_;
(...skipping 10 matching lines...) Expand all
138 // Weak pointer passed to |listener_| for callbacks. 145 // Weak pointer passed to |listener_| for callbacks.
139 // NOTE: Weak pointers must be invalidated before all other member variables. 146 // NOTE: Weak pointers must be invalidated before all other member variables.
140 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_; 147 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_;
141 148
142 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); 149 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid);
143 }; 150 };
144 151
145 } // namespace media 152 } // namespace media
146 153
147 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ 154 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698