-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathImageSaving.h
152 lines (108 loc) · 3.57 KB
/
ImageSaving.h
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// *****************************************************************************
//
// Copyright (c) 2013, Pleora Technologies Inc., All rights reserved.
//
// *****************************************************************************
#ifndef __IMAGE_SAVING_H__
#define __IMAGE_SAVING_H__
#include "IPersistent.h"
#include <string>
#include "DisplayThread.h"
#include "NetworkManager.h"
#ifdef QT_VERSION
#include <QtCore/QTime>
#endif
class ImageFiltering;
class PvBufferWriter;
class IMp4Writer;
class ImageSaving : public IPersistent
{
#ifdef _AFXDLL
DECLARE_DYNAMIC( ImageSaving )
#endif // _AFXDLL
public:
ImageSaving( ImageFiltering *aImageFiltering, NetworkManager * aNetworkManager);
~ImageSaving();
PvResult Save( PvConfigurationWriter *aWriter );
PvResult Load( PvConfigurationReader *aReader );
void Reset();
void ResetStats();
typedef enum
{
ThrottleOneOutOf = 0,
ThrottleMaxRate = 1,
ThrottleAverageThroughput = 2,
ThrottleNone = 3
} Throttle;
typedef enum
{
FormatBmp = 0,
FormatRaw = 1,
FormatTiff = 2,
FormatMp4 = 3
} Format;
bool GetEnabled() const { return mEnabled; }
Throttle GetThrottling() const { return mThrottling; }
uint32_t GetOneOutOf() const { return mOneOutOf; }
uint32_t GetMaxRate() const { return mMaxRate; }
uint32_t GetAverageThroughput() const { return mAverageThroughput; }
PvString GetPath() const { return mPath.c_str(); }
Format GetFormat() const { return mFormat; }
uint32_t GetAvgBitrate() const;
void SetEnabled( bool aValue ) { mEnabled = aValue; }
void SetThrottling( Throttle aValue ) { mThrottling = aValue; }
void SetOneOutOf( uint32_t aValue ) { mOneOutOf = aValue; }
void SetMaxRate( uint32_t aValue ) { mMaxRate = aValue; }
void SetAverageThroughput( uint32_t aValue ) { mAverageThroughput = aValue; }
void SetPath( const PvString &aValue ) { mPath = aValue.GetAscii(); }
void SetFormat( Format aValue ) { mFormat = aValue; }
void SetAvgBitrate( uint32_t aValue );
double GetFPS() { return mFPS; }
double GetMbps() { return mMbps; }
int32_t GetFrames() { return mFrames; }
int64_t GetTotalSize() { return mTotalSize / 1048576; }
bool SavePure( PvBuffer *aBuffer );
bool SaveDisplay( PvBuffer *aBuffer );
bool SaveCurrentImage( DisplayThread *aDisplayThread);
bool IsFormatVideo();
bool IsMp4Supported();
void NotifyStreamingStop();
void GetLastError( PvString &aString );
protected:
ImageSaving(); // Not implemented
bool SaveIfNecessary( PvBuffer *aBuffer );
bool SaveImage( PvBuffer *aRawBuffer, bool aUpdateStats );
void GetPath( PvBuffer *aBuffer, std::string &aLocation, std::string &aFilename );
void UpdateStats( PvBuffer *aBuffer, uint32_t aLastSize );
bool SaveMp4( PvBuffer *aBuffer );
private:
NetworkManager * m_NetworkManager;
bool mEnabled;
double mFPS;
double mMbps;
uint32_t mFrames;
int64_t mTotalSize;
Throttle mThrottling;
uint32_t mOneOutOf;
uint32_t mMaxRate;
uint32_t mAverageThroughput;
#ifdef QT_VERSION
QTime mTimer;
QTime mTimerLong;
#else
int64_t mStartTime;
int64_t mElapsedTime;
#endif
int64_t mCapturedSince;
int64_t mPrevious;
Format mFormat;
PvBufferWriter *mBufferWriter;
std::string mPath;
uint32_t mCount;
bool mStopped;
ImageFiltering *mImageFiltering;
// Used for MP4/H.264
IMp4Writer *mMp4Writer;
bool mMp4WriterOpenFailed;
};
#endif // __IMAGE_SAVING_H__