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

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

Issue 170233009: Initial implementation of AudioTrack, AudioTrackList, VideoTrack, and VideoTrackList. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@blink-master
Patch Set: Created 6 years, 10 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "config.h" 5 #include "config.h"
6 #include "WebMediaPlayerClientImpl.h" 6 #include "WebMediaPlayerClientImpl.h"
7 7
8 #include "WebDocument.h" 8 #include "WebDocument.h"
9 #include "WebFrameClient.h" 9 #include "WebFrameClient.h"
10 #include "WebFrameImpl.h" 10 #include "WebFrameImpl.h"
11 #include "WebHelperPlugin.h" 11 #include "WebHelperPlugin.h"
12 #include "WebViewImpl.h" 12 #include "WebViewImpl.h"
13 #include "core/frame/Frame.h" 13 #include "core/frame/Frame.h"
14 #include "core/html/HTMLMediaElement.h" 14 #include "core/html/HTMLMediaElement.h"
15 #include "core/html/TimeRanges.h" 15 #include "core/html/TimeRanges.h"
16 #include "core/html/track/AudioTrack.h"
17 #include "core/html/track/VideoTrack.h"
16 #include "core/rendering/RenderLayerCompositor.h" 18 #include "core/rendering/RenderLayerCompositor.h"
17 #include "core/rendering/RenderView.h" 19 #include "core/rendering/RenderView.h"
18 #include "modules/mediastream/MediaStreamRegistry.h" 20 #include "modules/mediastream/MediaStreamRegistry.h"
19 #include "platform/audio/AudioBus.h" 21 #include "platform/audio/AudioBus.h"
20 #include "platform/audio/AudioSourceProviderClient.h" 22 #include "platform/audio/AudioSourceProviderClient.h"
21 #include "platform/geometry/IntSize.h" 23 #include "platform/geometry/IntSize.h"
22 #include "platform/graphics/GraphicsContext.h" 24 #include "platform/graphics/GraphicsContext.h"
23 #include "platform/graphics/GraphicsLayer.h" 25 #include "platform/graphics/GraphicsLayer.h"
24 #include "platform/graphics/gpu/Extensions3DUtil.h" 26 #include "platform/graphics/gpu/Extensions3DUtil.h"
25 #include "platform/graphics/skia/GaneshUtils.h" 27 #include "platform/graphics/skia/GaneshUtils.h"
(...skipping 27 matching lines...) Expand all
53 55
54 static PassOwnPtr<WebMediaPlayer> createWebMediaPlayer(WebMediaPlayerClient* cli ent, const WebURL& url, Frame* frame) 56 static PassOwnPtr<WebMediaPlayer> createWebMediaPlayer(WebMediaPlayerClient* cli ent, const WebURL& url, Frame* frame)
55 { 57 {
56 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(frame); 58 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(frame);
57 59
58 if (!webFrame->client()) 60 if (!webFrame->client())
59 return nullptr; 61 return nullptr;
60 return adoptPtr(webFrame->client()->createMediaPlayer(webFrame, url, client) ); 62 return adoptPtr(webFrame->client()->createMediaPlayer(webFrame, url, client) );
61 } 63 }
62 64
63 WebMediaPlayer* WebMediaPlayerClientImpl::mediaPlayer() const 65 WebMediaPlayer* WebMediaPlayerClientImpl::webMediaPlayer() const
64 { 66 {
65 return m_webMediaPlayer.get(); 67 return m_webMediaPlayer.get();
66 } 68 }
67 69
68 // WebMediaPlayerClient -------------------------------------------------------- 70 // WebMediaPlayerClient --------------------------------------------------------
69 71
70 WebMediaPlayerClientImpl::~WebMediaPlayerClientImpl() 72 WebMediaPlayerClientImpl::~WebMediaPlayerClientImpl()
71 { 73 {
72 // Explicitly destroy the WebMediaPlayer to allow verification of tear down. 74 // Explicitly destroy the WebMediaPlayer to allow verification of tear down.
73 m_webMediaPlayer.clear(); 75 m_webMediaPlayer.clear();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 { 172 {
171 ASSERT(m_helperPlugin); 173 ASSERT(m_helperPlugin);
172 m_helperPlugin.clear(); 174 m_helperPlugin.clear();
173 } 175 }
174 176
175 void WebMediaPlayerClientImpl::setWebLayer(blink::WebLayer* layer) 177 void WebMediaPlayerClientImpl::setWebLayer(blink::WebLayer* layer)
176 { 178 {
177 m_client->mediaPlayerSetWebLayer(layer); 179 m_client->mediaPlayerSetWebLayer(layer);
178 } 180 }
179 181
182 static AtomicString VideoKindToString(WebMediaPlayerClient::VideoTrackKind kind)
183 {
184 switch (kind) {
185 case WebMediaPlayerClient::VideoTrackKindNone:
186 return AtomicString();
187 break;
188 case WebMediaPlayerClient::VideoTrackKindAlternative:
189 return VideoTrack::alternativeKeyword();
190 break;
191 case WebMediaPlayerClient::VideoTrackKindCaptions:
192 return VideoTrack::captionsKeyword();
193 break;
194 case WebMediaPlayerClient::VideoTrackKindMain:
195 return VideoTrack::mainKeyword();
196 break;
197 case WebMediaPlayerClient::VideoTrackKindSign:
198 return VideoTrack::signKeyword();
199 break;
200 case WebMediaPlayerClient::VideoTrackKindSubtitles:
201 return VideoTrack::subtitlesKeyword();
202 break;
203 case WebMediaPlayerClient::VideoTrackKindCommentary:
204 return VideoTrack::commentaryKeyword();
205 break;
206 }
207
208 ASSERT_NOT_REACHED();
209 return AtomicString();
210 }
211
212 void WebMediaPlayerClientImpl::addVideoTrack(const WebString& id, VideoTrackKind kind, const WebString& label, const WebString& language, bool selected)
213 {
214 m_client->mediaPlayerDidAddVideoTrack(id, VideoKindToString(kind), label, la nguage, selected);
215 }
216
217 void WebMediaPlayerClientImpl::removeVideoTrack(const WebString& id)
218 {
219 m_client->mediaPlayerDidRemoveVideoTrack(id);
220 }
221
222 static AtomicString AudioKindToString(WebMediaPlayerClient::AudioTrackKind kind)
223 {
224 switch (kind) {
225 case WebMediaPlayerClient::AudioTrackKindNone:
226 return AtomicString();
227 break;
228 case WebMediaPlayerClient::AudioTrackKindAlternative:
229 return AudioTrack::alternativeKeyword();
230 break;
231 case WebMediaPlayerClient::AudioTrackKindDescriptions:
232 return AudioTrack::descriptionsKeyword();
233 break;
234 case WebMediaPlayerClient::AudioTrackKindMain:
235 return AudioTrack::mainKeyword();
236 break;
237 case WebMediaPlayerClient::AudioTrackKindMainDescriptions:
238 return AudioTrack::mainDescriptionsKeyword();
239 break;
240 case WebMediaPlayerClient::AudioTrackKindTranslation:
241 return AudioTrack::translationKeyword();
242 break;
243 case WebMediaPlayerClient::AudioTrackKindCommentary:
244 return AudioTrack::commentaryKeyword();
245 break;
246 }
247
248 ASSERT_NOT_REACHED();
249 return AtomicString();
250 }
251
252 void WebMediaPlayerClientImpl::addAudioTrack(const WebString& id, AudioTrackKind kind, const WebString& label, const WebString& language, bool enabled)
253 {
254 m_client->mediaPlayerDidAddAudioTrack(id, AudioKindToString(kind), label, la nguage, enabled);
255 }
256
257 void WebMediaPlayerClientImpl::removeAudioTrack(const WebString& id)
258 {
259 m_client->mediaPlayerDidRemoveAudioTrack(id);
260 }
261
180 void WebMediaPlayerClientImpl::addTextTrack(WebInbandTextTrack* textTrack) 262 void WebMediaPlayerClientImpl::addTextTrack(WebInbandTextTrack* textTrack)
181 { 263 {
182 m_client->mediaPlayerDidAddTrack(textTrack); 264 m_client->mediaPlayerDidAddTextTrack(textTrack);
183 } 265 }
184 266
185 void WebMediaPlayerClientImpl::removeTextTrack(WebInbandTextTrack* textTrack) 267 void WebMediaPlayerClientImpl::removeTextTrack(WebInbandTextTrack* textTrack)
186 { 268 {
187 m_client->mediaPlayerDidRemoveTrack(textTrack); 269 m_client->mediaPlayerDidRemoveTextTrack(textTrack);
188 } 270 }
189 271
190 void WebMediaPlayerClientImpl::mediaSourceOpened(WebMediaSource* webMediaSource) 272 void WebMediaPlayerClientImpl::mediaSourceOpened(WebMediaSource* webMediaSource)
191 { 273 {
192 ASSERT(webMediaSource); 274 ASSERT(webMediaSource);
193 m_client->mediaPlayerMediaSourceOpened(webMediaSource); 275 m_client->mediaPlayerMediaSourceOpened(webMediaSource);
194 } 276 }
195 277
196 void WebMediaPlayerClientImpl::requestFullscreen() 278 void WebMediaPlayerClientImpl::requestFullscreen()
197 { 279 {
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 758
677 void WebMediaPlayerClientImpl::AudioClientImpl::setFormat(size_t numberOfChannel s, float sampleRate) 759 void WebMediaPlayerClientImpl::AudioClientImpl::setFormat(size_t numberOfChannel s, float sampleRate)
678 { 760 {
679 if (m_client) 761 if (m_client)
680 m_client->setFormat(numberOfChannels, sampleRate); 762 m_client->setFormat(numberOfChannels, sampleRate);
681 } 763 }
682 764
683 #endif 765 #endif
684 766
685 } // namespace blink 767 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698