MCPcopy Create free account
hub / github.com/TzuHuanTai/RaspberryPi-WebRTC / QueryFile

Method QueryFile

src/rtc/conductor.cpp:287–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

285}
286
287void Conductor::QueryFile(std::shared_ptr<RtcChannel> datachannel, const protocol::Packet &pkt) {
288 if (!pkt.has_query_file_request()) {
289 ERROR_PRINT("Invalid metadata request");
290 return;
291 }
292
293 if (args.record_path.empty()) {
294 ERROR_PRINT("Recording path is not set, unable to query files.");
295 return;
296 }
297
298 auto req = pkt.query_file_request();
299 auto type = req.type();
300 const std::string &parameter = req.parameter();
301
302 if (type == protocol::QueryFileType::LATEST_FILE || parameter.empty()) {
303 auto path = Utils::FindSecondNewestFile(args.record_path, ".mp4");
304 DEBUG_PRINT("LATEST: %s", path.c_str());
305 SendFileResponse(datachannel, path);
306 } else if (type == protocol::QueryFileType::BEFORE_FILE) {
307 auto paths = Utils::FindOlderFiles(parameter, 8);
308 for (auto &path : paths) {
309 DEBUG_PRINT("OLDER: %s", path.c_str());
310 SendFileResponse(datachannel, path);
311 }
312 } else if (type == protocol::QueryFileType::BEFORE_TIME) {
313 auto path = Utils::FindFilesFromDatetime(args.record_path, parameter);
314 DEBUG_PRINT("TIME_MATCH: %s", path.c_str());
315 SendFileResponse(datachannel, path);
316 }
317}
318
319void Conductor::SendFileResponse(std::shared_ptr<RtcChannel> datachannel, const std::string &path) {
320 if (path.empty())

Callers

nothing calls this directly

Calls 2

emptyMethod · 0.80
typeMethod · 0.80

Tested by

no test coverage detected