-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRecordingManagement.cpp
executable file
·115 lines (94 loc) · 2.84 KB
/
RecordingManagement.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/**
* @file RecordingManagement.cpp
* @ingroup Kinect
* @author Dominique Vaufreydaz, Grenoble Alpes University, Inria
* @copyright All right reserved.
*/
#include "RecordingManagement.h"
bool RecordingManagement::StartRecording( const char* SessionFolder )
{
// If we are recording, do nothing
if ( IsRecording == true )
{
return false;
}
Omiscid::SmartLocker ProtectAccess_SL(ProtectAccess);
bool Success = true;
for( RecContexts.First(); RecContexts.NotAtEnd(); RecContexts.Next() )
{
KinectRecording * pRec = RecContexts.GetCurrent();
if ( pRec->IsActive )
{
if ( pRec->StartRecording( SessionFolder ) == false )
{
// One sub recorder does not start, it is likely that the other
// won't start also, anyway, recording process is partial, stop it
Success = false;
break;
}
}
}
// Check is we succeeded in all sub start recording
if ( Success == false )
{
// Unlock mutex
ProtectAccess_SL.Unlock();
// Stop all started recordings
StopRecording();
return false;
}
// everything went fine
IsRecording = true;
return true;
}
void RecordingManagement::StopRecording()
{
if ( IsRecording == false )
{
return;
}
Omiscid::SmartLocker ProtectAccess_SL(ProtectAccess);
double CurrentTime = GetCurrentTime();
// Call all record context to stop
for( RecContexts.First(); RecContexts.NotAtEnd(); RecContexts.Next() )
{
KinectRecording * pRec = RecContexts.GetCurrent();
if ( pRec->IsActive )
{
pRec->StopRecording( CurrentTime );
}
}
IsRecording = false;
}
KinectRecording* RecordingManagement::AddRecContext(const Omiscid::SimpleString& Prefix, const Omiscid::SimpleString& _FrameType, int TypeOfContext )
{
KinectRecording* pKR = RecordingContextFactory::CreateContextRecording( Prefix, _FrameType, RecordingContextFactory::VideoRecContext);
RecContexts.AddTail(pKR);
return pKR;
}
void RecordingManagement::ClearRecContexts()
{
Omiscid::SmartLocker ProtectAccess_SL(ProtectAccess);
while( RecContexts.IsNotEmpty() == true )
{
KinectRecording* pKR = RecContexts.ExtractFirst();
if ( pKR != (KinectRecording*)nullptr )
{
delete pKR;
}
}
}
void RecordingManagement::SaveTimestamp( FILE* f, const struct timeb& lTimestamp, unsigned int numFrame, TIMESPAN FrameTime, char * SuppInfo /* = nullptr */ )
{
if ( IsRecording == false )
{
return;
}
Omiscid::SmartLocker ProtectAccess_SL(ProtectAccess);
KinectRecording::SaveTimestamp( f, lTimestamp, numFrame, FrameTime, SuppInfo );
}
void RecordingManagement::SaveDataAndIncreaseInputNumber( KinectRecording& RecordContext, const struct timeb& lTimestamp, char * SuppInfo /* = nullptr */ )
{
Omiscid::SmartLocker ProtectAccess_SL(ProtectAccess);
RecordContext.SaveDataAndIncreaseInputNumber( lTimestamp, SuppInfo );
}