|
1 | 1 | #include "stream_outlet_impl.h" |
| 2 | +#include "api_config.h" |
2 | 3 | #include "tcp_server.h" |
3 | 4 | #include "udp_server.h" |
4 | 5 | #include <memory> |
5 | 6 | #include <sstream> |
6 | 7 |
|
7 | | -using namespace lsl; |
8 | 8 | using namespace lslboost::asio; |
9 | 9 |
|
| 10 | +namespace lsl { |
| 11 | + |
10 | 12 | stream_outlet_impl::stream_outlet_impl( |
11 | 13 | const stream_info_impl &info, int chunk_size, int max_capacity) |
12 | 14 | : sample_factory_(std::make_shared<factory>(info.channel_format(), info.channel_count(), |
@@ -135,8 +137,35 @@ stream_outlet_impl::~stream_outlet_impl() { |
135 | 137 | } catch (...) { LOG_F(ERROR, "Severe error during stream outlet shutdown."); } |
136 | 138 | } |
137 | 139 |
|
| 140 | +void stream_outlet_impl::push_numeric_raw(const void *data, double timestamp, bool pushthrough) { |
| 141 | + if (lsl::api_config::get_instance()->force_default_timestamps()) timestamp = 0.0; |
| 142 | + sample_p smp( |
| 143 | + sample_factory_->new_sample(timestamp == 0.0 ? lsl_clock() : timestamp, pushthrough)); |
| 144 | + smp->assign_untyped(data); |
| 145 | + send_buffer_->push_sample(smp); |
| 146 | +} |
| 147 | + |
138 | 148 | bool stream_outlet_impl::have_consumers() { return send_buffer_->have_consumers(); } |
139 | 149 |
|
140 | 150 | bool stream_outlet_impl::wait_for_consumers(double timeout) { |
141 | 151 | return send_buffer_->wait_for_consumers(timeout); |
142 | 152 | } |
| 153 | + |
| 154 | +template <class T> |
| 155 | +void stream_outlet_impl::enqueue(const T *data, double timestamp, bool pushthrough) { |
| 156 | + if (lsl::api_config::get_instance()->force_default_timestamps()) timestamp = 0.0; |
| 157 | + sample_p smp( |
| 158 | + sample_factory_->new_sample(timestamp == 0.0 ? lsl_clock() : timestamp, pushthrough)); |
| 159 | + smp->assign_typed(data); |
| 160 | + send_buffer_->push_sample(smp); |
| 161 | +} |
| 162 | + |
| 163 | +template void stream_outlet_impl::enqueue<char>(const char *data, double, bool); |
| 164 | +template void stream_outlet_impl::enqueue<int16_t>(const int16_t *data, double, bool); |
| 165 | +template void stream_outlet_impl::enqueue<int32_t>(const int32_t *data, double, bool); |
| 166 | +template void stream_outlet_impl::enqueue<int64_t>(const int64_t *data, double, bool); |
| 167 | +template void stream_outlet_impl::enqueue<float>(const float *data, double, bool); |
| 168 | +template void stream_outlet_impl::enqueue<double>(const double *data, double, bool); |
| 169 | +template void stream_outlet_impl::enqueue<std::string>(const std::string *data, double, bool); |
| 170 | + |
| 171 | +} // namespace lsl |
0 commit comments