Skip to content

FileProperties: StreamProperties stored by streamIndex into a map #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions src/AvTranscoder/mediaProperty/FileProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,22 @@ void FileProperties::extractStreamProperties( IProgress& progress, const EAnalys

// once the streams vectors are filled, add their references the base streams vector
for( size_t streamIndex = 0; streamIndex < _videoStreams.size(); ++streamIndex )
_streams.push_back( &_videoStreams.at( streamIndex ) );
_streams[ _videoStreams.at( streamIndex ).getStreamIndex() ] = &_videoStreams.at( streamIndex );

for( size_t streamIndex = 0; streamIndex < _audioStreams.size(); ++ streamIndex )
_streams.push_back( &_audioStreams.at(streamIndex) );
_streams[ _audioStreams.at(streamIndex).getStreamIndex() ] = &_audioStreams.at(streamIndex);

for( size_t streamIndex = 0; streamIndex < _dataStreams.size(); ++ streamIndex )
_streams.push_back( &_dataStreams.at(streamIndex) );
_streams[ _dataStreams.at(streamIndex).getStreamIndex() ] = &_dataStreams.at(streamIndex);

for( size_t streamIndex = 0; streamIndex < _subtitleStreams.size(); ++ streamIndex )
_streams.push_back( &_subtitleStreams.at(streamIndex) );
_streams[ _subtitleStreams.at(streamIndex).getStreamIndex() ] = &_subtitleStreams.at(streamIndex);

for( size_t streamIndex = 0; streamIndex < _attachementStreams.size(); ++ streamIndex )
_streams.push_back( &_attachementStreams.at(streamIndex) );
_streams[ _attachementStreams.at(streamIndex).getStreamIndex() ] = &_attachementStreams.at(streamIndex);

for( size_t streamIndex = 0; streamIndex < _unknownStreams.size(); ++ streamIndex )
_streams.push_back( &_unknownStreams.at(streamIndex) );
_streams[ _unknownStreams.at(streamIndex).getStreamIndex() ] = &_unknownStreams.at(streamIndex);

// if the analysis level has decoded some streams parts, return at the beginning
if( level > eAnalyseLevelHeader )
Expand Down Expand Up @@ -162,11 +162,9 @@ size_t FileProperties::getPacketSize() const

const avtranscoder::StreamProperties& FileProperties::getStreamPropertiesWithIndex( const size_t streamIndex ) const
{
for( std::vector< StreamProperties* >::const_iterator it = _streams.begin(); it != _streams.end(); ++it )
{
if( (*it)->getStreamIndex() == streamIndex )
return *(*it);
}
avtranscoder::StreamProperties* properties = _streams.find( streamIndex )->second;
if( properties )
return *properties;
std::stringstream os;
os << "No stream properties correspond to stream at index ";
os << streamIndex;
Expand Down
5 changes: 4 additions & 1 deletion src/AvTranscoder/mediaProperty/FileProperties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <string>
#include <vector>
#include <map>

namespace avtranscoder
{
Expand Down Expand Up @@ -61,6 +62,7 @@ class AvExport FileProperties

//@{
// @brief Get the properties at the indicated stream index
// @throws A runtime error if the streamIndex does not match any stream
const avtranscoder::StreamProperties& getStreamPropertiesWithIndex( const size_t streamIndex ) const;
//@}

Expand Down Expand Up @@ -102,7 +104,8 @@ class AvExport FileProperties
const FormatContext* _formatContext; ///< Has link (no ownership)
const AVFormatContext* _avFormatContext; ///< Has link (no ownership)

std::vector< StreamProperties* > _streams; ///< Array of properties per stream (of all types) - only references to the following properties
std::map< size_t, StreamProperties* > _streams; ///< Map of properties per stream index (of all types) - only references to the following properties

std::vector< VideoProperties > _videoStreams; ///< Array of properties per video stream
std::vector< AudioProperties > _audioStreams; ///< Array of properties per audio stream
std::vector< DataProperties > _dataStreams; ///< Array of properties per data stream
Expand Down