diff --git a/applications/ftl2mkv/src/main.cpp b/applications/ftl2mkv/src/main.cpp index 0ebf1a0bfdecd03e1696b3c688744dc761f92862..b7898646430099b1825c01cd543deda5660d150c 100644 --- a/applications/ftl2mkv/src/main.cpp +++ b/applications/ftl2mkv/src/main.cpp @@ -17,7 +17,7 @@ extern "C" { using ftl::codecs::codec_t; using ftl::codecs::Channel; -static AVStream *add_video_stream(AVFormatContext *oc, const ftl::codecs::Packet &pkt) +static AVStream *add_video_stream(AVFormatContext *oc, const ftl::codecs::Packet &pkt, const ftl::rgbd::Camera &cam) { //AVCodecContext *c; AVStream *st; @@ -47,9 +47,9 @@ static AVStream *add_video_stream(AVFormatContext *oc, const ftl::codecs::Packet //st->nb_frames = 0; st->codecpar->codec_id = codec_id; st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; - st->codecpar->width = ftl::codecs::getWidth(pkt.definition); + st->codecpar->width = cam.width; //ftl::codecs::getWidth(pkt.definition); //if (pkt.flags & ftl::codecs::kFlagStereo) st->codecpar->width *= 2; - st->codecpar->height = ftl::codecs::getHeight(pkt.definition); + st->codecpar->height = cam.height; //ftl::codecs::getHeight(pkt.definition); st->codecpar->format = AV_PIX_FMT_NV12; st->codecpar->bit_rate = 4000000; @@ -149,6 +149,11 @@ int main(int argc, char **argv) { // TODO: In future, find a better way to discover number of streams... // Read entire file to find all streams before reading again to write data bool res = r.read(90000000000000, [&first_ts,¤t_stream,¤t_channel,&r,&video_st,oc](const ftl::codecs::StreamPacket &spkt, const ftl::codecs::Packet &pkt) { + // Extract calibration information to determine frame resolution + if (spkt.channel == ftl::codecs::Channel::Calibration) { + // FIXME: Implement this!! + } + if (spkt.channel != static_cast<ftl::codecs::Channel>(current_channel) && current_channel != -1) return; if (spkt.frame_number == current_stream || current_stream == 255) { @@ -161,7 +166,7 @@ int main(int argc, char **argv) { if (spkt.timestamp < first_ts) first_ts = spkt.timestamp; if (video_st[spkt.frame_number][(spkt.channel == Channel::Left) ? 0 : 1] == nullptr) { - video_st[spkt.frame_number][(spkt.channel == Channel::Left) ? 0 : 1] = add_video_stream(oc, pkt); + video_st[spkt.frame_number][(spkt.channel == Channel::Left) ? 0 : 1] = add_video_stream(oc, pkt, {0}); // FIXME: Use real calib data } } }); diff --git a/components/codecs/include/ftl/codecs/packet.hpp b/components/codecs/include/ftl/codecs/packet.hpp index 97bda6e826a52627e546f4537df6df30e12818d9..f9aea4ca6db5e4349fde498261e54087b5d4b9fc 100644 --- a/components/codecs/include/ftl/codecs/packet.hpp +++ b/components/codecs/include/ftl/codecs/packet.hpp @@ -36,12 +36,7 @@ struct IndexHeader { */ struct Packet { ftl::codecs::codec_t codec; - - union { - [[deprecated]] ftl::codecs::definition_t definition; // Data resolution - uint8_t reserved=7; - }; - + uint8_t reserved=0; uint8_t frame_count; // v4+ Frames included in this packet uint8_t bitrate=0; // v4+ For multi-bitrate encoding, 0=highest uint8_t flags; // Codec dependent flags (eg. I-Frame or P-Frame) @@ -62,12 +57,7 @@ struct StreamPacket { int64_t timestamp; uint8_t streamID; // Source number [or v4 frameset id] - - union { - [[deprecated]] uint8_t channel_count; // v1-3 Number of channels to expect for this frame(set) to complete (usually 1 or 2) - uint8_t frame_number; // v4+ First frame number (packet may include multiple frames) - }; - + uint8_t frame_number; // v4+ First frame number (packet may include multiple frames) ftl::codecs::Channel channel; // Actual channel of this current set of packets inline int frameNumber() const { return (version >= 4) ? frame_number : streamID; } diff --git a/components/streams/src/builder.cpp b/components/streams/src/builder.cpp index a52b7e6c03965cbb5ca7ca66c6edf4508f6c07c2..8d2e60f8bea38a7d1cb318ba8bb1b21974d7d3cf 100644 --- a/components/streams/src/builder.cpp +++ b/components/streams/src/builder.cpp @@ -220,7 +220,6 @@ LockedFrameSet ForeignBuilder::get(int64_t timestamp) { auto fs = _get(timestamp); LockedFrameSet lfs(fs.get(), fs->smtx, [this,fs](ftl::data::FrameSet *d) { - // TODO: schedule completed if (fs->isComplete()) { if (bufferSize_ == 0 && !fs->test(ftl::data::FSFlag::STALE)) { UNIQUE_LOCK(mutex_, lk); diff --git a/components/streams/src/netstream.cpp b/components/streams/src/netstream.cpp index 8d08d4ecd2c9011075a764459afe2b8228982f43..e871df7ecff569fe89f1cdb25e053efa38204eca 100644 --- a/components/streams/src/netstream.cpp +++ b/components/streams/src/netstream.cpp @@ -291,7 +291,7 @@ bool Net::_sendRequest(Channel c, uint8_t frameset, uint8_t frames, uint8_t coun Packet pkt = { codec_t::Any, // TODO: Allow specific codec requests - definition_t::Any, // TODO: Allow specific definition requests + 0, count, bitrate, ftl::codecs::kFlagRequest diff --git a/components/streams/test/filestream_unit.cpp b/components/streams/test/filestream_unit.cpp index 35cc4a09df0d2c2f577ef648958735f86b021783..ec05be42f71814e7c1692e9c2d1d2826d619ea46 100644 --- a/components/streams/test/filestream_unit.cpp +++ b/components/streams/test/filestream_unit.cpp @@ -30,7 +30,7 @@ TEST_CASE("ftl::stream::File write and read", "[stream]") { REQUIRE( writer->begin() ); - REQUIRE( writer->post({4,ftl::timer::get_time(),2,1,ftl::codecs::Channel::Confidence},{ftl::codecs::codec_t::Any, ftl::codecs::definition_t::Any, 0, 0, 0, {'f'}}) ); + REQUIRE( writer->post({4,ftl::timer::get_time(),2,1,ftl::codecs::Channel::Confidence},{ftl::codecs::codec_t::Any, 0, 0, 0, 0, {'f'}}) ); writer->end(); @@ -56,9 +56,9 @@ TEST_CASE("ftl::stream::File write and read", "[stream]") { REQUIRE( writer->begin() ); - REQUIRE( writer->post({4,0,0,1,ftl::codecs::Channel::Confidence},{ftl::codecs::codec_t::Any, ftl::codecs::definition_t::Any, 0, 0, 0, {'f'}}) ); - REQUIRE( writer->post({4,0,1,1,ftl::codecs::Channel::Depth},{ftl::codecs::codec_t::Any, ftl::codecs::definition_t::Any, 0, 0, 0, {'f'}}) ); - REQUIRE( writer->post({4,0,2,1,ftl::codecs::Channel::Screen},{ftl::codecs::codec_t::Any, ftl::codecs::definition_t::Any, 0, 0, 0, {'f'}}) ); + REQUIRE( writer->post({4,0,0,1,ftl::codecs::Channel::Confidence},{ftl::codecs::codec_t::Any, 0, 0, 0, 0, {'f'}}) ); + REQUIRE( writer->post({4,0,1,1,ftl::codecs::Channel::Depth},{ftl::codecs::codec_t::Any, 0, 0, 0, 0, {'f'}}) ); + REQUIRE( writer->post({4,0,2,1,ftl::codecs::Channel::Screen},{ftl::codecs::codec_t::Any, 0, 0, 0, 0, {'f'}}) ); writer->end(); @@ -88,9 +88,9 @@ TEST_CASE("ftl::stream::File write and read", "[stream]") { REQUIRE( writer->begin() ); auto time = ftl::timer::get_time(); - REQUIRE( writer->post({4,time,0,1,ftl::codecs::Channel::Confidence},{ftl::codecs::codec_t::Any, ftl::codecs::definition_t::Any, 0, 0, 0, {'f'}}) ); - REQUIRE( writer->post({4,time+ftl::timer::getInterval(),0,1,ftl::codecs::Channel::Depth},{ftl::codecs::codec_t::Any, ftl::codecs::definition_t::Any, 0, 0, 0, {'f'}}) ); - REQUIRE( writer->post({4,time+2*ftl::timer::getInterval(),0,1,ftl::codecs::Channel::Screen},{ftl::codecs::codec_t::Any, ftl::codecs::definition_t::Any, 0, 0, 0, {'f'}}) ); + REQUIRE( writer->post({4,time,0,1,ftl::codecs::Channel::Confidence},{ftl::codecs::codec_t::Any, 0, 0, 0, 0, {'f'}}) ); + REQUIRE( writer->post({4,time+ftl::timer::getInterval(),0,1,ftl::codecs::Channel::Depth},{ftl::codecs::codec_t::Any, 0, 0, 0, 0, {'f'}}) ); + REQUIRE( writer->post({4,time+2*ftl::timer::getInterval(),0,1,ftl::codecs::Channel::Screen},{ftl::codecs::codec_t::Any, 0, 0, 0, 0, {'f'}}) ); writer->end(); diff --git a/components/streams/test/sender_unit.cpp b/components/streams/test/sender_unit.cpp index 2da7a52e5c0d8f370f26990e1f38f01959372a91..0564992d02b31116084eaf8d2ba5f1b417d86ea7 100644 --- a/components/streams/test/sender_unit.cpp +++ b/components/streams/test/sender_unit.cpp @@ -287,7 +287,7 @@ TEST_CASE( "Sender request to control encoding" ) { stream.post({ 4, 1000, 0, 255, Channel::Colour },{ - codec_t::Any, definition_t::Any, 255, 255, 0, {} + codec_t::Any, 0, 255, 255, 0, {} }); fs.count = 1;