Skip to content

Commit 8a895ac

Browse files
committed
Merge pull request #216 from cchampet/dev_propertiesDeletePrintHeader
properties: overload operator<< in each class properties: added fillVector method to avoid copy of the vector
2 parents 6a915de + dac41e8 commit 8a895ac

24 files changed

+257
-214
lines changed

app/avMeta/avMeta.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#include <AvTranscoder/file/InputFile.hpp>
2-
#include <AvTranscoder/properties/print.hpp>
3-
42
#include <AvTranscoder/progress/NoDisplayProgress.hpp>
53

64
#include <iostream>

src/AvTranscoder/file/InputFile.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,51 @@ void InputFile::setupUnwrapping(const ProfileLoader::Profile& profile)
203203
}
204204
}
205205
}
206+
207+
std::ostream& operator<<(std::ostream& flux, const InputFile& input)
208+
{
209+
// wrapper
210+
flux << input.getProperties();
211+
212+
// video streams
213+
for(size_t videoStreamIndex = 0; videoStreamIndex < input.getProperties().getNbVideoStreams(); ++videoStreamIndex)
214+
{
215+
flux << input.getProperties().getVideoProperties().at(videoStreamIndex);
216+
}
217+
218+
// audio streams
219+
for(size_t audioStreamIndex = 0; audioStreamIndex < input.getProperties().getNbAudioStreams(); ++audioStreamIndex)
220+
{
221+
flux << input.getProperties().getAudioProperties().at(audioStreamIndex);
222+
}
223+
224+
// data streams
225+
for(size_t dataStreamIndex = 0; dataStreamIndex < input.getProperties().getNbDataStreams(); ++dataStreamIndex)
226+
{
227+
flux << input.getProperties().getDataProperties().at(dataStreamIndex);
228+
}
229+
230+
// subtitle streams
231+
for(size_t subtitleStreamIndex = 0; subtitleStreamIndex < input.getProperties().getNbSubtitleStreams();
232+
++subtitleStreamIndex)
233+
{
234+
flux << input.getProperties().getSubtitleProperties().at(subtitleStreamIndex);
235+
}
236+
237+
// attachement streams
238+
for(size_t attachementStreamIndex = 0; attachementStreamIndex < input.getProperties().getNbAttachementStreams();
239+
++attachementStreamIndex)
240+
{
241+
flux << input.getProperties().getAttachementProperties().at(attachementStreamIndex);
242+
}
243+
244+
// unknown streams
245+
for(size_t unknownStreamIndex = 0; unknownStreamIndex < input.getProperties().getNbUnknownStreams();
246+
++unknownStreamIndex)
247+
{
248+
flux << input.getProperties().getUnknownProperties().at(unknownStreamIndex);
249+
}
250+
251+
return flux;
252+
}
206253
}

src/AvTranscoder/file/InputFile.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ class AvExport InputFile
125125
std::string _filename;
126126
std::vector<InputStream*> _inputStreams; ///< Has ownership
127127
};
128+
129+
#ifndef SWIG
130+
AvExport std::ostream& operator<<(std::ostream& flux, const InputFile& input);
131+
#endif
128132
}
129133

130134
#endif
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include "AttachementProperties.hpp"
2+
3+
#include <AvTranscoder/properties/util.hpp>
4+
5+
namespace avtranscoder
6+
{
7+
8+
std::ostream& operator<<(std::ostream& flux, const AttachementProperties& attachementProperties)
9+
{
10+
flux << detail::separator << " Attachement stream " << detail::separator << std::endl;
11+
12+
PropertyVector properties = attachementProperties.asVector();
13+
for(PropertyVector::iterator it = properties.begin(); it != properties.end(); ++it)
14+
{
15+
flux << std::setw(detail::keyWidth) << it->first << ": " << it->second << std::endl;
16+
}
17+
18+
return flux;
19+
}
20+
}

src/AvTranscoder/properties/AttachementProperties.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ class AvExport AttachementProperties : public StreamProperties
1414
{
1515
}
1616
};
17+
18+
#ifndef SWIG
19+
AvExport std::ostream& operator<<(std::ostream& flux, const AttachementProperties& attachementProperties);
20+
#endif
1721
}
1822

1923
#endif

src/AvTranscoder/properties/AudioProperties.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "AudioProperties.hpp"
22

3+
#include <AvTranscoder/properties/util.hpp>
4+
35
extern "C" {
46
#include <libavcodec/avcodec.h>
57
#include <libavformat/avformat.h>
@@ -147,12 +149,11 @@ size_t AudioProperties::getTicksPerFrame() const
147149
return _codecContext->ticks_per_frame;
148150
}
149151

