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

Side by Side Diff: Source/web/WebMediaPlayerClientImpl.h

Issue 302093011: Oilpan: move the MediaPlayer and MediaPlayerClient objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Have MediaController weakly track its media elements Created 6 years, 6 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 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 23 matching lines...) Expand all
34 #include "platform/audio/AudioSourceProvider.h" 34 #include "platform/audio/AudioSourceProvider.h"
35 #include "platform/graphics/media/MediaPlayer.h" 35 #include "platform/graphics/media/MediaPlayer.h"
36 #include "public/platform/WebAudioSourceProviderClient.h" 36 #include "public/platform/WebAudioSourceProviderClient.h"
37 #include "public/platform/WebMediaPlayerClient.h" 37 #include "public/platform/WebMediaPlayerClient.h"
38 #include "third_party/khronos/GLES2/gl2.h" 38 #include "third_party/khronos/GLES2/gl2.h"
39 #if OS(ANDROID) 39 #if OS(ANDROID)
40 #include "third_party/skia/include/core/SkBitmap.h" 40 #include "third_party/skia/include/core/SkBitmap.h"
41 #include "third_party/skia/include/core/SkRefCnt.h" 41 #include "third_party/skia/include/core/SkRefCnt.h"
42 #include "third_party/skia/include/gpu/GrTexture.h" 42 #include "third_party/skia/include/gpu/GrTexture.h"
43 #endif 43 #endif
44 #include "platform/heap/Handle.h"
44 #include "platform/weborigin/KURL.h" 45 #include "platform/weborigin/KURL.h"
45 #include "wtf/OwnPtr.h" 46 #include "wtf/OwnPtr.h"
46 #include "wtf/PassOwnPtr.h" 47 #include "wtf/PassOwnPtr.h"
47 #include "wtf/ThreadingPrimitives.h" 48 #include "wtf/ThreadingPrimitives.h"
48 49
49 namespace WebCore { 50 namespace WebCore {
50 class AudioSourceProviderClient; 51 class AudioSourceProviderClient;
51 class HTMLMediaElement; 52 class HTMLMediaElement;
52 } 53 }
53 54
54 namespace blink { 55 namespace blink {
55 56
56 class WebAudioSourceProvider; 57 class WebAudioSourceProvider;
57 class WebContentDecryptionModule; 58 class WebContentDecryptionModule;
58 class WebMediaPlayer; 59 class WebMediaPlayer;
59 class WebGraphicsContext3D; 60 class WebGraphicsContext3D;
60 61
61 // This class serves as a bridge between WebCore::MediaPlayer and 62 // This class serves as a bridge between WebCore::MediaPlayer and
62 // blink::WebMediaPlayer. 63 // blink::WebMediaPlayer.
63 class WebMediaPlayerClientImpl FINAL : public WebCore::MediaPlayer, public WebMe diaPlayerClient { 64 class WebMediaPlayerClientImpl FINAL : public NoBaseWillBeGarbageCollectedFinali zed<WebMediaPlayerClientImpl>, public WebCore::MediaPlayer, public WebMediaPlaye rClient {
64 65 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WebMediaPlayerClientImpl);
65 public: 66 public:
66 static PassOwnPtr<WebCore::MediaPlayer> create(WebCore::MediaPlayerClient*); 67 static PassOwnPtrWillBeRawPtr<WebCore::MediaPlayer> create(WebCore::MediaPla yerClient*);
67 68
68 virtual ~WebMediaPlayerClientImpl(); 69 virtual ~WebMediaPlayerClientImpl();
69 70
70 // WebMediaPlayerClient methods: 71 // WebMediaPlayerClient methods:
71 virtual void networkStateChanged() OVERRIDE; 72 virtual void networkStateChanged() OVERRIDE;
72 virtual void readyStateChanged() OVERRIDE; 73 virtual void readyStateChanged() OVERRIDE;
73 virtual void timeChanged() OVERRIDE; 74 virtual void timeChanged() OVERRIDE;
74 virtual void repaint() OVERRIDE; 75 virtual void repaint() OVERRIDE;
75 virtual void durationChanged() OVERRIDE; 76 virtual void durationChanged() OVERRIDE;
76 virtual void sizeChanged() OVERRIDE; 77 virtual void sizeChanged() OVERRIDE;
77 virtual double volume() const OVERRIDE; 78 virtual double volume() const OVERRIDE;
78 virtual void playbackStateChanged() OVERRIDE; 79 virtual void playbackStateChanged() OVERRIDE;
79 virtual WebMediaPlayer::Preload preload() const OVERRIDE; 80 virtual WebMediaPlayer::Preload preload() const OVERRIDE;
80 81
81 // WebEncryptedMediaPlayerClient methods: 82 // WebEncryptedMediaPlayerClient methods:
82 virtual void keyAdded(const WebString& keySystem, const WebString& sessionId ) OVERRIDE; 83 virtual void keyAdded(const WebString& keySystem, const WebString& sessionId ) OVERRIDE;
83 virtual void keyError(const WebString& keySystem, const WebString& sessionId , MediaKeyErrorCode, unsigned short systemCode) OVERRIDE; 84 virtual void keyError(const WebString& keySystem, const WebString& sessionId , MediaKeyErrorCode, unsigned short systemCode) OVERRIDE;
84 virtual void keyMessage(const WebString& keySystem, const WebString& session Id, const unsigned char* message, unsigned messageLength, const WebURL& defaultU RL) OVERRIDE; 85 virtual void keyMessage(const WebString& keySystem, const WebString& session Id, const unsigned char* message, unsigned messageLength, const WebURL& defaultU RL) OVERRIDE;
85 virtual void keyNeeded(const WebString& contentType, const unsigned char* in itData, unsigned initDataLength) OVERRIDE; 86 virtual void keyNeeded(const WebString& contentType, const unsigned char* in itData, unsigned initDataLength) OVERRIDE;
86 87
87 virtual void setWebLayer(WebLayer*) OVERRIDE; 88 virtual void setWebLayer(WebLayer*) OVERRIDE;
88 virtual void addTextTrack(WebInbandTextTrack*) OVERRIDE; 89 virtual void addTextTrack(WebInbandTextTrack*) OVERRIDE;
89 virtual void removeTextTrack(WebInbandTextTrack*) OVERRIDE; 90 virtual void removeTextTrack(WebInbandTextTrack*) OVERRIDE;
90 virtual void mediaSourceOpened(WebMediaSource*) OVERRIDE; 91 virtual void mediaSourceOpened(WebMediaSource*) OVERRIDE;
91 virtual void requestFullscreen() OVERRIDE; 92 virtual void requestFullscreen() OVERRIDE;
92 virtual void requestSeek(double) OVERRIDE; 93 virtual void requestSeek(double) OVERRIDE;
93 94
94 // MediaPlayer methods: 95 // MediaPlayer methods:
95 virtual WebMediaPlayer* webMediaPlayer() const OVERRIDE; 96 virtual WebMediaPlayer* webMediaPlayer() const OVERRIDE;
97 virtual void detach() OVERRIDE;
96 virtual void load(WebMediaPlayer::LoadType, const WTF::String& url, WebMedia Player::CORSMode) OVERRIDE; 98 virtual void load(WebMediaPlayer::LoadType, const WTF::String& url, WebMedia Player::CORSMode) OVERRIDE;
97 virtual void play() OVERRIDE; 99 virtual void play() OVERRIDE;
98 virtual void pause() OVERRIDE; 100 virtual void pause() OVERRIDE;
99 virtual bool supportsSave() const OVERRIDE; 101 virtual bool supportsSave() const OVERRIDE;
100 virtual double duration() const OVERRIDE; 102 virtual double duration() const OVERRIDE;
101 virtual double currentTime() const OVERRIDE; 103 virtual double currentTime() const OVERRIDE;
102 virtual void seek(double time) OVERRIDE; 104 virtual void seek(double time) OVERRIDE;
103 virtual bool seeking() const OVERRIDE; 105 virtual bool seeking() const OVERRIDE;
104 virtual double rate() const OVERRIDE; 106 virtual double rate() const OVERRIDE;
105 virtual void setRate(double) OVERRIDE; 107 virtual void setRate(double) OVERRIDE;
106 virtual bool paused() const OVERRIDE; 108 virtual bool paused() const OVERRIDE;
107 virtual void setPoster(const WebCore::KURL&) OVERRIDE; 109 virtual void setPoster(const WebCore::KURL&) OVERRIDE;
108 virtual WebCore::MediaPlayer::NetworkState networkState() const OVERRIDE; 110 virtual WebCore::MediaPlayer::NetworkState networkState() const OVERRIDE;
109 virtual WebCore::MediaPlayer::ReadyState readyState() const OVERRIDE; 111 virtual WebCore::MediaPlayer::ReadyState readyState() const OVERRIDE;
110 virtual double maxTimeSeekable() const OVERRIDE; 112 virtual double maxTimeSeekable() const OVERRIDE;
111 virtual WTF::PassRefPtr<WebCore::TimeRanges> buffered() const OVERRIDE; 113 virtual WTF::PassRefPtr<WebCore::TimeRanges> buffered() const OVERRIDE;
112 virtual bool didLoadingProgress() const OVERRIDE; 114 virtual bool didLoadingProgress() const OVERRIDE;
113 virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect&) OVERR IDE; 115 virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect&) OVERR IDE;
114 virtual bool copyVideoTextureToPlatformTexture(WebGraphicsContext3D*, Platfo rm3DObject texture, GLint level, GLenum type, GLenum internalFormat, bool premul tiplyAlpha, bool flipY) OVERRIDE; 116 virtual bool copyVideoTextureToPlatformTexture(WebGraphicsContext3D*, Platfo rm3DObject texture, GLint level, GLenum type, GLenum internalFormat, bool premul tiplyAlpha, bool flipY) OVERRIDE;
115 virtual void setPreload(WebCore::MediaPlayer::Preload) OVERRIDE; 117 virtual void setPreload(WebCore::MediaPlayer::Preload) OVERRIDE;
116 virtual bool hasSingleSecurityOrigin() const OVERRIDE; 118 virtual bool hasSingleSecurityOrigin() const OVERRIDE;
117 virtual double mediaTimeForTimeValue(double timeValue) const OVERRIDE; 119 virtual double mediaTimeForTimeValue(double timeValue) const OVERRIDE;
118 120
119 #if ENABLE(WEB_AUDIO) 121 #if ENABLE(WEB_AUDIO)
120 virtual WebCore::AudioSourceProvider* audioSourceProvider() OVERRIDE; 122 virtual WebCore::AudioSourceProvider* audioSourceProvider() OVERRIDE;
121 #endif 123 #endif
122 124
125 virtual void trace(WebCore::Visitor*) OVERRIDE;
126
123 private: 127 private:
124 explicit WebMediaPlayerClientImpl(WebCore::MediaPlayerClient*); 128 explicit WebMediaPlayerClientImpl(WebCore::MediaPlayerClient*);
125 129
126 WebCore::HTMLMediaElement& mediaElement() const; 130 WebCore::HTMLMediaElement& mediaElement() const;
127 131
128 WebCore::MediaPlayerClient* m_client; 132 RawPtrWillBeMember<WebCore::MediaPlayerClient> m_client;
129 OwnPtr<WebMediaPlayer> m_webMediaPlayer; 133 OwnPtr<WebMediaPlayer> m_webMediaPlayer;
130 WebCore::MediaPlayer::Preload m_preload; 134 WebCore::MediaPlayer::Preload m_preload;
131 double m_rate; 135 double m_rate;
132 136
133 #if OS(ANDROID) 137 #if OS(ANDROID)
134 // FIXME: This path "only works" on Android. It is a workaround for the prob lem that Skia could not handle Android's GL_TEXTURE_EXTERNAL_OES 138 // FIXME: This path "only works" on Android. It is a workaround for the prob lem that Skia could not handle Android's GL_TEXTURE_EXTERNAL_OES
135 // texture internally. It should be removed and replaced by the normal paint path. 139 // texture internally. It should be removed and replaced by the normal paint path.
136 // https://code.google.com/p/skia/issues/detail?id=1189 140 // https://code.google.com/p/skia/issues/detail?id=1189
137 void paintOnAndroid(WebCore::GraphicsContext*, const WebCore::IntRect&, uint 8_t alpha); 141 void paintOnAndroid(WebCore::GraphicsContext*, const WebCore::IntRect&, uint 8_t alpha);
138 SkBitmap m_bitmap; 142 SkBitmap m_bitmap;
(...skipping 15 matching lines...) Expand all
154 158
155 // WebAudioSourceProviderClient 159 // WebAudioSourceProviderClient
156 virtual void setFormat(size_t numberOfChannels, float sampleRate) OVERRI DE; 160 virtual void setFormat(size_t numberOfChannels, float sampleRate) OVERRI DE;
157 161
158 private: 162 private:
159 WebCore::AudioSourceProviderClient* m_client; 163 WebCore::AudioSourceProviderClient* m_client;
160 }; 164 };
161 165
162 // AudioSourceProviderImpl wraps a WebAudioSourceProvider. 166 // AudioSourceProviderImpl wraps a WebAudioSourceProvider.
163 // provideInput() calls into Chromium to get a rendered audio stream. 167 // provideInput() calls into Chromium to get a rendered audio stream.
164 168 // FIXME: Oilpan: consider moving this object to the heap.
165 class AudioSourceProviderImpl FINAL : public WebCore::AudioSourceProvider { 169 class AudioSourceProviderImpl FINAL : public WebCore::AudioSourceProvider {
166 public: 170 public:
167 AudioSourceProviderImpl() 171 AudioSourceProviderImpl()
168 : m_webAudioSourceProvider(0) 172 : m_webAudioSourceProvider(0)
169 { 173 {
170 } 174 }
171 175
172 virtual ~AudioSourceProviderImpl() { } 176 virtual ~AudioSourceProviderImpl() { }
173 177
174 // Wraps the given WebAudioSourceProvider. 178 // Wraps the given WebAudioSourceProvider.
175 void wrap(WebAudioSourceProvider*); 179 void wrap(WebAudioSourceProvider*);
176 180
177 // WebCore::AudioSourceProvider 181 // WebCore::AudioSourceProvider
178 virtual void setClient(WebCore::AudioSourceProviderClient*) OVERRIDE; 182 virtual void setClient(WebCore::AudioSourceProviderClient*) OVERRIDE;
179 virtual void provideInput(WebCore::AudioBus*, size_t framesToProcess) OV ERRIDE; 183 virtual void provideInput(WebCore::AudioBus*, size_t framesToProcess) OV ERRIDE;
180 184
181 private: 185 private:
182 WebAudioSourceProvider* m_webAudioSourceProvider; 186 WebAudioSourceProvider* m_webAudioSourceProvider;
183 OwnPtr<AudioClientImpl> m_client; 187 OwnPtr<AudioClientImpl> m_client;
184 Mutex provideInputLock; 188 Mutex provideInputLock;
185 }; 189 };
186 190
187 AudioSourceProviderImpl m_audioSourceProvider; 191 AudioSourceProviderImpl m_audioSourceProvider;
188 #endif 192 #endif
189 }; 193 };
190 194
191 } // namespace blink 195 } // namespace blink
192 196
193 #endif 197 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698