Title: [157991] trunk/Source
Revision
157991
Author
[email protected]
Date
2013-10-25 00:07:07 -0700 (Fri, 25 Oct 2013)

Log Message

[Mac] Add helper methods to convert CMTime <--> MediaTime
https://bugs.webkit.org/show_bug.cgi?id=123285

Reviewed by Eric Carlson.

Source/WebCore:

Add utility methods to convert between CMTime (a rational time class) and MediaTime.
Once there, PlatformClockCM can now vend and accept MediaTimes for currentTime.

* platform/mac/MediaTimeMac.h:
* platform/mac/MediaTimeMac.cpp:
(WebCore::toMediaTime): Added conversion utility method.
(WebCore::toCMTime): Ditto.

* platform/mac/PlatformClockCM.h:
* platform/mac/PlatformClockCM.mm:
(PlatformClockCM::setCurrentMediaTime): Added.
(PlatformClockCM::currentMediaTime): Added.

* WebCore.xcodeproj/project.pbxproj: Add new files to project.

Source/WTF:

Add a #ifdef header_h protector.

* wtf/MediaTime.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (157990 => 157991)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2013-10-25 05:17:56 UTC (rev 157990)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2013-10-25 07:07:07 UTC (rev 157991)
@@ -2461,7 +2461,6 @@
 		C2F0F2D016BAEEE900187C19 /* StructureRareData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StructureRareData.cpp; sourceTree = "<group>"; };
 		C2FC9BD216644DFB00810D33 /* CopiedBlockInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CopiedBlockInlines.h; sourceTree = "<group>"; };
 		C2FE18A316BAEC4000AF3061 /* StructureRareData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StructureRareData.h; sourceTree = "<group>"; };
-		FEE7D5A00D99AC04005351F6 /* iOS.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = iOS.xcconfig; sourceTree = "<group>"; };
 		D21202280AD4310C00ED79B6 /* DateConversion.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = DateConversion.cpp; sourceTree = "<group>"; };
 		D21202290AD4310C00ED79B6 /* DateConversion.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DateConversion.h; sourceTree = "<group>"; };
 		DDF7ABD211F60ED200108E36 /* GCActivityCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GCActivityCallback.h; sourceTree = "<group>"; };
@@ -2514,6 +2513,7 @@
 		FED94F2B171E3E2300BE77A4 /* Watchdog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Watchdog.cpp; sourceTree = "<group>"; };
 		FED94F2C171E3E2300BE77A4 /* Watchdog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Watchdog.h; sourceTree = "<group>"; };
 		FED94F2D171E3E2300BE77A4 /* WatchdogMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WatchdogMac.cpp; sourceTree = "<group>"; };
+		FEE7D5A00D99AC04005351F6 /* iOS.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = iOS.xcconfig; sourceTree = "<group>"; };
 		FEF6835A174343CC00A32E25 /* JITStubsARM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITStubsARM.h; sourceTree = "<group>"; };
 		FEF6835B174343CC00A32E25 /* JITStubsARMv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITStubsARMv7.h; sourceTree = "<group>"; };
 		FEF6835C174343CC00A32E25 /* JITStubsX86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITStubsX86_64.h; sourceTree = "<group>"; };

Modified: trunk/Source/WTF/ChangeLog (157990 => 157991)


--- trunk/Source/WTF/ChangeLog	2013-10-25 05:17:56 UTC (rev 157990)
+++ trunk/Source/WTF/ChangeLog	2013-10-25 07:07:07 UTC (rev 157991)
@@ -1,3 +1,14 @@
+2013-10-24  Jer Noble  <[email protected]>
+
+        [Mac] Add helper methods to convert CMTime <--> MediaTime
+        https://bugs.webkit.org/show_bug.cgi?id=123285
+
+        Reviewed by Eric Carlson.
+
+        Add a #ifdef header_h protector.
+
+        * wtf/MediaTime.h:
+
 2013-10-24  Mark Rowe  <[email protected]>
 
         Remove references to OS X 10.7 from Xcode configuration settings.

Modified: trunk/Source/WTF/wtf/MediaTime.h (157990 => 157991)


--- trunk/Source/WTF/wtf/MediaTime.h	2013-10-25 05:17:56 UTC (rev 157990)
+++ trunk/Source/WTF/wtf/MediaTime.h	2013-10-25 07:07:07 UTC (rev 157991)
@@ -26,6 +26,9 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifndef MediaTime_h
+#define MediaTime_h
+
 #include <wtf/FastMalloc.h>
 
 #include <cmath>
@@ -107,3 +110,5 @@
 
 using WTF::MediaTime;
 using WTF::abs;
+
+#endif

Modified: trunk/Source/WebCore/ChangeLog (157990 => 157991)


--- trunk/Source/WebCore/ChangeLog	2013-10-25 05:17:56 UTC (rev 157990)
+++ trunk/Source/WebCore/ChangeLog	2013-10-25 07:07:07 UTC (rev 157991)
@@ -1,3 +1,25 @@
+2013-10-24  Jer Noble  <[email protected]>
+
+        [Mac] Add helper methods to convert CMTime <--> MediaTime
+        https://bugs.webkit.org/show_bug.cgi?id=123285
+
+        Reviewed by Eric Carlson.
+
+        Add utility methods to convert between CMTime (a rational time class) and MediaTime.
+        Once there, PlatformClockCM can now vend and accept MediaTimes for currentTime.
+
+        * platform/mac/MediaTimeMac.h:
+        * platform/mac/MediaTimeMac.cpp:
+        (WebCore::toMediaTime): Added conversion utility method.
+        (WebCore::toCMTime): Ditto.
+
+        * platform/mac/PlatformClockCM.h:
+        * platform/mac/PlatformClockCM.mm:
+        (PlatformClockCM::setCurrentMediaTime): Added.
+        (PlatformClockCM::currentMediaTime): Added.
+
+        * WebCore.xcodeproj/project.pbxproj: Add new files to project.
+
 2013-10-24  Mark Rowe  <[email protected]>
 
         Remove references to OS X 10.7 from Xcode configuration settings.

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (157990 => 157991)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-10-25 05:17:56 UTC (rev 157990)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-10-25 07:07:07 UTC (rev 157991)
@@ -5318,6 +5318,8 @@
 		CD61FE851794CC59004101EB /* JSWebKitSourceBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = CD61FE811794CC59004101EB /* JSWebKitSourceBuffer.h */; };
 		CD61FE861794CC59004101EB /* JSWebKitSourceBufferList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD61FE821794CC59004101EB /* JSWebKitSourceBufferList.cpp */; };
 		CD61FE871794CC59004101EB /* JSWebKitSourceBufferList.h in Headers */ = {isa = PBXBuildFile; fileRef = CD61FE831794CC59004101EB /* JSWebKitSourceBufferList.h */; };
