@@ -1256,19 +1256,21 @@ void FileInformation::startExport(const QString &exportFileName)
12561256// ---------------------------------------------------------------------------
12571257void FileInformation::Export_XmlGz (const QString &ExportFileName, const activefilters& filters)
12581258{
1259- std::stringstream Data;
1259+ std::string Data;
12601260
12611261 // 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 ();
12721274
12731275 // From stats
12741276 for (size_t Pos=0 ; Pos<Stats.size (); Pos++)
@@ -1281,12 +1283,13 @@ void FileInformation::Export_XmlGz (const QString &ExportFileName, const activef
12811283 videoStats->setWidth (m_mediaParser->availableVideoStreams ()[0 ].stream ()->codecpar ->width );
12821284 videoStats->setHeight (m_mediaParser->availableVideoStreams ()[0 ].stream ()->codecpar ->height );
12831285 }
1284- Data<< Stats[Pos]->StatsToXML (filters);
1286+ Data+= Stats[Pos]->StatsToXML (filters);
12851287 }
12861288 }
12871289
12881290 // Footer
1289- Data<<" </frames>" ;
1291+ std::stringstream Footer;
1292+ Footer<<" </frames>" ;
12901293
12911294 QString streamsAndFormats;
12921295 QXmlStreamWriter writer (&streamsAndFormats);
@@ -1305,9 +1308,10 @@ void FileInformation::Export_XmlGz (const QString &ExportFileName, const activef
13051308 splitted[i] = QString (qAbs (writer.autoFormattingIndent ()), writer.autoFormattingIndent () > 0 ? ' ' : ' \t ' ) + splitted[i];
13061309 streamsAndFormats = splitted.join (" \n " );
13071310
1308- Data <<streamsAndFormats.toStdString () << " \n\n " ;
1311+ Footer <<streamsAndFormats.toStdString () << " \n\n " ;
13091312
1310- Data<<" </ffprobe:ffprobe>" ;
1313+ Footer<<" </ffprobe:ffprobe>" ;
1314+ Data+=Footer.str ();
13111315
13121316 SharedFile file;
13131317 QString name;
@@ -1323,23 +1327,21 @@ void FileInformation::Export_XmlGz (const QString &ExportFileName, const activef
13231327 name = info.fileName ();
13241328 }
13251329
1326- std::string DataS=Data.str ();
13271330 uLongf Buffer_Size=65536 ;
1328-
13291331 if (file->open (QIODevice::ReadWrite))
13301332 {
1331- if (name.endsWith (" .qctools. xml" ))
1333+ if (name.endsWith (" .xml" ))
13321334 {
1333- auto bytesLeft = Data.str (). size ();
1334- auto writePtr = DataS .c_str ();
1335+ auto bytesLeft = Data.size ();
1336+ auto writePtr = Data .c_str ();
13351337 auto totalBytesWritten = 0 ;
13361338
13371339 while (bytesLeft) {
13381340 auto bytesToWrite = std::min (size_t (Buffer_Size), bytesLeft);
13391341 auto bytesWritten = file->write (writePtr, bytesToWrite);
13401342 totalBytesWritten += bytesWritten;
13411343
1342- Q_EMIT statsFileGenerationProgress (totalBytesWritten, DataS .size ());
1344+ Q_EMIT statsFileGenerationProgress (totalBytesWritten, Data .size ());
13431345
13441346 writePtr += bytesToWrite;
13451347 bytesLeft -= bytesWritten;
@@ -1348,14 +1350,12 @@ void FileInformation::Export_XmlGz (const QString &ExportFileName, const activef
13481350 break ;
13491351 }
13501352 }
1351- else if (name. endsWith ( " .xml " ))
1353+ else
13521354 {
1353- file->write (DataS.c_str (), DataS.length ());
1354- } else {
13551355 char * Buffer=new char [Buffer_Size];
13561356 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 () ;
13591359 strm.total_out = 0 ;
13601360 strm.zalloc = Z_NULL;
13611361 strm.zfree = Z_NULL;
@@ -1369,7 +1369,7 @@ void FileInformation::Export_XmlGz (const QString &ExportFileName, const activef
13691369 break ;
13701370 file->write (Buffer, Buffer_Size-strm.avail_out );
13711371
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 ());
13731373 }
13741374 while (strm.avail_out == 0 );
13751375 deflateEnd (&strm);
0 commit comments