virtual void ProcessMediaSample(void* SampleBuffer, uint32 SampleSize, FTimespan SampleDuration, FTimespan SampleTime) { /** if (SampleSize > 0 && SampleBuffer != nullptr) { int8 * buffer = (int8*)SampleBuffer; int32 test_sample = (buffer[SampleSize / 4] << 16) + (buffer[SampleSize / 2] << 8) + buffer[SampleSize * 3 / 4]; static int32 previous_sample = 0; if (previous_sample != test_sample) { FPlatformMisc::LowLevelOutputDebugStringf(TEXT("FJavaAndroidMediaMediaPlayer::ProcessMediaSample: sample test = %d"), test_sample); previous_sample = test_sample; } } **/ for (IMediaSinkWeakPtr& SinkPtr : Sinks) { IMediaSinkPtr Sink = SinkPtr.Pin(); if (Sink.IsValid()) { Sink->ProcessMediaSample(SampleBuffer, SampleSize, FTimespan(SampleDuration), FTimespan(SampleTime)); } } }
void UBasicVolumeComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); if (m_octree.IsValid()) { // Traverse all the nodes and see if they need to be updated, // if so we queue a task. m_octree->Traverse([=](FSparseOctreeNode* node) -> ETraverseOptions { if (node->m_hasChildren) { return ETraverseOptions::Continue; } if (!node->IsUpToDate() && !node->IsSceduled() && !node->IsTaskRunning()) { node->m_lastSceduledForUpdate = FTimespan(0, 0, FPlatformTime::Seconds()); node->m_bTaskRunning = true; FVoreealExtractorOptions Options(TWeakPtr<FSparseOctree>(m_octree), node->m_selfId, node->m_bounds, 0); if (bOverrideExtractor) { Options.bOverrideExtractor = true; Options.ExtractorType = ExtractorType; } SCOPE_CYCLE_COUNTER(STAT_RequestMesh); AddTask(GetVolume(), Options); } return ETraverseOptions::Continue; }); // Get Finished Tasks TSharedPtr<FVoreealMesh> Task; while (FindFinishedTask(Task)) { if (Task.IsValid()) { FVoreealMesh* Mesh = Task.Get(); Mesh->CreateSection(MeshComponent, true); FSparseOctreeNode* Node = m_octree->GetNodeAt(Mesh->GetOptions().Identifier); Node->m_meshLastChanged = FTimespan(0, 0, FPlatformTime::Seconds()); Node->m_bTaskRunning = false; SCOPE_CYCLE_COUNTER(STAT_ReturnMesh); } } } }
FTimespan TimeHandler::TimeElapsed(TimeCanal canal) { if (isRunning(canal)) return FDateTime::Now() - startTime[(int)canal]; else return FTimespan(0); }
void ATimeManager::IncrementTime(float deltaTime) { if (!bIsCalendarInitialized) { return; } double increment = deltaTime * TimeScaleMultiplier; double millisec = FMath::Frac(increment) * 1000; double microsec = FMath::Frac(millisec) * 1000; InternalTime = InternalTime + FTimespan(0, 0, 0, FPlatformMath::FloorToInt(increment), FPlatformMath::FloorToInt(millisec), FPlatformMath::FloorToInt(microsec)); if (CurrentLocalTime.Day != InternalTime.GetDay()) { int32 leapDays = IsLeapYear(InternalTime.GetYear()); DayOfYear = InternalTime.GetDayOfYear(); if (DayOfYear >= (79 + leapDays) && DayOfYear < (265 + leapDays)) { bDaylightSavingsActive = true; } } CurrentLocalTime = ConvertToTimeDate(InternalTime); }
void ATimeManager::InitializeCalendar(FTimeDate time) { time = ValidateTimeDate(time); InternalTime = ConvertToDateTime(time); OffsetUTC = FMath::Clamp(OffsetUTC, -12, 12); DayOfYear = InternalTime.GetDayOfYear(); int32 leapDays = IsLeapYear(time.Year); if (DayOfYear >= (79 + leapDays) && DayOfYear < (265 + leapDays)) { bDaylightSavingsActive = true; } OffsetDST = bAllowDaylightSavings && bDaylightSavingsActive ? 1 : 0; // Local Standard Time Meridian (degrees) = 15 * Hour Offset from UTC LSTM = 15 * OffsetUTC; SpanUTC = FTimespan((FMath::Abs(OffsetUTC) + OffsetDST), 0, 0); Latitude = FMath::Clamp(Latitude, -90.0f, 90.0f); Longitude = FMath::Clamp(Longitude, -180.0f, 180.0f); CurrentLocalTime = time; bIsCalendarInitialized = true; }
static void ParseFilesResults(const FP4RecordSet& InRecords, TArray< TSharedRef<ISourceControlRevision, ESPMode::ThreadSafe> >& OutRevisions, const FString& InClientRoot) { // Iterate over each record found as a result of the command, parsing it for relevant information for (int32 Index = 0; Index < InRecords.Num(); ++Index) { const FP4Record& ClientRecord = InRecords[Index]; FString DepotFile = ClientRecord(TEXT("depotFile")); FString RevisionNumber = ClientRecord(TEXT("rev")); FString Date = ClientRecord(TEXT("time")); FString ChangelistNumber = ClientRecord(TEXT("change")); FString Action = ClientRecord(TEXT("action")); check(RevisionNumber.Len() != 0); // @todo: this revision is incomplete, but is sufficient for now given the usage of labels to get files, rather // than review revision histories. TSharedRef<FPerforceSourceControlRevision, ESPMode::ThreadSafe> Revision = MakeShareable( new FPerforceSourceControlRevision() ); Revision->FileName = DepotFile; Revision->RevisionNumber = FCString::Atoi(*RevisionNumber); Revision->ChangelistNumber = FCString::Atoi(*ChangelistNumber); Revision->Action = Action; Revision->Date = FDateTime(1970, 1, 1, 0, 0, 0, 0) + FTimespan(0, 0, FCString::Atoi(*Date)); OutRevisions.Add(Revision); } }
FProfilerSession::FProfilerSession( const FString& InDataFilepath ) : bRequestStatMetadataUpdate( false ) , bLastPacket( false ) , StatMetaDataSize( 0 ) , OnTick( FTickerDelegate::CreateRaw( this, &FProfilerSession::HandleTicker ) ) , DataProvider( MakeShareable( new FArrayDataProvider() ) ) , StatMetaData( MakeShareable( new FProfilerStatMetaData() ) ) , EventGraphDataTotal( MakeShareable( new FEventGraphData() ) ) , EventGraphDataMaximum( MakeShareable( new FEventGraphData() ) ) , EventGraphDataCurrent( nullptr ) , CreationTime( FDateTime::Now() ) , SessionType( EProfilerSessionTypes::StatsFile ) , SessionInstanceInfo( nullptr ) , SessionInstanceID( FGuid::NewGuid() ) , DataFilepath( InDataFilepath.Replace( *FStatConstants::StatsFileExtension, TEXT( "" ) ) ) , NumFrames( 0 ) , NumFramesProcessed( 0 ) , bDataPreviewing( false ) , bDataCapturing( false ) , bHasAllProfilerData( false ) , FPSAnalyzer( MakeShareable( new FFPSAnalyzer( 5, 0, 90 ) ) ) { // Randomize creation time to test loading profiler captures with different creation time and different amount of data. CreationTime = FDateTime::Now() += FTimespan( 0, 0, FMath::RandRange( 2, 8 ) ); OnTickHandle = FTicker::GetCoreTicker().AddTicker( OnTick ); }
void FIOSTargetPlatform::HandleDeviceConnected(const FIOSLaunchDaemonPong& Message) { FTargetDeviceId DeviceId; FTargetDeviceId::Parse(Message.DeviceID, DeviceId); FIOSTargetDevicePtr& Device = Devices.FindOrAdd(DeviceId); if (!Device.IsValid()) { Device = MakeShareable(new FIOSTargetDevice(*this)); Device->SetFeature(ETargetDeviceFeatures::Reboot, Message.bCanReboot); Device->SetFeature(ETargetDeviceFeatures::PowerOn, Message.bCanPowerOn); Device->SetFeature(ETargetDeviceFeatures::PowerOff, Message.bCanPowerOff); Device->SetDeviceId(DeviceId); Device->SetDeviceName(Message.DeviceName); Device->SetDeviceType(Message.DeviceType); Device->SetIsSimulated(Message.DeviceID.Contains(TEXT("Simulator"))); DeviceDiscoveredEvent.Broadcast(Device.ToSharedRef()); } // Add a very long time period to prevent the devices from getting disconnected due to a lack of pong messages Device->LastPinged = FDateTime::UtcNow() + FTimespan(100, 0, 0, 0, 0); }
bool FTimespanTest::RunTest( const FString& Parameters ) { // constructors must create equal objects FTimespan ts1_1 = FTimespan(3, 2, 1); FTimespan ts1_2 = FTimespan(0, 3, 2, 1); FTimespan ts1_3 = FTimespan(0, 3, 2, 1, 0); TestEqual(TEXT("Constructors must create equal objects (Hours/Minutes/Seconds vs. Days/Hours/Minutes/Seconds)"), ts1_1, ts1_2); TestEqual(TEXT("Constructors must create equal objects (Hours/Minutes/Seconds vs. Days/Hours/Minutes/Seconds/Milliseconds)"), ts1_1, ts1_3); // component getters must return correct values FTimespan ts2_1 = FTimespan(1, 2, 3, 4, 5); TestEqual(TEXT("Component getters must return correct values (Days)"), ts2_1.GetDays(), 1); TestEqual(TEXT("Component getters must return correct values (Hours)"), ts2_1.GetHours(), 2); TestEqual(TEXT("Component getters must return correct values (Minutes)"), ts2_1.GetMinutes(), 3); TestEqual(TEXT("Component getters must return correct values (Seconds)"), ts2_1.GetSeconds(), 4); TestEqual(TEXT("Component getters must return correct values (Milliseconds)"), ts2_1.GetMilliseconds(), 5); // durations of positive and negative time spans must match FTimespan ts3_1 = FTimespan(1, 2, 3, 4, 5); FTimespan ts3_2 = FTimespan(-1, -2, -3, -4, -5); TestEqual(TEXT("Durations of positive and negative time spans must match"), ts3_1.GetDuration(), ts3_2.GetDuration()); // static constructors must create correct values TestEqual(TEXT("Static constructors must create correct values (FromDays)"), FTimespan::FromDays(123).GetTotalDays(), 123.0); TestEqual(TEXT("Static constructors must create correct values (FromHours)"), FTimespan::FromHours(123).GetTotalHours(), 123.0); TestEqual(TEXT("Static constructors must create correct values (FromMinutes)"), FTimespan::FromMinutes(123).GetTotalMinutes(), 123.0); TestEqual(TEXT("Static constructors must create correct values (FromSeconds)"), FTimespan::FromSeconds(123).GetTotalSeconds(), 123.0); TestEqual(TEXT("Static constructors must create correct values (FromMilliseconds)"), FTimespan::FromMilliseconds(123).GetTotalMilliseconds(), 123.0); // string conversions must return correct strings FTimespan ts5_1 = FTimespan(1, 2, 3, 4, 5); TestEqual<FString>(TEXT("String conversion (Default)"), ts5_1.ToString(), TEXT("1.02:03:04.005")); TestEqual<FString>(TEXT("String conversion (%n%d.%h:%m:%s.%f)"), ts5_1.ToString(TEXT("%n%d.%h:%m:%s.%f")), TEXT("1.02:03:04.005")); // parsing valid strings must succeed FTimespan ts6_1 = FTimespan(1, 2, 3, 4, 5); FTimespan ts6_2; TestTrue(TEXT("Parsing valid strings must succeed (1.02:03:04.005)"), FTimespan::Parse(TEXT("1.02:03:04.005"), ts6_2)); TestEqual(TEXT("Parsing valid strings must result in correct values (1.02:03:04.005)"), ts6_2, ts6_1); // parsing invalid strings must fail FTimespan ts7_1; //TestFalse(TEXT("Parsing invalid strings must fail (1,02:03:04.005)"), FTimespan::Parse(TEXT("1,02:03:04.005"), ts7_1)); //TestFalse(TEXT("Parsing invalid strings must fail (1.1.02:03:04:005)"), FTimespan::Parse(TEXT("1.1.02:03:04:005"), ts7_1)); //TestFalse(TEXT("Parsing invalid strings must fail (04:005)"), FTimespan::Parse(TEXT("04:005"), ts7_1)); return true; }
int32 FContentDirectoryMonitor::StartProcessing() { // We only process things that haven't changed for a given threshold auto& FileManager = IFileManager::Get(); const FDateTime Threshold = FDateTime::UtcNow() - FTimespan(0, 0, GetDefault<UEditorLoadingSavingSettings>()->AutoReimportThreshold); // Get all the changes that have happend beyond our import threshold auto OutstandingChanges = Cache.FilterOutstandingChanges([=](const DirectoryWatcher::FUpdateCacheTransaction& Transaction, const FDateTime& TimeOfChange){ return TimeOfChange <= Threshold && ShouldConsiderChange(Transaction); }); if (OutstandingChanges.Num() == 0) { return 0; } const auto* Settings = GetDefault<UEditorLoadingSavingSettings>(); for (auto& Transaction : OutstandingChanges) { switch(Transaction.Action) { case DirectoryWatcher::EFileAction::Added: if (Settings->bAutoCreateAssets && !MountedContentPath.IsEmpty()) { AddedFiles.Emplace(MoveTemp(Transaction)); } else { Cache.CompleteTransaction(MoveTemp(Transaction)); } break; case DirectoryWatcher::EFileAction::Moved: case DirectoryWatcher::EFileAction::Modified: ModifiedFiles.Emplace(MoveTemp(Transaction)); break; case DirectoryWatcher::EFileAction::Removed: if (Settings->bAutoDeleteAssets && !MountedContentPath.IsEmpty()) { DeletedFiles.Emplace(MoveTemp(Transaction)); } else { Cache.CompleteTransaction(MoveTemp(Transaction)); } break; } } return AddedFiles.Num() + ModifiedFiles.Num() + DeletedFiles.Num(); }
void PlayFabApiTest_GetUserData::CheckTimestamp(const FDateTime& updateTime) { FDateTime utcNow = FDateTime::UtcNow(); FTimespan delta = FTimespan(0, 5, 0); FDateTime minTest = utcNow - delta; FDateTime maxTest = utcNow + delta; if (minTest <= updateTime && updateTime <= maxTest) { UE_LOG(LogTemp, Log, TEXT("GetUserData: LastUpdated timestamp parsed as expected")); } else { UE_LOG(LogTemp, Error, TEXT("GetUserData: LastUpdated timestamp was not parsed correctly")); } }
int32 FContentDirectoryMonitor::GetNumUnprocessedChanges() const { const FDateTime Threshold = FDateTime::UtcNow() - FTimespan(0, 0, GetDefault<UEditorLoadingSavingSettings>()->AutoReimportThreshold); int32 Total = 0; // Get all the changes that have happend beyond our import threshold Cache.IterateOutstandingChanges([=, &Total](const DirectoryWatcher::FUpdateCacheTransaction& Transaction, const FDateTime& TimeOfChange){ if (TimeOfChange <= Threshold && ShouldConsiderChange(Transaction)) { ++Total; } return true; }); return Total; }
void AEscapeBallGameMode::Tick(float DeltaSeconds) { // Add time to the total Time totalGameTime += DeltaSeconds; FTimespan timeFormatter = FTimespan(0, 0, 0, FMath::Floor(totalGameTime), FMath::Floor(FMath::Fmod(totalGameTime, 1.0f)*1000.0f)); totalGameTimeString = timeFormatter.ToString(); // Check if player has touched the goal. UWorld* worldRef = GetWorld(); //ADestinationGoal* goalRef = Cast<ADestinationGoal>(goal); if (goal && goal->isTriggered()) { //GEngine->AddOnScreenDebugMessage(-1, 0.1f, FColor::Yellow, TEXT("Reached Goal")); UGameplayStatics::OpenLevel(GWorld, "LevelEditorQuickStartGuide", false, ""); } }
void FContentDirectoryMonitor::Tick() { Cache.Tick(); // Immediately resolve any changes that we should not consider const FDateTime Threshold = FDateTime::UtcNow() - FTimespan(0, 0, GetDefault<UEditorLoadingSavingSettings>()->AutoReimportThreshold); TArray<DirectoryWatcher::FUpdateCacheTransaction> InsignificantTransactions = Cache.FilterOutstandingChanges([=](const DirectoryWatcher::FUpdateCacheTransaction& Transaction, const FDateTime& TimeOfChange){ return TimeOfChange <= Threshold && !ShouldConsiderChange(Transaction); }); for (DirectoryWatcher::FUpdateCacheTransaction& Transaction : InsignificantTransactions) { Cache.CompleteTransaction(MoveTemp(Transaction)); } const double Now = FPlatformTime::Seconds(); if (Now - LastSaveTime > ResaveIntervalS) { LastSaveTime = Now; Cache.WriteCache(); } }
bool FTcpMessageTransportConnection::BlockingSend(const uint8* Data, int32 BytesToSend) { int32 TotalBytes = BytesToSend; while (BytesToSend > 0) { while (!Socket->Wait(ESocketWaitConditions::WaitForWrite, FTimespan(0, 0, 1))) { if (Socket->GetConnectionState() == SCS_ConnectionError) { return false; } } int32 BytesSent = 0; if (!Socket->Send(Data, BytesToSend, BytesSent)) { return false; } BytesToSend -= BytesSent; Data += BytesSent; } return true; }
FDateTime FDateTimeStructCustomization::ConvertTime(const FDateTime& InDate, int32 InTimezone, int32 OutTimezone) { if (InTimezone == OutTimezone) { return InDate; } // Timezone Hour ranges go from -12 to +14 from UTC // Convert from whole-hour to the full-format HHMM (-5 -> -0500, 0 -> +0000, etc) InTimezone = ConvertShortTimezone(InTimezone); OutTimezone = ConvertShortTimezone(OutTimezone); // Extract timezone minutes const int32 InTimezoneMinutes = (FMath::Abs(InTimezone) % 100); const int32 OutTimezoneMinutes = (FMath::Abs(OutTimezone) % 100); // Calculate our Minutes difference const int32 MinutesDifference = OutTimezoneMinutes - InTimezoneMinutes; // Calculate our Hours difference const int64 HoursDifference = (OutTimezone / 100) - (InTimezone / 100); return FDateTime(InDate + FTimespan(HoursDifference, MinutesDifference, 0)); }
FTimespan FTimespan::FromMilliseconds( double Milliseconds ) { check((Milliseconds >= MinValue().GetTotalMilliseconds()) && (Milliseconds <= MaxValue().GetTotalMilliseconds())); return FTimespan(Milliseconds * ETimespan::TicksPerMillisecond); }
bool FDateTime::ParseIso8601( const TCHAR* DateTimeString, FDateTime& OutDateTime ) { // DateOnly: YYYY-MM-DD // DateTime: YYYY-mm-ddTHH:MM:SS(.ssss)(Z|+th:tm|-th:tm) const TCHAR* Ptr = DateTimeString; TCHAR* Next = nullptr; int32 Year = 0, Month = 0, Day = 0; int32 Hour = 0, Minute = 0, Second = 0, Millisecond = 0; int32 TzHour = 0, TzMinute = 0; // get date Year = FCString::Strtoi(Ptr, &Next, 10); if ((Next <= Ptr) || (*Next == TCHAR('\0'))) { return false; } Ptr = Next + 1; // skip separator Month = FCString::Strtoi(Ptr, &Next, 10); if ((Next <= Ptr) || (*Next == TCHAR('\0'))) { return false; } Ptr = Next + 1; // skip separator Day = FCString::Strtoi(Ptr, &Next, 10); if (Next <= Ptr) { return false; } // see if this is date+time if (*Next == TCHAR('T')) { Ptr = Next + 1; // parse time Hour = FCString::Strtoi(Ptr, &Next, 10); if ((Next <= Ptr) || (*Next == TCHAR('\0'))) { return false; } Ptr = Next + 1; // skip separator Minute = FCString::Strtoi(Ptr, &Next, 10); if ((Next <= Ptr) || (*Next == TCHAR('\0'))) { return false; } Ptr = Next + 1; // skip separator Second = FCString::Strtoi(Ptr, &Next, 10); if (Next <= Ptr) { return false; } // check for milliseconds if (*Next == TCHAR('.')) { Ptr = Next + 1; Millisecond = FCString::Strtoi(Ptr, &Next, 10); // should be no more than 3 digits if ((Next <= Ptr) || (Next > Ptr + 3)) { return false; } for (int32 Digits = Next - Ptr; Digits < 3; ++Digits) { Millisecond *= 10; } } // see if the timezone offset is included if (*Next == TCHAR('+') || *Next == TCHAR('-')) { // include the separator since it's + or - Ptr = Next; // parse the timezone offset TzHour = FCString::Strtoi(Ptr, &Next, 10); if ((Next <= Ptr) || (*Next == TCHAR('\0'))) { return false; } Ptr = Next + 1; // skip separator TzMinute = FCString::Strtoi(Ptr, &Next, 10); if (Next <= Ptr) { return false; } } else if ((*Next != TCHAR('\0')) && (*Next != TCHAR('Z'))) { return false; } } else if (*Next != TCHAR('\0')) { return false; } FDateTime Final(Year, Month, Day, Hour, Minute, Second, Millisecond); // adjust for the timezone (bringing the DateTime into UTC) int32 TzOffsetMinutes = (TzHour < 0) ? TzHour * 60 - TzMinute : TzHour * 60 + TzMinute; Final -= FTimespan(0, TzOffsetMinutes, 0); OutDateTime = Final; return true; }
void UPagedVolumeComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); // Check what chunks should be loaded. // TODO: // Loop and create new tasks if required. for (TSharedPtr<FPagedVolumeChunk> Chunk : ArrayChunks) { if (Chunk->m_octree.IsValid()) { // Traverse all the nodes and see if they need to be updated, // if so we queue a task. Chunk->m_octree->Traverse([=](FSparseOctreeNode* Node) -> ETraverseOptions { if (Node->m_hasChildren) { return ETraverseOptions::Continue; } if (!Node->IsUpToDate() && !Node->IsSceduled() && !Node->IsTaskRunning()) { Node->m_lastSceduledForUpdate = FTimespan(0, 0, FPlatformTime::Seconds()); Node->m_bTaskRunning = true; FVoreealExtractorOptions Options(Chunk->m_octree, Node->m_selfId, Node->m_bounds, 0); SCOPE_CYCLE_COUNTER(STAT_RequestMesh); AddTask(Volume, Options); } return ETraverseOptions::Continue; }); } } // Get Finished Tasks TSharedPtr<FVoreealMesh> Task; while (FindFinishedTask(Task)) { if (Task.IsValid()) { // Get the task result FVoreealMesh* Mesh = Task.Get(); FVoreealExtractorOptions Options = Mesh->GetOptions(); const uint32 LocationHash = MortonHash(Options.PagedIdentifier.X, Options.PagedIdentifier.Y, Options.PagedIdentifier.Z); // Get the procedural mesh component UProceduralMeshComponent* MComponent = nullptr; if (ProceduralMeshComponents.Contains(LocationHash)) MComponent = ProceduralMeshComponents[LocationHash]; if (MComponent == nullptr) { MComponent = NewObject<UProceduralMeshComponent>(); MComponent->AttachToComponent(this, FAttachmentTransformRules::KeepWorldTransform); ProceduralMeshComponents.Add(LocationHash, MComponent); } // Update the mesh node Mesh->CreateSection(MComponent, true); // this shouldn't be needed, but lets have it here in case. if (Options.Octree.IsValid()) { TSharedPtr<FSparseOctree> Octree = Options.Octree.Pin(); FSparseOctreeNode* Node = Octree->GetNodeAt(Options.Identifier); Node->m_meshLastChanged = FTimespan(0, 0, FPlatformTime::Seconds()); Node->m_bTaskRunning = false; } } } }
FTimespan FTimespan::FromMinutes( double Minutes ) { check((Minutes >= MinValue().GetTotalMinutes()) && (Minutes <= MaxValue().GetTotalMinutes())); return FTimespan(Minutes * ETimespan::TicksPerMinute); }
FTimespan FTimespan::FromDays( double Days ) { check((Days >= MinValue().GetTotalDays()) && (Days <= MaxValue().GetTotalDays())); return FTimespan(Days * ETimespan::TicksPerDay); }
FTimespan UKismetMathLibrary::MakeTimespan(int32 Days, int32 Hours, int32 Minutes, int32 Seconds, int32 Milliseconds) { return FTimespan(Days, Hours, Minutes, Seconds, Milliseconds); }
FTimespan FTimespan::FromSeconds( double Seconds ) { check((Seconds >= MinValue().GetTotalSeconds()) && (Seconds <= MaxValue().GetTotalSeconds())); return FTimespan(Seconds * ETimespan::TicksPerSecond); }
static void ParseHistoryResults(const FP4RecordSet& InRecords, const TArray<FPerforceSourceControlState>& InStates, FPerforceUpdateStatusWorker::FHistoryMap& OutHistory) { if (InRecords.Num() > 0) { // Iterate over each record, extracting the relevant information for each for (int32 RecordIndex = 0; RecordIndex < InRecords.Num(); ++RecordIndex) { const FP4Record& ClientRecord = InRecords[RecordIndex]; // Extract the file name check(ClientRecord.Contains(TEXT("depotFile"))); FString DepotFileName = ClientRecord(TEXT("depotFile")); FString LocalFileName = FindWorkspaceFile(InStates, DepotFileName); TArray< TSharedRef<FPerforceSourceControlRevision, ESPMode::ThreadSafe> > Revisions; int32 RevisionNumbers = 0; for (;;) { // Extract the revision number FString VarName = FString::Printf(TEXT("rev%d"), RevisionNumbers); if (!ClientRecord.Contains(*VarName)) { // No more revisions break; } FString RevisionNumber = ClientRecord(*VarName); // Extract the user name VarName = FString::Printf(TEXT("user%d"), RevisionNumbers); check(ClientRecord.Contains(*VarName)); FString UserName = ClientRecord(*VarName); // Extract the date VarName = FString::Printf(TEXT("time%d"), RevisionNumbers); check(ClientRecord.Contains(*VarName)); FString Date = ClientRecord(*VarName); // Extract the changelist number VarName = FString::Printf(TEXT("change%d"), RevisionNumbers); check(ClientRecord.Contains(*VarName)); FString ChangelistNumber = ClientRecord(*VarName); // Extract the description VarName = FString::Printf(TEXT("desc%d"), RevisionNumbers); check(ClientRecord.Contains(*VarName)); FString Description = ClientRecord(*VarName); // Extract the action VarName = FString::Printf(TEXT("action%d"), RevisionNumbers); check(ClientRecord.Contains(*VarName)); FString Action = ClientRecord(*VarName); FString FileSize(TEXT("0")); // Extract the file size if(Action.ToLower() != TEXT("delete") && Action.ToLower() != TEXT("move/delete")) //delete actions don't have a fileSize from PV4 { VarName = FString::Printf(TEXT("fileSize%d"), RevisionNumbers); check(ClientRecord.Contains(*VarName)); FileSize = ClientRecord(*VarName); } // Extract the clientspec/workspace VarName = FString::Printf(TEXT("client%d"), RevisionNumbers); check(ClientRecord.Contains(*VarName)); FString ClientSpec = ClientRecord(*VarName); // check for branch TSharedPtr<FPerforceSourceControlRevision, ESPMode::ThreadSafe> BranchSource; VarName = FString::Printf(TEXT("how%d,0"), RevisionNumbers); if(ClientRecord.Contains(*VarName)) { BranchSource = MakeShareable( new FPerforceSourceControlRevision() ); VarName = FString::Printf(TEXT("file%d,0"), RevisionNumbers); FString BranchSourceFileName = ClientRecord(*VarName); BranchSource->FileName = FindWorkspaceFile(InStates, BranchSourceFileName); VarName = FString::Printf(TEXT("erev%d,0"), RevisionNumbers); FString BranchSourceRevision = ClientRecord(*VarName); BranchSource->RevisionNumber = FCString::Atoi(*BranchSourceRevision); } TSharedRef<FPerforceSourceControlRevision, ESPMode::ThreadSafe> Revision = MakeShareable( new FPerforceSourceControlRevision() ); Revision->FileName = LocalFileName; Revision->RevisionNumber = FCString::Atoi(*RevisionNumber); Revision->Revision = RevisionNumber; Revision->ChangelistNumber = FCString::Atoi(*ChangelistNumber); Revision->Description = Description; Revision->UserName = UserName; Revision->ClientSpec = ClientSpec; Revision->Action = Action; Revision->BranchSource = BranchSource; Revision->Date = FDateTime(1970, 1, 1, 0, 0, 0, 0) + FTimespan(0, 0, FCString::Atoi(*Date)); Revision->FileSize = FCString::Atoi(*FileSize); Revisions.Add(Revision); RevisionNumbers++; } if(Revisions.Num() > 0) { OutHistory.Add(LocalFileName, Revisions); } } } }
FTimespan FTimespan::FromHours( double Hours ) { check((Hours >= MinValue().GetTotalHours()) && (Hours <= MaxValue().GetTotalHours())); return FTimespan(Hours * ETimespan::TicksPerHour); }
bool FWmfMediaPlayer::InitializeMediaSession( IUnknown* SourceObject, const FString& SourceUrl ) { Close(); if (SourceObject == nullptr) { return false; } UE_LOG(LogWmfMedia, Verbose, TEXT("Initializing media session for %s"), *SourceUrl); // create presentation descriptor TComPtr<IMFMediaSource> MediaSource; if (FAILED(SourceObject->QueryInterface(IID_PPV_ARGS(&MediaSource)))) { UE_LOG(LogWmfMedia, Error, TEXT("Failed to query media source")); return false; } TComPtr<IMFPresentationDescriptor> PresentationDescriptor; if (FAILED(MediaSource->CreatePresentationDescriptor(&PresentationDescriptor))) { UE_LOG(LogWmfMedia, Error, TEXT("Failed to create presentation descriptor")); return false; } // create playback topology DWORD StreamCount = 0; if (FAILED(PresentationDescriptor->GetStreamDescriptorCount(&StreamCount))) { UE_LOG(LogWmfMedia, Error, TEXT("Failed to get stream count")); return false; } TComPtr<IMFTopology> Topology; if (FAILED(::MFCreateTopology(&Topology))) { UE_LOG(LogWmfMedia, Error, TEXT("Failed to create playback topology")); return false; } for (uint32 StreamIndex = 0; StreamIndex < StreamCount; ++StreamIndex) { AddStreamToTopology(StreamIndex, Topology, PresentationDescriptor, MediaSource); } UE_LOG(LogWmfMedia, Verbose, TEXT("Added a total of %i tracks"), Tracks.Num()); UINT64 PresentationDuration = 0; PresentationDescriptor->GetUINT64(MF_PD_DURATION, &PresentationDuration); Duration = FTimespan(PresentationDuration); // create session MediaSession = new FWmfMediaSession(Duration, Topology); MediaUrl = SourceUrl; OpenedEvent.Broadcast(SourceUrl); return (MediaSession->GetState() != EMediaStates::Error); }