in idb_companion/Server/FBIDBServiceHandler.mm [1234:1255]
Status FBIDBServiceHandler::record(grpc::ServerContext *context, grpc::ServerReaderWriter<idb::RecordResponse, idb::RecordRequest> *stream)
{@autoreleasepool{
idb::RecordRequest initial;
stream->Read(&initial);
NSError *error = nil;
const std::string requestedFilePath = initial.start().file_path();
NSString *filePath = requestedFilePath.length() > 0 ? nsstring_from_c_string(requestedFilePath.c_str()) : [[_target.auxillaryDirectory stringByAppendingPathComponent:@"idb_encode"] stringByAppendingPathExtension:@"mp4"];
id<FBiOSTargetOperation> operation = [[_target startRecordingToFile:filePath] block:&error];
if (!operation) {
return Status(grpc::StatusCode::INTERNAL, error.localizedDescription.UTF8String);
}
idb::RecordRequest stop;
stream->Read(&stop);
if (![[_target stopRecording] succeeds:&error]) {
return Status(grpc::StatusCode::INTERNAL, error.localizedDescription.UTF8String);
}
if (requestedFilePath.length() > 0) {
return respond_file_path(nil, filePath, stream);
} else {
return drain_writer([FBArchiveOperations createGzipForPath:filePath queue:dispatch_queue_create("com.facebook.idb.record", DISPATCH_QUEUE_SERIAL) logger:_target.logger], stream);
}
}}