[MSE][Mac] Report the intrinsic size of the media element
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Jan 2014 01:49:21 +0000 (01:49 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Jan 2014 01:49:21 +0000 (01:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=125156

Reviewed by Eric Carlson.

* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::naturalSize): Pass to MediaSourcePrivateAVFObjC.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::sizeChanged): Added; Pass to MediaPlayer.
* platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
(WebCore::MediaSourcePrivateAVFObjC::naturalSize): Return the union of the naturalSizes of all active buffers.
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset): Notify the media player that the size changed.
(WebCore::SourceBufferPrivateAVFObjC::naturalSize): Return the size of the selected video track.
* platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.h:
* platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.mm: Renamed from Source/WebCore/platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.cpp.
(WebCore::VideoTrackPrivateMediaSourceAVFObjC::assetTrack): Made const.
(WebCore::VideoTrackPrivateMediaSourceAVFObjC::naturalSize): Return the size of the AVAssetTrack.

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

Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.mm [moved from Source/WebCore/platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.cpp with 86% similarity]

index 9862000..92adebe 100644 (file)
@@ -1,3 +1,27 @@
+2014-01-08  Jer Noble  <jer.noble@apple.com>
+
+        [MSE][Mac] Report the intrinsic size of the media element
+        https://bugs.webkit.org/show_bug.cgi?id=125156
+
+        Reviewed by Eric Carlson.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::naturalSize): Pass to MediaSourcePrivateAVFObjC.
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::sizeChanged): Added; Pass to MediaPlayer.
+        * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
+        (WebCore::MediaSourcePrivateAVFObjC::naturalSize): Return the union of the naturalSizes of all active buffers.
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+        (WebCore::SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset): Notify the media player that the size changed.
+        (WebCore::SourceBufferPrivateAVFObjC::naturalSize): Return the size of the selected video track.
+        * platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.h:
+        * platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.mm: Renamed from Source/WebCore/platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.cpp.
+        (WebCore::VideoTrackPrivateMediaSourceAVFObjC::assetTrack): Made const.
+        (WebCore::VideoTrackPrivateMediaSourceAVFObjC::naturalSize): Return the size of the AVAssetTrack.
+
 2014-01-09  Joseph Pecoraro  <pecoraro@apple.com>
 
         Unreviewed Windows build fix for r161563.
index d68055f..a355144 100644 (file)
                CD82030D1395AB6A00F956C6 /* WebVideoFullscreenHUDWindowController.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD8203091395AB6A00F956C6 /* WebVideoFullscreenHUDWindowController.mm */; };
                CD8203101395ACE700F956C6 /* WebWindowAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = CD82030E1395ACE700F956C6 /* WebWindowAnimation.h */; settings = {ATTRIBUTES = (Private, ); }; };
                CD8203111395ACE700F956C6 /* WebWindowAnimation.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD82030F1395ACE700F956C6 /* WebWindowAnimation.mm */; };
-               CD8B5A42180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD8B5A40180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.cpp */; };
+               CD8B5A42180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD8B5A40180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.mm */; };
                CD8B5A43180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8B5A41180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.h */; };
                CD8B5A46180DFF4E008B8E65 /* VideoTrackMediaSource.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8B5A45180DFF4E008B8E65 /* VideoTrackMediaSource.h */; };
                CD8B5A49180E138B008B8E65 /* TextTrackMediaSource.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8B5A48180E138B008B8E65 /* TextTrackMediaSource.h */; };
                CD8203091395AB6A00F956C6 /* WebVideoFullscreenHUDWindowController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebVideoFullscreenHUDWindowController.mm; sourceTree = "<group>"; };
                CD82030E1395ACE700F956C6 /* WebWindowAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebWindowAnimation.h; sourceTree = "<group>"; };
                CD82030F1395ACE700F956C6 /* WebWindowAnimation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebWindowAnimation.mm; sourceTree = "<group>"; };
-               CD8B5A40180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VideoTrackPrivateMediaSourceAVFObjC.cpp; path = objc/VideoTrackPrivateMediaSourceAVFObjC.cpp; sourceTree = "<group>"; };
+               CD8B5A40180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = VideoTrackPrivateMediaSourceAVFObjC.mm; path = objc/VideoTrackPrivateMediaSourceAVFObjC.mm; sourceTree = "<group>"; };
                CD8B5A41180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VideoTrackPrivateMediaSourceAVFObjC.h; path = objc/VideoTrackPrivateMediaSourceAVFObjC.h; sourceTree = "<group>"; };
                CD8B5A44180DD8D6008B8E65 /* VideoTrackMediaSource.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = VideoTrackMediaSource.idl; sourceTree = "<group>"; };
                CD8B5A45180DFF4E008B8E65 /* VideoTrackMediaSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoTrackMediaSource.h; sourceTree = "<group>"; };
                                CDC8B5A818047FF10016E685 /* SourceBufferPrivateAVFObjC.mm */,
                                CD336F6517FA0AC600DDDCD0 /* VideoTrackPrivateAVFObjC.cpp */,
                                CD336F6617FA0AC600DDDCD0 /* VideoTrackPrivateAVFObjC.h */,