+		CD641EBF1819B36000EE4C41 /* MediaTimeMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD641EBD1819B35900EE4C41 /* MediaTimeMac.cpp */; };
+		CD641EC01819B36000EE4C41 /* MediaTimeMac.h in Headers */ = {isa = PBXBuildFile; fileRef = CD641EBE1819B35900EE4C41 /* MediaTimeMac.h */; };
 		CD7E05221651C28200C1201F /* WebCoreAVFResourceLoader.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD7E05211651A84100C1201F /* WebCoreAVFResourceLoader.mm */; };
 		CD82030A1395AB6A00F956C6 /* WebVideoFullscreenController.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8203061395AB6A00F956C6 /* WebVideoFullscreenController.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		CD82030B1395AB6A00F956C6 /* WebVideoFullscreenController.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD8203071395AB6A00F956C6 /* WebVideoFullscreenController.mm */; settings = {COMPILER_FLAGS = "-Wno-undef -Wno-deprecated-declarations"; }; };
@@ -12258,6 +12260,8 @@
 		CD61FE811794CC59004101EB /* JSWebKitSourceBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebKitSourceBuffer.h; sourceTree = "<group>"; };
 		CD61FE821794CC59004101EB /* JSWebKitSourceBufferList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitSourceBufferList.cpp; sourceTree = "<group>"; };
 		CD61FE831794CC59004101EB /* JSWebKitSourceBufferList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebKitSourceBufferList.h; sourceTree = "<group>"; };
+		CD641EBD1819B35900EE4C41 /* MediaTimeMac.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MediaTimeMac.cpp; sourceTree = "<group>"; };
+		CD641EBE1819B35900EE4C41 /* MediaTimeMac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaTimeMac.h; sourceTree = "<group>"; };
 		CD7E05201651A84100C1201F /* WebCoreAVFResourceLoader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WebCoreAVFResourceLoader.h; path = objc/WebCoreAVFResourceLoader.h; sourceTree = "<group>"; };
 		CD7E05211651A84100C1201F /* WebCoreAVFResourceLoader.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WebCoreAVFResourceLoader.mm; path = objc/WebCoreAVFResourceLoader.mm; sourceTree = "<group>"; };
 		CD8203061395AB6A00F956C6 /* WebVideoFullscreenController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebVideoFullscreenController.h; sourceTree = "<group>"; };
@@ -15207,6 +15211,8 @@
 				06E81EEB0AB5DA9700C87837 /* LocalCurrentGraphicsContext.mm */,
 				BC25B528131C6D3900180E10 /* LocalizedStringsMac.cpp */,
 				1402645D0AFDC19B005919E2 /* LoggingMac.mm */,
