VideoVis  0.9
Generates a volume visualisation of a video
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
VideoFrameLoader.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <mfapi.h>
4 #include <mfidl.h>
5 #include <mfreadwrite.h>
6 
7 #include <list>
8 
9 
10 
11 #define MAXVideoURLLenght 256
12 
13 #define VFL_OK 0
14 #define VFL_ERROR -1
15 #define VFL_NO_FILE_URL_SET 1
16 #define VFL_URL_TO_LONG 2
17 #define VFL_PATH_TO_LONG 3
18 #define VFL_NO_VIDEO_SOURCE 4
19 #define VFL_VIDEO_ATTRIBUTES_NOT_SET 5
20 #define VFL_VIDEO_BUFFER_IS_NULL 6
21 #define VFL_COULD_NOT_CONVERT_PATH_TO_URL 25
22 #define VFL_COULD_NOT_READ_SOURCE_FILE 26
23 #define VFL_COULD_NOT_DECODE_FILE 27
24 #define VFL_COULD_NOT_GET_MEDIA_TYPE 28
25 #define VFL_COULD_NOT_GET_MEDIA_ATTRIBUTES 29
26 #define VFL_COULD_NOT_READ_ANY_FRAMES 30
27 #define VFL_NO_MORE_FRAMES 31
28 
29 typedef int VFLResult;
30 
31 using namespace std;
32 
34 
41 {
42 public:
44 
49  CVideoFrameLoader(void);
50 
52 
57  CVideoFrameLoader(PWSTR filePath);
58 
60 
63  ~CVideoFrameLoader(void);
64 
66 
73  VFLResult setVideoPath(PWSTR filePath);
74 
76 
83  VFLResult setVideoURL(PWSTR fileURL);
84 
86 
94  VFLResult loadAllFramesIntoBuffer();
95 
97 
107  VFLResult loadAllFramesIntoBuffer(int offset, int distanceBetween);
108 
110 
121  VFLResult loadAllFramesIntoBuffer(int offset, int distanceBetween, int lastFrame);
122 
124 
131  VFLResult addNextFrameToBuffer();
132 
134 
142  VFLResult addNextFrameToBuffer(int distanceFromLast);
143 
145 
152  VFLResult getVideoResolution(int *width, int *height);
153 
155 
167  VFLResult getVideoBuffer(PBYTE *videoArray);
168 
170 
177  VFLResult getBufferFrameCount(int *frameCount);
178 
180 
184  void reset();
185 
187 
194  HRESULT setPosition(const LONGLONG& hnsPosition);
195 protected:
196  PBYTE p_videoArray;
198 
206  virtual VFLResult resetProperties();
207 
209 
217  void copyVideoListToVideoArray();
218 private:
219  PWSTR p_videoURL;
220  IMFSourceReader *p_videoReader;
221  int m_frameCount;
222  int m_totalFrameCount;
223  UINT32 m_videoWidth, m_videoHeight;
224  bool m_videoBufferTransfered;
225  bool m_comInitialisationSuccessful;
226  bool m_mediaFoundationInitalisationSuccessful;
227 
228  list<PBYTE, allocator<PBYTE>> *p_videoList;
229 
230  void initializeFrameLoader();
231  VFLResult setVideoPath(PWSTR filePath, bool reset);
232  VFLResult setVideoURL(PWSTR fileURL, bool reset);
233  VFLResult openFileInSourceReader();
234  HRESULT configureDecoder(IMFSourceReader *pReader);
235  VFLResult copyFrameToBuffer(IMFSample *pSample);
236  void SafeRelease(IUnknown **ppT);
237 };
238