MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / init

Method init

Source/Node/VideoNode.cpp:152–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150 AnnexBNalSplitter splitter;
151
152 bool init(String filename) {
153 decoderStorage = h264bsdAlloc();
154 if (!decoderStorage) {
155 Error("VideoNode: failed to allocate decoder storage");
156 return false;
157 }
158
159 u32 result = h264bsdInit(decoderStorage, 1); // 0 = enable output reordering
160 if (result != H264BSD_RDY) {
161 Error("VideoNode: failed to initialize decoder, error code: {}", result);
162 h264bsdFree(decoderStorage);
163 decoderStorage = nullptr;
164 return false;
165 }
166
167 std::string fullPath = SharedContent.getFullPath(filename);
168 fileHandle = SDL_RWFromFile(fullPath.c_str(), "rb");
169 if (!fileHandle) {
170 Error("VideoNode: failed to open file: {}, error: {}", fullPath, SDL_GetError());
171 return false;
172 }
173
174 while (readFileChunk(true)) {
175 if (videoWidth > 0 && videoHeight > 0) {
176 break;
177 }
178 }
179
180 if (videoWidth == 0 || videoHeight == 0 || frameRate == 0) {
181 Error("VideoNode: failed to get video parameters from file {}", fullPath);
182 return false;
183 }
184
185 return true;
186 }
187
188 bool readFileChunk(bool init = false) {
189 if (!fileHandle) return false;

Callers

nothing calls this directly

Calls 8

h264bsdAllocFunction · 0.85
h264bsdInitFunction · 0.85
h264bsdFreeFunction · 0.85
SDL_RWFromFileFunction · 0.85
SDL_GetErrorFunction · 0.85
getFullPathMethod · 0.80
ErrorEnum · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected