void Call::stopRecording(bool flush) { if (!isRecording) return; debug(QString("Call %1: stop recording").arg(id)); // NOTE: we don't delete the sockets here, because we may be here as a // reaction to their disconnected() signals; and they don't like being // deleted during their signals. we don't delete the servers either, // since they own the sockets and we're too lazy to reparent. it's // easiest to let QT handle all this on its own. there will be some // memory wasted if you start/stop recording within the same call a few // times, but unless you do it thousands of times, the waste is more // than acceptable. // flush data to writer if (flush) tryToWrite(true); writer->close(); delete writer; if (syncFile.isOpen()) syncFile.close(); // we must disconnect all signals from the sockets first, so that upon // closing them it won't call checkConnections() and we don't land here // recursively again disconnect(socketLocal, 0, this, 0); disconnect(socketRemote, 0, this, 0); socketLocal->close(); socketRemote->close(); isRecording = false; emit stoppedRecording(id); }
static bool writeAFile(const MAUtil::String& dir) { // find a root path printf("Dir: '%s'\n", dir.c_str()); FileLister fl; int res = fl.start(dir.c_str()); if(res < 0) { printf("Error %i\n", res); return false; } MAUtil::String file; while(1) { res = fl.next(file); printf("%i: '%s'\n", res, file.c_str()); if(res < 0) { printf("Error %i\n", res); return false; } if(res == 0) { printf("Dir '%s' ends.\n", dir.c_str()); return false; } if(file[file.size()-1] == '/') { if(tryToWrite(dir + file)) return true; if(writeAFile(dir + file)) return true; } } }
void Call::readRemote() { bufferRemote += socketRemote->readAll(); if (isRecording) tryToWrite(); }
void Call::readLocal() { bufferLocal += socketLocal->readAll(); if (isRecording) tryToWrite(); }