+				CD641EBD1819B35900EE4C41 /* MediaTimeMac.cpp */,
+				CD641EBE1819B35900EE4C41 /* MediaTimeMac.h */,
 				657EDA0A1385CBD8004E0645 /* MemoryPressureHandlerMac.mm */,
 				BC772C5D0C4EB3440083285F /* MIMETypeRegistryMac.mm */,
 				93500F3113FDE3BE0099EC24 /* NSScrollerImpDetails.h */,
@@ -22761,6 +22767,7 @@
 				1A71D57C0F33819000F9CE4E /* IdentifierRep.h in Headers */,
 				5913A24213D49EBA00F5B05C /* IdentifiersFactory.h in Headers */,
 				49E911C50EF86D47009D0CAF /* IdentityTransformOperation.h in Headers */,
+				CD641EC01819B36000EE4C41 /* MediaTimeMac.h in Headers */,
 				C0C054CD1118C8E400CE2636 /* IDLParser.pm in Headers */,
 				C3CF17A515B0063F00276D39 /* IdTargetObserver.h in Headers */,
 				C3CF17A715B0063F00276D39 /* IdTargetObserverRegistry.h in Headers */,
@@ -26343,6 +26350,7 @@
 				CDA98E0616039E1F00FEA3B1 /* JSMediaKeySession.cpp in Sources */,
 				BC3C39B60C0D3D8D005F4D7A /* JSMediaList.cpp in Sources */,
 				D3A94A46122DC40F00A37BBC /* JSMediaQueryList.cpp in Sources */,
+				CD641EBF1819B36000EE4C41 /* MediaTimeMac.cpp in Sources */,
 				FDBD480C159BC6870093EB4F /* JSMediaStreamAudioSourceNode.cpp in Sources */,
 				E107400D0E77BDC00033AF24 /* JSMessageChannel.cpp in Sources */,
 				E1A5F99B0E7EAA2500AF85EA /* JSMessageChannelCustom.cpp in Sources */,

Copied: trunk/Source/WebCore/platform/mac/MediaTimeMac.cpp (from rev 157990, trunk/Source/WebCore/platform/mac/PlatformClockCM.h) (0 => 157991)


--- trunk/Source/WebCore/platform/mac/MediaTimeMac.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/mac/MediaTimeMac.cpp	2013-10-25 07:07:07 UTC (rev 157991)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "MediaTimeMac.h"
+
+#if USE(COREMEDIA)
+
+namespace WebCore {
+
+MediaTime toMediaTime(const CMTime& cmTime)
+{
+    uint32_t flags = 0;
+    if (CMTIME_IS_VALID(cmTime))
+        flags |= MediaTime::Valid;
+    if (CMTIME_HAS_BEEN_ROUNDED(cmTime))
+        flags |= MediaTime::HasBeenRounded;
+    if (CMTIME_IS_POSITIVE_INFINITY(cmTime))
+        flags |= MediaTime::PositiveInfinite;
+    if (CMTIME_IS_NEGATIVE_INFINITY(cmTime))
+        flags |= MediaTime::NegativeInfinite;
+    if (CMTIME_IS_INDEFINITE(cmTime))
+        flags |= MediaTime::Indefinite;
+
+    return MediaTime(cmTime.value, cmTime.timescale, flags);
+}
+
+CMTime toCMTime(const MediaTime& mediaTime)
+{
+    CMTime time = {mediaTime.timeValue(), mediaTime.timeScale(), 0, 0};
+
+    if (mediaTime.isValid())
+        time.flags |= kCMTimeFlags_Valid;
+    if (mediaTime.hasBeenRounded())
+        time.flags |= kCMTimeFlags_HasBeenRounded;
+    if (mediaTime.isPositiveInfinite())
+        time.flags |= kCMTimeFlags_PositiveInfinity;
+    if (mediaTime.isNegativeInfinite())
+        time.flags |= kCMTimeFlags_NegativeInfinity;
+
+    return time;
+}
+
+}
+
+#endif

