Changeset 283585 in webkit
- Timestamp:
- Oct 5, 2021 4:43:27 PM (10 months ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/http/tests/media/video-hls-copy-into-canvas-expected.txt (added)
-
LayoutTests/http/tests/media/video-hls-copy-into-canvas.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (modified) (3 diffs)
-
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r283584 r283585 1 2021-10-05 Jean-Yves Avenard <jya@apple.com> 2 3 createImageBitmap using a HLS video as source always return a black image. 4 https://bugs.webkit.org/show_bug.cgi?id=231225 5 rdar://83884031 6 7 Reviewed by Eric Carlson. 8 9 * http/tests/media/video-hls-copy-into-canvas-expected.txt: Added. 10 * http/tests/media/video-hls-copy-into-canvas.html: Added. 11 1 12 2021-10-05 Ayumi Kojima <ayumi_kojima@apple.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r283583 r283585 1 2021-10-05 Jean-Yves Avenard <jya@apple.com> 2 3 createImageBitmap using a HLS video as source always return a black image. 4 https://bugs.webkit.org/show_bug.cgi?id=231225 5 rdar://83884031 6 7 When playing HLS content, [AVURLAsset tracks] return an empty array. 8 We need to instead retrieve it from the AVPlayerItem object. The method 9 paintWithVideoOutput would have bailed out early as a consequence. 10 So we refactor the code a little to retrieve the tracks where they can be found 11 12 Reviewed by Eric Carlson. 13 14 Test: http/tests/media/video-hls-copy-into-canvas.html 15 16 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h: 17 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: 18 (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem): 19 (WebCore::MediaPlayerPrivateAVFoundationObjC::tracksChanged): 20 (WebCore::MediaPlayerPrivateAVFoundationObjC::updateRotationSession): 21 (WebCore::MediaPlayerPrivateAVFoundationObjC::audioSourceProvider): 22 (WebCore::MediaPlayerPrivateAVFoundationObjC::updateLastImage): 23 (WebCore::MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput): 24 (WebCore::MediaPlayerPrivateAVFoundationObjC::firstEnabledTrack const): 25 (WebCore::MediaPlayerPrivateAVFoundationObjC::firstEnabledAudibleTrack const): 26 (WebCore::MediaPlayerPrivateAVFoundationObjC::firstEnabledVisibleTrack const): 27 1 28 2021-10-05 Jean-Yves Avenard <jya@apple.com> 2 29 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
r283583 r283585 33 33 34 34 OBJC_CLASS AVAssetImageGenerator; 35 OBJC_CLASS AVAssetTrack; 35 36 OBJC_CLASS AVAssetResourceLoadingRequest; 36 37 OBJC_CLASS AVMediaSelectionGroup; … … 51 52 typedef struct CGImage *CGImageRef; 52 53 typedef struct __CVBuffer *CVPixelBufferRef; 54 typedef NSString *AVMediaCharacteristic; 53 55 54 56 namespace WebCore { … … 276 278 AVMediaSelectionGroup *safeMediaSelectionGroupForVisualMedia(); 277 279 278 NSArray *safeAVAssetTracksForAudibleMedia(); 279 NSArray *safeAVAssetTracksForVisualMedia(); 280 AVAssetTrack* firstEnabledAudibleTrack() const; 281 AVAssetTrack* firstEnabledVisibleTrack() const; 282 AVAssetTrack* firstEnabledTrack(AVMediaCharacteristic) const; 280 283 281 284 #if ENABLE(DATACUE_VALUE) -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
r283583 r283585 248 248 static NSArray *assetTrackMetadataKeyNames(); 249 249 static NSArray *playerKVOProperties(); 250 static AVAssetTrack* firstEnabledTrack(NSArray* tracks);251 250 252 251 static dispatch_queue_t globalLoaderDelegateQueue() … … 1169 1168 if (m_provider) { 1170 1169 m_provider->setPlayerItem(m_avPlayerItem.get()); 1171 m_provider->setAudioTrack(firstEnabled Track(safeAVAssetTracksForAudibleMedia()));1170 m_provider->setAudioTrack(firstEnabledAudibleTrack()); 1172 1171 } 1173 1172 #endif … … 2087 2086 } 2088 2087 2089 static AVAssetTrack* firstEnabledTrack(NSArray* tracks)2090 {2091 NSUInteger index = [tracks indexOfObjectPassingTest:^(id obj, NSUInteger, BOOL *) {2092 return [static_cast<AVAssetTrack*>(obj) isEnabled];2093 }];2094 if (index == NSNotFound)2095 return nil;2096 return [tracks objectAtIndex:index];2097 }2098 2099 2088 void MediaPlayerPrivateAVFoundationObjC::metadataLoaded() 2100 2089 { … … 2142 2131 // We don't have a player item yet, so check with the asset because some assets support inspection 2143 2132 // prior to becoming ready to play. 2144 AVAssetTrack* firstEnabledVideoTrack = firstEnabledTrack(safeAVAssetTracksForVisualMedia());2133 auto* firstEnabledVideoTrack = firstEnabledVisibleTrack(); 2145 2134 setHasVideo(firstEnabledVideoTrack); 2146 setHasAudio(firstEnabled Track(safeAVAssetTracksForAudibleMedia()));2135 setHasAudio(firstEnabledAudibleTrack()); 2147 2136 auto size = firstEnabledVideoTrack ? FloatSize(CGSizeApplyAffineTransform([firstEnabledVideoTrack naturalSize], [firstEnabledVideoTrack preferredTransform])) : FloatSize(); 2148 2137 // For videos with rotation tag set, the transformation above might return a CGSize instance with negative width or height. … … 2215 2204 #if ENABLE(WEB_AUDIO) && USE(MEDIATOOLBOX) 2216 2205 if (m_provider) 2217 m_provider->setAudioTrack(firstEnabled Track(safeAVAssetTracksForAudibleMedia()));2206 m_provider->setAudioTrack(firstEnabledAudibleTrack()); 2218 2207 #endif 2219 2208 … … 2228 2217 AffineTransform finalTransform = m_avAsset.get().preferredTransform; 2229 2218 FloatSize naturalSize; 2230 if (auto* firstEnabledVideoTrack = firstEnabled Track(safeAVAssetTracksForVisualMedia())) {2219 if (auto* firstEnabledVideoTrack = firstEnabledVisibleTrack()) { 2231 2220 naturalSize = FloatSize(firstEnabledVideoTrack.naturalSize); 2232 2221 finalTransform *= firstEnabledVideoTrack.preferredTransform; … … 2418 2407 if (!m_provider) { 2419 2408 m_provider = AudioSourceProviderAVFObjC::create(m_avPlayerItem.get()); 2420 m_provider->setAudioTrack(firstEnabled Track(safeAVAssetTracksForAudibleMedia()));2409 m_provider->setAudioTrack(firstEnabledAudibleTrack()); 2421 2410 } 2422 2411 return m_provider.get(); … … 2546 2535 return; 2547 2536 2537 auto* firstEnabledVideoTrack = firstEnabledVisibleTrack(); 2538 if (!firstEnabledVideoTrack) 2539 return; 2540 2548 2541 if (type == UpdateType::UpdateSynchronously && !m_lastImage && !videoOutputHasAvailableFrame()) 2549 2542 waitForVideoOutputMediaDataWillChange(); … … 2571 2564 updateLastImage(UpdateType::UpdateSynchronously); 2572 2565 if (!m_lastImage) 2573 return;2574 2575 AVAssetTrack* firstEnabledVideoTrack = firstEnabledTrack(safeAVAssetTracksForVisualMedia());2576 if (!firstEnabledVideoTrack)2577 2566 return; 2578 2567 … … 2751 2740 #endif 2752 2741 2753 NSArray* MediaPlayerPrivateAVFoundationObjC::safeAVAssetTracksForAudibleMedia() 2754 { 2742 AVAssetTrack* MediaPlayerPrivateAVFoundationObjC::firstEnabledTrack(AVMediaCharacteristic characteristic) const 2743 { 2744 if (m_avPlayerItem) { 2745 for (AVPlayerItemTrack* track in [m_avPlayerItem tracks]) { 2746 if (!track.enabled) 2747 continue; 2748 if (!track.assetTrack) 2749 continue; 2750 if ([track.assetTrack hasMediaCharacteristic:characteristic]) 2751 return track.assetTrack; 2752 } 2753 } 2755 2754 if (!m_avAsset) 2756 2755 return nil; … … 2759 2758 return nil; 2760 2759 2761 return [m_avAsset tracksWithMediaCharacteristic:AVMediaCharacteristicAudible]; 2762 } 2763 2764 NSArray* MediaPlayerPrivateAVFoundationObjC::safeAVAssetTracksForVisualMedia() 2765 { 2766 if (!m_avAsset) 2767 return nil; 2768 2769 if ([m_avAsset.get() statusOfValueForKey:@"tracks" error:NULL] != AVKeyValueStatusLoaded) 2770 return nil; 2771 2772 return [m_avAsset tracksWithMediaCharacteristic:AVMediaCharacteristicVisual]; 2760 return [] (NSArray* tracks) -> AVAssetTrack* { 2761 NSUInteger index = [tracks indexOfObjectPassingTest:^(id obj, NSUInteger, BOOL *) { 2762 return [static_cast<AVAssetTrack*>(obj) isEnabled]; 2763 }]; 2764 if (index == NSNotFound) 2765 return nil; 2766 return [tracks objectAtIndex:index]; 2767 }([m_avAsset tracksWithMediaCharacteristic:characteristic]); 2768 } 2769 2770 AVAssetTrack* MediaPlayerPrivateAVFoundationObjC::firstEnabledAudibleTrack() const 2771 { 2772 return firstEnabledTrack(AVMediaCharacteristicAudible); 2773 } 2774 2775 AVAssetTrack* MediaPlayerPrivateAVFoundationObjC::firstEnabledVisibleTrack() const 2776 { 2777 return firstEnabledTrack(AVMediaCharacteristicVisual); 2773 2778 } 2774 2779
Note: See TracChangeset
for help on using the changeset viewer.