avfvideosrc: account for retina displays when capturing screens
Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=770030
This commit is contained in:
parent
c42eb9932e
commit
6de83e0515
@ -138,6 +138,7 @@ G_DEFINE_TYPE (GstAVFVideoSrc, gst_avf_video_src, GST_TYPE_PUSH_SRC);
|
|||||||
- (GstVideoFormat)getGstVideoFormat:(NSNumber *)pixel_format;
|
- (GstVideoFormat)getGstVideoFormat:(NSNumber *)pixel_format;
|
||||||
#if !HAVE_IOS
|
#if !HAVE_IOS
|
||||||
- (CGDirectDisplayID)getDisplayIdFromDeviceIndex;
|
- (CGDirectDisplayID)getDisplayIdFromDeviceIndex;
|
||||||
|
- (float)getScaleFactorFromDeviceIndex;
|
||||||
#endif
|
#endif
|
||||||
- (GstCaps *)getDeviceCaps;
|
- (GstCaps *)getDeviceCaps;
|
||||||
- (BOOL)setDeviceCaps:(GstVideoInfo *)info;
|
- (BOOL)setDeviceCaps:(GstVideoInfo *)info;
|
||||||
@ -416,6 +417,20 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
|||||||
displayId = [description objectForKey:@"NSScreenNumber"];
|
displayId = [description objectForKey:@"NSScreenNumber"];
|
||||||
return [displayId unsignedIntegerValue];
|
return [displayId unsignedIntegerValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (float)getScaleFactorFromDeviceIndex
|
||||||
|
{
|
||||||
|
NSArray *screens = [NSScreen screens];
|
||||||
|
|
||||||
|
if (deviceIndex == DEFAULT_DEVICE_INDEX)
|
||||||
|
return [[NSScreen mainScreen] backingScaleFactor];
|
||||||
|
if (deviceIndex >= [screens count]) {
|
||||||
|
GST_ELEMENT_ERROR (element, RESOURCE, NOT_FOUND,
|
||||||
|
("Invalid screen capture device index"), (NULL));
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
return [[screens objectAtIndex:deviceIndex] backingScaleFactor];
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
- (GstCaps *)getDeviceCaps
|
- (GstCaps *)getDeviceCaps
|
||||||
@ -648,12 +663,13 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
|||||||
if (captureScreen) {
|
if (captureScreen) {
|
||||||
#if !HAVE_IOS
|
#if !HAVE_IOS
|
||||||
CGRect rect = CGDisplayBounds ([self getDisplayIdFromDeviceIndex]);
|
CGRect rect = CGDisplayBounds ([self getDisplayIdFromDeviceIndex]);
|
||||||
|
float scale = [self getScaleFactorFromDeviceIndex];
|
||||||
for (NSNumber *pixel_format in pixel_formats) {
|
for (NSNumber *pixel_format in pixel_formats) {
|
||||||
GstVideoFormat gst_format = [self getGstVideoFormat:pixel_format];
|
GstVideoFormat gst_format = [self getGstVideoFormat:pixel_format];
|
||||||
if (gst_format != GST_VIDEO_FORMAT_UNKNOWN)
|
if (gst_format != GST_VIDEO_FORMAT_UNKNOWN)
|
||||||
gst_caps_append (result, gst_caps_new_simple ("video/x-raw",
|
gst_caps_append (result, gst_caps_new_simple ("video/x-raw",
|
||||||
"width", G_TYPE_INT, (int)rect.size.width,
|
"width", G_TYPE_INT, (int)(rect.size.width * scale),
|
||||||
"height", G_TYPE_INT, (int)rect.size.height,
|
"height", G_TYPE_INT, (int)(rect.size.height * scale),
|
||||||
"format", G_TYPE_STRING, gst_video_format_to_string (gst_format),
|
"format", G_TYPE_STRING, gst_video_format_to_string (gst_format),
|
||||||
NULL));
|
NULL));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user