Skip to content
Snippets Groups Projects
Commit dd2fd919 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Send and receive data channels

parent 022863c1
No related branches found
No related tags found
1 merge request!219Add data channels to frames
Pipeline #18437 passed
This commit is part of merge request !219. Comments created here will be created in the context of that merge request.
...@@ -83,6 +83,12 @@ SourceWindow::SourceWindow(ftl::gui::Screen *screen) ...@@ -83,6 +83,12 @@ SourceWindow::SourceWindow(ftl::gui::Screen *screen)
// Request the channels required by current camera configuration // Request the channels required by current camera configuration
interceptor_->select(fs.id, _aggregateChannels()); interceptor_->select(fs.id, _aggregateChannels());
/*if (fs.frames[0].hasChannel(Channel::Data)) {
int data = 0;
fs.frames[0].get(Channel::Data, data);
LOG(INFO) << "GOT DATA : " << data;
}*/
const auto *cstream = interceptor_; const auto *cstream = interceptor_;
_createDefaultCameras(fs, cstream->available(fs.id).has(Channel::Depth)); _createDefaultCameras(fs, cstream->available(fs.id).has(Channel::Depth));
......
...@@ -188,6 +188,7 @@ static void run(ftl::Configurable *root) { ...@@ -188,6 +188,7 @@ static void run(ftl::Configurable *root) {
reconstr->setGenerator(gen); reconstr->setGenerator(gen);
reconstr->onFrameSet([sender,i](ftl::rgbd::FrameSet &fs) { reconstr->onFrameSet([sender,i](ftl::rgbd::FrameSet &fs) {
fs.id = i; fs.id = i;
//fs.frames[0].create(Channel::Data, 44);
sender->post(fs); sender->post(fs);
return true; return true;
}); });
......
...@@ -284,6 +284,9 @@ public: ...@@ -284,6 +284,9 @@ public:
* Obtain a mask of all available channels in the frame. * Obtain a mask of all available channels in the frame.
*/ */
inline ftl::codecs::Channels<0> getChannels() const { return channels_; } inline ftl::codecs::Channels<0> getChannels() const { return channels_; }
inline ftl::codecs::Channels<0> getVideoChannels() const { return channels_; }
inline ftl::codecs::Channels<2048> getDataChannels() const { return data_channels_; }
/** /**
* Is the channel data currently located on GPU. This also returns false if * Is the channel data currently located on GPU. This also returns false if
...@@ -381,6 +384,13 @@ public: ...@@ -381,6 +384,13 @@ public:
*/ */
std::string getConfigString() const; std::string getConfigString() const;
/**
* Access the raw data channel vector object.
*/
const std::vector<unsigned char> &getRawData(ftl::codecs::Channel c) const;
void createRawData(ftl::codecs::Channel c, const std::vector<unsigned char> &v);
/** /**
* Wrapper to access a config property. If the property does not exist or * Wrapper to access a config property. If the property does not exist or
* is not of the requested type then the returned optional is false. * is not of the requested type then the returned optional is false.
......
...@@ -443,3 +443,15 @@ std::string ftl::rgbd::Frame::getConfigString() const { ...@@ -443,3 +443,15 @@ std::string ftl::rgbd::Frame::getConfigString() const {
return get<nlohmann::json>(ftl::codecs::Channel::Configuration).dump(); return get<nlohmann::json>(ftl::codecs::Channel::Configuration).dump();
} }
const std::vector<unsigned char> &ftl::rgbd::Frame::getRawData(ftl::codecs::Channel channel) const {
if (static_cast<int>(channel) < static_cast<int>(ftl::codecs::Channel::Data)) throw ftl::exception("Non data channel");
if (!hasChannel(channel)) throw ftl::exception("Data channel does not exist");
return data_data_.at(static_cast<int>(channel));
}
void ftl::rgbd::Frame::createRawData(ftl::codecs::Channel c, const std::vector<unsigned char> &v) {
data_data_.insert({static_cast<int>(c), v});
data_channels_ += c;
}
...@@ -103,7 +103,11 @@ void Receiver::setStream(ftl::stream::Stream *s) { ...@@ -103,7 +103,11 @@ void Receiver::setStream(ftl::stream::Stream *s) {
//return; //return;
//} //}
if (channum >= 64) { if (channum >= 2048) {
InternalStates &frame = _getFrame(spkt);
frame.frame.createRawData(spkt.channel, pkt.data);
return;
} else if (channum >= 64) {
for (int i=0; i<pkt.frame_count; ++i) { for (int i=0; i<pkt.frame_count; ++i) {
InternalStates &frame = _getFrame(spkt,i); InternalStates &frame = _getFrame(spkt,i);
......
...@@ -141,6 +141,25 @@ void Sender::post(const ftl::rgbd::FrameSet &fs) { ...@@ -141,6 +141,25 @@ void Sender::post(const ftl::rgbd::FrameSet &fs) {
available += c; available += c;
} }
} }
// FIXME: Allow data channel selection rather than always send
for (auto c : frame.getDataChannels()) {
StreamPacket spkt;
spkt.version = 4;
spkt.timestamp = fs.timestamp;
spkt.streamID = 0; //fs.id;
spkt.frame_number = i;
spkt.channel = c;
ftl::codecs::Packet pkt;
pkt.codec = ftl::codecs::codec_t::MSGPACK;
pkt.definition = ftl::codecs::definition_t::Any;
pkt.frame_count = 1;
pkt.flags = 0;
pkt.bitrate = 0;
pkt.data = frame.getRawData(c);
stream_->post(spkt, pkt);
}
} }
for (auto c : available) { for (auto c : available) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment