WebKit Bugzilla
Attachment 347855 Details for
Bug 188866
: [MediaStream] Store video preset sizes in a map
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188866-20180822153548.patch (text/plain), 13.19 KB, created by
Eric Carlson
on 2018-08-22 15:35:49 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Eric Carlson
Created:
2018-08-22 15:35:49 PDT
Size:
13.19 KB
patch
obsolete
>Subversion Revision: 235110 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 67ce640d4aef7339fddccf59205b71a98300fcdd..6e0631c96838cf39063d9714590c3c73972107da 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,24 @@ >+2018-08-22 Eric Carlson <eric.carlson@apple.com> >+ >+ [MediaStream] Store video preset sizes in a map >+ https://bugs.webkit.org/show_bug.cgi?id=188866 >+ <rdar://problem/43622643> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No new tests, tested manually. >+ >+ * platform/mediastream/RealtimeMediaSource.h: >+ * platform/mediastream/mac/AVVideoCaptureSource.h: >+ * platform/mediastream/mac/AVVideoCaptureSource.mm: >+ (WebCore::AVVideoCaptureSource::AVVideoCaptureSource): >+ (WebCore::AVVideoCaptureSource::initializeCapabilities): >+ (WebCore::AVVideoCaptureSource::sizeForPreset): >+ (WebCore::AVVideoCaptureSource::setPreset): >+ (WebCore::AVVideoCaptureSource::bestSessionPresetForVideoDimensions): >+ (WebCore::sizeForPreset): Deleted. >+ (WebCore::AVVideoCaptureSource::bestSessionPresetForVideoDimensions const): Deleted. >+ > 2018-08-21 Philippe Normand <philn@igalia.com> > > [GStreamer][MSE] Generic main thread notification support >diff --git a/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp b/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp >index 8a4609a2d2647410689bf402a2c1d634612c7fd1..59ca93f9b65eb284f549c293e72dbad4645f88b9 100644 >--- a/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp >+++ b/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp >@@ -949,6 +949,11 @@ void RealtimeMediaSource::scheduleDeferredTask(WTF::Function<void()>&& function) > }); > } > >+RealtimeMediaSource::VideoPresetMap& RealtimeMediaSource::videoPresets() >+{ >+ return m_supportedPresets; >+} >+ > RealtimeMediaSource::Observer::~Observer() > { > } >diff --git a/Source/WebCore/platform/mediastream/RealtimeMediaSource.h b/Source/WebCore/platform/mediastream/RealtimeMediaSource.h >index c29ab19c16df3b1fd01a0040b92fa5a723b48b0a..881d6e3fc0cf569c7e73ce35973a163f01415b19 100644 >--- a/Source/WebCore/platform/mediastream/RealtimeMediaSource.h >+++ b/Source/WebCore/platform/mediastream/RealtimeMediaSource.h >@@ -37,6 +37,7 @@ > > #include "CaptureDevice.h" > #include "Image.h" >+#include "IntSizeHash.h" > #include "MediaConstraints.h" > #include "MediaSample.h" > #include "PlatformLayer.h" >@@ -250,6 +251,9 @@ protected: > void videoSampleAvailable(MediaSample&); > void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t); > >+ using VideoPresetMap = HashMap<String, IntSize>; >+ VideoPresetMap& videoPresets(); >+ > private: > virtual void startProducingData() { } > virtual void stopProducingData() { } >@@ -272,6 +276,7 @@ private: > double m_sampleSize { 0 }; > double m_fitnessScore { std::numeric_limits<double>::infinity() }; > RealtimeMediaSourceSettings::VideoFacingMode m_facingMode { RealtimeMediaSourceSettings::User}; >+ VideoPresetMap m_supportedPresets; > > bool m_echoCancellation { false }; > bool m_pendingSettingsDidChangeNotification { false }; >diff --git a/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h b/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h >index cf62427edd97bb7364ab4e35f53b5ce8968dae30..8ae7115230796b3d01c02cb69ccb93b70370187a 100644 >--- a/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h >+++ b/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h >@@ -71,7 +71,7 @@ private: > > bool isFrameRateSupported(double frameRate); > >- NSString *bestSessionPresetForVideoDimensions(std::optional<int> width, std::optional<int> height) const; >+ NSString *bestSessionPresetForVideoDimensions(std::optional<int> width, std::optional<int> height); > bool supportsSizeAndFrameRate(std::optional<int> width, std::optional<int> height, std::optional<double>) final; > > void initializeCapabilities(RealtimeMediaSourceCapabilities&) final; >@@ -84,11 +84,13 @@ private: > > void captureOutputDidOutputSampleBufferFromConnection(AVCaptureOutput*, CMSampleBufferRef, AVCaptureConnection*) final; > void processNewFrame(RetainPtr<CMSampleBufferRef>, RetainPtr<AVCaptureConnection>); >+ IntSize sizeForPreset(NSString*); > > RetainPtr<NSString> m_pendingPreset; > RetainPtr<CMSampleBufferRef> m_buffer; > RetainPtr<AVCaptureVideoDataOutput> m_videoOutput; > >+ IntSize m_presetSize; > int32_t m_width { 0 }; > int32_t m_height { 0 }; > int m_sensorOrientation { 0 }; >diff --git a/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm b/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm >index ab04f03e908b5e944e47c411d09f649c7ac718c4..bc5d010f6ee73aa7441ad2de592d9c9815ae0758 100644 >--- a/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm >+++ b/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm >@@ -94,6 +94,14 @@ SOFT_LINK_CONSTANT_MAY_FAIL(AVFoundation, AVCaptureSessionPreset320x240, NSStrin > #define AVCaptureSessionPreset352x288 getAVCaptureSessionPreset352x288() > #define AVCaptureSessionPreset320x240 getAVCaptureSessionPreset320x240() > >+#if PLATFORM(IOS) >+SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVCaptureSessionPreset3840x2160, NSString *) >+SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVCaptureSessionPreset1920x1080, NSString *) >+ >+#define AVCaptureSessionPreset3840x2160 getAVCaptureSessionPreset3840x2160() >+#define AVCaptureSessionPreset1920x1080 getAVCaptureSessionPreset1920x1080() >+#endif >+ > using namespace WebCore; > > namespace WebCore { >@@ -123,6 +131,32 @@ CaptureSourceOrError AVVideoCaptureSource::create(const AtomicString& id, const > AVVideoCaptureSource::AVVideoCaptureSource(AVCaptureDeviceTypedef* device, const AtomicString& id) > : AVMediaCaptureSource(device, id, Type::Video) > { >+ struct VideoPreset { >+ bool symbolAvailable; >+ NSString* name; >+ int width; >+ int height; >+ }; >+ >+ static const VideoPreset presets[] = { >+#if PLATFORM(IOS) >+ { canLoadAVCaptureSessionPreset3840x2160(), AVCaptureSessionPreset3840x2160, 3840, 2160 }, >+ { canLoadAVCaptureSessionPreset1920x1080(), AVCaptureSessionPreset1920x1080, 1920, 1080 }, >+#endif >+ { canLoadAVCaptureSessionPreset1280x720(), AVCaptureSessionPreset1280x720, 1280, 720 }, >+ { canLoadAVCaptureSessionPreset960x540(), AVCaptureSessionPreset960x540, 960, 540 }, >+ { canLoadAVCaptureSessionPreset640x480(), AVCaptureSessionPreset640x480, 640, 480 }, >+ { canLoadAVCaptureSessionPreset352x288(), AVCaptureSessionPreset352x288, 352, 288 }, >+ { canLoadAVCaptureSessionPreset320x240(), AVCaptureSessionPreset320x240, 320, 240 }, >+ }; >+ >+ auto* presetsMap = &videoPresets(); >+ for (auto& preset : presets) { >+ if (!preset.symbolAvailable || !preset.name || ![device supportsAVCaptureSessionPreset:preset.name]) >+ continue; >+ >+ presetsMap->add(String(preset.name), IntSize(preset.width, preset.height)); >+ } > } > > AVVideoCaptureSource::~AVVideoCaptureSource() >@@ -168,32 +202,13 @@ void AVVideoCaptureSource::initializeCapabilities(RealtimeMediaSourceCapabilitie > lowestFrameRateRange = std::min<Float64>(lowestFrameRateRange, range.minFrameRate); > highestFrameRateRange = std::max<Float64>(highestFrameRateRange, range.maxFrameRate); > } >+ } > >- if (canLoadAVCaptureSessionPreset1280x720() && [videoDevice supportsAVCaptureSessionPreset:AVCaptureSessionPreset1280x720]) { >- updateSizeMinMax(minimumWidth, maximumWidth, 1280); >- updateSizeMinMax(minimumHeight, maximumHeight, 720); >- updateAspectRatioMinMax(minimumAspectRatio, maximumAspectRatio, 1280.0 / 720); >- } >- if (canLoadAVCaptureSessionPreset960x540() && [videoDevice supportsAVCaptureSessionPreset:AVCaptureSessionPreset960x540]) { >- updateSizeMinMax(minimumWidth, maximumWidth, 960); >- updateSizeMinMax(minimumHeight, maximumHeight, 540); >- updateAspectRatioMinMax(minimumAspectRatio, maximumAspectRatio, 960 / 540); >- } >- if (canLoadAVCaptureSessionPreset640x480() && [videoDevice supportsAVCaptureSessionPreset:AVCaptureSessionPreset640x480]) { >- updateSizeMinMax(minimumWidth, maximumWidth, 640); >- updateSizeMinMax(minimumHeight, maximumHeight, 480); >- updateAspectRatioMinMax(minimumAspectRatio, maximumAspectRatio, 640 / 480); >- } >- if (canLoadAVCaptureSessionPreset352x288() && [videoDevice supportsAVCaptureSessionPreset:AVCaptureSessionPreset352x288]) { >- updateSizeMinMax(minimumWidth, maximumWidth, 352); >- updateSizeMinMax(minimumHeight, maximumHeight, 288); >- updateAspectRatioMinMax(minimumAspectRatio, maximumAspectRatio, 352 / 288); >- } >- if (canLoadAVCaptureSessionPreset320x240() && [videoDevice supportsAVCaptureSessionPreset:AVCaptureSessionPreset320x240]) { >- updateSizeMinMax(minimumWidth, maximumWidth, 320); >- updateSizeMinMax(minimumHeight, maximumHeight, 240); >- updateAspectRatioMinMax(minimumAspectRatio, maximumAspectRatio, 320 / 240); >- } >+ for (auto& preset : videoPresets()) { >+ auto values = preset.value; >+ updateSizeMinMax(minimumWidth, maximumWidth, values.width()); >+ updateSizeMinMax(minimumHeight, maximumHeight, values.height()); >+ updateAspectRatioMinMax(minimumAspectRatio, maximumAspectRatio, static_cast<double>(values.width()) / values.height()); > } > > capabilities.setFrameRate(CapabilityValueOrRange(lowestFrameRateRange, highestFrameRateRange)); >@@ -241,28 +256,17 @@ bool AVVideoCaptureSource::applySize(const IntSize& size) > return setPreset(preset); > } > >-static IntSize sizeForPreset(NSString* preset) >+IntSize AVVideoCaptureSource::sizeForPreset(NSString* preset) > { > if (!preset) > return { }; > >- if (canLoadAVCaptureSessionPreset1280x720() && [preset isEqualToString:AVCaptureSessionPreset1280x720]) >- return { 1280, 720 }; >- >- if (canLoadAVCaptureSessionPreset960x540() && [preset isEqualToString:AVCaptureSessionPreset960x540]) >- return { 960, 540 }; >- >- if (canLoadAVCaptureSessionPreset640x480() && [preset isEqualToString:AVCaptureSessionPreset640x480]) >- return { 640, 480 }; >- >- if (canLoadAVCaptureSessionPreset352x288() && [preset isEqualToString:AVCaptureSessionPreset352x288]) >- return { 352, 288 }; >+ auto& presets = videoPresets(); >+ auto it = presets.find(String(preset)); >+ if (it != presets.end()) >+ return { it->value.width(), it->value.height() }; > >- if (canLoadAVCaptureSessionPreset320x240() && [preset isEqualToString:AVCaptureSessionPreset320x240]) >- return { 320, 240 }; >- > return { }; >- > } > > bool AVVideoCaptureSource::setPreset(NSString *preset) >@@ -273,9 +277,11 @@ bool AVVideoCaptureSource::setPreset(NSString *preset) > } > > auto size = sizeForPreset(preset); >- if (size.width() == m_width && size.height() == m_height) >+ if (m_presetSize == size) > return true; > >+ m_presetSize = size; >+ > @try { > session().sessionPreset = preset; > #if PLATFORM(MAC) >@@ -506,26 +512,21 @@ void AVVideoCaptureSource::captureOutputDidOutputSampleBufferFromConnection(AVCa > }); > } > >-NSString* AVVideoCaptureSource::bestSessionPresetForVideoDimensions(std::optional<int> width, std::optional<int> height) const >+NSString* AVVideoCaptureSource::bestSessionPresetForVideoDimensions(std::optional<int> width, std::optional<int> height) > { > if (!width && !height) > return nil; > >- AVCaptureDeviceTypedef *videoDevice = device(); >- if ((!width || width.value() == 1280) && (!height || height.value() == 720) && canLoadAVCaptureSessionPreset1280x720()) >- return [videoDevice supportsAVCaptureSessionPreset:AVCaptureSessionPreset1280x720] ? AVCaptureSessionPreset1280x720 : nil; >- >- if ((!width || width.value() == 960) && (!height || height.value() == 540) && canLoadAVCaptureSessionPreset960x540()) >- return [videoDevice supportsAVCaptureSessionPreset:AVCaptureSessionPreset960x540] ? AVCaptureSessionPreset960x540 : nil; >+ int widthValue = width ? width.value() : 0; >+ int heightValue = height ? height.value() : 0; > >- if ((!width || width.value() == 640) && (!height || height.value() == 480 ) && canLoadAVCaptureSessionPreset640x480()) >- return [videoDevice supportsAVCaptureSessionPreset:AVCaptureSessionPreset640x480] ? AVCaptureSessionPreset640x480 : nil; >+ for (auto& preset : videoPresets()) { >+ auto size = preset.value; >+ NSString* name = preset.key; > >- if ((!width || width.value() == 352) && (!height || height.value() == 288 ) && canLoadAVCaptureSessionPreset352x288()) >- return [videoDevice supportsAVCaptureSessionPreset:AVCaptureSessionPreset352x288] ? AVCaptureSessionPreset352x288 : nil; >- >- if ((!width || width.value() == 320) && (!height || height.value() == 240 ) && canLoadAVCaptureSessionPreset320x240()) >- return [videoDevice supportsAVCaptureSessionPreset:AVCaptureSessionPreset320x240] ? AVCaptureSessionPreset320x240 : nil; >+ if ((!widthValue || widthValue == size.width()) && (!heightValue || heightValue == size.height())) >+ return name; >+ } > > return nil; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
youennf
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188866
:
347855
|
347872
|
347927