Skip to content

Commit

Permalink
Documentation added to all files except Stream files (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmo16 authored Nov 23, 2019
1 parent 9ef4960 commit 0f84350
Show file tree
Hide file tree
Showing 15 changed files with 187 additions and 2 deletions.
12 changes: 12 additions & 0 deletions steno/src/model/audio_suppresser/audio_suppresser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

namespace Model
{
/**
* @brief Take audio buffer in input and remove sources in sourcesToSuppress/
* @param [IN] sourcesToSuppress - vector of audio sources to remove.
* @param [IN/OUT] audioBuf - Audio buffer to modify
* @param [IN] bufferLength
*/
void AudioSuppresser::suppressSources(const std::vector<int> &sourcesToSuppress, uint8_t *audioBuf,
const int bufferLength)
{
Expand All @@ -28,6 +34,12 @@ void AudioSuppresser::suppressSources(const std::vector<int> &sourcesToSuppress,
}
}

/**
* @brief Create a mask to suppress a source in a audio source.
* @param [IN] index - index of the source
* @param [OUT] mask - mask for suppression
* @param [IN] maskLength
*/
void AudioSuppresser::createMaskFromIndex(const int index, uint8_t *mask, const int maskLength)
{
// By default we use 16 bits precision => 2 bytes per source
Expand Down
11 changes: 10 additions & 1 deletion steno/src/model/classifier/classifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@

namespace Model
{
/**
* @brief Classify audio sources, this way the images are always there but the useless sounds are removed based on
* localizations.
* @param audioPositions - audio positions from odas localization.
* @param imagePositions - image positions to compare with audio positions.
* @param rangeThreshold - distance threshold
* @return vector of index of noisy sources to remove from the audio.
*/
std::vector<int> Classifier::classify(const std::vector<SourcePosition> &audioPositions,
const std::vector<SphericalAngleRect> &imagePositions, const float &rangeThreshold)
const std::vector<SphericalAngleRect> &imagePositions,
const float &rangeThreshold)
{
std::vector<int> sourcesToSuppress;

Expand Down
7 changes: 7 additions & 0 deletions steno/src/model/config/base_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ BaseConfig::BaseConfig(const QString &group, std::shared_ptr<QSettings> settings
{
}

/**
* @brief Update the Qt subconfigs
*/
void BaseConfig::updateSubconfigs()
{
for (auto config : m_subConfigs)
Expand All @@ -21,6 +24,10 @@ void BaseConfig::updateSubconfigs()
}
}

/**
* @brief Add a subconfig section to the global config.
* @param [IN] - config to add.
*/
void BaseConfig::addSubConfig(std::shared_ptr<BaseConfig> cfg)
{
if (!cfg->group().isEmpty() && !m_mapConfig.contains(cfg->group()))
Expand Down
7 changes: 7 additions & 0 deletions steno/src/model/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ Config::Config(std::shared_ptr<QSettings> settings, const QString &configPath)
settings->sync();
}

/**
* @brief Config::appConfig
* @return The application configuration, these are global configuration parameters usefull everywhere.
*/
std::shared_ptr<AppConfig> Config::appConfig() const
{
return m_appConfig;
Expand Down Expand Up @@ -93,6 +97,9 @@ std::shared_ptr<DarknetConfig> Config::darknetConfig() const
return m_darknetConfig;
}

/**
* @brief Load the default configuration, if the config file is modified by the user this is not called.
*/
void Config::loadDefault()
{
m_appConfig->setValue(AppConfig::Key::OUTPUT_FOLDER, QDir::homePath());
Expand Down
20 changes: 20 additions & 0 deletions steno/src/model/media/media.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Media::Media(std::shared_ptr<Config> config)
initRecorder();
}

/**
* @brief Tell the camera where to render the camera images.
* @param [IN] view
*/
void Media::setViewFinder(QCameraViewfinder* view)
{
if (!m_camera.isNull())
Expand All @@ -26,21 +30,34 @@ void Media::setViewFinder(QCameraViewfinder* view)
}
}

/**
* @brief Start the recording of the audio and video stream.
*/
void Media::startRecorder()
{
m_mediaRecorder->record();
}

/**
* @brief Stop the recording of the audio and video stream.
*/
void Media::stopRecorder()
{
m_mediaRecorder->stop();
}

/**
* @brief Media::recorderState
* @return the current state of the Qt recording object.
*/
QMediaRecorder::State Media::recorderState() const
{
return m_mediaRecorder->state();
}

/**
* @brief Initialize the camera to record based on the desired camera in the config file.
*/
void Media::initCamera()
{
auto deviceName = m_videoConfig->value(VideoConfig::Key::DEVICE_NAME).toString();
Expand All @@ -54,6 +71,9 @@ void Media::initCamera()
}
}

/**
* Initialization of the Qt recording object (Codecs, qualities, etc.)
*/
void Media::initRecorder()
{
m_mediaRecorder.reset(new QMediaRecorder(m_camera.get()));
Expand Down
12 changes: 12 additions & 0 deletions steno/src/model/media_player/media_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ int MediaPlayer::volume() const
return m_mediaPlayer.volume();
}

/**
* @brief Set the current media file to play.
* @param [IN] url - Path to the file to play.
*/
void MediaPlayer::setMedia(const QUrl &url)
{
m_mediaPlayer.setMedia(url);
Expand Down Expand Up @@ -63,12 +67,20 @@ void MediaPlayer::play()
}
}

/**
* @brief Set the current position in time of the media file.
* @param [IN] position
*/
void MediaPlayer::setPosition(int position)
{
m_mediaPlayer.setPosition(position);
m_subtitles.setCurrentTime(position);
}

/**
* @brief what to do when the QMediaPlayer state changed
* @param [IN] state
*/
void MediaPlayer::onStateChanged(QMediaPlayer::State state)
{
if (state == QMediaPlayer::State::StoppedState)
Expand Down
5 changes: 5 additions & 0 deletions steno/src/model/media_player/subtitles/srt_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

namespace Model
{
/**
* @brief Parse a srt file and extract the subtitles.
* @param [IN] path - absolute path to the file to parse.
* @return Vector of subtitles.
*/
std::vector<SubtitleItem> SrtFile::parse(const QString& path)
{
std::vector<SubtitleItem> subtitles;
Expand Down
39 changes: 39 additions & 0 deletions steno/src/model/media_player/subtitles/subtitles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,18 @@ Subtitles::Subtitles(QObject *parent)
connect(&m_timer, &QTimer::timeout, [=] { onTimerTimeout(); });
}

/**
* @brief Open a SRT file and parse the content.
* @param [IN] srtFilePath - SRT file to open.
*/
void Subtitles::open(const QString &srtFilePath)
{
m_subtitles = SrtFile::parse(srtFilePath);
}

/**
* @brief Start the substitle engine based on the timestamps.
*/
void Subtitles::play()
{
if (!m_subtitles.empty())
Expand All @@ -34,6 +41,9 @@ void Subtitles::play()
}
}

/**
* @brief Pause the subtitles engine.
*/
void Subtitles::pause()
{
if (!m_subtitles.empty())
Expand All @@ -42,6 +52,9 @@ void Subtitles::pause()
}
}

/**
* @brief Stop the subtitles engine.
*/
void Subtitles::stop()
{
if (!m_subtitles.empty())
Expand All @@ -51,6 +64,10 @@ void Subtitles::stop()
}
}

