@@ -1256,19 +1256,21 @@ void FileInformation::startExport(const QString &exportFileName)
1256
1256
// ---------------------------------------------------------------------------
1257
1257
void FileInformation::Export_XmlGz (const QString &ExportFileName, const activefilters& filters)
1258
1258
{
1259
- std::stringstream Data;
1259
+ std::string Data;
1260
1260
1261
1261
// Header
1262
- Data<<" <?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n " ;
1263
- Data<<" <!-- Created by QCTools " << Version << " -->\n " ;
1264
- Data<<" <ffprobe:ffprobe xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ffprobe='http://www.ffmpeg.org/schema/ffprobe' xsi:schemaLocation='http://www.ffmpeg.org/schema/ffprobe ffprobe.xsd'>\n " ;
1265
- Data<<" <program_version version=\" " << FFmpeg_Version () << " \" copyright=\" Copyright (c) 2007-" << FFmpeg_Year () << " the FFmpeg developers\" build_date=\" " __DATE__ " \" build_time=\" " __TIME__ " \" compiler_ident=\" " << FFmpeg_Compiler () << " \" configuration=\" " << FFmpeg_Configuration () << " \" />\n " ;
1266
- Data<<" \n " ;
1267
- Data<<" <library_versions>\n " ;
1268
- Data<<FFmpeg_LibsVersion ();
1269
- Data<<" </library_versions>\n " ;
1270
-
1271
- Data<<" <frames>\n " ;
1262
+ std::stringstream Header;
1263
+ Header<<" <?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n " ;
1264
+ Header<<" <!-- Created by QCTools " << Version << " -->\n " ;
1265
+ Header<<" <ffprobe:ffprobe xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ffprobe='http://www.ffmpeg.org/schema/ffprobe' xsi:schemaLocation='http://www.ffmpeg.org/schema/ffprobe ffprobe.xsd'>\n " ;
1266
+ Header<<" <program_version version=\" " << FFmpeg_Version () << " \" copyright=\" Copyright (c) 2007-" << FFmpeg_Year () << " the FFmpeg developers\" build_date=\" " __DATE__ " \" build_time=\" " __TIME__ " \" compiler_ident=\" " << FFmpeg_Compiler () << " \" configuration=\" " << FFmpeg_Configuration () << " \" />\n " ;
1267
+ Header<<" \n " ;
1268
+ Header<<" <library_versions>\n " ;
1269
+ Header<<FFmpeg_LibsVersion ();
1270
+ Header<<" </library_versions>\n " ;
1271
+
1272
+ Header<<" <frames>\n " ;
1273
+ Data+=Header.str ();
1272
1274
1273
1275
// From stats
1274
1276
for (size_t Pos=0 ; Pos<Stats.size (); Pos++)
@@ -1281,12 +1283,13 @@ void FileInformation::Export_XmlGz (const QString &ExportFileName, const activef
1281
1283
videoStats->setWidth (m_mediaParser->availableVideoStreams ()[0 ].stream ()->codecpar ->width );
1282
1284
videoStats->setHeight (m_mediaParser->availableVideoStreams ()[0 ].stream ()->codecpar ->height );
1283
1285
}
1284
- Data<< Stats[Pos]->StatsToXML (filters);
1286
+ Data+= Stats[Pos]->StatsToXML (filters);
1285
1287
}
1286
1288
}
1287
1289
1288
1290
// Footer
1289
- Data<<" </frames>" ;
1291
+ std::stringstream Footer;
1292
+ Footer<<" </frames>" ;
1290
1293
1291
1294
QString streamsAndFormats;
1292
1295
QXmlStreamWriter writer (&streamsAndFormats);
@@ -1305,9 +1308,10 @@ void FileInformation::Export_XmlGz (const QString &ExportFileName, const activef
1305
1308
splitted[i] = QString (qAbs (writer.autoFormattingIndent ()), writer.autoFormattingIndent () > 0 ? ' ' : ' \t ' ) + splitted[i];
1306
1309
streamsAndFormats = splitted.join (" \n " );
1307
1310
1308
- Data <<streamsAndFormats.toStdString () << " \n\n " ;
1311
+ Footer <<streamsAndFormats.toStdString () << " \n\n " ;
1309
1312
1310
- Data<<" </ffprobe:ffprobe>" ;
1313
+ Footer<<" </ffprobe:ffprobe>" ;
1314
+ Data+=Footer.str ();
1311
1315
1312
1316
SharedFile file;
1313
1317
QString name;
@@ -1323,23 +1327,21 @@ void FileInformation::Export_XmlGz (const QString &ExportFileName, const activef
1323
1327
name = info.fileName ();
1324
1328
}
1325
1329
1326
- std::string DataS=Data.str ();
1327
1330
uLongf Buffer_Size=65536 ;
1328
-
1329
1331
if (file->open (QIODevice::ReadWrite))
1330
1332
{
1331
- if (name.endsWith (" .qctools. xml" ))
1333
+ if (name.endsWith (" .xml" ))
1332
1334
{
1333
- auto bytesLeft = Data.str (). size ();
1334
- auto writePtr = DataS .c_str ();
1335
+ auto bytesLeft = Data.size ();
1336
+ auto writePtr = Data .c_str ();
1335
1337
auto totalBytesWritten = 0 ;
1336
1338
1337
1339
while (bytesLeft) {
1338
1340
auto bytesToWrite = std::min (size_t (Buffer_Size), bytesLeft);
1339
1341
auto bytesWritten = file->write (writePtr, bytesToWrite);
1340
1342
totalBytesWritten += bytesWritten;
1341
1343
1342
- Q_EMIT statsFileGenerationProgress (totalBytesWritten, DataS .size ());
1344
+ Q_EMIT statsFileGenerationProgress (totalBytesWritten, Data .size ());
1343
1345
1344
1346
writePtr += bytesToWrite;
1345
1347
bytesLeft -= bytesWritten;
@@ -1348,14 +1350,12 @@ void FileInformation::Export_XmlGz (const QString &ExportFileName, const activef
1348
1350
break ;
1349
1351
}
1350
1352
}
1351
- else if (name. endsWith ( " .xml " ))
1353
+ else
1352
1354
{
1353
- file->write (DataS.c_str (), DataS.length ());
1354
- } else {
1355
1355
char * Buffer=new char [Buffer_Size];
1356
1356
z_stream strm;
1357
- strm.next_in = (Bytef *) DataS .c_str ();
1358
- strm.avail_in = DataS .size () ;
1357
+ strm.next_in = (Bytef *) Data .c_str ();
1358
+ strm.avail_in = Data .size () ;
1359
1359
strm.total_out = 0 ;
1360
1360
strm.zalloc = Z_NULL;
1361
1361
strm.zfree = Z_NULL;
@@ -1369,7 +1369,7 @@ void FileInformation::Export_XmlGz (const QString &ExportFileName, const activef
1369
1369
break ;
1370
1370
file->write (Buffer, Buffer_Size-strm.avail_out );
1371
1371
1372
- Q_EMIT statsFileGenerationProgress ((char *) strm.next_in - DataS .c_str (), DataS .size ());
1372
+ Q_EMIT statsFileGenerationProgress ((char *) strm.next_in - Data .c_str (), Data .size ());
1373
1373
}
1374
1374
while (strm.avail_out == 0 );
1375
1375
deflateEnd (&strm);
0 commit comments