Changeset 246699 in webkit
- Timestamp:
- Jun 21, 2019 3:08:58 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r246696 r246699 1 2019-06-21 Truitt Savell <tsavell@apple.com> 2 3 Unreviewed, rolling out r246611. 4 5 Introduced a flakey test. 6 7 Reverted changeset: 8 9 "iOS 12.2 Drawing portrait video to canvas is sideways" 10 https://bugs.webkit.org/show_bug.cgi?id=196772 11 https://trac.webkit.org/changeset/246611 12 1 13 2019-06-21 Myles C. Maxfield <mmaxfield@apple.com> 2 14 -
trunk/LayoutTests/media/media-source/only-bcp47-language-tags-accepted-as-valid-expected.txt
r246611 r246699 1 CONSOLE MESSAGE: line 22 2: The language 'a' is not a valid BCP 47 language tag.1 CONSOLE MESSAGE: line 221: The language 'a' is not a valid BCP 47 language tag. 2 2 CONSOLE MESSAGE: line 106: The language 'a' is not a valid BCP 47 language tag. 3 CONSOLE MESSAGE: line 22 2: The language 'a' is not a valid BCP 47 language tag.4 CONSOLE MESSAGE: line 22 2: The language '1' is not a valid BCP 47 language tag.3 CONSOLE MESSAGE: line 221: The language 'a' is not a valid BCP 47 language tag. 4 CONSOLE MESSAGE: line 221: The language '1' is not a valid BCP 47 language tag. 5 5 CONSOLE MESSAGE: line 106: The language '1' is not a valid BCP 47 language tag. 6 CONSOLE MESSAGE: line 22 2: The language '1' is not a valid BCP 47 language tag.7 CONSOLE MESSAGE: line 22 2: The language 'ab-abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij' is not a valid BCP 47 language tag.6 CONSOLE MESSAGE: line 221: The language '1' is not a valid BCP 47 language tag. 7 CONSOLE MESSAGE: line 221: The language 'ab-abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij' is not a valid BCP 47 language tag. 8 8 CONSOLE MESSAGE: line 106: The language 'ab-abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij' is not a valid BCP 47 language tag. 9 CONSOLE MESSAGE: line 22 2: The language 'ab-abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij' is not a valid BCP 47 language tag.10 CONSOLE MESSAGE: line 22 2: The language '1a' is not a valid BCP 47 language tag.9 CONSOLE MESSAGE: line 221: The language 'ab-abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij' is not a valid BCP 47 language tag. 10 CONSOLE MESSAGE: line 221: The language '1a' is not a valid BCP 47 language tag. 11 11 CONSOLE MESSAGE: line 106: The language '1a' is not a valid BCP 47 language tag. 12 CONSOLE MESSAGE: line 22 2: The language '1a' is not a valid BCP 47 language tag.13 CONSOLE MESSAGE: line 22 2: The language '-a' is not a valid BCP 47 language tag.12 CONSOLE MESSAGE: line 221: The language '1a' is not a valid BCP 47 language tag. 13 CONSOLE MESSAGE: line 221: The language '-a' is not a valid BCP 47 language tag. 14 14 CONSOLE MESSAGE: line 106: The language '-a' is not a valid BCP 47 language tag. 15 CONSOLE MESSAGE: line 22 2: The language '-a' is not a valid BCP 47 language tag.16 CONSOLE MESSAGE: line 22 2: The language 'a-' is not a valid BCP 47 language tag.15 CONSOLE MESSAGE: line 221: The language '-a' is not a valid BCP 47 language tag. 16 CONSOLE MESSAGE: line 221: The language 'a-' is not a valid BCP 47 language tag. 17 17 CONSOLE MESSAGE: line 106: The language 'a-' is not a valid BCP 47 language tag. 18 CONSOLE MESSAGE: line 22 2: The language 'a-' is not a valid BCP 47 language tag.19 CONSOLE MESSAGE: line 22 2: The language 'a1' is not a valid BCP 47 language tag.18 CONSOLE MESSAGE: line 221: The language 'a-' is not a valid BCP 47 language tag. 19 CONSOLE MESSAGE: line 221: The language 'a1' is not a valid BCP 47 language tag. 20 20 CONSOLE MESSAGE: line 106: The language 'a1' is not a valid BCP 47 language tag. 21 CONSOLE MESSAGE: line 22 2: The language 'a1' is not a valid BCP 47 language tag.22 CONSOLE MESSAGE: line 22 2: The language 'aa1' is not a valid BCP 47 language tag.21 CONSOLE MESSAGE: line 221: The language 'a1' is not a valid BCP 47 language tag. 22 CONSOLE MESSAGE: line 221: The language 'aa1' is not a valid BCP 47 language tag. 23 23 CONSOLE MESSAGE: line 106: The language 'aa1' is not a valid BCP 47 language tag. 24 CONSOLE MESSAGE: line 22 2: The language 'aa1' is not a valid BCP 47 language tag.25 CONSOLE MESSAGE: line 22 2: The language 'aaaa' is not a valid BCP 47 language tag.24 CONSOLE MESSAGE: line 221: The language 'aa1' is not a valid BCP 47 language tag. 25 CONSOLE MESSAGE: line 221: The language 'aaaa' is not a valid BCP 47 language tag. 26 26 CONSOLE MESSAGE: line 106: The language 'aaaa' is not a valid BCP 47 language tag. 27 CONSOLE MESSAGE: line 22 2: The language 'aaaa' is not a valid BCP 47 language tag.28 CONSOLE MESSAGE: line 22 2: The language 'aaa1' is not a valid BCP 47 language tag.27 CONSOLE MESSAGE: line 221: The language 'aaaa' is not a valid BCP 47 language tag. 28 CONSOLE MESSAGE: line 221: The language 'aaa1' is not a valid BCP 47 language tag. 29 29 CONSOLE MESSAGE: line 106: The language 'aaa1' is not a valid BCP 47 language tag. 30 CONSOLE MESSAGE: line 22 2: The language 'aaa1' is not a valid BCP 47 language tag.31 CONSOLE MESSAGE: line 22 2: The language 'inv-alid-char space' is not a valid BCP 47 language tag.30 CONSOLE MESSAGE: line 221: The language 'aaa1' is not a valid BCP 47 language tag. 31 CONSOLE MESSAGE: line 221: The language 'inv-alid-char space' is not a valid BCP 47 language tag. 32 32 CONSOLE MESSAGE: line 106: The language 'inv-alid-char space' is not a valid BCP 47 language tag. 33 CONSOLE MESSAGE: line 22 2: The language 'inv-alid-char space' is not a valid BCP 47 language tag.34 CONSOLE MESSAGE: line 22 2: The language 'inv-alid-char–longDash' is not a valid BCP 47 language tag.33 CONSOLE MESSAGE: line 221: The language 'inv-alid-char space' is not a valid BCP 47 language tag. 34 CONSOLE MESSAGE: line 221: The language 'inv-alid-char–longDash' is not a valid BCP 47 language tag. 35 35 CONSOLE MESSAGE: line 106: The language 'inv-alid-char–longDash' is not a valid BCP 47 language tag. 36 CONSOLE MESSAGE: line 22 2: The language 'inv-alid-char–longDash' is not a valid BCP 47 language tag.37 CONSOLE MESSAGE: line 22 2: The language 'inv-alid-char-Pålska' is not a valid BCP 47 language tag.36 CONSOLE MESSAGE: line 221: The language 'inv-alid-char–longDash' is not a valid BCP 47 language tag. 37 CONSOLE MESSAGE: line 221: The language 'inv-alid-char-Pålska' is not a valid BCP 47 language tag. 38 38 CONSOLE MESSAGE: line 106: The language 'inv-alid-char-Pålska' is not a valid BCP 47 language tag. 39 CONSOLE MESSAGE: line 22 2: The language 'inv-alid-char-Pålska' is not a valid BCP 47 language tag.40 CONSOLE MESSAGE: line 22 2: The language 'inv-alid-char-*' is not a valid BCP 47 language tag.39 CONSOLE MESSAGE: line 221: The language 'inv-alid-char-Pålska' is not a valid BCP 47 language tag. 40 CONSOLE MESSAGE: line 221: The language 'inv-alid-char-*' is not a valid BCP 47 language tag. 41 41 CONSOLE MESSAGE: line 106: The language 'inv-alid-char-*' is not a valid BCP 47 language tag. 42 CONSOLE MESSAGE: line 22 2: The language 'inv-alid-char-*' is not a valid BCP 47 language tag.43 CONSOLE MESSAGE: line 22 2: The language 'inv-alid-char-' is not a valid BCP 47 language tag.42 CONSOLE MESSAGE: line 221: The language 'inv-alid-char-*' is not a valid BCP 47 language tag. 43 CONSOLE MESSAGE: line 221: The language 'inv-alid-char-' is not a valid BCP 47 language tag. 44 44 CONSOLE MESSAGE: line 106: The language 'inv-alid-char-' is not a valid BCP 47 language tag. 45 CONSOLE MESSAGE: line 22 2: The language 'inv-alid-char-' is not a valid BCP 47 language tag.45 CONSOLE MESSAGE: line 221: The language 'inv-alid-char-' is not a valid BCP 47 language tag. 46 46 Test that only BCP47 language tags are accepted as valid but still reflected. 47 47 -
trunk/LayoutTests/media/video-test.js
r246611 r246699 187 187 } 188 188 189 function waitFor(element, type , silent) {189 function waitFor(element, type) { 190 190 return new Promise(resolve => { 191 191 element.addEventListener(type, event => { 192 if (!silent) 193 consoleWrite(`EVENT(${event.type})`); 192 consoleWrite(`EVENT(${event.type})`); 194 193 resolve(event); 195 194 }, { once: true }); -
trunk/Source/WebCore/ChangeLog
r246695 r246699 1 2019-06-21 Truitt Savell <tsavell@apple.com> 2 3 Unreviewed, rolling out r246611. 4 5 Introduced a flakey test. 6 7 Reverted changeset: 8 9 "iOS 12.2 Drawing portrait video to canvas is sideways" 10 https://bugs.webkit.org/show_bug.cgi?id=196772 11 https://trac.webkit.org/changeset/246611 12 1 13 2019-06-21 Tim Horton <timothy_horton@apple.com> 2 14 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r246644 r246699 4028 4028 CD225C0B1C46FBF400140761 /* WebCoreNSURLSession.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD225C091C46FBF400140761 /* WebCoreNSURLSession.mm */; }; 4029 4029 CD225C0C1C46FBF400140761 /* WebCoreNSURLSession.h in Headers */ = {isa = PBXBuildFile; fileRef = CD225C0A1C46FBF400140761 /* WebCoreNSURLSession.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4030 CD27AE5022A9868700947FF9 /* ImageRotationSessionVT.h in Headers */ = {isa = PBXBuildFile; fileRef = CD27AE4E22A9868700947FF9 /* ImageRotationSessionVT.h */; };4031 CD27AE5122A9868700947FF9 /* ImageRotationSessionVT.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD27AE4F22A9868700947FF9 /* ImageRotationSessionVT.mm */; };4032 4030 CD2F4A2418D89F700063746D /* AudioHardwareListener.h in Headers */ = {isa = PBXBuildFile; fileRef = CD2F4A2218D89F700063746D /* AudioHardwareListener.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4033 4031 CD2F4A2818D8A3490063746D /* AudioHardwareListenerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = CD2F4A2618D8A3490063746D /* AudioHardwareListenerMac.h */; }; … … 13519 13517 CD225C091C46FBF400140761 /* WebCoreNSURLSession.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreNSURLSession.mm; sourceTree = "<group>"; }; 13520 13518 CD225C0A1C46FBF400140761 /* WebCoreNSURLSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreNSURLSession.h; sourceTree = "<group>"; }; 13521 CD27AE4E22A9868700947FF9 /* ImageRotationSessionVT.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageRotationSessionVT.h; sourceTree = "<group>"; };13522 CD27AE4F22A9868700947FF9 /* ImageRotationSessionVT.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ImageRotationSessionVT.mm; sourceTree = "<group>"; };13523 13519 CD27F6E014575C1B0078207D /* MediaController.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MediaController.idl; sourceTree = "<group>"; }; 13524 13520 CD27F6E2145767580078207D /* JSMediaController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaController.cpp; sourceTree = "<group>"; }; … … 25683 25679 isa = PBXGroup; 25684 25680 children = ( 25685 CD27AE4E22A9868700947FF9 /* ImageRotationSessionVT.h */,25686 CD27AE4F22A9868700947FF9 /* ImageRotationSessionVT.mm */,25687 25681 0746D30C2146EA38003DDF84 /* ImageTransferSessionVT.h */, 25688 25682 0746D30A2146EA37003DDF84 /* ImageTransferSessionVT.mm */, … … 29524 29518 B51A2F3F17D7D3AE0072517A /* ImageQualityController.h in Headers */, 29525 29519 49291E4B134172C800E753DE /* ImageRenderingMode.h in Headers */, 29526 CD27AE5022A9868700947FF9 /* ImageRotationSessionVT.h in Headers */,29527 29520 7C193BC11F5E0EED0088F3E6 /* ImageSmoothingQuality.h in Headers */, 29528 29521 5546757B1FD212A9003B10B0 /* ImageSource.h in Headers */, … … 32780 32773 1AC900C31943C0FC008625B5 /* HTTPHeaderNames.cpp in Sources */, 32781 32774 CD19FEAF1F574B6D000C42FB /* ImageDecoderAVFObjC.mm in Sources */, 32782 CD27AE5122A9868700947FF9 /* ImageRotationSessionVT.mm in Sources */,32783 32775 BE961C5418AD338500D07DC5 /* InbandDataTextTrack.cpp in Sources */, 32784 32776 BE16C59217CFE17200852C04 /* InbandGenericTextTrack.cpp in Sources */, -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h
r246611 r246699 39 39 OBJC_CLASS WebCoreSharedBufferResourceLoaderDelegate; 40 40 typedef struct opaqueCMSampleBuffer* CMSampleBufferRef; 41 typedef struct OpaqueVTImageRotationSession* VTImageRotationSessionRef; 42 typedef struct __CVPixelBufferPool* CVPixelBufferPoolRef; 41 43 42 44 namespace WTF { … … 48 50 class ContentType; 49 51 class ImageDecoderAVFObjCSample; 50 class ImageRotationSessionVT;51 52 class PixelBufferConformerCV; 52 53 class WebCoreDecompressionSession; … … 90 91 void clearFrameBufferCache(size_t) final; 91 92 93 struct RotationProperties { 94 bool flipX { false }; 95 bool flipY { false }; 96 unsigned angle { 0 }; 97 98 bool isIdentity() const { return !flipX && !flipY && !angle; } 99 }; 100 92 101 private: 93 102 ImageDecoderAVFObjC(SharedBuffer&, const String& mimeType, AlphaOption, GammaAndColorProfileOption); … … 108 117 RetainPtr<AVAssetTrack> m_track; 109 118 RetainPtr<WebCoreSharedBufferResourceLoaderDelegate> m_loader; 110 std::unique_ptr<ImageRotationSessionVT> m_imageRotationSession; 119 RetainPtr<VTImageRotationSessionRef> m_rotationSession; 120 RetainPtr<CVPixelBufferPoolRef> m_rotationPool; 111 121 Ref<WebCoreDecompressionSession> m_decompressionSession; 112 122 WTF::Function<void(EncodedDataStatus)> m_encodedDataStatusChangedCallback; … … 117 127 bool m_isAllDataReceived { false }; 118 128 Optional<IntSize> m_size; 129 Optional<RotationProperties> m_rotation; 119 130 }; 120 131 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm
r246611 r246699 35 35 #import "FloatRect.h" 36 36 #import "FloatSize.h" 37 #import "ImageRotationSessionVT.h"38 37 #import "Logging.h" 39 38 #import "MIMETypeRegistry.h" … … 235 234 } 236 235 236 static ImageDecoderAVFObjC::RotationProperties transformToRotationProperties(AffineTransform inTransform) 237 { 238 ImageDecoderAVFObjC::RotationProperties rotation; 239 if (inTransform.isIdentity()) 240 return rotation; 241 242 AffineTransform::DecomposedType decomposed { }; 243 if (!inTransform.decompose(decomposed)) 244 return rotation; 245 246 rotation.flipY = WTF::areEssentiallyEqual(decomposed.scaleX, -1.); 247 rotation.flipX = WTF::areEssentiallyEqual(decomposed.scaleY, -1.); 248 auto degrees = rad2deg(decomposed.angle); 249 while (degrees < 0) 250 degrees += 360; 251 252 // Only support rotation in multiples of 90º: 253 if (WTF::areEssentiallyEqual(fmod(degrees, 90.), 0.)) 254 rotation.angle = clampToUnsigned(degrees); 255 256 return rotation; 257 } 258 237 259 class ImageDecoderAVFObjCSample : public MediaSampleAVFObjC { 238 260 public: … … 401 423 void ImageDecoderAVFObjC::readTrackMetadata() 402 424 { 403 AffineTransform finalTransform = CGAffineTransformConcat(m_asset.get().preferredTransform, m_track.get().preferredTransform); 404 auto size = expandedIntSize(FloatSize(m_track.get().naturalSize)); 405 if (finalTransform.isIdentity()) { 406 m_size = size; 407 m_imageRotationSession = nullptr; 408 return; 409 } 410 411 if (!m_imageRotationSession 412 || !m_imageRotationSession->transform() 413 || m_imageRotationSession->transform().value() != finalTransform 414 || m_imageRotationSession->size() != size) 415 m_imageRotationSession = std::make_unique<ImageRotationSessionVT>(WTFMove(finalTransform), size, kCVPixelFormatType_32BGRA, ImageRotationSessionVT::IsCGImageCompatible::Yes); 416 417 m_size = expandedIntSize(m_imageRotationSession->rotatedSize()); 425 if (!m_rotation) 426 m_rotation = transformToRotationProperties(CGAffineTransformConcat(m_asset.get().preferredTransform, m_track.get().preferredTransform)); 427 428 if (!m_size) { 429 auto size = FloatSize(m_track.get().naturalSize); 430 auto angle = m_rotation.value().angle; 431 if (angle == 90 || angle == 270) 432 size = size.transposedSize(); 433 434 m_size = expandedIntSize(size); 435 } 418 436 } 419 437 … … 429 447 auto iter = m_sampleData.presentationOrder().findSampleWithPresentationTime(presentationTime); 430 448 431 if (m_imageRotationSession) 432 pixelBuffer = m_imageRotationSession->rotate(pixelBuffer.get()); 449 if (m_rotation && !m_rotation.value().isIdentity()) { 450 auto& rotation = m_rotation.value(); 451 if (!m_rotationSession) { 452 VTImageRotationSessionRef rawRotationSession = nullptr; 453 VTImageRotationSessionCreate(kCFAllocatorDefault, rotation.angle, &rawRotationSession); 454 m_rotationSession = rawRotationSession; 455 VTImageRotationSessionSetProperty(m_rotationSession.get(), kVTImageRotationPropertyKey_EnableHighSpeedTransfer, kCFBooleanTrue); 456 457 if (rotation.flipY) 458 VTImageRotationSessionSetProperty(m_rotationSession.get(), kVTImageRotationPropertyKey_FlipVerticalOrientation, kCFBooleanTrue); 459 if (rotation.flipX) 460 VTImageRotationSessionSetProperty(m_rotationSession.get(), kVTImageRotationPropertyKey_FlipHorizontalOrientation, kCFBooleanTrue); 461 } 462 463 if (!m_rotationPool) { 464 auto pixelAttributes = @{ 465 (__bridge NSString *)kCVPixelBufferWidthKey: @(m_size.value().width()), 466 (__bridge NSString *)kCVPixelBufferHeightKey: @(m_size.value().height()), 467 (__bridge NSString *)kCVPixelBufferPixelFormatTypeKey: @(kCVPixelFormatType_32BGRA), 468 (__bridge NSString *)kCVPixelBufferCGImageCompatibilityKey: @YES, 469 }; 470 CVPixelBufferPoolRef rawPool = nullptr; 471 CVPixelBufferPoolCreate(kCFAllocatorDefault, nullptr, (__bridge CFDictionaryRef)pixelAttributes, &rawPool); 472 m_rotationPool = adoptCF(rawPool); 473 } 474 475 CVPixelBufferRef rawRotatedBuffer = nullptr; 476 CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, m_rotationPool.get(), &rawRotatedBuffer); 477 auto status = VTImageRotationSessionTransferImage(m_rotationSession.get(), pixelBuffer.get(), rawRotatedBuffer); 478 if (status == noErr) 479 pixelBuffer = adoptCF(rawRotatedBuffer); 480 } 433 481 434 482 CGImageRef rawImage = nullptr; … … 459 507 m_sampleData.clear(); 460 508 m_size.reset(); 509 m_rotation.reset(); 461 510 m_cursor = m_sampleData.decodeOrder().end(); 462 m_ imageRotationSession = nullptr;511 m_rotationSession = nullptr; 463 512 464 513 [track loadValuesAsynchronouslyForKeys:@[@"naturalSize", @"preferredTransform"] completionHandler:[protectedThis = makeRefPtr(this)] () mutable { -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
r246611 r246699 59 59 class CDMInstanceFairPlayStreamingAVFObjC; 60 60 class CDMSessionAVFoundationObjC; 61 class ImageRotationSessionVT;62 61 class InbandMetadataTextTrackPrivateAVF; 63 62 class MediaSelectionGroupAVFObjC; … … 327 326 328 327 void setShouldDisableSleep(bool) override; 329 void updateRotationSession();330 328 331 329 Optional<VideoPlaybackQualityMetrics> videoPlaybackQualityMetrics() final; … … 363 361 RetainPtr<CGImageRef> m_lastImage; 364 362 BinarySemaphore m_videoOutputSemaphore; 365 std::unique_ptr<ImageRotationSessionVT> m_imageRotationSession;366 363 std::unique_ptr<VideoTextureCopierCV> m_videoTextureCopier; 367 364 #endif -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
r246611 r246699 44 44 #import "GraphicsContext3D.h" 45 45 #import "GraphicsContextCG.h" 46 #import "ImageRotationSessionVT.h"47 46 #import "InbandMetadataTextTrackPrivateAVF.h" 48 47 #import "InbandTextTrackPrivateAVFObjC.h" … … 1865 1864 } 1866 1865 1867 void MediaPlayerPrivateAVFoundationObjC::updateRotationSession()1868 {1869 AffineTransform finalTransform = m_avAsset.get().preferredTransform;1870 FloatSize naturalSize;1871 if (auto* firstEnabledVideoTrack = firstEnabledTrack([m_avAsset.get() tracksWithMediaCharacteristic:AVMediaCharacteristicVisual])) {1872 naturalSize = FloatSize(firstEnabledVideoTrack.naturalSize);1873 finalTransform *= firstEnabledVideoTrack.preferredTransform;1874 }1875 1876 if (finalTransform.isIdentity()) {1877 m_imageRotationSession = nullptr;1878 return;1879 }1880 1881 if (m_imageRotationSession1882 && m_imageRotationSession->transform()1883 && m_imageRotationSession->transform().value() == finalTransform1884 && m_imageRotationSession->size() == naturalSize)1885 return;1886 1887 m_imageRotationSession = std::make_unique<ImageRotationSessionVT>(WTFMove(finalTransform), naturalSize, kCVPixelFormatType_32BGRA, ImageRotationSessionVT::IsCGImageCompatible::Yes);1888 }1889 1890 1866 #if ENABLE(VIDEO_TRACK) 1891 1867 … … 2078 2054 return; 2079 2055 2080 updateRotationSession();2081 2056 setNaturalSize(m_cachedPresentationSize); 2082 2057 } … … 2166 2141 2167 2142 m_lastPixelBuffer = adoptCF([m_videoOutput.get() copyPixelBufferForItemTime:currentTime itemTimeForDisplay:nil]); 2168 2169 if (m_imageRotationSession)2170 m_lastPixelBuffer = m_imageRotationSession->rotate(m_lastPixelBuffer.get());2171 2172 2143 m_lastImage = nullptr; 2173 2144 return true; … … 2236 2207 INFO_LOG(LOGIDENTIFIER); 2237 2208 2209 GraphicsContextStateSaver stateSaver(context); 2238 2210 FloatRect imageRect(0, 0, CGImageGetWidth(m_lastImage.get()), CGImageGetHeight(m_lastImage.get())); 2239 context.drawNativeImage(m_lastImage.get(), imageRect.size(), outputRect, imageRect); 2211 AffineTransform videoTransform = [firstEnabledVideoTrack preferredTransform]; 2212 FloatRect transformedOutputRect = videoTransform.inverse().valueOr(AffineTransform()).mapRect(outputRect); 2213 2214 context.concatCTM(videoTransform); 2215 context.drawNativeImage(m_lastImage.get(), imageRect.size(), transformedOutputRect, imageRect); 2240 2216 2241 2217 // If we have created an AVAssetImageGenerator in the past due to m_videoOutput not having an available -
trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.cpp
r246611 r246699 29 29 #if USE(LIBWEBRTC) 30 30 31 #include "ImageRotationSessionVT.h"32 31 #include "Logging.h" 33 32 #include "RealtimeIncomingVideoSourceCocoa.h" -
trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.h
r246611 r246699 32 32 #include <webrtc/api/video/video_rotation.h> 33 33 34 typedef struct OpaqueVTImageRotationSession* VTImageRotationSessionRef; 35 typedef struct __CVPixelBufferPool* CVPixelBufferPoolRef; 36 34 37 namespace WebCore { 35 36 class ImageRotationSessionVT;37 38 38 39 class RealtimeOutgoingVideoSourceCocoa final : public RealtimeOutgoingVideoSource { … … 52 53 53 54 std::unique_ptr<PixelBufferConformerCV> m_pixelBufferConformer; 54 std::unique_ptr<ImageRotationSessionVT> m_rotationSession; 55 RetainPtr<VTImageRotationSessionRef> m_rotationSession; 56 RetainPtr<CVPixelBufferPoolRef> m_rotationPool; 55 57 webrtc::VideoRotation m_currentRotationSessionAngle { webrtc::kVideoRotation_0 }; 56 58 size_t m_rotatedWidth { 0 }; -
trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.mm
r246611 r246699 29 29 #if USE(LIBWEBRTC) 30 30 31 #import "AffineTransform.h"32 #import "ImageRotationSessionVT.h"33 31 #import "Logging.h" 34 32 #import "MediaSample.h" … … 52 50 } 53 51 54 static inline unsigned rotationToAngle(webrtc::VideoRotation rotation)52 static inline void computeRotatedWidthAndHeight(CVPixelBufferRef pixelBuffer, webrtc::VideoRotation rotation, size_t& width, size_t& height) 55 53 { 56 54 switch (rotation) { 57 55 case webrtc::kVideoRotation_0: 58 return 0; 56 case webrtc::kVideoRotation_180: 57 width = CVPixelBufferGetWidth(pixelBuffer); 58 height = CVPixelBufferGetHeight(pixelBuffer); 59 return; 59 60 case webrtc::kVideoRotation_90: 60 return 90;61 case webrtc::kVideoRotation_180:62 return 180;63 61 case webrtc::kVideoRotation_270: 64 return 270; 62 width = CVPixelBufferGetHeight(pixelBuffer); 63 height = CVPixelBufferGetWidth(pixelBuffer); 64 return; 65 65 } 66 66 } … … 73 73 74 74 if (!m_rotationSession || rotation != m_currentRotationSessionAngle) { 75 IntSize size = { (int)CVPixelBufferGetWidth(pixelBuffer) , (int)CVPixelBufferGetHeight(pixelBuffer) }; 76 AffineTransform transform; 77 transform.rotate(rotationToAngle(rotation)); 78 m_rotationSession = std::make_unique<ImageRotationSessionVT>(WTFMove(transform), size, CVPixelBufferGetPixelFormatType(pixelBuffer), ImageRotationSessionVT::IsCGImageCompatible::No); 75 VTImageRotationSessionRef rawRotationSession = nullptr; 76 auto status = VTImageRotationSessionCreate(kCFAllocatorDefault, rotation, &rawRotationSession); 77 if (status != noErr) { 78 ERROR_LOG(LOGIDENTIFIER, "Failed creating a rotation session with error ", status); 79 return nullptr; 80 } 81 82 m_rotationSession = adoptCF(rawRotationSession); 83 m_currentRotationSessionAngle = rotation; 84 85 VTImageRotationSessionSetProperty(rawRotationSession, kVTImageRotationPropertyKey_EnableHighSpeedTransfer, kCFBooleanTrue); 79 86 } 80 87 81 return m_rotationSession->rotate(pixelBuffer); 88 size_t rotatedWidth, rotatedHeight; 89 computeRotatedWidthAndHeight(pixelBuffer, rotation, rotatedWidth, rotatedHeight); 90 auto format = CVPixelBufferGetPixelFormatType(pixelBuffer); 91 if (!m_rotationPool || rotatedWidth != m_rotatedWidth || rotatedHeight != m_rotatedHeight || format != m_rotatedFormat) { 92 auto pixelAttributes = @{ 93 (__bridge NSString *)kCVPixelBufferWidthKey: @(rotatedWidth), 94 (__bridge NSString *)kCVPixelBufferHeightKey: @(rotatedHeight), 95 (__bridge NSString *)kCVPixelBufferPixelFormatTypeKey: @(format), 96 (__bridge NSString *)kCVPixelBufferCGImageCompatibilityKey: @NO, 97 }; 98 99 CVPixelBufferPoolRef pool = nullptr; 100 auto status = CVPixelBufferPoolCreate(kCFAllocatorDefault, nullptr, (__bridge CFDictionaryRef)pixelAttributes, &pool); 101 102 if (status != kCVReturnSuccess) { 103 ERROR_LOG(LOGIDENTIFIER, "Failed creating a pixel buffer pool with error ", status); 104 return nullptr; 105 } 106 m_rotationPool = adoptCF(pool); 107 108 m_rotatedWidth = rotatedWidth; 109 m_rotatedHeight = rotatedHeight; 110 m_rotatedFormat = format; 111 } 112 113 CVPixelBufferRef rawRotatedBuffer = nullptr; 114 auto status = CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, m_rotationPool.get(), &rawRotatedBuffer); 115 116 if (status != kCVReturnSuccess) { 117 ERROR_LOG(LOGIDENTIFIER, "Failed creating a pixel buffer with error ", status); 118 return nullptr; 119 } 120 RetainPtr<CVPixelBufferRef> rotatedBuffer = adoptCF(rawRotatedBuffer); 121 122 status = VTImageRotationSessionTransferImage(m_rotationSession.get(), pixelBuffer, rotatedBuffer.get()); 123 124 if (status != noErr) { 125 ERROR_LOG(LOGIDENTIFIER, "Failed rotating with error ", status, " for rotation ", m_currentRotation); 126 return nullptr; 127 } 128 return rotatedBuffer; 82 129 } 83 130
Note: See TracChangeset
for help on using the changeset viewer.