1/* 2 * Copyright (C) 2011, 2013-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#ifndef MediaPlayerPrivateAVFoundationCF_h 27#define MediaPlayerPrivateAVFoundationCF_h 28 29#if PLATFORM(WIN) && ENABLE(VIDEO) && USE(AVFOUNDATION) 30 31#include "MediaPlayerPrivateAVFoundation.h" 32 33#if HAVE(AVFOUNDATION_LOADER_DELEGATE) || HAVE(ENCRYPTED_MEDIA_V2) 34typedef struct OpaqueAVCFAssetResourceLoadingRequest* AVCFAssetResourceLoadingRequestRef; 35#endif 36 37namespace WebCore { 38 39class AVFWrapper; 40class WebCoreAVCFResourceLoader; 41 42class MediaPlayerPrivateAVFoundationCF : public MediaPlayerPrivateAVFoundation { 43public: 44 virtual ~MediaPlayerPrivateAVFoundationCF(); 45 46 virtual void tracksChanged() override; 47 48#if HAVE(AVFOUNDATION_LOADER_DELEGATE) 49 bool shouldWaitForLoadingOfResource(AVCFAssetResourceLoadingRequestRef); 50 void didCancelLoadingRequest(AVCFAssetResourceLoadingRequestRef); 51 void didStopLoadingRequest(AVCFAssetResourceLoadingRequestRef); 52#endif 53 54#if ENABLE(ENCRYPTED_MEDIA_V2) 55 RetainPtr<AVCFAssetResourceLoadingRequestRef> takeRequestForKeyURI(const String&); 56#endif 57 58 static void registerMediaEngine(MediaEngineRegistrar); 59 60private: 61 MediaPlayerPrivateAVFoundationCF(MediaPlayer*); 62 63 // Engine support 64 static PassOwnPtr<MediaPlayerPrivateInterface> create(MediaPlayer*); 65 static void getSupportedTypes(HashSet<String>& types); 66 static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&); 67 static bool isAvailable(); 68 69 virtual void cancelLoad(); 70 71 virtual PlatformMedia platformMedia() const; 72 73 virtual void platformSetVisible(bool); 74 virtual void platformPlay(); 75 virtual void platformPause(); 76 virtual double currentTimeDouble() const override; 77 virtual void setVolume(float); 78 virtual void setClosedCaptionsVisible(bool); 79 virtual void paint(GraphicsContext*, const IntRect&); 80 virtual void paintCurrentFrameInContext(GraphicsContext*, const IntRect&); 81 virtual PlatformLayer* platformLayer() const; 82 virtual bool supportsAcceleratedRendering() const { return true; } 83 virtual float mediaTimeForTimeValue(float) const; 84 85 virtual void createAVPlayer(); 86 virtual void createAVPlayerItem(); 87 virtual void createAVAssetForURL(const String& url); 88 virtual MediaPlayerPrivateAVFoundation::ItemStatus playerItemStatus() const; 89 virtual MediaPlayerPrivateAVFoundation::AssetStatus assetStatus() const; 90 91 virtual void checkPlayability(); 92 virtual void updateRate(); 93 virtual float rate() const; 94 virtual void seekToTime(double time, double negativeTolerance, double positiveTolerance); 95 virtual unsigned long long totalBytes() const; 96 virtual std::unique_ptr<PlatformTimeRanges> platformBufferedTimeRanges() const; 97 virtual double platformMinTimeSeekable() const; 98 virtual double platformMaxTimeSeekable() const; 99 virtual double platformDuration() const; 100 virtual float platformMaxTimeLoaded() const; 101 virtual void beginLoadingMetadata(); 102 virtual void sizeChanged(); 103 virtual bool requiresImmediateCompositing() const override; 104 105 virtual bool hasAvailableVideoFrame() const; 106 107 virtual void createContextVideoRenderer(); 108 virtual void destroyContextVideoRenderer(); 109 110 virtual void createVideoLayer(); 111 virtual void destroyVideoLayer(); 112 113 virtual bool hasContextRenderer() const; 114 virtual bool hasLayerRenderer() const; 115 116 virtual void updateVideoLayerGravity() override; 117 118 virtual void contentsNeedsDisplay(); 119 120#if ENABLE(ENCRYPTED_MEDIA_V2) 121 virtual std::unique_ptr<CDMSession> createSession(const String&) override; 122#endif 123 124 virtual String languageOfPrimaryAudioTrack() const override; 125 126#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) 127 void processMediaSelectionOptions(); 128#endif 129 130 virtual void setCurrentTextTrack(InbandTextTrackPrivateAVF*) override; 131 virtual InbandTextTrackPrivateAVF* currentTextTrack() const override; 132 133#if !HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT) 134 void processLegacyClosedCaptionsTracks(); 135#endif 136 137 friend class AVFWrapper; 138 AVFWrapper* m_avfWrapper; 139 140 mutable String m_languageOfPrimaryAudioTrack; 141 142#if HAVE(AVFOUNDATION_LOADER_DELEGATE) 143 friend class WebCoreAVCFResourceLoader; 144 HashMap<RetainPtr<AVCFAssetResourceLoadingRequestRef>, RefPtr<WebCoreAVCFResourceLoader>> m_resourceLoaderMap; 145#endif 146 147 bool m_videoFrameHasDrawn; 148}; 149 150} 151 152#endif // PLATFORM(WIN) && ENABLE(VIDEO) && USE(AVFOUNDATION) 153#endif // MediaPlayerPrivateAVFoundationCF_h 154