Updated method to return unique queue names in MPPVisionTaskRunner

This commit is contained in:
Prianka Liz Kariat 2023-05-04 16:14:46 +05:30
parent 37e14a7cad
commit 7797aa932b
2 changed files with 20 additions and 7 deletions

View File

@ -141,7 +141,19 @@ NS_ASSUME_NONNULL_BEGIN
(mediapipe::tasks::core::PacketsCallback)packetsCallback (mediapipe::tasks::core::PacketsCallback)packetsCallback
error:(NSError **)error NS_UNAVAILABLE; error:(NSError **)error NS_UNAVAILABLE;
+ (const char *)uniqueQueueNameWithTaskName:(NSString *)taskName; /**
* This method returns a unique dispatch queue name by adding the given suffix and a `UUID` to the
* pre-defined queue name prefix for vision tasks. The vision tasks can use this method to get
* unique dispatch queue names which are consistent with other vision tasks.
* Dispatch queue names need not be unique, but for easy debugging we ensure that the queue names
* are unique.
*
* @param suffix A suffix that identifies a dispatch queue's functionality.
*
* @return A unique dispatch queue name by adding the given suffix and a `UUID` to the pre-defined
* queue name prefix for vision tasks.
*/
+ (const char *)uniqueDispatchQueueNameWithSuffix:(NSString *)suffix;
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;

View File

@ -55,10 +55,10 @@ static NSString *const kTaskPrefix = @"com.mediapipe.tasks.vision";
case MPPRunningModeImage: case MPPRunningModeImage:
case MPPRunningModeVideo: { case MPPRunningModeVideo: {
if (packetsCallback) { if (packetsCallback) {
[MPPCommonUtils [MPPCommonUtils createCustomError:error
createCustomError:error
withCode:MPPTasksErrorCodeInvalidArgumentError withCode:MPPTasksErrorCodeInvalidArgumentError
description:@"The vision task is in image or video mode. The delegate must not be set in the task's options."]; description:@"The vision task is in image or video mode. The "
@"delegate must not be set in the task's options."];
return nil; return nil;
} }
break; break;
@ -203,8 +203,9 @@ static NSString *const kTaskPrefix = @"com.mediapipe.tasks.vision";
return [self sendPacketMap:packetMap error:error]; return [self sendPacketMap:packetMap error:error];
} }
+ (const char *)uniqueQueueNameWithTaskName:(NSString *)taskName { + (const char *)uniqueDispatchQueueNameWithSuffix:(NSString *)suffix {
return [NSString stringWithFormat:@"%@.%@_%@",kTaskPrefix, taskName, [NSString uuidString]].UTF8String; return [NSString stringWithFormat:@"%@.%@_%@", kTaskPrefix, suffix, [NSString uuidString]]
.UTF8String;
} }
@end @end