2021-06-02 09:21:01 -04:00
|
|
|
/*
|
|
|
|
sender.cpp
|
|
|
|
|
|
|
|
Copyright (c) 2021 Kevin Matz (kevin.matz@gmail.com)
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
SOFTWARE.
|
|
|
|
*/
|
|
|
|
#include "source.h"
|
|
|
|
|
2021-08-28 09:01:33 -04:00
|
|
|
namespace sACN {
|
2021-06-02 09:21:01 -04:00
|
|
|
|
2021-06-20 09:35:56 -04:00
|
|
|
/**
|
|
|
|
* @brief Source::Source
|
|
|
|
* @param cid
|
|
|
|
*/
|
2021-06-02 09:21:01 -04:00
|
|
|
Source::Source(UUID::uuid cid)
|
2021-08-25 10:57:31 -04:00
|
|
|
: Component(cid)
|
2021-06-02 09:21:01 -04:00
|
|
|
{
|
2021-08-24 18:10:20 -04:00
|
|
|
fctn_ = "OpenLCP sACN Source";
|
2021-06-02 09:21:01 -04:00
|
|
|
}
|
|
|
|
|
2021-06-20 09:35:56 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Source::create
|
|
|
|
* @param num
|
|
|
|
*/
|
2021-06-20 09:12:14 -04:00
|
|
|
void Source::create(const uint16_t num)
|
2021-06-20 09:35:56 -04:00
|
|
|
{
|
2021-08-15 23:36:29 -04:00
|
|
|
if (universes_.count(num))
|
|
|
|
return;
|
|
|
|
universes_.emplace(num, new Universe());
|
|
|
|
|
2021-08-28 14:47:30 -04:00
|
|
|
auto metadata = std::shared_ptr<DATA::data_header>(new DATA::data_header());
|
|
|
|
metadata->source_name = this->name();
|
|
|
|
metadata->universe = num;
|
|
|
|
universes_[num]->setProvenance(metadata);
|
2021-06-20 09:35:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Source::terminate
|
|
|
|
* @param num
|
|
|
|
*/
|
|
|
|
void Source::terminate(const uint16_t num)
|
2021-06-20 09:12:14 -04:00
|
|
|
{
|
2021-08-15 23:36:29 -04:00
|
|
|
if (!universes_.count(num))
|
|
|
|
return;
|
2021-06-20 09:35:56 -04:00
|
|
|
|
2021-08-28 10:17:53 -04:00
|
|
|
auto metadata = universes_[num]->provenance();
|
2021-08-28 09:10:28 -04:00
|
|
|
auto options = DATA::data_options();
|
|
|
|
|
2021-08-28 10:17:53 -04:00
|
|
|
options.force_synchronization = metadata->options.force_synchronization;
|
|
|
|
options.preview_data = metadata->options.preview_data;
|
2021-08-28 09:10:28 -04:00
|
|
|
options.stream_terminated = true;
|
|
|
|
|
2021-08-28 10:17:53 -04:00
|
|
|
metadata->options = options;
|
2021-06-20 09:12:14 -04:00
|
|
|
}
|
|
|
|
|
2021-06-20 09:35:56 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Source::end
|
|
|
|
* @param num
|
|
|
|
*/
|
|
|
|
void Source::end(const uint16_t num)
|
|
|
|
{
|
2021-08-15 23:36:29 -04:00
|
|
|
if (!universes_.count(num))
|
|
|
|
return;
|
2021-06-20 09:35:56 -04:00
|
|
|
|
2021-08-15 23:36:29 -04:00
|
|
|
universes_.erase(num);
|
2021-06-20 09:12:14 -04:00
|
|
|
}
|
|
|
|
|
2021-06-20 09:35:56 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Source::universe
|
|
|
|
* @param num
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
Universe * Source::universe(const uint16_t num)
|
|
|
|
{
|
2021-08-15 23:36:29 -04:00
|
|
|
if (!universes_.count(num))
|
2021-08-22 12:04:30 -04:00
|
|
|
return nullptr;
|
2021-06-20 09:35:56 -04:00
|
|
|
|
2021-08-15 23:36:29 -04:00
|
|
|
return universes_.at(num);
|
2021-06-20 09:12:14 -04:00
|
|
|
}
|
|
|
|
|
2021-06-02 09:21:01 -04:00
|
|
|
} // SACN
|