From e72a156625f2692d23d9dda84d3e96d3a01f050e Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Fri, 11 Oct 2019 14:02:56 +0300 Subject: [PATCH] Send I-frames for channel 2 also --- applications/player/src/main.cpp | 9 ++++++--- components/rgbd-sources/src/streamer.cpp | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/applications/player/src/main.cpp b/applications/player/src/main.cpp index 896aac5ae..8d96c54ad 100644 --- a/applications/player/src/main.cpp +++ b/applications/player/src/main.cpp @@ -42,9 +42,10 @@ int main(int argc, char **argv) { LOG(INFO) << "Playing..."; int current_stream = 0; + int current_channel = 0; - bool res = r.read(90000000000000, [¤t_stream,&r](const ftl::codecs::StreamPacket &spkt, const ftl::codecs::Packet &pkt) { - if (spkt.channel & 0x1 > 0) return; + bool res = r.read(90000000000000, [¤t_stream,¤t_channel,&r](const ftl::codecs::StreamPacket &spkt, const ftl::codecs::Packet &pkt) { + if (spkt.channel != current_channel) return; if (spkt.streamID == current_stream) { if (pkt.codec == codec_t::POSE) { @@ -61,7 +62,7 @@ int main(int argc, char **argv) { LOG(INFO) << "Reading packet: (" << (int)spkt.streamID << "," << (int)spkt.channel << ") " << (int)pkt.codec << ", " << (int)pkt.definition; - cv::Mat frame(cv::Size(ftl::codecs::getWidth(pkt.definition),ftl::codecs::getHeight(pkt.definition)), CV_8UC3); + cv::Mat frame(cv::Size(ftl::codecs::getWidth(pkt.definition),ftl::codecs::getHeight(pkt.definition)), (spkt.channel == 1) ? CV_32F : CV_8UC3); createDecoder(pkt); try { @@ -78,6 +79,8 @@ int main(int argc, char **argv) { int key = cv::waitKey(20); if (key >= 48 && key <= 57) { current_stream = key - 48; + } else if (key == 'd') { + current_channel = (current_channel == 0) ? 1 : 0; } else if (key == 27) { r.end(); } diff --git a/components/rgbd-sources/src/streamer.cpp b/components/rgbd-sources/src/streamer.cpp index 462d49946..40cd7d710 100644 --- a/components/rgbd-sources/src/streamer.cpp +++ b/components/rgbd-sources/src/streamer.cpp @@ -424,6 +424,7 @@ void Streamer::_process(ftl::rgbd::FrameSet &fs) { // Receiver only waits for channel 1 by default // TODO: Each encode could be done in own thread if (hasChan2) { + if (fs.timestamp % (10*ftl::timer::getInterval()) == 0) enc2->reset(); enc2->encode(fs.frames[j].get<cv::Mat>(fs.sources[j]->getChannel()), src->hq_bitrate, [this,src,hasChan2](const ftl::codecs::Packet &blk){ _transmitPacket(src, blk, 1, hasChan2, Quality::High); }); -- GitLab