-                               CD8B5A40180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.cpp */,
+                               CD8B5A40180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.mm */,
                                CD8B5A41180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.h */,
                                CD7E05201651A84100C1201F /* WebCoreAVFResourceLoader.h */,
                                CD7E05211651A84100C1201F /* WebCoreAVFResourceLoader.mm */,
                                07969DB917D14151007FF842 /* JSRTCPeerConnection.cpp in Sources */,
                                E0FEF372B27C53EAC1C1FBEE /* EventSource.cpp in Sources */,
                                E12EDBEA0B308E0B002704B6 /* EventTarget.cpp in Sources */,
-                               CD8B5A42180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.cpp in Sources */,
+                               CD8B5A42180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.mm in Sources */,
                                BC60D8F20D2A11E000B9918F /* ExceptionBase.cpp in Sources */,
                                973DC63F145A9409002842C2 /* ExceptionCodeDescription.cpp in Sources */,
                                A7CACDB113CE875C00BBBE3F /* ExceptionCodePlaceholder.cpp in Sources */,
index 0ed8f69..7f42f98 100644 (file)
@@ -303,8 +303,7 @@ void MediaPlayerPrivateMediaSourceAVFObjC::setMuted(bool muted)
 
 IntSize MediaPlayerPrivateMediaSourceAVFObjC::naturalSize() const
 {
-    // FIXME(125156): Report the intrinsic size of the enabled video track.
-    return IntSize();
+    return m_mediaSourcePrivate->naturalSize();
 }
 
 bool MediaPlayerPrivateMediaSourceAVFObjC::hasVideo() const
@@ -520,6 +519,11 @@ void MediaPlayerPrivateMediaSourceAVFObjC::effectiveRateChanged()
     m_player->rateChanged();
 }
 
+void MediaPlayerPrivateMediaSourceAVFObjC::sizeChanged()
+{
+    m_player->sizeChanged();
+}
+
 void MediaPlayerPrivateMediaSourceAVFObjC::setReadyState(MediaPlayer::ReadyState readyState)
 {
     if (m_readyState == readyState)
index 1834009..c4fc17a 100644 (file)
@@ -66,6 +66,7 @@ public:
     bool hasVideo() const;
 
     MediaTime seekToTime(MediaTime, MediaTime negativeThreshold, MediaTime positiveThreshold);
+    IntSize naturalSize() const;
 
 private:
     MediaSourcePrivateAVFObjC(MediaPlayerPrivateMediaSourceAVFObjC*);
index b83be72..53fac7b 100644 (file)
@@ -174,6 +174,16 @@ MediaTime MediaSourcePrivateAVFObjC::seekToTime(MediaTime targetTime, MediaTime
     return seekTime;
 }
 
+IntSize MediaSourcePrivateAVFObjC::naturalSize() const
+{
+    IntSize result;
+
+    for (auto* sourceBuffer : m_activeSourceBuffers)
+        result = result.expandedTo(sourceBuffer->naturalSize());
+
+    return result;
+}
+
 }
 
 #endif // ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION)
index c054c1d..82ca9a4 100644 (file)
@@ -79,6 +79,7 @@ public:
 
     void seekToTime(MediaTime);
     MediaTime fastSeekTimeForMediaTime(MediaTime, MediaTime negativeThreshold, MediaTime positiveThreshold);
+    IntSize naturalSize();
 
 private:
     explicit SourceBufferPrivateAVFObjC(MediaSourcePrivateAVFObjC*);
@@ -104,8 +105,8 @@ private:
     void didBecomeReadyForMoreSamples(int trackID);
     void destroyRenderers();
 
-    Vector<RefPtr<VideoTrackPrivate>> m_videoTracks;
-    Vector<RefPtr<AudioTrackPrivate>> m_audioTracks;
+    Vector<RefPtr<VideoTrackPrivateMediaSourceAVFObjC>> m_videoTracks;
+    Vector<RefPtr<AudioTrackPrivateMediaSourceAVFObjC>> m_audioTracks;
 
     RetainPtr<AVStreamDataParser> m_parser;
     RetainPtr<AVAsset> m_asset;
index 2102818..744ab58 100644 (file)
@@ -319,18 +319,25 @@ void SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset(AVAsset* asset)
 
     m_asset = asset;
 