/**
* @brief change the timer value.
* @param [IN] time - value to set.
*/
void Subtitles::setCurrentTime(qint64 time)
{
if (!m_subtitles.empty())
Expand All @@ -65,6 +82,9 @@ void Subtitles::setCurrentTime(qint64 time)
}
}

/**
* @brief What to do when the timer is finished.
*/
void Subtitles::onTimerTimeout()
{
m_currentTime += m_timerInterval;
Expand All @@ -76,6 +96,9 @@ void Subtitles::onTimerTimeout()
}
}

/**
* @brief Reset subtitles engine.
*/
void Subtitles::reset()
{
m_subtitles.clear();
Expand All @@ -85,6 +108,12 @@ void Subtitles::reset()
subtitleChanged(QString());
}

/**
* @brief Get the current subtile
* @param [IN] time
* @param [IN] manual
* @return
*/
QString Subtitles::currentSubtitle(qint64 time, bool manual)
{
QString subtitle = "";
Expand All @@ -106,6 +135,11 @@ QString Subtitles::currentSubtitle(qint64 time, bool manual)
return subtitle;
}

/**
* @brief Search algorithm for a specific subtitle.
* @param [IN] time
* @param [OUT] subtitle
*/
void Subtitles::linearSearch(qint64 time, QString &subtitle)
{
for (quint64 i = m_lastSubtitleIndex, len = m_subtitles.size(); i < len; i++)
Expand All @@ -120,6 +154,11 @@ void Subtitles::linearSearch(qint64 time, QString &subtitle)
}
}

