FreeRDP
Loading...
Searching...
No Matches
FreeRDPCameraAVFoundationModes Class Reference

#include <modes.h>

Inheritance diagram for FreeRDPCameraAVFoundationModes:
Collaboration diagram for FreeRDPCameraAVFoundationModes:

Instance Methods

(instancetype) - initWithFormats:
 
(size_t) - copyMediaTypes:capacity:
 
(AVCaptureDeviceFormat *) - formatForMediaType:frameDuration:
 

Detailed Description

FreeRDP: A Remote Desktop Protocol Implementation MS-RDPECAM AVFoundation native mode cache.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition at line 27 of file modes.h.

Method Documentation

◆ copyMediaTypes:capacity:

- (size_t) copyMediaTypes: (CAM_MEDIA_TYPE_DESCRIPTION *)  mediaTypes
capacity: (size_t)  capacity 

Definition at line 51 of file modes.m.

115 :(CAM_MEDIA_TYPE_DESCRIPTION *)mediaTypes capacity:(size_t)capacity
116{
117 WINPR_ASSERT(mediaTypes);
118 size_t count = 0;
119 for (FreeRDPCameraAVFoundationMode *entry in _entries)
120 {
121 if (count >= capacity)
122 break;
123 mediaTypes[count++] = entry.mediaType;
124 }
125 return count;
126}

◆ formatForMediaType:frameDuration:

- (AVCaptureDeviceFormat *) formatForMediaType: (const CAM_MEDIA_TYPE_DESCRIPTION *)  mediaType
frameDuration: (CMTime *)  frameDuration 

Definition at line 51 of file modes.m.

128 :(const CAM_MEDIA_TYPE_DESCRIPTION *)mediaType
129 frameDuration:(CMTime *)frameDuration
130{
131 WINPR_ASSERT(frameDuration);
132 FreeRDPCameraAVFoundationMode *entry = _lookup[cam_avfoundation_mode_key(mediaType)];
133 *frameDuration = entry ? entry.frameDuration : kCMTimeInvalid;
134 return entry.format;
135}

◆ initWithFormats:

- (instancetype) initWithFormats: (NSArray<AVCaptureDeviceFormat *> *)  formats

Definition at line 51 of file modes.m.

54 :(NSArray<AVCaptureDeviceFormat *> *)formats
55{
56 self = [super init];
57 if (!self)
58 return nil;
59 NSMutableArray<FreeRDPCameraAVFoundationMode *> *entries = [NSMutableArray array];
60 NSMutableDictionary<NSString *, FreeRDPCameraAVFoundationMode *> *lookup =
61 [NSMutableDictionary dictionary];
62 for (AVCaptureDeviceFormat *format in formats)
63 {
64 const CMVideoDimensions size =
65 CMVideoFormatDescriptionGetDimensions(format.formatDescription);
66 if ((size.width < CAM_AVFOUNDATION_MIN_WIDTH) ||
67 (size.height < CAM_AVFOUNDATION_MIN_HEIGHT) ||
68 (size.width > CAM_AVFOUNDATION_MAX_WIDTH) ||
69 (size.height > CAM_AVFOUNDATION_MAX_HEIGHT) || (size.width % 2) || (size.height % 2))
70 continue;
71 const UINT32 rates[] = CAM_AVFOUNDATION_FRAME_RATES;
72 for (size_t r = 0; r < ARRAYSIZE(rates); r++)
73 {
74 CMTime duration = kCMTimeInvalid;
75 for (AVFrameRateRange *range in format.videoSupportedFrameRateRanges)
76 {
77 if (cam_avfoundation_frame_duration(rates[r], 1, range.minFrameDuration,
78 range.maxFrameDuration, &duration))
79 break;
80 }
82 CAM_MEDIA_FORMAT_NV12, (UINT32)size.width, (UINT32)size.height, 0, 0, 1, 1, 0
83 };
84 if (!cam_avfoundation_frame_rate(duration, &type.FrameRateNumerator,
85 &type.FrameRateDenominator))
86 continue;
87 NSString *key = cam_avfoundation_mode_key(&type);
88 if (lookup[key] || (entries.count >= ECAM_MAX_MEDIA_TYPE_DESCRIPTORS))
89 continue;
90 FreeRDPCameraAVFoundationMode *entry = [[FreeRDPCameraAVFoundationMode alloc] init];
91 if (!entry)
92 {
93 [self release];
94 return nil;
95 }
96 entry.mediaType = type;
97 entry.format = format;
98 /* Keep the native clock representation, not a duration rebuilt from the wire rate. */
99 entry.frameDuration = duration;
100 [entries addObject:entry];
101 lookup[key] = entry;
102 [entry release];
103 }
104 }
105 _entries = [entries copy];
106 _lookup = [lookup copy];
107 if (!_entries || !_lookup)
108 {
109 [self release];
110 return nil;
111 }
112 return self;
113}

The documentation for this class was generated from the following files: