[iOS] add missing QuickTime plug-in replacement API
[WebKit-https.git] / Source / WebCore / platform / graphics / MediaPlayer.cpp
1 /*
2  * Copyright (C) 2007-2014 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24  */
25
26 #include "config.h"
27
28 #if ENABLE(VIDEO)
29 #include "MediaPlayer.h"
30
31 #include "ContentType.h"
32 #include "Document.h"
33 #include "Frame.h"
34 #include "FrameView.h"
35 #include "IntRect.h"
36 #include "Logging.h"
37 #include "MIMETypeRegistry.h"
38 #include "MediaPlayerPrivate.h"
39 #include "PlatformTimeRanges.h"
40 #include "Settings.h"
41 #include <wtf/text/CString.h>
42
43 #if ENABLE(VIDEO_TRACK)
44 #include "InbandTextTrackPrivate.h"
45 #endif
46
47 #if ENABLE(MEDIA_SOURCE)
48 #include "MediaSourcePrivateClient.h"
49 #endif
50
51 #if USE(GSTREAMER)
52 #include "MediaPlayerPrivateGStreamer.h"
53 #define PlatformMediaEngineClassName MediaPlayerPrivateGStreamer
54 #endif
55
56 #if PLATFORM(COCOA)
57 #if PLATFORM(IOS)
58 #include "MediaPlayerPrivateIOS.h"
59 #else
60 #include "MediaPlayerPrivateQTKit.h"
61 #endif
62 #if USE(AVFOUNDATION)
63 #include "MediaPlayerPrivateAVFoundationObjC.h"
64 #if ENABLE(MEDIA_SOURCE)
65 #include "MediaPlayerPrivateMediaSourceAVFObjC.h"
66 #endif
67 #endif
68 #elif OS(WINCE)
69 #include "MediaPlayerPrivateWinCE.h"
70 #define PlatformMediaEngineClassName MediaPlayerPrivate
71 #elif PLATFORM(WIN) && !USE(GSTREAMER)
72 #if USE(AVFOUNDATION)
73 #include "MediaPlayerPrivateAVFoundationCF.h"
74 #endif // USE(AVFOUNDATION)
75 #endif
76
77 namespace WebCore {
78
79 const PlatformMedia NoPlatformMedia = { PlatformMedia::None, {0} };
80
81 // a null player to make MediaPlayer logic simpler
82
83 class NullMediaPlayerPrivate : public MediaPlayerPrivateInterface {
84 public:
85     NullMediaPlayerPrivate(MediaPlayer*) { }
86
87     virtual void load(const String&) { }
88 #if ENABLE(MEDIA_SOURCE)
89     virtual void load(const String&, MediaSourcePrivateClient*) { }
90 #endif
91     virtual void cancelLoad() { }
92
93     virtual void prepareToPlay() { }
94     virtual void play() { }
95     virtual void pause() { }    
96
97     virtual PlatformMedia platformMedia() const { return NoPlatformMedia; }
98     virtual PlatformLayer* platformLayer() const { return 0; }
99
100     virtual IntSize naturalSize() const { return IntSize(0, 0); }
101
102     virtual bool hasVideo() const { return false; }
103     virtual bool hasAudio() const { return false; }
104
105     virtual void setVisible(bool) { }
106
107     virtual double durationDouble() const { return 0; }
108
109     virtual double currentTimeDouble() const { return 0; }
110     virtual void seekDouble(double) { }
111     virtual bool seeking() const { return false; }
112
113     virtual void setRateDouble(double) { }
114     virtual void setPreservesPitch(bool) { }
115     virtual bool paused() const { return false; }
116
117     virtual void setVolumeDouble(double) { }
118
119     virtual bool supportsMuting() const { return false; }
120     virtual void setMuted(bool) { }
121
122     virtual bool hasClosedCaptions() const { return false; }
123     virtual void setClosedCaptionsVisible(bool) { };
124
125     virtual MediaPlayer::NetworkState networkState() const { return MediaPlayer::Empty; }
126     virtual MediaPlayer::ReadyState readyState() const { return MediaPlayer::HaveNothing; }
127
128     virtual double maxTimeSeekableDouble() const { return 0; }
129     virtual double minTimeSeekable() const { return 0; }
130     virtual std::unique_ptr<PlatformTimeRanges> buffered() const { return PlatformTimeRanges::create(); }
131
132     virtual unsigned totalBytes() const { return 0; }
133     virtual bool didLoadingProgress() const { return false; }
134
135     virtual void setSize(const IntSize&) { }
136
137     virtual void paint(GraphicsContext*, const IntRect&) { }
138
139     virtual bool canLoadPoster() const { return false; }
140     virtual void setPoster(const String&) { }
141
142 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
143     virtual void deliverNotification(MediaPlayerProxyNotificationType) { }
144     virtual void setMediaPlayerProxy(WebMediaPlayerProxy*) { }
145     virtual void setControls(bool) { }
146 #endif
147
148     virtual bool hasSingleSecurityOrigin() const { return true; }
149
150 #if ENABLE(ENCRYPTED_MEDIA)
151     virtual MediaPlayer::MediaKeyException generateKeyRequest(const String&, const unsigned char*, unsigned) override { return MediaPlayer::InvalidPlayerState; }
152     virtual MediaPlayer::MediaKeyException addKey(const String&, const unsigned char*, unsigned, const unsigned char*, unsigned, const String&) override { return MediaPlayer::InvalidPlayerState; }
153     virtual MediaPlayer::MediaKeyException cancelKeyRequest(const String&, const String&) override { return MediaPlayer::InvalidPlayerState; }
154 #endif
155 };
156
157 static PassOwnPtr<MediaPlayerPrivateInterface> createNullMediaPlayer(MediaPlayer* player) 
158
159     return adoptPtr(new NullMediaPlayerPrivate(player)); 
160 }
161
162
163 // engine support
164
165 struct MediaPlayerFactory {
166     WTF_MAKE_NONCOPYABLE(MediaPlayerFactory); WTF_MAKE_FAST_ALLOCATED;
167 public:
168     MediaPlayerFactory(CreateMediaEnginePlayer constructor, MediaEngineSupportedTypes getSupportedTypes, MediaEngineSupportsType supportsTypeAndCodecs,
169         MediaEngineGetSitesInMediaCache getSitesInMediaCache, MediaEngineClearMediaCache clearMediaCache, MediaEngineClearMediaCacheForSite clearMediaCacheForSite, MediaEngineSupportsKeySystem supportsKeySystem)
170         : constructor(constructor)
171         , getSupportedTypes(getSupportedTypes)
172         , supportsTypeAndCodecs(supportsTypeAndCodecs)
173         , getSitesInMediaCache(getSitesInMediaCache)
174         , clearMediaCache(clearMediaCache)
175         , clearMediaCacheForSite(clearMediaCacheForSite)
176         , supportsKeySystem(supportsKeySystem)
177     {
178     }
179
180     CreateMediaEnginePlayer constructor;
181     MediaEngineSupportedTypes getSupportedTypes;
182     MediaEngineSupportsType supportsTypeAndCodecs;
183     MediaEngineGetSitesInMediaCache getSitesInMediaCache;
184     MediaEngineClearMediaCache clearMediaCache;
185     MediaEngineClearMediaCacheForSite clearMediaCacheForSite;
186     MediaEngineSupportsKeySystem supportsKeySystem;
187 };
188
189 static void addMediaEngine(CreateMediaEnginePlayer, MediaEngineSupportedTypes, MediaEngineSupportsType, MediaEngineGetSitesInMediaCache, MediaEngineClearMediaCache, MediaEngineClearMediaCacheForSite, MediaEngineSupportsKeySystem);
190
191 static MediaPlayerFactory* bestMediaEngineForSupportParameters(const MediaEngineSupportParameters&, MediaPlayerFactory* current = 0);
192 static MediaPlayerFactory* nextMediaEngine(MediaPlayerFactory* current);
193
194 enum RequeryEngineOptions { DoNotResetEngines, ResetEngines };
195 static Vector<MediaPlayerFactory*>& installedMediaEngines(RequeryEngineOptions requeryFlags = DoNotResetEngines )
196 {
197     DEPRECATED_DEFINE_STATIC_LOCAL(Vector<MediaPlayerFactory*>, installedEngines, ());
198     static bool enginesQueried = false;
199
200     if (requeryFlags == ResetEngines) {
201         installedEngines.clear();
202         enginesQueried = false;
203         return installedEngines;
204     }
205
206     if (enginesQueried)
207         return installedEngines;
208
209     enginesQueried = true;
210
211 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
212     if (Settings::isVideoPluginProxyEnabled())
213         MediaPlayerPrivateIOS::registerMediaEngine(addMediaEngine);
214 #endif
215
216 #if USE(AVFOUNDATION)
217     if (Settings::isAVFoundationEnabled()) {
218 #if PLATFORM(COCOA)
219         MediaPlayerPrivateAVFoundationObjC::registerMediaEngine(addMediaEngine);
220 #if ENABLE(MEDIA_SOURCE)
221         MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine(addMediaEngine);
222 #endif
223 #elif PLATFORM(WIN)
224         MediaPlayerPrivateAVFoundationCF::registerMediaEngine(addMediaEngine);
225 #endif
226     }
227 #endif
228
229 #if PLATFORM(MAC)
230     if (Settings::isQTKitEnabled())
231         MediaPlayerPrivateQTKit::registerMediaEngine(addMediaEngine);
232 #endif
233
234 #if defined(PlatformMediaEngineClassName)
235     PlatformMediaEngineClassName::registerMediaEngine(addMediaEngine);
236 #endif
237
238     return installedEngines;
239 }
240
241 static void addMediaEngine(CreateMediaEnginePlayer constructor, MediaEngineSupportedTypes getSupportedTypes, MediaEngineSupportsType supportsType,
242     MediaEngineGetSitesInMediaCache getSitesInMediaCache, MediaEngineClearMediaCache clearMediaCache, MediaEngineClearMediaCacheForSite clearMediaCacheForSite, MediaEngineSupportsKeySystem supportsKeySystem)
243 {
244     ASSERT(constructor);
245     ASSERT(getSupportedTypes);
246     ASSERT(supportsType);
247
248     installedMediaEngines().append(new MediaPlayerFactory(constructor, getSupportedTypes, supportsType, getSitesInMediaCache, clearMediaCache, clearMediaCacheForSite, supportsKeySystem));
249 }
250
251 static const AtomicString& applicationOctetStream()
252 {
253     DEPRECATED_DEFINE_STATIC_LOCAL(const AtomicString, applicationOctetStream, ("application/octet-stream", AtomicString::ConstructFromLiteral));
254     return applicationOctetStream;
255 }
256
257 static const AtomicString& textPlain()
258 {
259     DEPRECATED_DEFINE_STATIC_LOCAL(const AtomicString, textPlain, ("text/plain", AtomicString::ConstructFromLiteral));
260     return textPlain;
261 }
262
263 static const AtomicString& codecs()
264 {
265     DEPRECATED_DEFINE_STATIC_LOCAL(const AtomicString, codecs, ("codecs", AtomicString::ConstructFromLiteral));
266     return codecs;
267 }
268
269 static MediaPlayerFactory* bestMediaEngineForSupportParameters(const MediaEngineSupportParameters& parameters, MediaPlayerFactory* current)
270 {
271     if (parameters.type.isEmpty())
272         return 0;
273
274     Vector<MediaPlayerFactory*>& engines = installedMediaEngines();
275     if (engines.isEmpty())
276         return 0;
277
278     // 4.8.10.3 MIME types - In the absence of a specification to the contrary, the MIME type "application/octet-stream" 
279     // when used with parameters, e.g. "application/octet-stream;codecs=theora", is a type that the user agent knows 
280     // it cannot render.
281     if (parameters.type == applicationOctetStream()) {
282         if (!parameters.codecs.isEmpty())
283             return 0;
284     }
285
286     MediaPlayerFactory* engine = 0;
287     MediaPlayer::SupportsType supported = MediaPlayer::IsNotSupported;
288     unsigned count = engines.size();
289     for (unsigned ndx = 0; ndx < count; ndx++) {
290         if (current) {
291             if (current == engines[ndx])
292                 current = 0;
293             continue;
294         }
295         MediaPlayer::SupportsType engineSupport = engines[ndx]->supportsTypeAndCodecs(parameters);
296         if (engineSupport > supported) {
297             supported = engineSupport;
298             engine = engines[ndx];
299         }
300     }
301
302     return engine;
303 }
304
305 static MediaPlayerFactory* nextMediaEngine(MediaPlayerFactory* current)
306 {
307     Vector<MediaPlayerFactory*>& engines = installedMediaEngines();
308     if (engines.isEmpty())
309         return 0;
310
311     if (!current) 
312         return engines.first();
313
314     size_t currentIndex = engines.find(current);
315     if (currentIndex == WTF::notFound || currentIndex + 1 >= engines.size()) 
316         return 0;
317
318     return engines[currentIndex + 1];
319 }
320
321 // media player
322
323 MediaPlayer::MediaPlayer(MediaPlayerClient* client)
324     : m_mediaPlayerClient(client)
325     , m_reloadTimer(this, &MediaPlayer::reloadTimerFired)
326     , m_private(createNullMediaPlayer(this))
327     , m_currentMediaEngine(0)
328     , m_frameView(0)
329     , m_preload(Auto)
330     , m_visible(false)
331     , m_rate(1.0f)
332     , m_volume(1.0f)
333     , m_muted(false)
334     , m_preservesPitch(true)
335     , m_privateBrowsing(false)
336     , m_shouldPrepareToRender(false)
337     , m_contentMIMETypeWasInferredFromExtension(false)
338 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
339     , m_playerProxy(0)
340 #endif
341 {
342 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
343     Vector<MediaPlayerFactory*>& engines = installedMediaEngines();
344     if (Settings::isVideoPluginProxyEnabled() && !engines.isEmpty()) {
345         m_currentMediaEngine = engines[0];
346         m_private = engines[0]->constructor(this);
347         if (m_mediaPlayerClient)
348             m_mediaPlayerClient->mediaPlayerEngineUpdated(this);
349     }
350 #endif
351 }
352
353 MediaPlayer::~MediaPlayer()
354 {
355     m_mediaPlayerClient = 0;
356 }
357
358 bool MediaPlayer::load(const URL& url, const ContentType& contentType, const String& keySystem)
359 {
360     m_contentMIMEType = contentType.type().lower();
361     m_contentTypeCodecs = contentType.parameter(codecs());
362     m_url = url;
363     m_keySystem = keySystem.lower();
364     m_contentMIMETypeWasInferredFromExtension = false;
365
366 #if ENABLE(MEDIA_SOURCE)
367     m_mediaSource = 0;
368 #endif
369
370     // If the MIME type is missing or is not meaningful, try to figure it out from the URL.
371     if (m_contentMIMEType.isEmpty() || m_contentMIMEType == applicationOctetStream() || m_contentMIMEType == textPlain()) {
372         if (m_url.protocolIsData())
373             m_contentMIMEType = mimeTypeFromDataURL(m_url.string());
374         else {
375             String lastPathComponent = url.lastPathComponent();
376             size_t pos = lastPathComponent.reverseFind('.');
377             if (pos != notFound) {
378                 String extension = lastPathComponent.substring(pos + 1);
379                 String mediaType = MIMETypeRegistry::getMediaMIMETypeForExtension(extension);
380                 if (!mediaType.isEmpty()) {
381                     m_contentMIMEType = mediaType;
382                     m_contentMIMETypeWasInferredFromExtension = true;
383                 }
384             }
385         }
386     }
387
388     loadWithNextMediaEngine(0);
389     return m_currentMediaEngine;
390 }
391
392 #if ENABLE(MEDIA_SOURCE)
393 bool MediaPlayer::load(const URL& url, const ContentType& contentType, MediaSourcePrivateClient* mediaSource)
394 {
395     ASSERT(mediaSource);
396     m_mediaSource = mediaSource;
397     m_contentMIMEType = contentType.type().lower();
398     m_contentTypeCodecs = contentType.parameter(codecs());
399     m_url = url;
400     m_keySystem = "";
401     m_contentMIMETypeWasInferredFromExtension = false;
402     loadWithNextMediaEngine(0);
403     return m_currentMediaEngine;
404 }
405 #endif
406
407 MediaPlayerFactory* MediaPlayer::nextBestMediaEngine(MediaPlayerFactory* current) const
408 {
409     MediaEngineSupportParameters parameters;
410     parameters.type = m_contentMIMEType;
411     parameters.codecs = m_contentTypeCodecs;
412     parameters.url = m_url;
413 #if ENABLE(ENCRYPTED_MEDIA)
414     parameters.keySystem = m_keySystem;
415 #endif
416 #if ENABLE(MEDIA_SOURCE)
417     parameters.isMediaSource = !!m_mediaSource;
418 #endif
419
420     return bestMediaEngineForSupportParameters(parameters, current);
421 }
422
423 void MediaPlayer::loadWithNextMediaEngine(MediaPlayerFactory* current)
424 {
425     MediaPlayerFactory* engine = 0;
426
427     if (!m_contentMIMEType.isEmpty())
428         engine = nextBestMediaEngine(current);
429
430     // If no MIME type is specified or the type was inferred from the file extension, just use the next engine.
431     if (!engine && (m_contentMIMEType.isEmpty() || m_contentMIMETypeWasInferredFromExtension))
432         engine = nextMediaEngine(current);
433
434     // Don't delete and recreate the player unless it comes from a different engine.
435     if (!engine) {
436         LOG(Media, "MediaPlayer::loadWithNextMediaEngine - no media engine found for type \"%s\"", m_contentMIMEType.utf8().data());
437         m_currentMediaEngine = engine;
438         m_private = nullptr;
439     } else if (m_currentMediaEngine != engine) {
440         m_currentMediaEngine = engine;
441         m_private = engine->constructor(this);
442         if (m_mediaPlayerClient)
443             m_mediaPlayerClient->mediaPlayerEngineUpdated(this);
444 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
445         m_private->setMediaPlayerProxy(m_playerProxy);
446 #endif
447         m_private->setPrivateBrowsingMode(m_privateBrowsing);
448         m_private->setPreload(m_preload);
449         m_private->setPreservesPitch(preservesPitch());
450         if (m_shouldPrepareToRender)
451             m_private->prepareForRendering();
452     }
453
454     if (m_private) {
455 #if ENABLE(MEDIA_SOURCE)
456         if (m_mediaSource)
457             m_private->load(m_url.string(), m_mediaSource.get());
458         else
459 #endif
460         m_private->load(m_url.string());
461     } else {
462         m_private = createNullMediaPlayer(this);
463         if (m_mediaPlayerClient) {
464             m_mediaPlayerClient->mediaPlayerEngineUpdated(this);
465             m_mediaPlayerClient->mediaPlayerResourceNotSupported(this);
466         }
467     }
468 }
469
470 bool MediaPlayer::hasAvailableVideoFrame() const
471 {
472     return m_private->hasAvailableVideoFrame();
473 }
474
475 void MediaPlayer::prepareForRendering()
476 {
477     m_shouldPrepareToRender = true;
478     m_private->prepareForRendering();
479 }
480
481 bool MediaPlayer::canLoadPoster() const
482 {
483     return m_private->canLoadPoster();
484 }
485
486 void MediaPlayer::setPoster(const String& url)
487 {
488     m_private->setPoster(url);
489 }    
490
491 void MediaPlayer::cancelLoad()
492 {
493     m_private->cancelLoad();
494 }    
495
496 void MediaPlayer::prepareToPlay()
497 {
498     m_private->prepareToPlay();
499 }
500
501 void MediaPlayer::play()
502 {
503     m_private->play();
504 }
505
506 void MediaPlayer::pause()
507 {
508     m_private->pause();
509 }
510
511 #if ENABLE(ENCRYPTED_MEDIA)
512 MediaPlayer::MediaKeyException MediaPlayer::generateKeyRequest(const String& keySystem, const unsigned char* initData, unsigned initDataLength)
513 {
514     return m_private->generateKeyRequest(keySystem.lower(), initData, initDataLength);
515 }
516
517 MediaPlayer::MediaKeyException MediaPlayer::addKey(const String& keySystem, const unsigned char* key, unsigned keyLength, const unsigned char* initData, unsigned initDataLength, const String& sessionId)
518 {
519     return m_private->addKey(keySystem.lower(), key, keyLength, initData, initDataLength, sessionId);
520 }
521
522 MediaPlayer::MediaKeyException MediaPlayer::cancelKeyRequest(const String& keySystem, const String& sessionId)
523 {
524     return m_private->cancelKeyRequest(keySystem.lower(), sessionId);
525 }
526 #endif
527
528 #if ENABLE(ENCRYPTED_MEDIA_V2)
529 std::unique_ptr<CDMSession> MediaPlayer::createSession(const String& keySystem)
530 {
531     return m_private->createSession(keySystem);
532 }
533 #endif
534     
535 double MediaPlayer::duration() const
536 {
537     return m_private->durationDouble();
538 }
539
540 double MediaPlayer::startTime() const
541 {
542     return m_private->startTimeDouble();
543 }
544
545 double MediaPlayer::initialTime() const
546 {
547     return m_private->initialTime();
548 }
549
550 double MediaPlayer::currentTime() const
551 {
552     return m_private->currentTimeDouble();
553 }
554
555 void MediaPlayer::seekWithTolerance(double time, double negativeTolerance, double positiveTolerance)
556 {
557     m_private->seekWithTolerance(time, negativeTolerance, positiveTolerance);
558 }
559
560 void MediaPlayer::seek(double time)
561 {
562     m_private->seekDouble(time);
563 }
564
565 bool MediaPlayer::paused() const
566 {
567     return m_private->paused();
568 }
569
570 bool MediaPlayer::seeking() const
571 {
572     return m_private->seeking();
573 }
574
575 bool MediaPlayer::supportsFullscreen() const
576 {
577     return m_private->supportsFullscreen();
578 }
579
580 bool MediaPlayer::supportsSave() const
581 {
582     return m_private->supportsSave();
583 }
584
585 bool MediaPlayer::supportsScanning() const
586 {
587     return m_private->supportsScanning();
588 }
589
590 bool MediaPlayer::requiresImmediateCompositing() const
591 {
592     return m_private->requiresImmediateCompositing();
593 }
594
595 IntSize MediaPlayer::naturalSize()
596 {
597     return m_private->naturalSize();
598 }
599
600 bool MediaPlayer::hasVideo() const
601 {
602     return m_private->hasVideo();
603 }
604
605 bool MediaPlayer::hasAudio() const
606 {
607     return m_private->hasAudio();
608 }
609
610 bool MediaPlayer::inMediaDocument()
611 {
612     if (!m_frameView)
613         return false;
614     Document* document = m_frameView->frame().document();
615     return document && document->isMediaDocument();
616 }
617
618 PlatformMedia MediaPlayer::platformMedia() const
619 {
620     return m_private->platformMedia();
621 }
622
623 PlatformLayer* MediaPlayer::platformLayer() const
624 {
625     return m_private->platformLayer();
626 }
627     
628 #if PLATFORM(IOS)
629 void MediaPlayer::setVideoFullscreenLayer(PlatformLayer* layer)
630 {
631     m_private->setVideoFullscreenLayer(layer);
632 }
633
634 void MediaPlayer::setVideoFullscreenFrame(FloatRect frame)
635 {
636     m_private->setVideoFullscreenFrame(frame);
637 }
638
639 void MediaPlayer::setVideoFullscreenGravity(MediaPlayer::VideoGravity gravity)
640 {
641     m_private->setVideoFullscreenGravity(gravity);
642 }
643
644 NSArray* MediaPlayer::timedMetadata() const
645 {
646     return m_private->timedMetadata();
647 }
648
649 String MediaPlayer::accessLog() const
650 {
651     return m_private->accessLog();
652 }
653
654 String MediaPlayer::errorLog() const
655 {
656     return m_private->errorLog();
657 }
658 #endif
659
660 MediaPlayer::NetworkState MediaPlayer::networkState()
661 {
662     return m_private->networkState();
663 }
664
665 MediaPlayer::ReadyState MediaPlayer::readyState()
666 {
667     return m_private->readyState();
668 }
669
670 double MediaPlayer::volume() const
671 {
672     return m_volume;
673 }
674
675 void MediaPlayer::setVolume(double volume)
676 {
677     m_volume = volume;
678
679     if (m_private->supportsMuting() || !m_muted)
680         m_private->setVolumeDouble(volume);
681 }
682
683 bool MediaPlayer::muted() const
684 {
685     return m_muted;
686 }
687
688 void MediaPlayer::setMuted(bool muted)
689 {
690     m_muted = muted;
691
692     if (m_private->supportsMuting())
693         m_private->setMuted(muted);
694     else
695         m_private->setVolume(muted ? 0 : m_volume);
696 }
697
698 bool MediaPlayer::hasClosedCaptions() const
699 {
700     return m_private->hasClosedCaptions();
701 }
702
703 void MediaPlayer::setClosedCaptionsVisible(bool closedCaptionsVisible)
704 {
705     m_private->setClosedCaptionsVisible(closedCaptionsVisible);
706 }
707
708 double MediaPlayer::rate() const
709 {
710     return m_rate;
711 }
712
713 void MediaPlayer::setRate(double rate)
714 {
715     m_rate = rate;
716     m_private->setRateDouble(rate);
717 }
718
719 bool MediaPlayer::preservesPitch() const
720 {
721     return m_preservesPitch;
722 }
723
724 void MediaPlayer::setPreservesPitch(bool preservesPitch)
725 {
726     m_preservesPitch = preservesPitch;
727     m_private->setPreservesPitch(preservesPitch);
728 }
729
730 std::unique_ptr<PlatformTimeRanges> MediaPlayer::buffered()
731 {
732     return m_private->buffered();
733 }
734
735 std::unique_ptr<PlatformTimeRanges> MediaPlayer::seekable()
736 {
737     return m_private->seekable();
738 }
739
740 double MediaPlayer::maxTimeSeekable()
741 {
742     return m_private->maxTimeSeekableDouble();
743 }
744
745 double MediaPlayer::minTimeSeekable()
746 {
747     return m_private->minTimeSeekable();
748 }
749
750 bool MediaPlayer::didLoadingProgress()
751 {
752     return m_private->didLoadingProgress();
753 }
754
755 void MediaPlayer::setSize(const IntSize& size)
756
757     m_size = size;
758     m_private->setSize(size);
759 }
760
761 bool MediaPlayer::visible() const
762 {
763     return m_visible;
764 }
765
766 void MediaPlayer::setVisible(bool b)
767 {
768     m_visible = b;
769     m_private->setVisible(b);
770 }
771
772 MediaPlayer::Preload MediaPlayer::preload() const
773 {
774     return m_preload;
775 }
776
777 void MediaPlayer::setPreload(MediaPlayer::Preload preload)
778 {
779     m_preload = preload;
780     m_private->setPreload(preload);
781 }
782
783 void MediaPlayer::paint(GraphicsContext* p, const IntRect& r)
784 {
785     m_private->paint(p, r);
786 }
787
788 void MediaPlayer::paintCurrentFrameInContext(GraphicsContext* p, const IntRect& r)
789 {
790     m_private->paintCurrentFrameInContext(p, r);
791 }
792
793 bool MediaPlayer::copyVideoTextureToPlatformTexture(GraphicsContext3D* context, Platform3DObject texture, GC3Dint level, GC3Denum type, GC3Denum internalFormat, bool premultiplyAlpha, bool flipY)
794 {
795     return m_private->copyVideoTextureToPlatformTexture(context, texture, level, type, internalFormat, premultiplyAlpha, flipY);
796 }
797
798 PassNativeImagePtr MediaPlayer::nativeImageForCurrentTime()
799 {
800     return m_private->nativeImageForCurrentTime();
801 }
802
803 MediaPlayer::SupportsType MediaPlayer::supportsType(const MediaEngineSupportParameters& parameters, const MediaPlayerSupportsTypeClient* client)
804 {
805     // 4.8.10.3 MIME types - The canPlayType(type) method must return the empty string if type is a type that the 
806     // user agent knows it cannot render or is the type "application/octet-stream"
807     if (parameters.type == applicationOctetStream())
808         return IsNotSupported;
809
810     MediaPlayerFactory* engine = bestMediaEngineForSupportParameters(parameters);
811     if (!engine)
812         return IsNotSupported;
813
814 #if PLATFORM(COCOA)
815     // YouTube will ask if the HTMLMediaElement canPlayType video/webm, then
816     // video/x-flv, then finally video/mp4, and will then load a URL of the first type
817     // in that list which returns "probably". When Perian is installed,
818     // MediaPlayerPrivateQTKit claims to support both video/webm and video/x-flv, but
819     // due to a bug in Perian, loading media in these formats will sometimes fail on
820     // slow connections. <https://bugs.webkit.org/show_bug.cgi?id=86409>
821     if (client && client->mediaPlayerNeedsSiteSpecificHacks()) {
822         String host = client->mediaPlayerDocumentHost();
823         if ((host.endsWith(".youtube.com", false) || equalIgnoringCase("youtube.com", host))
824             && (parameters.type.startsWith("video/webm", false) || parameters.type.startsWith("video/x-flv", false)))
825             return IsNotSupported;
826     }
827 #else
828     UNUSED_PARAM(client);
829 #endif
830
831     return engine->supportsTypeAndCodecs(parameters);
832 }
833
834 void MediaPlayer::getSupportedTypes(HashSet<String>& types)
835 {
836     Vector<MediaPlayerFactory*>& engines = installedMediaEngines();
837     if (engines.isEmpty())
838         return;
839
840     unsigned count = engines.size();
841     for (unsigned ndx = 0; ndx < count; ndx++)
842         engines[ndx]->getSupportedTypes(types);
843
844
845 bool MediaPlayer::isAvailable()
846 {
847     return !installedMediaEngines().isEmpty();
848
849
850 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
851 void MediaPlayer::deliverNotification(MediaPlayerProxyNotificationType notification)
852 {
853     m_private->deliverNotification(notification);
854 }
855
856 void MediaPlayer::setMediaPlayerProxy(WebMediaPlayerProxy* proxy)
857 {
858     m_playerProxy = proxy;
859     m_private->setMediaPlayerProxy(proxy);
860 }
861
862 void MediaPlayer::setControls(bool controls)
863 {
864     m_private->setControls(controls);
865 }
866 #endif
867
868 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) || USE(NATIVE_FULLSCREEN_VIDEO)
869 void MediaPlayer::enterFullscreen()
870 {
871     m_private->enterFullscreen();
872 }
873
874 void MediaPlayer::exitFullscreen()
875 {
876     m_private->exitFullscreen();
877 }
878 #endif
879
880 #if ENABLE(IOS_AIRPLAY)
881 bool MediaPlayer::isCurrentPlaybackTargetWireless() const
882 {
883     return m_private->isCurrentPlaybackTargetWireless();
884 }
885
886 String MediaPlayer::wirelessPlaybackTargetName() const
887 {
888     return m_private->wirelessPlaybackTargetName();
889 }
890
891 MediaPlayer::WirelessPlaybackTargetType MediaPlayer::wirelessPlaybackTargetType() const
892 {
893     return m_private->wirelessPlaybackTargetType();
894 }
895
896 void MediaPlayer::showPlaybackTargetPicker()
897 {
898     m_private->showPlaybackTargetPicker();
899 }
900
901 bool MediaPlayer::hasWirelessPlaybackTargets() const
902 {
903     return m_private->hasWirelessPlaybackTargets();
904 }
905
906 bool MediaPlayer::wirelessVideoPlaybackDisabled() const
907 {
908     return m_private->wirelessVideoPlaybackDisabled();
909 }
910
911 void MediaPlayer::setWirelessVideoPlaybackDisabled(bool disabled)
912 {
913     m_private->setWirelessVideoPlaybackDisabled(disabled);
914 }
915
916 void MediaPlayer::setHasPlaybackTargetAvailabilityListeners(bool hasListeners)
917 {
918     m_private->setHasPlaybackTargetAvailabilityListeners(hasListeners);
919 }
920
921 void MediaPlayer::currentPlaybackTargetIsWirelessChanged()
922 {
923     if (m_mediaPlayerClient)
924         m_mediaPlayerClient->mediaPlayerCurrentPlaybackTargetIsWirelessChanged(this);
925 }
926
927 void MediaPlayer::playbackTargetAvailabilityChanged()
928 {
929     if (m_mediaPlayerClient)
930         m_mediaPlayerClient->mediaPlayerPlaybackTargetAvailabilityChanged(this);
931 }
932 #endif
933
934 #if USE(NATIVE_FULLSCREEN_VIDEO)
935 bool MediaPlayer::canEnterFullscreen() const
936 {
937     return m_private->canEnterFullscreen();
938 }
939 #endif
940
941 void MediaPlayer::acceleratedRenderingStateChanged()
942 {
943     m_private->acceleratedRenderingStateChanged();
944 }
945
946 bool MediaPlayer::supportsAcceleratedRendering() const
947 {
948     return m_private->supportsAcceleratedRendering();
949 }
950
951 bool MediaPlayer::shouldMaintainAspectRatio() const
952 {
953     return m_private->shouldMaintainAspectRatio();
954 }
955
956 void MediaPlayer::setShouldMaintainAspectRatio(bool maintainAspectRatio)
957 {
958     m_private->setShouldMaintainAspectRatio(maintainAspectRatio);
959 }
960
961 bool MediaPlayer::hasSingleSecurityOrigin() const
962 {
963     return m_private->hasSingleSecurityOrigin();
964 }
965
966 bool MediaPlayer::didPassCORSAccessCheck() const
967 {
968     return m_private->didPassCORSAccessCheck();
969 }
970
971 MediaPlayer::MovieLoadType MediaPlayer::movieLoadType() const
972 {
973     return m_private->movieLoadType();
974 }
975
976 double MediaPlayer::mediaTimeForTimeValue(double timeValue) const
977 {
978     return m_private->mediaTimeForTimeValueDouble(timeValue);
979 }
980
981 double MediaPlayer::maximumDurationToCacheMediaTime() const
982 {
983     return m_private->maximumDurationToCacheMediaTime();
984 }
985
986 unsigned MediaPlayer::decodedFrameCount() const
987 {
988     return m_private->decodedFrameCount();
989 }
990
991 unsigned MediaPlayer::droppedFrameCount() const
992 {
993     return m_private->droppedFrameCount();
994 }
995
996 unsigned MediaPlayer::audioDecodedByteCount() const
997 {
998     return m_private->audioDecodedByteCount();
999 }
1000
1001 unsigned MediaPlayer::videoDecodedByteCount() const
1002 {
1003     return m_private->videoDecodedByteCount();
1004 }
1005
1006 void MediaPlayer::reloadTimerFired(Timer<MediaPlayer>&)
1007 {
1008     m_private->cancelLoad();
1009     loadWithNextMediaEngine(m_currentMediaEngine);
1010 }
1011
1012 void MediaPlayer::getSitesInMediaCache(Vector<String>& sites)
1013 {
1014     Vector<MediaPlayerFactory*>& engines = installedMediaEngines();
1015     unsigned size = engines.size();
1016     for (unsigned i = 0; i < size; i++) {
1017         if (!engines[i]->getSitesInMediaCache)
1018             continue;
1019         Vector<String> engineSites;
1020         engines[i]->getSitesInMediaCache(engineSites);
1021         sites.appendVector(engineSites);
1022     }
1023 }
1024
1025 void MediaPlayer::clearMediaCache()
1026 {
1027     Vector<MediaPlayerFactory*>& engines = installedMediaEngines();
1028     unsigned size = engines.size();
1029     for (unsigned i = 0; i < size; i++) {
1030         if (engines[i]->clearMediaCache)
1031             engines[i]->clearMediaCache();
1032     }
1033 }
1034
1035 void MediaPlayer::clearMediaCacheForSite(const String& site)
1036 {
1037     Vector<MediaPlayerFactory*>& engines = installedMediaEngines();
1038     unsigned size = engines.size();
1039     for (unsigned i = 0; i < size; i++) {
1040         if (engines[i]->clearMediaCacheForSite)
1041             engines[i]->clearMediaCacheForSite(site);
1042     }
1043 }
1044
1045 bool MediaPlayer::supportsKeySystem(const String& keySystem, const String& mimeType)
1046 {
1047     for (auto& engine : installedMediaEngines()) {
1048         if (engine->supportsKeySystem && engine->supportsKeySystem(keySystem, mimeType))
1049             return true;
1050     }
1051     return false;
1052 }
1053
1054 void MediaPlayer::setPrivateBrowsingMode(bool privateBrowsingMode)
1055 {
1056     m_privateBrowsing = privateBrowsingMode;
1057     m_private->setPrivateBrowsingMode(m_privateBrowsing);
1058 }
1059
1060 #if PLATFORM(IOS)
1061 void MediaPlayer::attributeChanged(const String& name, const String& value) 
1062 {
1063     m_private->attributeChanged(name, value);
1064 }
1065
1066 bool MediaPlayer::readyForPlayback() const
1067 {
1068     return m_private->readyForPlayback();
1069 }
1070 #endif
1071
1072 // Client callbacks.
1073 void MediaPlayer::networkStateChanged()
1074 {
1075     // If more than one media engine is installed and this one failed before finding metadata,
1076     // let the next engine try.
1077     if (m_private->networkState() >= FormatError
1078         && m_private->readyState() < HaveMetadata
1079         && installedMediaEngines().size() > 1) {
1080         if (m_contentMIMEType.isEmpty() || nextBestMediaEngine(m_currentMediaEngine)) {
1081             m_reloadTimer.startOneShot(0);
1082             return;
1083         }
1084     }
1085     if (m_mediaPlayerClient)
1086         m_mediaPlayerClient->mediaPlayerNetworkStateChanged(this);
1087 }
1088
1089 void MediaPlayer::readyStateChanged()
1090 {
1091     if (m_mediaPlayerClient)
1092         m_mediaPlayerClient->mediaPlayerReadyStateChanged(this);
1093 }
1094
1095 void MediaPlayer::volumeChanged(double newVolume)
1096 {
1097 #if PLATFORM(IOS)
1098     UNUSED_PARAM(newVolume);
1099     m_volume = m_private->volume();
1100 #else
1101     m_volume = newVolume;
1102 #endif
1103     if (m_mediaPlayerClient)
1104         m_mediaPlayerClient->mediaPlayerVolumeChanged(this);
1105 }
1106
1107 void MediaPlayer::muteChanged(bool newMuted)
1108 {
1109     m_muted = newMuted;
1110     if (m_mediaPlayerClient)
1111         m_mediaPlayerClient->mediaPlayerMuteChanged(this);
1112 }
1113
1114 void MediaPlayer::timeChanged()
1115 {
1116     if (m_mediaPlayerClient)
1117         m_mediaPlayerClient->mediaPlayerTimeChanged(this);
1118 }
1119
1120 void MediaPlayer::sizeChanged()
1121 {
1122     if (m_mediaPlayerClient)
1123         m_mediaPlayerClient->mediaPlayerSizeChanged(this);
1124 }
1125
1126 void MediaPlayer::repaint()
1127 {
1128     if (m_mediaPlayerClient)
1129         m_mediaPlayerClient->mediaPlayerRepaint(this);
1130 }
1131
1132 void MediaPlayer::durationChanged()
1133 {
1134     if (m_mediaPlayerClient)
1135         m_mediaPlayerClient->mediaPlayerDurationChanged(this);
1136 }
1137
1138 void MediaPlayer::rateChanged()
1139 {
1140     if (m_mediaPlayerClient)
1141         m_mediaPlayerClient->mediaPlayerRateChanged(this);
1142 }
1143
1144 void MediaPlayer::playbackStateChanged()
1145 {
1146     if (m_mediaPlayerClient)
1147         m_mediaPlayerClient->mediaPlayerPlaybackStateChanged(this);
1148 }
1149
1150 void MediaPlayer::firstVideoFrameAvailable()
1151 {
1152     if (m_mediaPlayerClient)
1153         m_mediaPlayerClient->mediaPlayerFirstVideoFrameAvailable(this);
1154 }
1155
1156 void MediaPlayer::characteristicChanged()
1157 {
1158     if (m_mediaPlayerClient)
1159         m_mediaPlayerClient->mediaPlayerCharacteristicChanged(this);
1160 }
1161
1162 #if ENABLE(WEB_AUDIO)
1163 AudioSourceProvider* MediaPlayer::audioSourceProvider()
1164 {
1165     return m_private->audioSourceProvider();
1166 }
1167 #endif // WEB_AUDIO
1168
1169 #if ENABLE(ENCRYPTED_MEDIA)
1170 void MediaPlayer::keyAdded(const String& keySystem, const String& sessionId)
1171 {
1172     if (m_mediaPlayerClient)
1173         m_mediaPlayerClient->mediaPlayerKeyAdded(this, keySystem, sessionId);
1174 }
1175
1176 void MediaPlayer::keyError(const String& keySystem, const String& sessionId, MediaPlayerClient::MediaKeyErrorCode errorCode, unsigned short systemCode)
1177 {
1178     if (m_mediaPlayerClient)
1179         m_mediaPlayerClient->mediaPlayerKeyError(this, keySystem, sessionId, errorCode, systemCode);
1180 }
1181
1182 void MediaPlayer::keyMessage(const String& keySystem, const String& sessionId, const unsigned char* message, unsigned messageLength, const URL& defaultURL)
1183 {
1184     if (m_mediaPlayerClient)
1185         m_mediaPlayerClient->mediaPlayerKeyMessage(this, keySystem, sessionId, message, messageLength, defaultURL);
1186 }
1187
1188 bool MediaPlayer::keyNeeded(const String& keySystem, const String& sessionId, const unsigned char* initData, unsigned initDataLength)
1189 {
1190     if (m_mediaPlayerClient)
1191         return m_mediaPlayerClient->mediaPlayerKeyNeeded(this, keySystem, sessionId, initData, initDataLength);
1192     return false;
1193 }
1194 #endif
1195
1196 #if ENABLE(ENCRYPTED_MEDIA_V2)
1197 bool MediaPlayer::keyNeeded(Uint8Array* initData)
1198 {
1199     if (m_mediaPlayerClient)
1200         return m_mediaPlayerClient->mediaPlayerKeyNeeded(this, initData);
1201     return false;
1202 }
1203 #endif
1204
1205 String MediaPlayer::referrer() const
1206 {
1207     if (!m_mediaPlayerClient)
1208         return String();
1209
1210     return m_mediaPlayerClient->mediaPlayerReferrer();
1211 }
1212
1213 String MediaPlayer::userAgent() const
1214 {
1215     if (!m_mediaPlayerClient)
1216         return String();
1217     
1218     return m_mediaPlayerClient->mediaPlayerUserAgent();
1219 }
1220
1221 String MediaPlayer::engineDescription() const
1222 {
1223     if (!m_private)
1224         return String();
1225
1226     return m_private->engineDescription();
1227 }
1228
1229 #if PLATFORM(WIN) && USE(AVFOUNDATION)
1230 GraphicsDeviceAdapter* MediaPlayer::graphicsDeviceAdapter() const
1231 {
1232     if (!m_mediaPlayerClient)
1233         return 0;
1234     
1235     return m_mediaPlayerClient->mediaPlayerGraphicsDeviceAdapter(this);
1236 }
1237 #endif
1238
1239 CachedResourceLoader* MediaPlayer::cachedResourceLoader()
1240 {
1241     if (!m_mediaPlayerClient)
1242         return 0;
1243
1244     return m_mediaPlayerClient->mediaPlayerCachedResourceLoader();
1245 }
1246
1247 #if ENABLE(VIDEO_TRACK)
1248 void MediaPlayer::addAudioTrack(PassRefPtr<AudioTrackPrivate> track)
1249 {
1250     if (!m_mediaPlayerClient)
1251         return;
1252
1253     m_mediaPlayerClient->mediaPlayerDidAddAudioTrack(track);
1254 }
1255
1256 void MediaPlayer::removeAudioTrack(PassRefPtr<AudioTrackPrivate> track)
1257 {
1258     if (!m_mediaPlayerClient)
1259         return;
1260
1261     m_mediaPlayerClient->mediaPlayerDidRemoveAudioTrack(track);
1262 }
1263
1264 void MediaPlayer::addTextTrack(PassRefPtr<InbandTextTrackPrivate> track)
1265 {
1266     if (!m_mediaPlayerClient)
1267         return;
1268
1269     m_mediaPlayerClient->mediaPlayerDidAddTextTrack(track);
1270 }
1271
1272 void MediaPlayer::removeTextTrack(PassRefPtr<InbandTextTrackPrivate> track)
1273 {
1274     if (!m_mediaPlayerClient)
1275         return;
1276
1277     m_mediaPlayerClient->mediaPlayerDidRemoveTextTrack(track);
1278 }
1279
1280 void MediaPlayer::addVideoTrack(PassRefPtr<VideoTrackPrivate> track)
1281 {
1282     if (!m_mediaPlayerClient)
1283         return;
1284
1285     m_mediaPlayerClient->mediaPlayerDidAddVideoTrack(track);
1286 }
1287
1288 void MediaPlayer::removeVideoTrack(PassRefPtr<VideoTrackPrivate> track)
1289 {
1290     if (!m_mediaPlayerClient)
1291         return;
1292
1293     m_mediaPlayerClient->mediaPlayerDidRemoveVideoTrack(track);
1294 }
1295
1296 bool MediaPlayer::requiresTextTrackRepresentation() const
1297 {
1298     return m_private->requiresTextTrackRepresentation();
1299 }
1300
1301 void MediaPlayer::setTextTrackRepresentation(TextTrackRepresentation* representation)
1302 {
1303     m_private->setTextTrackRepresentation(representation);
1304 }
1305
1306 #if ENABLE(AVF_CAPTIONS)
1307 void MediaPlayer::notifyTrackModeChanged()
1308 {
1309     if (m_private)
1310         m_private->notifyTrackModeChanged();
1311 }
1312
1313 Vector<RefPtr<PlatformTextTrack>> MediaPlayer::outOfBandTrackSources()
1314 {
1315     if (!m_mediaPlayerClient)
1316         return Vector<RefPtr<PlatformTextTrack>> ();
1317     
1318     return m_mediaPlayerClient->outOfBandTrackSources();
1319 }
1320 #endif
1321
1322 #endif // ENABLE(VIDEO_TRACK)
1323
1324 #if USE(PLATFORM_TEXT_TRACK_MENU)
1325 bool MediaPlayer::implementsTextTrackControls() const
1326 {
1327     return m_private->implementsTextTrackControls();
1328 }
1329
1330 PassRefPtr<PlatformTextTrackMenuInterface> MediaPlayer::textTrackMenu()
1331 {
1332     return m_private->textTrackMenu();
1333 }
1334 #endif // USE(PLATFORM_TEXT_TRACK_MENU)
1335
1336 void MediaPlayer::resetMediaEngines()
1337 {
1338     installedMediaEngines(ResetEngines);
1339 }
1340
1341 #if USE(GSTREAMER)
1342 void MediaPlayer::simulateAudioInterruption()
1343 {
1344     if (!m_private)
1345         return;
1346
1347     m_private->simulateAudioInterruption();
1348 }
1349 #endif
1350
1351 String MediaPlayer::languageOfPrimaryAudioTrack() const
1352 {
1353     if (!m_private)
1354         return emptyString();
1355     
1356     return m_private->languageOfPrimaryAudioTrack();
1357 }
1358
1359 size_t MediaPlayer::extraMemoryCost() const
1360 {
1361     if (!m_private)
1362         return 0;
1363
1364     return m_private->extraMemoryCost();
1365 }
1366
1367 unsigned long long MediaPlayer::fileSize() const
1368 {
1369     if (!m_private)
1370         return 0;
1371     
1372     return m_private->fileSize();
1373 }
1374
1375 #if ENABLE(MEDIA_SOURCE)
1376 unsigned long MediaPlayer::totalVideoFrames()
1377 {
1378     if (!m_private)
1379         return 0;
1380
1381     return m_private->totalVideoFrames();
1382 }
1383
1384 unsigned long MediaPlayer::droppedVideoFrames()
1385 {
1386     if (!m_private)
1387         return 0;
1388
1389     return m_private->droppedVideoFrames();
1390 }
1391
1392 unsigned long MediaPlayer::corruptedVideoFrames()
1393 {
1394     if (!m_private)
1395         return 0;
1396
1397     return m_private->corruptedVideoFrames();
1398 }
1399
1400 double MediaPlayer::totalFrameDelay()
1401 {
1402     if (!m_private)
1403         return 0;
1404
1405     return m_private->totalFrameDelay();
1406 }
1407 #endif
1408
1409 bool MediaPlayer::shouldWaitForResponseToAuthenticationChallenge(const AuthenticationChallenge& challenge)
1410 {
1411     if (!m_mediaPlayerClient)
1412         return false;
1413
1414     return m_mediaPlayerClient->mediaPlayerShouldWaitForResponseToAuthenticationChallenge(challenge);
1415 }
1416     
1417 void MediaPlayer::handlePlaybackCommand(MediaSession::RemoteControlCommandType command)
1418 {
1419     if (!m_mediaPlayerClient)
1420         return;
1421     
1422     m_mediaPlayerClient->mediaPlayerHandlePlaybackCommand(command);
1423 }
1424
1425 void MediaPlayerFactorySupport::callRegisterMediaEngine(MediaEngineRegister registerMediaEngine)
1426 {
1427     registerMediaEngine(addMediaEngine);
1428 }
1429
1430 bool MediaPlayer::doesHaveAttribute(const AtomicString& attribute, AtomicString* value) const
1431 {
1432     if (!m_mediaPlayerClient)
1433         return false;
1434     
1435     return m_mediaPlayerClient->doesHaveAttribute(attribute, value);
1436 }
1437
1438 }
1439
1440 #endif