/**
* @brief Search algorithm for a specific subtitle faster than linearSearch.
* @param [IN] time
* @param [OUT] subtitle
*/
void Subtitles::binarySearch(qint64 time, QString &subtitle)
{
quint64 lo = 0, hi = m_subtitles.size() - 1;
Expand Down
5 changes: 4 additions & 1 deletion steno/src/model/stream/media_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ MediaThread::MediaThread(std::unique_ptr<IAudioSource> audioSource, std::unique_
}
}

/**
* @brief Managing odas threads for audio and localization + camera and images processing.
*/
void MediaThread::run()
{
// Utilitary objects
Expand Down Expand Up @@ -202,7 +205,7 @@ void MediaThread::run()
}

int readCount = videoStabilizer.getLastFrameTimeMs() / (chunkDurationMs / 2) + 1;

AudioChunk audioChunk;
while (audioSource_->readAudioChunk(audioChunk) && readCount > 0)
{
Expand Down
9 changes: 9 additions & 0 deletions steno/src/model/stream/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ Stream::~Stream()
m_objectFactory->deallocateObjectLockTripleBuffer(*m_imageBuffer);
}

/**
* @brief Start children threads.
*/
void Stream::start()
{
if (m_state == IStream::State::Stopped)
Expand All @@ -115,6 +118,9 @@ void Stream::start()
}
}

/**
* @brief Stop children threads.
*/
void Stream::stop()
{
updateState(IStream::State::Stopping);
Expand Down Expand Up @@ -142,6 +148,9 @@ void Stream::updateState(const IStream::State& state)
emit stateChanged(m_state);
}

/**
* @brief What to do when a child thread crash.
*/
void Stream::updateObserver()
{
OdasClientState state = m_odasClient->getState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

namespace Model
{
/**
* @brief Initialize the v4l2loopback device with the default image.
* @param [IN] - deviceName
*/
void DefaultVirtualCameraOutput::writeDefaultImage(const QString& deviceName)
{
QProcess process;
Expand Down
9 changes: 9 additions & 0 deletions steno/src/view/components/side_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ SideBar::SideBar(QWidget* parent)

connect(m_ui->list, &QListWidget::currentRowChanged, [=](int index) { emit currentRowChanged(index); });
}
/**
* @brief Add an item to the sidebar menu.
* @param [IN] name
* @param [IN] icon
*/
void SideBar::add(const QString& name, const QIcon& icon)
{
auto sideBarItem = new SideBarItem(name, icon, this);
Expand All @@ -40,6 +45,10 @@ void SideBar::add(const QString& name, const QIcon& icon)
listWidgetItem->setSizeHint(m_itemSize);
}

/**
* @brief Change the current selected item in the sidebar menu.
* @param row
*/
void SideBar::setCurrentRow(int row)
{
m_ui->list->setCurrentRow(row);
Expand Down
Loading

0 comments on commit 0f84350

Please sign in to comment.