<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[166312] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/166312">166312</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-03-26 13:17:39 -0700 (Wed, 26 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Implement hasLiveStreamingContent property in WebAVPlayerController
https://bugs.webkit.org/show_bug.cgi?id=128684

Patch by Jeremy Jones &lt;jeremyj@apple.com&gt; on 2014-03-26
Reviewed by Simon Fraser.

Source/WebCore:

* WebCore.exp.in:
Add export for WebVideoFullscreenInterfaceAVKit::setSeekableRanges().

* platform/ios/WebVideoFullscreenInterface.h:
Add setSeekableRanges()

* platform/ios/WebVideoFullscreenInterfaceAVKit.h:
Add setSeekableRanges()

* platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
Remove vestigial playerLayer property. Add seekableTimeRanges property.

(-[WebAVPlayerController dealloc]):
Release _seekableTimeRanges.
Remove references to _playerLayer.

(-[WebAVPlayerController hasLiveStreamingContent]):
Implement based on duration. Live stream has an infinite duration.

(+[WebAVPlayerController keyPathsForValuesAffectingHasLiveStreamingContent]):
Describe dependent keys for computed property hasLiveStreamingContent.

(-[WebAVPlayerController skipBackwardThirtySeconds:]):
Seek back 30 seconds if that time is in the seekable ranges.

(-[WebAVPlayerController gotoEndOfSeekableRanges:]):
Jump to live by going to the of the seekable ranges.

(WebVideoFullscreenInterfaceAVKit::setSeekableRanges):
Convert TimeRange to CMTimeRange.

* platform/ios/WebVideoFullscreenModelMediaElement.mm:
(WebVideoFullscreenModelMediaElement::setMediaElement):
Set initial seekable ranges.

(WebVideoFullscreenModelMediaElement::handleEvent):
Update seekable ranges when time changes.

Source/WebKit2:

Plumb through the seekable ranges to the fullscreen interface.

* UIProcess/ios/WebVideoFullscreenManagerProxy.h:
Add declaration for setSeekableRangesVector()

* UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in:
Add interface SetSeekableRangesVector()

* UIProcess/ios/WebVideoFullscreenManagerProxy.mm:
(WebKit::WebVideoFullscreenManagerProxy::setSeekableRangesVector):
Add setSeekableRangesVector that translates the vector into a TimeRanges and calls setSeekableRanges()

* WebProcess/ios/WebVideoFullscreenManager.h:
Add setSeekableRanges()

