[iOS] Pass additional options to AVFoundation during playback.
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Mar 2014 21:00:19 +0000 (21:00 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Mar 2014 21:00:19 +0000 (21:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=130624

Reviewed by Eric Carlson.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::doesHaveAttribute): Return attribute value if the user
passes a pointer to fill in.
* html/HTMLMediaElement.h:
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::doesHaveAttribute):
* platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayerClient::doesHaveAttribute):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem): Pass additional
option if supplied by user.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166250 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/platform/graphics/MediaPlayer.cpp
Source/WebCore/platform/graphics/MediaPlayer.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

index 1bb96fb17da93e85beaa207e1311cfbf7cd8b35c..a5584c50d5d30d2ed1a3fbc5bc62895e1fa93714 100644 (file)
@@ -1,3 +1,22 @@
+2014-03-25  Brent Fulgham  <bfulgham@apple.com>
+
+        [iOS] Pass additional options to AVFoundation during playback.
+        https://bugs.webkit.org/show_bug.cgi?id=130624
+
+        Reviewed by Eric Carlson.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::doesHaveAttribute): Return attribute value if the user
+        passes a pointer to fill in.
+        * html/HTMLMediaElement.h:
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::doesHaveAttribute):
+        * platform/graphics/MediaPlayer.h:
+        (WebCore::MediaPlayerClient::doesHaveAttribute):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem): Pass additional
+        option if supplied by user.
+
 2014-03-25  Michael Saboff  <msaboff@apple.com>
 
         Unreviewed, rolling out r166070.
index 9249b628aa1d7373f90ba8ad76076898d20bfac4..bb82aa8797326b7826f270f1afb695eb33d5997d 100644 (file)
@@ -6042,16 +6042,21 @@ void HTMLMediaElement::didReceiveRemoteControlCommand(MediaSession::RemoteContro
     }
 }
 
-bool HTMLMediaElement::doesHaveAttribute(const AtomicString& attribute) const
+bool HTMLMediaElement::doesHaveAttribute(const AtomicString& attribute, AtomicString* value) const
 {
     QualifiedName attributeName(nullAtom, attribute, nullAtom);
-    if (!fastHasAttribute(attributeName))
+
+    AtomicString elementValue = fastGetAttribute(attributeName);
+    if (elementValue.isNull())
         return false;
     
     if (Settings* settings = document().settings()) {
-        if (attributeName == HTMLNames::x_itunes_inherit_uri_query_componentAttr)
-            return settings->enableInheritURIQueryComponent();
+        if (attributeName == HTMLNames::x_itunes_inherit_uri_query_componentAttr && !settings->enableInheritURIQueryComponent())
+            return false;
     }
+
+    if (value)
+        *value = elementValue;
     
     return true;
 }
index da7d2c68c89606542c0b8835e7a4c0bdf053568b..2fbeb51b24a511878dbfc046ef2346b41f8c6bf6 100644 (file)
@@ -129,7 +129,7 @@ public:
     virtual bool supportsSave() const;
     virtual bool supportsScanning() const override;
     
-    virtual bool doesHaveAttribute(const AtomicString&) const override;
+    virtual bool doesHaveAttribute(const AtomicString&, AtomicString* value = nullptr) const override;
 
     PlatformMedia platformMedia() const;
     PlatformLayer* platformLayer() const;
index 9d0f0122e457e5cfee62088d54f1809391358904..b4ea65deb0fddb6d45d1bc2d5508f98d628d7d4c 100644 (file)
@@ -1412,12 +1412,12 @@ void MediaPlayerFactorySupport::callRegisterMediaEngine(MediaEngineRegister regi
     registerMediaEngine(addMediaEngine);
 }
 
-bool MediaPlayer::doesHaveAttribute(const AtomicString& attribute) const
+bool MediaPlayer::doesHaveAttribute(const AtomicString& attribute, AtomicString* value) const
 {
     if (!m_mediaPlayerClient)
         return false;
     
-    return m_mediaPlayerClient->doesHaveAttribute(attribute);
+    return m_mediaPlayerClient->doesHaveAttribute(attribute, value);
 }
 
 }
index bd613701fee9d4b8d7aeb87a144bd974e178a19d..c634646b4888c42deeb7142a288c033ce22725ea 100644 (file)
@@ -248,7 +248,7 @@ public:
     virtual HostWindow* mediaPlayerHostWindow() { return 0; }
     virtual IntRect mediaPlayerWindowClipRect() { return IntRect(); }
     virtual CachedResourceLoader* mediaPlayerCachedResourceLoader() { return 0; }
-    virtual bool doesHaveAttribute(const AtomicString&) const { return false; }
+    virtual bool doesHaveAttribute(const AtomicString&, AtomicString* = 0) const { return false; }
 
 #if ENABLE(VIDEO_TRACK)
     virtual void mediaPlayerDidAddAudioTrack(PassRefPtr<AudioTrackPrivate>) { }
@@ -300,7 +300,7 @@ public:
     bool supportsSave() const;
     bool supportsScanning() const;
     bool requiresImmediateCompositing() const;
-    bool doesHaveAttribute(const AtomicString&) const;
+    bool doesHaveAttribute(const AtomicString&, AtomicString* value = nullptr) const;
     PlatformMedia platformMedia() const;
     PlatformLayer* platformLayer() const;
 #if PLATFORM(IOS)
index a02b2f758db3ba025695b49f035f6a72346634cd..45f609fa658810ba86efdda8ae29fce8cfe0cdf9 100644 (file)
 @end
 #endif
 
+#if PLATFORM(IOS)
+@class AVPlayerItem;
+@interface AVPlayerItem (WebKitExtensions)
+@property (nonatomic, copy) NSString* dataYouTubeID;
+@end
+#endif
+
 SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
 SOFT_LINK_FRAMEWORK_OPTIONAL(CoreMedia)
 SOFT_LINK_FRAMEWORK_OPTIONAL(CoreImage)
@@ -702,6 +709,12 @@ void MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem()
     if (m_avPlayer)
         [m_avPlayer.get() replaceCurrentItemWithPlayerItem:m_avPlayerItem.get()];
 
+#if PLATFORM(IOS)
+    AtomicString value;
+    if (player()->doesHaveAttribute("data-youtube-id", &value)) {
+        [m_avPlayerItem.get() setDataYouTubeID: value];
+ #endif
+
 #if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
     const NSTimeInterval legibleOutputAdvanceInterval = 2;