Copied: trunk/Source/WebCore/platform/mac/MediaTimeMac.h (from rev 157990, trunk/Source/WebCore/platform/mac/PlatformClockCM.h) (0 => 157991)


--- trunk/Source/WebCore/platform/mac/MediaTimeMac.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/mac/MediaTimeMac.h	2013-10-25 07:07:07 UTC (rev 157991)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef MediaTimeMac_h
+#define MediaTimeMac_h
+
+#if USE(COREMEDIA)
+
+#include <CoreMedia/CMTime.h>
+#include <wtf/MediaTime.h>
+
+namespace WebCore {
+
+CMTime toCMTime(const MediaTime&);
+MediaTime toMediaTime(const CMTime&);
+
+}
+
+#endif
+
+#endif

Modified: trunk/Source/WebCore/platform/mac/PlatformClockCM.h (157990 => 157991)


--- trunk/Source/WebCore/platform/mac/PlatformClockCM.h	2013-10-25 05:17:56 UTC (rev 157990)
+++ trunk/Source/WebCore/platform/mac/PlatformClockCM.h	2013-10-25 07:07:07 UTC (rev 157991)
@@ -29,6 +29,7 @@
 #if USE(COREMEDIA)
 
 #include "Clock.h"
+#include <wtf/MediaTime.h>
 #include <wtf/RetainPtr.h>
 
 typedef struct OpaqueCMTimebase* CMTimebaseRef;
@@ -41,12 +42,12 @@
     PlatformClockCM();
     PlatformClockCM(CMClockRef);
 
-private:
-    void initializeWithTimingSource(CMClockRef);
-
     virtual void setCurrentTime(double) OVERRIDE;
     virtual double currentTime() const OVERRIDE;
 
+    void setCurrentMediaTime(const MediaTime&);
+    MediaTime currentMediaTime() const;
+
     virtual void setPlayRate(double) OVERRIDE;
     virtual double playRate() const OVERRIDE { return m_rate; }
 
@@ -54,6 +55,9 @@
     virtual void stop() OVERRIDE;
     virtual bool isRunning() const OVERRIDE { return m_running; }
 
+private:
+    void initializeWithTimingSource(CMClockRef);
+
     RetainPtr<CMTimebaseRef> m_timebase;
     double m_rate;
     bool m_running;

Modified: trunk/Source/WebCore/platform/mac/PlatformClockCM.mm (157990 => 157991)


--- trunk/Source/WebCore/platform/mac/PlatformClockCM.mm	2013-10-25 05:17:56 UTC (rev 157990)
+++ trunk/Source/WebCore/platform/mac/PlatformClockCM.mm	2013-10-25 07:07:07 UTC (rev 157991)
@@ -29,6 +29,7 @@
 
 #import "PlatformClockCM.h"
 
+#import "MediaTimeMac.h"
 #import "SoftLinking.h"
 #import <CoreMedia/CMAudioDeviceClock.h>
 
@@ -84,6 +85,16 @@
     return CMTimeGetSeconds(cmTime);
 }
 
+void PlatformClockCM::setCurrentMediaTime(const MediaTime& time)
+{
+    CMTimebaseSetTime(m_timebase.get(), toCMTime(time));
+}
+
+MediaTime PlatformClockCM::currentMediaTime() const
+{
+    return toMediaTime(CMTimebaseGetTime(m_timebase.get()));
+}
+
 void PlatformClockCM::setPlayRate(double rate)
 {
     if (m_rate == rate)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to