|
3 | 3 | #include <AvTranscoder/progress/NoDisplayProgress.hpp>
|
4 | 4 |
|
5 | 5 | #include <stdexcept>
|
| 6 | +#include <sstream> |
6 | 7 |
|
7 | 8 | namespace avtranscoder
|
8 | 9 | {
|
@@ -40,36 +41,42 @@ void FileProperties::extractStreamProperties( IProgress& progress, const EAnalys
|
40 | 41 | {
|
41 | 42 | VideoProperties properties( *_formatContext, streamIndex, progress, level );
|
42 | 43 | _videoStreams.push_back( properties );
|
| 44 | + _streams.push_back( &_videoStreams.back() ); |
43 | 45 | break;
|
44 | 46 | }
|
45 | 47 | case AVMEDIA_TYPE_AUDIO:
|
46 | 48 | {
|
47 | 49 | AudioProperties properties( *_formatContext, streamIndex );
|
48 | 50 | _audioStreams.push_back( properties );
|
| 51 | + _streams.push_back( &_audioStreams.back() ); |
49 | 52 | break;
|
50 | 53 | }
|
51 | 54 | case AVMEDIA_TYPE_DATA:
|
52 | 55 | {
|
53 | 56 | DataProperties properties( *_formatContext, streamIndex );
|
54 | 57 | _dataStreams.push_back( properties );
|
| 58 | + _streams.push_back( &_dataStreams.back() ); |
55 | 59 | break;
|
56 | 60 | }
|
57 | 61 | case AVMEDIA_TYPE_SUBTITLE:
|
58 | 62 | {
|
59 | 63 | SubtitleProperties properties( *_formatContext, streamIndex );
|
60 | 64 | _subtitleStreams.push_back( properties );
|
| 65 | + _streams.push_back( &_subtitleStreams.back() ); |
61 | 66 | break;
|
62 | 67 | }
|
63 | 68 | case AVMEDIA_TYPE_ATTACHMENT:
|
64 | 69 | {
|
65 | 70 | AttachementProperties properties( *_formatContext, streamIndex );
|
66 | 71 | _attachementStreams.push_back( properties );
|
| 72 | + _streams.push_back( &_attachementStreams.back() ); |
67 | 73 | break;
|
68 | 74 | }
|
69 | 75 | case AVMEDIA_TYPE_UNKNOWN:
|
70 | 76 | {
|
71 | 77 | UnknownProperties properties( *_formatContext, streamIndex );
|
72 | 78 | _unknownStreams.push_back( properties );
|
| 79 | + _streams.push_back( &_unknownStreams.back() ); |
73 | 80 | break;
|
74 | 81 | }
|
75 | 82 | case AVMEDIA_TYPE_NB:
|
@@ -140,28 +147,17 @@ size_t FileProperties::getPacketSize() const
|
140 | 147 | return _avFormatContext->packet_size;
|
141 | 148 | }
|
142 | 149 |
|
143 |
| -const avtranscoder::VideoProperties& FileProperties::getVideoPropertiesWithStreamIndex( const size_t streamIndex ) const |
| 150 | +const avtranscoder::StreamProperties& FileProperties::getStreamPropertiesWithIndex( const size_t streamIndex ) const |
144 | 151 | {
|
145 |
| - for( std::vector< VideoProperties >::const_iterator it = _videoStreams.begin(); it != _videoStreams.end(); ++it ) |
| 152 | + for( std::vector< StreamProperties* >::const_iterator it = _streams.begin(); it != _streams.end(); ++it ) |
146 | 153 | {
|
147 |
| - if( it->getStreamIndex() == streamIndex ) |
148 |
| - return *it; |
| 154 | + if( (*it)->getStreamIndex() == streamIndex ) |
| 155 | + return *(*it); |
149 | 156 | }
|
150 |
| - std::string msg( "no video properties correspond to stream at index " ); |
151 |
| - msg += streamIndex; |
152 |
| - throw std::runtime_error( msg ); |
153 |
| -} |
154 |
| - |
155 |
| -const avtranscoder::AudioProperties& FileProperties::getAudioPropertiesWithStreamIndex( const size_t streamIndex ) const |
156 |
| -{ |
157 |
| - for( std::vector< AudioProperties >::const_iterator it = _audioStreams.begin(); it != _audioStreams.end(); ++it ) |
158 |
| - { |
159 |
| - if( it->getStreamIndex() == streamIndex ) |
160 |
| - return *it; |
161 |
| - } |
162 |
| - std::string msg( "no audio properties correspond to stream at index " ); |
163 |
| - msg += streamIndex; |
164 |
| - throw std::runtime_error( msg ); |
| 157 | + std::stringstream os; |
| 158 | + os << "No stream properties correspond to stream at index "; |
| 159 | + os << streamIndex; |
| 160 | + throw std::runtime_error( os.str() ); |
165 | 161 | }
|
166 | 162 |
|
167 | 163 | size_t FileProperties::getNbStreams() const
|
@@ -202,6 +198,8 @@ PropertyVector FileProperties::getPropertiesAsVector() const
|
202 | 198 |
|
203 | 199 | void FileProperties::clearStreamProperties()
|
204 | 200 | {
|
| 201 | + _streams.clear(); |
| 202 | + |
205 | 203 | _videoStreams.clear();
|
206 | 204 | _audioStreams.clear();
|
207 | 205 | _dataStreams.clear();
|
|
0 commit comments