150-
PropertyVector AudioProperties::asVector() const
152+
PropertyVector& AudioProperties::fillVector(PropertyVector& data) const
151153
{
152-
PropertyVector data;
153-
154154
// Add properties of base class
155-
PropertyVector basedProperty = StreamProperties::asVector();
155+
PropertyVector basedProperty;
156+
StreamProperties::fillVector(basedProperty);
156157
data.insert(data.begin(), basedProperty.begin(), basedProperty.end());
157158

158159
addProperty(data, "sampleFormatName", &AudioProperties::getSampleFormatName);
@@ -168,4 +169,18 @@ PropertyVector AudioProperties::asVector() const
168169

169170
return data;
170171
}
172+
173+
std::ostream& operator<<(std::ostream& flux, const AudioProperties& audioProperties)
174+
{
175+
flux << std::left;
176+
flux << detail::separator << " Audio stream " << detail::separator << std::endl;
177+
178+
PropertyVector properties = audioProperties.asVector();
179+
for(PropertyVector::iterator it = properties.begin(); it != properties.end(); ++it)
180+
{
181+
flux << std::setw(detail::keyWidth) << it->first << ": " << it->second << std::endl;
182+
}
183+
184+
return flux;
185+
}
171186
}

src/AvTranscoder/properties/AudioProperties.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class AvExport AudioProperties : public StreamProperties
3030
AVCodecContext& getAVCodecContext() { return *_codecContext; }
3131
#endif
3232

33-
PropertyVector asVector() const;
33+
PropertyVector& fillVector(PropertyVector& data) const;
3434

3535
private:
3636
#ifndef SWIG
@@ -48,6 +48,10 @@ class AvExport AudioProperties : public StreamProperties
4848
}
4949
#endif
5050
};
51+
52+
#ifndef SWIG
53+
AvExport std::ostream& operator<<(std::ostream& flux, const AudioProperties& audioProperties);
54+
#endif
5155
}
5256

5357
#endif

src/AvTranscoder/properties/DataProperties.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "DataProperties.hpp"
22

3+
#include <AvTranscoder/properties/util.hpp>
4+
35
extern "C" {
46
#include <libavcodec/avcodec.h>
57
}
@@ -77,4 +79,17 @@ void DataProperties::detectAncillaryData()
7779
break;
7880
}
7981
}
82+
83+
std::ostream& operator<<(std::ostream& flux, const DataProperties& dataProperties)
84+
{
85+
flux << detail::separator << " Data stream " << detail::separator << std::endl;
86+
87+
PropertyVector properties = dataProperties.asVector();
88+
for(PropertyVector::iterator it = properties.begin(); it != properties.end(); ++it)
89+
{
90+
flux << std::setw(detail::keyWidth) << it->first << ": " << it->second << std::endl;
91+
}
92+
93+
return flux;
94+
}
8095
}

src/AvTranscoder/properties/DataProperties.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ class AvExport DataProperties : public StreamProperties
1717
private:
1818
void detectAncillaryData();
1919
};
20+
21+
#ifndef SWIG
22+
AvExport std::ostream& operator<<(std::ostream& flux, const DataProperties& dataProperties);
23+
#endif
2024
}
2125

2226
#endif

src/AvTranscoder/properties/FileProperties.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "FileProperties.hpp"
22

3+
#include <AvTranscoder/properties/util.hpp>
34
#include <AvTranscoder/properties/JsonWriter.hpp>
45
#include <AvTranscoder/progress/NoDisplayProgress.hpp>
56

@@ -209,8 +210,12 @@ size_t FileProperties::getNbStreams() const
209210

210211
PropertyVector FileProperties::asVector() const
211212
{
212-
PropertyVector data;
213+
PropertyVector propertyVector;
214+
return fillVector(propertyVector);
215+
}
213216

217+
PropertyVector& FileProperties::fillVector(PropertyVector& data) const
218+
{
214219
addProperty(data, "filename", &FileProperties::getFilename);
215220
addProperty(data, "formatName", &FileProperties::getFormatName);
216221
addProperty(data, "formatLongName", &FileProperties::getFormatLongName);
@@ -341,4 +346,18 @@ void FileProperties::clearStreamProperties()
341346
_attachementStreams.clear();
342347
_unknownStreams.clear();
343348
}
349+
350+
std::ostream& operator<<(std::ostream& flux, const FileProperties& fileProperties)
351+
{
352+
flux << std::left;
353+
flux << detail::separator << " Wrapper " << detail::separator << std::endl;
354+
355+
PropertyVector properties = fileProperties.asVector();
356+
for(PropertyVector::iterator it = properties.begin(); it != properties.end(); ++it)
357+
{
358+
flux << std::setw(detail::keyWidth) << it->first << ": " << it->second << std::endl;
359+
}
360+
361+
return flux;
362+
}
344363
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy