[vlc-commits] sout: sdi: refactor mapping by id
Francois Cartegnie
git at videolan.org
Mon Oct 8 18:11:28 CEST 2018
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Sep 5 19:13:21 2018 +0200| [743caf4ebe0177a9138de7eee2d89a1a6e34c297] | committer: Francois Cartegnie
sout: sdi: refactor mapping by id
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=743caf4ebe0177a9138de7eee2d89a1a6e34c297
---
modules/stream_out/sdi/SDIAudioMultiplex.cpp | 35 +++++++++++++++++-----------
modules/stream_out/sdi/SDIAudioMultiplex.hpp | 2 ++
modules/stream_out/sdi/SDIStream.cpp | 2 +-
modules/stream_out/sdi/SDIStream.hpp | 2 +-
4 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/modules/stream_out/sdi/SDIAudioMultiplex.cpp b/modules/stream_out/sdi/SDIAudioMultiplex.cpp
index 4369932f64..9fe6b4e751 100644
--- a/modules/stream_out/sdi/SDIAudioMultiplex.cpp
+++ b/modules/stream_out/sdi/SDIAudioMultiplex.cpp
@@ -268,6 +268,22 @@ bool SDIAudioMultiplexConfig::addMapping(const StreamID &id, std::vector<uint8_t
return true;
}
+SDIAudioMultiplexConfig::Mapping *
+ SDIAudioMultiplexConfig::getMappingByID(const StreamID &id)
+{
+ auto it = std::find_if(mappings.begin(), mappings.end(),
+ [&id](Mapping *e) { return e->id == id; });
+ return (it != mappings.end()) ? *it : NULL;
+}
+
+const SDIAudioMultiplexConfig::Mapping *
+ SDIAudioMultiplexConfig::getMappingByID(const StreamID &id) const
+{
+ auto it = std::find_if(mappings.begin(), mappings.end(),
+ [&id](const Mapping *e) { return e->id == id; });
+ return (it != mappings.end()) ? *it : NULL;
+}
+
unsigned SDIAudioMultiplexConfig::getMaxSamplesForBlockSize(size_t s) const
{
return s / (2 * sizeof(uint16_t) * getMultiplexedFramesCount());
@@ -276,30 +292,23 @@ unsigned SDIAudioMultiplexConfig::getMaxSamplesForBlockSize(size_t s) const
SDIAudioMultiplexBuffer *
SDIAudioMultiplexConfig::getBufferForStream(const StreamID &id)
{
- for(size_t i=0; i<mappings.size(); i++)
- {
- if(mappings[i]->id == id)
- return &mappings[i]->buffer;
- }
- return NULL;
+ Mapping *map = getMappingByID(id);
+ return map ? &map->buffer : NULL;
}
const es_format_t * SDIAudioMultiplexConfig::getConfigurationForStream(const StreamID &id) const
{
- auto it = std::find_if(mappings.begin(), mappings.end(),
- [&id](Mapping *e) { return e->id == id; });
- return (it != mappings.end()) ? &(*it)->fmt : NULL;
+ const Mapping *map = getMappingByID(id);
+ return map ? &map->fmt : NULL;
}
const es_format_t *
SDIAudioMultiplexConfig::updateFromRealESConfig(const StreamID &id,
const es_format_t *fmt)
{
- auto it = std::find_if(mappings.begin(), mappings.end(),
- [&id](Mapping *e) { return e->id == id; });
- if(it != mappings.end())
+ Mapping *mapping = getMappingByID(id);
+ if(mapping)
{
- Mapping *mapping = (*it);
if(mapping->subframesslots.size() > 2 && fmt->audio.i_channels > 2)
ConfigureChannels(fmt->audio.i_channels, &mapping->fmt);
mapping->buffer.setSubFramesCount(mapping->fmt.audio.i_channels);
diff --git a/modules/stream_out/sdi/SDIAudioMultiplex.hpp b/modules/stream_out/sdi/SDIAudioMultiplex.hpp
index a571cf689f..d65263e1d7 100644
--- a/modules/stream_out/sdi/SDIAudioMultiplex.hpp
+++ b/modules/stream_out/sdi/SDIAudioMultiplex.hpp
@@ -73,6 +73,8 @@ namespace sdi_sout
std::vector<uint8_t> subframesslots;
};
std::vector<Mapping *> mappings;
+ Mapping *getMappingByID(const StreamID &);
+ const Mapping *getMappingByID(const StreamID &) const;
unsigned subframeslotbitmap;
uint8_t framewidth;
bool b_accept_any;
diff --git a/modules/stream_out/sdi/SDIStream.cpp b/modules/stream_out/sdi/SDIStream.cpp
index 441910025a..9819a9c663 100644
--- a/modules/stream_out/sdi/SDIStream.cpp
+++ b/modules/stream_out/sdi/SDIStream.cpp
@@ -129,7 +129,7 @@ StreamID& StreamID::operator=(const StreamID &other)
return *this;
}
-bool StreamID::operator==(const StreamID &other)
+bool StreamID::operator==(const StreamID &other) const
{
if(stream_id == -1 || other.stream_id == -1)
return sequence_id == other.sequence_id;
diff --git a/modules/stream_out/sdi/SDIStream.hpp b/modules/stream_out/sdi/SDIStream.hpp
index ec50338dd9..67cef9af43 100644
--- a/modules/stream_out/sdi/SDIStream.hpp
+++ b/modules/stream_out/sdi/SDIStream.hpp
@@ -73,7 +73,7 @@ namespace sdi_sout
StreamID(int);
StreamID(int, int);
StreamID& operator=(const StreamID &);
- bool operator==(const StreamID &);
+ bool operator==(const StreamID &) const;
std::string toString() const;
private:
More information about the vlc-commits
mailing list