* WebProcess/ios/WebVideoFullscreenManager.mm:
(WebKit::WebVideoFullscreenManager::setSeekableRanges):
setSeekableRanges() converts TimeRanges to Vector and calls SetSeekableRangesVector()</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceh">trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterface.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKith">trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKitmm">trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenModelMediaElementmm">trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWebVideoFullscreenManagerProxyh">trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWebVideoFullscreenManagerProxymessagesin">trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWebVideoFullscreenManagerProxymm">trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessiosWebVideoFullscreenManagerh">trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessiosWebVideoFullscreenManagermm">trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (166311 => 166312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-26 19:52:07 UTC (rev 166311)
+++ trunk/Source/WebCore/ChangeLog        2014-03-26 20:17:39 UTC (rev 166312)
</span><span class="lines">@@ -1,3 +1,48 @@
</span><ins>+2014-03-26  Jeremy Jones  &lt;jeremyj@apple.com&gt;
+
+        Implement hasLiveStreamingContent property in WebAVPlayerController
+        https://bugs.webkit.org/show_bug.cgi?id=128684
+
+        Reviewed by Simon Fraser.
+
+        * WebCore.exp.in:
+        Add export for WebVideoFullscreenInterfaceAVKit::setSeekableRanges().
+
+        * platform/ios/WebVideoFullscreenInterface.h:
+        Add setSeekableRanges()
+
+        * platform/ios/WebVideoFullscreenInterfaceAVKit.h:
+        Add setSeekableRanges()
+
+        * platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
+        Remove vestigial playerLayer property. Add seekableTimeRanges property.
+
+        (-[WebAVPlayerController dealloc]):
+        Release _seekableTimeRanges.
+        Remove references to _playerLayer.
+
+        (-[WebAVPlayerController hasLiveStreamingContent]):
+        Implement based on duration. Live stream has an infinite duration.
+
+        (+[WebAVPlayerController keyPathsForValuesAffectingHasLiveStreamingContent]):
+        Describe dependent keys for computed property hasLiveStreamingContent.
+
+        (-[WebAVPlayerController skipBackwardThirtySeconds:]):
+        Seek back 30 seconds if that time is in the seekable ranges.
+
+        (-[WebAVPlayerController gotoEndOfSeekableRanges:]):
+        Jump to live by going to the of the seekable ranges.
+
+        (WebVideoFullscreenInterfaceAVKit::setSeekableRanges):
+        Convert TimeRange to CMTimeRange.
+
+        * platform/ios/WebVideoFullscreenModelMediaElement.mm:
+        (WebVideoFullscreenModelMediaElement::setMediaElement):
+        Set initial seekable ranges.
+
+        (WebVideoFullscreenModelMediaElement::handleEvent):
+        Update seekable ranges when time changes.
+
</ins><span class="cx"> 2014-03-26  Brent Fulgham  &lt;bfulgham@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix OS X build.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (166311 => 166312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-03-26 19:52:07 UTC (rev 166311)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-03-26 20:17:39 UTC (rev 166312)
</span><span class="lines">@@ -3279,6 +3279,7 @@
</span><span class="cx"> __ZN7WebCore32WebVideoFullscreenInterfaceAVKit14exitFullscreenEv
</span><span class="cx"> __ZN7WebCore32WebVideoFullscreenInterfaceAVKit14setCurrentTimeEdd
</span><span class="cx"> __ZN7WebCore32WebVideoFullscreenInterfaceAVKit15enterFullscreenER7CALayer
</span><ins>+__ZN7WebCore32WebVideoFullscreenInterfaceAVKit17setSeekableRangesERKNS_10TimeRangesE
</ins><span class="cx"> __ZN7WebCore32WebVideoFullscreenInterfaceAVKit18setVideoDimensionsEbff
</span><span class="cx"> __ZN7WebCore32WebVideoFullscreenInterfaceAVKit26setWebVideoFullscreenModelEPNS_23WebVideoFullscreenModelE
</span><span class="cx"> __ZN7WebCore32WebVideoFullscreenInterfaceAVKit35setWebVideoFullscreenChangeObserverEPNS_32WebVideoFullscreenChangeObserverE
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterface.h (166311 => 166312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterface.h        2014-03-26 19:52:07 UTC (rev 166311)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterface.h        2014-03-26 20:17:39 UTC (rev 166312)
</span><span class="lines">@@ -29,10 +29,10 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> 
</span><del>-#import &lt;WebCore/PlatformLayer.h&gt;
-
</del><span class="cx"> namespace WebCore {
</span><span class="cx">     
</span><ins>+class TimeRanges;
+
</ins><span class="cx"> class WebVideoFullscreenInterface {
</span><span class="cx"> public:
</span><span class="cx">     virtual ~WebVideoFullscreenInterface() { };
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx">     virtual void setCurrentTime(double currentTime, double anchorTime) = 0;
</span><span class="cx">     virtual void setRate(bool isPlaying, float playbackRate) = 0;
</span><span class="cx">     virtual void setVideoDimensions(bool hasVideo, float width, float height) = 0;
</span><ins>+    virtual void setSeekableRanges(const TimeRanges&amp;) = 0;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKith"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h (166311 => 166312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h        2014-03-26 19:52:07 UTC (rev 166311)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.h        2014-03-26 20:17:39 UTC (rev 166312)
</span><span class="lines">@@ -80,6 +80,7 @@
</span><span class="cx">     virtual void setCurrentTime(double currentTime, double anchorTime) override;
</span><span class="cx">     virtual void setRate(bool isPlaying, float playbackRate) override;
</span><span class="cx">     virtual void setVideoDimensions(bool hasVideo, float width, float height) override;
</span><ins>+    virtual void setSeekableRanges(const TimeRanges&amp;) override;
</ins><span class="cx"> 
</span><span class="cx">     virtual void enterFullscreen(PlatformLayer&amp;);
</span><span class="cx">     virtual void exitFullscreen();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKitmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm (166311 => 166312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm        2014-03-26 19:52:07 UTC (rev 166311)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm        2014-03-26 20:17:39 UTC (rev 166312)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> 
</span><span class="cx"> #import &quot;Logging.h&quot;
</span><span class="cx"> #import &quot;WebVideoFullscreenModel.h&quot;
</span><ins>+#import &lt;AVFoundation/AVTime.h&gt;
</ins><span class="cx"> #import &lt;AVKit/AVKit.h&gt;
</span><span class="cx"> #import &lt;AVKit/AVPlayerController.h&gt;
</span><span class="cx"> #import &lt;AVKit/AVPlayerViewController_Private.h&gt;
</span><span class="lines">@@ -41,6 +42,7 @@
</span><span class="cx"> #import &lt;CoreMedia/CMTime.h&gt;
</span><span class="cx"> #import &lt;UIKit/UIKit.h&gt;
</span><span class="cx"> #import &lt;WebCore/SoftLinking.h&gt;
</span><ins>+#import &lt;WebCore/TimeRanges.h&gt;
</ins><span class="cx"> #import &lt;WebCore/WebCoreThreadRun.h&gt;
</span><span class="cx"> #import &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -64,11 +66,14 @@
</span><span class="cx"> SOFT_LINK_FRAMEWORK(CoreMedia)
</span><span class="cx"> SOFT_LINK(CoreMedia, CMTimeMakeWithSeconds, CMTime, (Float64 seconds, int32_t preferredTimeScale), (seconds, preferredTimeScale))
</span><span class="cx"> SOFT_LINK(CoreMedia, CMTimeGetSeconds, Float64, (CMTime time), (time))
</span><ins>+SOFT_LINK(CoreMedia, CMTimeMake, CMTime, (int64_t value, int32_t timescale), (value, timescale))
+SOFT_LINK(CoreMedia, CMTimeRangeContainsTime, Boolean, (CMTimeRange range, CMTime time), (range, time))
+SOFT_LINK(CoreMedia, CMTimeRangeMake, CMTimeRange, (CMTime start, CMTime duration), (start, duration))
+SOFT_LINK(CoreMedia, CMTimeSubtract, CMTime, (CMTime minuend, CMTime subtrahend), (minuend, subtrahend))
</ins><span class="cx"> 
</span><span class="cx"> @interface WebAVPlayerController : NSObject &lt;AVPlayerViewControllerDelegate&gt;
</span><span class="cx"> 
</span><span class="cx"> @property(retain) AVPlayerController* playerControllerProxy;
</span><del>-@property(retain) CALayer&lt;AVVideoLayer&gt; *playerLayer;
</del><span class="cx"> @property(assign) WebVideoFullscreenModel* delegate;
</span><span class="cx"> 
</span><span class="cx"> @property BOOL canPlay;
</span><span class="lines">@@ -87,6 +92,7 @@
</span><span class="cx"> @property(retain) NSArray *loadedTimeRanges;
</span><span class="cx"> @property AVPlayerControllerStatus status;
</span><span class="cx"> @property(retain) AVValueTiming *timing;
</span><ins>+@property(retain) NSArray *seekableTimeRanges;
</ins><span class="cx"> 
</span><span class="cx"> - (BOOL)playerViewController:(AVPlayerViewController *)playerViewController shouldDismissWithReason:(AVPlayerViewControllerDismissalReason)reason;
</span><span class="cx"> @end
</span><span class="lines">@@ -106,8 +112,8 @@
</span><span class="cx"> - (void)dealloc
</span><span class="cx"> {
</span><span class="cx">     [_playerControllerProxy release];
</span><del>-    [_playerLayer release];
</del><span class="cx">     [_loadedTimeRanges release];
</span><ins>+    [_seekableTimeRanges release];
</ins><span class="cx">     [_timing release];
</span><span class="cx">     [super dealloc];
</span><span class="cx"> }
</span><span class="lines">@@ -174,6 +180,52 @@
</span><span class="cx">     self.delegate-&gt;seekToTime(time);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (BOOL)hasLiveStreamingContent
+{
+    if ([self status] == AVPlayerControllerStatusReadyToPlay)
+        return [self contentDuration] == std::numeric_limits&lt;float&gt;::infinity();
+    return NO;
+}
+
++ (NSSet *)keyPathsForValuesAffectingHasLiveStreamingContent
+{
+    return [NSSet setWithObjects:@&quot;contentDuration&quot;, @&quot;status&quot;, nil];
+}
+
+- (void)skipBackwardThirtySeconds:(id)sender
+{
+    UNUSED_PARAM(sender);
+    BOOL isTimeWithinSeekableTimeRanges = NO;
+    CMTime currentTime = CMTimeMakeWithSeconds([[self timing] currentValue], 1000);
+    CMTime thirtySecondsBeforeCurrentTime = CMTimeSubtract(currentTime, CMTimeMake(30, 1));
+    
+    for (NSValue *seekableTimeRangeValue in [self seekableTimeRanges]) {
+        if (CMTimeRangeContainsTime([seekableTimeRangeValue CMTimeRangeValue], thirtySecondsBeforeCurrentTime)) {
+            isTimeWithinSeekableTimeRanges = YES;
+            break;
+        }
+    }
+    
+    if (isTimeWithinSeekableTimeRanges)
+        [self seekToTime:CMTimeGetSeconds(thirtySecondsBeforeCurrentTime)];
+}
+
+- (void)gotoEndOfSeekableRanges:(id)sender
+{
+    UNUSED_PARAM(sender);
+    NSTimeInterval timeAtEndOfSeekableTimeRanges = NAN;
+    
+    for (NSValue *seekableTimeRangeValue in [self seekableTimeRanges]) {
+        CMTimeRange seekableTimeRange = [seekableTimeRangeValue CMTimeRangeValue];
+        NSTimeInterval endOfSeekableTimeRange = CMTimeGetSeconds(CMTimeRangeGetEnd(seekableTimeRange));
+        if (isnan(timeAtEndOfSeekableTimeRanges) || endOfSeekableTimeRange &gt; timeAtEndOfSeekableTimeRanges)
+            timeAtEndOfSeekableTimeRanges = endOfSeekableTimeRange;
+    }
+    
+    if (!isnan(timeAtEndOfSeekableTimeRanges))
+        [self seekToTime:timeAtEndOfSeekableTimeRanges];
+}
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @interface WebAVVideoLayer : CALayer &lt;AVVideoLayer&gt;
</span><span class="lines">@@ -311,6 +363,22 @@
</span><span class="cx">     playerController().contentDimensions = CGSizeMake(width, height);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebVideoFullscreenInterfaceAVKit::setSeekableRanges(const TimeRanges&amp; timeRanges)
+{
+    NSMutableArray* seekableRanges = [NSMutableArray array];
+    ExceptionCode exceptionCode;
+
+    for (unsigned i = 0; i &lt; timeRanges.length(); i++) {
+        double start = timeRanges.start(i, exceptionCode);
+        double end = timeRanges.end(i, exceptionCode);
+        
+        CMTimeRange range = CMTimeRangeMake(CMTimeMakeWithSeconds(start, 1000), CMTimeMakeWithSeconds(end-start, 1000));
+        [seekableRanges addObject:[NSValue valueWithCMTimeRange:range]];
+    }
+    
+    playerController().seekableTimeRanges = seekableRanges;
+}
+
</ins><span class="cx"> void WebVideoFullscreenInterfaceAVKit::enterFullscreen(PlatformLayer&amp; videoLayer)
</span><span class="cx"> {
</span><span class="cx">     __block RefPtr&lt;WebVideoFullscreenInterfaceAVKit&gt; protect(this);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenModelMediaElementmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.mm (166311 => 166312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.mm        2014-03-26 19:52:07 UTC (rev 166311)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenModelMediaElement.mm        2014-03-26 20:17:39 UTC (rev 166312)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx"> #import &lt;WebCore/HTMLMediaElement.h&gt;
</span><span class="cx"> #import &lt;WebCore/HTMLVideoElement.h&gt;
</span><span class="cx"> #import &lt;WebCore/SoftLinking.h&gt;
</span><ins>+#import &lt;WebCore/TimeRanges.h&gt;
</ins><span class="cx"> #import &lt;WebCore/WebCoreThreadRun.h&gt;
</span><span class="cx"> #import &lt;QuartzCore/CoreAnimation.h&gt;
</span><span class="cx"> #import &lt;wtf/RetainPtr.h&gt;
</span><span class="lines">@@ -83,6 +84,7 @@
</span><span class="cx">     m_isListening = true;
</span><span class="cx"> 
</span><span class="cx">     m_videoFullscreenInterface-&gt;setDuration(m_mediaElement-&gt;duration());
</span><ins>+    m_videoFullscreenInterface-&gt;setSeekableRanges(*m_mediaElement-&gt;seekable());
</ins><span class="cx">     m_videoFullscreenInterface-&gt;setRate(m_mediaElement-&gt;isPlaying(), m_mediaElement-&gt;playbackRate());
</span><span class="cx"> 
</span><span class="cx">     m_videoFullscreenInterface-&gt;setCurrentTime(m_mediaElement-&gt;currentTime(), [[NSProcessInfo processInfo] systemUptime]);
</span><span class="lines">@@ -107,8 +109,11 @@
</span><span class="cx">         || event-&gt;type() == eventNames().playEvent
</span><span class="cx">         || event-&gt;type() == eventNames().ratechangeEvent)
</span><span class="cx">         m_videoFullscreenInterface-&gt;setRate(m_mediaElement-&gt;isPlaying(), m_mediaElement-&gt;playbackRate());
</span><del>-    else if (event-&gt;type() == eventNames().timeupdateEvent)
</del><ins>+    else if (event-&gt;type() == eventNames().timeupdateEvent) {
</ins><span class="cx">         m_videoFullscreenInterface-&gt;setCurrentTime(m_mediaElement-&gt;currentTime(), [[NSProcessInfo processInfo] systemUptime]);
</span><ins>+        // FIXME: 130788 - find a better event to update seekable ranges from.
+        m_videoFullscreenInterface-&gt;setSeekableRanges(*m_mediaElement-&gt;seekable());
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebVideoFullscreenModelMediaElement::setVideoFullscreenLayer(PlatformLayer* videoLayer)
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (166311 => 166312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-03-26 19:52:07 UTC (rev 166311)
+++ trunk/Source/WebKit2/ChangeLog        2014-03-26 20:17:39 UTC (rev 166312)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2014-03-26  Jeremy Jones  &lt;jeremyj@apple.com&gt;
+
+        Implement hasLiveStreamingContent property in WebAVPlayerController
+        https://bugs.webkit.org/show_bug.cgi?id=128684
+
+        Reviewed by Simon Fraser.
+
+        Plumb through the seekable ranges to the fullscreen interface.
+
+        * UIProcess/ios/WebVideoFullscreenManagerProxy.h:
+        Add declaration for setSeekableRangesVector()
+
+        * UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in:
+        Add interface SetSeekableRangesVector()
+
+        * UIProcess/ios/WebVideoFullscreenManagerProxy.mm:
+        (WebKit::WebVideoFullscreenManagerProxy::setSeekableRangesVector):
+        Add setSeekableRangesVector that translates the vector into a TimeRanges and calls setSeekableRanges()
+
+        * WebProcess/ios/WebVideoFullscreenManager.h:
+        Add setSeekableRanges()
+
+        * WebProcess/ios/WebVideoFullscreenManager.mm:
+        (WebKit::WebVideoFullscreenManager::setSeekableRanges):
+        setSeekableRanges() converts TimeRanges to Vector and calls SetSeekableRangesVector()
+
</ins><span class="cx"> 2014-03-26  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add a custom behavior flag to GraphicsLayer, piped down to PlatformCALayer, for scrolling layers
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWebVideoFullscreenManagerProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.h (166311 => 166312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.h        2014-03-26 19:52:07 UTC (rev 166311)
+++ trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.h        2014-03-26 20:17:39 UTC (rev 166312)
</span><span class="lines">@@ -53,6 +53,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Translate to FullscreenInterface
</span><span class="cx">     virtual void enterFullscreenWithID(uint32_t);
</span><ins>+    virtual void setSeekableRangesVector(Vector&lt;std::pair&lt;double, double&gt;&gt;&amp;);
</ins><span class="cx"> 
</span><span class="cx">     // Fullscreen Observer
</span><span class="cx">     virtual void requestExitFullscreen() override;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWebVideoFullscreenManagerProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in (166311 => 166312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in        2014-03-26 19:52:07 UTC (rev 166311)
+++ trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.messages.in        2014-03-26 20:17:39 UTC (rev 166312)
</span><span class="lines">@@ -24,6 +24,7 @@
</span><span class="cx"> messages -&gt; WebVideoFullscreenManagerProxy {
</span><span class="cx">     SetCurrentTime(double currentTime, double hostTime)
</span><span class="cx">     SetVideoDimensions(bool hasVideo, unsigned width, unsigned height)
</span><ins>+    SetSeekableRangesVector(Vector&lt;std::pair&lt;double, double&gt;&gt; ranges);
</ins><span class="cx">     SetDuration(double duration)
</span><span class="cx">     SetRate(bool isPlaying, double rate)
</span><span class="cx">     EnterFullscreenWithID(uint32_t videoLayerID)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWebVideoFullscreenManagerProxymm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.mm (166311 => 166312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.mm        2014-03-26 19:52:07 UTC (rev 166311)
+++ trunk/Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.mm        2014-03-26 20:17:39 UTC (rev 166312)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include &quot;WebVideoFullscreenManagerProxyMessages.h&quot;
</span><span class="cx"> #include &lt;QuartzCore/CoreAnimation.h&gt;
</span><span class="cx"> #include &lt;WebKitSystemInterface.h&gt;
</span><ins>+#include &lt;WebCore/TimeRanges.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="lines">@@ -63,7 +64,21 @@
</span><span class="cx">     m_layerHost = WKMakeRenderLayer(videoLayerID);
</span><span class="cx">     enterFullscreen(*m_layerHost.get());
</span><span class="cx"> }
</span><ins>+    
+void WebVideoFullscreenManagerProxy::setSeekableRangesVector(Vector&lt;std::pair&lt;double, double&gt;&gt;&amp; ranges)
+{
+    RefPtr&lt;TimeRanges&gt; timeRanges = TimeRanges::create();
+    for (const auto&amp; range : ranges)
+    {
+        ASSERT(isfinite(range.first));
+        ASSERT(isfinite(range.second));
+        ASSERT(range.second &gt;= range.first);
+        timeRanges-&gt;add(range.first, range.second);
+    }
</ins><span class="cx"> 
</span><ins>+    setSeekableRanges(*timeRanges);
+}
+
</ins><span class="cx"> void WebVideoFullscreenManagerProxy::requestExitFullscreen()
</span><span class="cx"> {
</span><span class="cx">     m_page-&gt;send(Messages::WebVideoFullscreenManager::RequestExitFullscreen(), m_page-&gt;pageID());
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessiosWebVideoFullscreenManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.h (166311 => 166312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.h        2014-03-26 19:52:07 UTC (rev 166311)
+++ trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.h        2014-03-26 20:17:39 UTC (rev 166312)
</span><span class="lines">@@ -70,6 +70,7 @@
</span><span class="cx">     virtual void setCurrentTime(double currentTime, double anchorTime) override;
</span><span class="cx">     virtual void setRate(bool isPlaying, float playbackRate) override;
</span><span class="cx">     virtual void setVideoDimensions(bool hasVideo, float width, float height) override;
</span><ins>+    virtual void setSeekableRanges(const WebCore::TimeRanges&amp;) override;
</ins><span class="cx">     
</span><span class="cx">     // additional incoming
</span><span class="cx">     virtual void didEnterFullscreen();
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessiosWebVideoFullscreenManagermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.mm (166311 => 166312)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.mm        2014-03-26 19:52:07 UTC (rev 166311)
+++ trunk/Source/WebKit2/WebProcess/ios/WebVideoFullscreenManager.mm        2014-03-26 20:17:39 UTC (rev 166312)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx"> #include &lt;WebCore/HTMLVideoElement.h&gt;
</span><span class="cx"> #include &lt;WebCore/PlatformCALayer.h&gt;
</span><span class="cx"> #include &lt;WebCore/Settings.h&gt;
</span><ins>+#include &lt;WebCore/TimeRanges.h&gt;
</ins><span class="cx"> #include &lt;WebCore/WebCoreThreadRun.h&gt;
</span><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="lines">@@ -119,7 +120,21 @@
</span><span class="cx"> {
</span><span class="cx">     m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetVideoDimensions(hasVideo, width, height), m_page-&gt;pageID());
</span><span class="cx"> }
</span><ins>+    
+void WebVideoFullscreenManager::setSeekableRanges(const WebCore::TimeRanges&amp; timeRanges)
+{
+    Vector&lt;std::pair&lt;double, double&gt;&gt; rangesVector;
+    
+    for (unsigned i = 0; i &lt; timeRanges.length(); i++) {
+        ExceptionCode exceptionCode;
+        double start = timeRanges.start(i, exceptionCode);
+        double end = timeRanges.end(i, exceptionCode);
+        rangesVector.append(std::pair&lt;double,double&gt;(start, end));
+    }
</ins><span class="cx"> 
</span><ins>+    m_page-&gt;send(Messages::WebVideoFullscreenManagerProxy::SetSeekableRangesVector(std::move(rangesVector)), m_page-&gt;pageID());
+}
+
</ins><span class="cx"> void WebVideoFullscreenManager::didEnterFullscreen()
</span><span class="cx"> {
</span><span class="cx">     m_isAnimating = false;
</span></span></pre>
</div>
</div>

</body>
</html>