1/* 2 * Copyright (C) 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. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#ifndef HTMLMediaSession_h 27#define HTMLMediaSession_h 28 29#if ENABLE(VIDEO) 30 31#include "MediaPlayer.h" 32#include "MediaSession.h" 33 34namespace WebCore { 35 36class HTMLMediaElement; 37class SourceBuffer; 38 39class HTMLMediaSession : public MediaSession { 40public: 41 static std::unique_ptr<HTMLMediaSession> create(MediaSessionClient&); 42 43 HTMLMediaSession(MediaSessionClient&); 44 virtual ~HTMLMediaSession() { } 45 46 bool playbackPermitted(const HTMLMediaElement&) const; 47 bool dataLoadingPermitted(const HTMLMediaElement&) const; 48 bool fullscreenPermitted(const HTMLMediaElement&) const; 49 bool pageAllowsDataLoading(const HTMLMediaElement&) const; 50 bool pageAllowsPlaybackAfterResuming(const HTMLMediaElement&) const; 51#if ENABLE(IOS_AIRPLAY) 52 bool showingPlaybackTargetPickerPermitted(const HTMLMediaElement&) const; 53 54 bool currentPlaybackTargetIsWireless(const HTMLMediaElement&) const; 55 void showPlaybackTargetPicker(const HTMLMediaElement&); 56 bool hasWirelessPlaybackTargets(const HTMLMediaElement&) const; 57 58 bool wirelessVideoPlaybackDisabled(const HTMLMediaElement&) const; 59 void setWirelessVideoPlaybackDisabled(const HTMLMediaElement&, bool); 60 61 void setHasPlaybackTargetAvailabilityListeners(const HTMLMediaElement&, bool); 62#endif 63 bool requiresFullscreenForVideoPlayback(const HTMLMediaElement&) const; 64 MediaPlayer::Preload effectivePreloadForElement(const HTMLMediaElement&) const; 65 66 void applyMediaPlayerRestrictions(const HTMLMediaElement&); 67 68 // Restrictions to modify default behaviors. 69 enum BehaviorRestrictionFlags { 70 NoRestrictions = 0, 71 RequireUserGestureForLoad = 1 << 0, 72 RequireUserGestureForRateChange = 1 << 1, 73 RequireUserGestureForFullscreen = 1 << 2, 74 RequirePageConsentToLoadMedia = 1 << 3, 75 RequirePageConsentToResumeMedia = 1 << 4, 76#if ENABLE(IOS_AIRPLAY) 77 RequireUserGestureToShowPlaybackTargetPicker = 1 << 5, 78 WirelessVideoPlaybackDisabled = 1 << 6, 79#endif 80 }; 81 typedef unsigned BehaviorRestrictions; 82 83 void addBehaviorRestriction(BehaviorRestrictions); 84 void removeBehaviorRestriction(BehaviorRestrictions); 85 86#if ENABLE(MEDIA_SOURCE) 87 size_t maximumMediaSourceBufferSize(const SourceBuffer&) const; 88#endif 89 90private: 91 BehaviorRestrictions m_restrictions; 92}; 93 94} 95 96#endif // MediaSession_h 97 98#endif // ENABLE(VIDEO) 99