22
33#include < QDateTime>
44#include < QDir>
5+ #include < QFileInfo>
56#include < QMessageBox>
67#include < QMutex>
78#include < QStorageInfo>
@@ -98,7 +99,7 @@ qint64 RecordingManager::getFreeSpace() {
9899 return rv;
99100}
100101
101- void RecordingManager::startRecording () {
102+ void RecordingManager::startRecording (const QString& recordingLocation ) {
102103 QString encodingType = m_pConfig->getValueString (
103104 ConfigKey (RECORDING_PREF_KEY , " Encoding" ));
104105 QString fileExtension = EncoderFactory::getFactory ()
@@ -121,14 +122,33 @@ void RecordingManager::startRecording() {
121122 }
122123
123124 m_iNumberSplits = 1 ;
124- // Append file extension.
125- QString date_time_str = formatDateTimeForFilename (QDateTime::currentDateTime ());
126- m_recordingFile = QString (" %1.%2" )
127- .arg (date_time_str, fileExtension);
128-
129- // Storing the absolutePath of the recording file without file extension.
130- m_recording_base_file = getRecordingDir ();
131- m_recording_base_file.append (" /" ).append (date_time_str);
125+
126+ if (recordingLocation.isEmpty ()) {
127+ // Append file extension.
128+ QString date_time_str = formatDateTimeForFilename (QDateTime::currentDateTime ());
129+ m_recordingFile = QStringLiteral (" %1.%2" )
130+ .arg (date_time_str, fileExtension);
131+
132+ // Storing the absolutePath of the recording file without file extension.
133+ m_recording_base_file = getRecordingDir ();
134+ m_recording_base_file.append (" /" ).append (date_time_str);
135+ } else {
136+ auto fileInfo = QFileInfo (recordingLocation);
137+
138+ if (!fileInfo.absoluteDir ().exists ()) {
139+ qWarning () << " Recoding directory is not found. Aborting." ;
140+ return ;
141+ }
142+ m_recordingFile = QStringLiteral (" %1.%2" )
143+ .arg (fileInfo.baseName (), fileExtension);
144+ if (m_recordingFile != fileInfo.fileName ()) {
145+ qWarning () << " Requested filename doesn't match with the "
146+ " configured recording encoder. Using"
147+ << m_recordingFile << " instead" ;
148+ }
149+ m_recording_base_file = fileInfo.absoluteDir ().filePath (fileInfo.baseName ());
150+ }
151+
132152 // Appending file extension to get the filelocation.
133153 m_recordingLocation = m_recording_base_file + QChar (' .' ) + fileExtension;
134154 m_pConfig->set (ConfigKey (RECORDING_PREF_KEY , " Path" ), m_recordingLocation);
0 commit comments