+    m_videoTracks.clear();
+    m_audioTracks.clear();
+
     SourceBufferPrivateClient::InitializationSegment segment;
     segment.duration = toMediaTime([m_asset duration]);
 
     for (AVAssetTrack* track in [m_asset tracks]) {
         if ([track hasMediaCharacteristic:AVMediaCharacteristicVisual]) {
             SourceBufferPrivateClient::InitializationSegment::VideoTrackInformation info;
-            info.track = VideoTrackPrivateMediaSourceAVFObjC::create(track, this);
+            RefPtr<VideoTrackPrivateMediaSourceAVFObjC> videoTrack = VideoTrackPrivateMediaSourceAVFObjC::create(track, this);
+            info.track = videoTrack;
+            m_videoTracks.append(videoTrack);
             info.description = MediaDescriptionAVFObjC::create(track);
             segment.videoTracks.append(info);
         } else if ([track hasMediaCharacteristic:AVMediaCharacteristicAudible]) {
             SourceBufferPrivateClient::InitializationSegment::AudioTrackInformation info;
-            info.track = AudioTrackPrivateMediaSourceAVFObjC::create(track, this);
+            RefPtr<AudioTrackPrivateMediaSourceAVFObjC> audioTrack = AudioTrackPrivateMediaSourceAVFObjC::create(track, this);
+            info.track = audioTrack;
+            m_audioTracks.append(audioTrack);
             info.description = MediaDescriptionAVFObjC::create(track);
             segment.audioTracks.append(info);
         }
@@ -338,6 +345,9 @@ void SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset(AVAsset* asset)
         // FIXME(125161): Add TextTrack support
     }
 
+    if (!m_videoTracks.isEmpty())
+        m_mediaSource->player()->sizeChanged();
+
     if (m_client)
         m_client->sourceBufferPrivateDidReceiveInitializationSegment(this, segment);
 }
@@ -633,6 +643,16 @@ void SourceBufferPrivateAVFObjC::seekToTime(MediaTime time)
         m_client->sourceBufferPrivateSeekToTime(this, time);
 }
 
+IntSize SourceBufferPrivateAVFObjC::naturalSize()
+{
+    for (auto videoTrack : m_videoTracks) {
+        if (videoTrack->selected())
+            return videoTrack->naturalSize();
+    }
+
+    return IntSize();
+}
+
 void SourceBufferPrivateAVFObjC::didBecomeReadyForMoreSamples(int trackID)
 {
     if (trackID == m_enabledVideoTrackID)
index b336e1b..a5e090e 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef VideoTrackPrivateMediaSourceAVFObjC_h
 #define VideoTrackPrivateMediaSourceAVFObjC_h
 
+#include "IntSize.h"
 #include "VideoTrackPrivateAVF.h"
 
 #if ENABLE(MEDIA_SOURCE) && ENABLE(VIDEO_TRACK)
@@ -50,10 +51,12 @@ public:
     virtual void setSelected(bool) OVERRIDE;
 
     void setAssetTrack(AVAssetTrack*);
-    AVAssetTrack* assetTrack();
+    AVAssetTrack* assetTrack() const;
 
     int trackID() { return m_trackID; }
 
+    IntSize naturalSize() const;
+
 private:
     explicit VideoTrackPrivateMediaSourceAVFObjC(AVAssetTrack*, SourceBufferPrivateAVFObjC* parent);
     
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#include "config.h"
-#include "VideoTrackPrivateMediaSourceAVFObjC.h"
+#import "config.h"
+#import "VideoTrackPrivateMediaSourceAVFObjC.h"
 
 #if ENABLE(MEDIA_SOURCE) && ENABLE(VIDEO_TRACK)
 
-#include "AVTrackPrivateAVFObjCImpl.h"
-#include "SourceBufferPrivateAVFObjC.h"
+#import "AVTrackPrivateAVFObjCImpl.h"
+#import "SourceBufferPrivateAVFObjC.h"
+#import <AVFoundation/AVAssetTrack.h>
 
 namespace WebCore {
 
@@ -58,7 +59,7 @@ void VideoTrackPrivateMediaSourceAVFObjC::setAssetTrack(AVAssetTrack *track)
     resetPropertiesFromTrack();
 }
 
-AVAssetTrack* VideoTrackPrivateMediaSourceAVFObjC::assetTrack()
+AVAssetTrack* VideoTrackPrivateMediaSourceAVFObjC::assetTrack() const
 {
     return m_impl->assetTrack();
 }
@@ -78,6 +79,11 @@ void VideoTrackPrivateMediaSourceAVFObjC::setSelected(bool selected)
     m_parent->trackDidChangeEnabled(this);
 }
 
+IntSize VideoTrackPrivateMediaSourceAVFObjC::naturalSize() const
+{
+    return IntSize([assetTrack() naturalSize]);
+}
+
 }
 
 #endif