From ccb2ce7f557e31412a959d29280ed7a6fd74fec3 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Wed, 9 Oct 2019 16:41:36 +0300
Subject: [PATCH] WIP File format changes to codec

---
 components/codecs/include/ftl/codecs/bitrates.hpp | 11 ++++++++++-
 components/codecs/include/ftl/codecs/packet.hpp   | 12 ++++++++++--
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/components/codecs/include/ftl/codecs/bitrates.hpp b/components/codecs/include/ftl/codecs/bitrates.hpp
index 19572daa5..6c66aeec6 100644
--- a/components/codecs/include/ftl/codecs/bitrates.hpp
+++ b/components/codecs/include/ftl/codecs/bitrates.hpp
@@ -14,7 +14,14 @@ enum struct codec_t : uint8_t {
 	JPG = 0,
 	PNG,
     H264,
-    HEVC  // H265
+    HEVC,  // H265
+
+	// TODO: Add audio codecs
+
+	JSON = 100,		// A JSON string
+	CALIBRATION,	// Camera parameters object
+	POSE,			// 4x4 eigen matrix
+	RAW				// Some unknown binary format (msgpack?)
 };
 
 /**
@@ -29,6 +36,8 @@ enum struct definition_t : uint8_t {
 	SD480 = 5,
 	LD360 = 6,
 	Any = 7
+
+	// TODO: Add audio definitions
 };
 
 /**
diff --git a/components/codecs/include/ftl/codecs/packet.hpp b/components/codecs/include/ftl/codecs/packet.hpp
index 98e46a601..bca68530a 100644
--- a/components/codecs/include/ftl/codecs/packet.hpp
+++ b/components/codecs/include/ftl/codecs/packet.hpp
@@ -10,6 +10,12 @@
 namespace ftl {
 namespace codecs {
 
+
+struct Header {
+	const char magic[4] = {'F','T','L','F'};
+	uint8_t version;
+};
+
 /**
  * A single network packet for the compressed video stream. It includes the raw
  * data along with any block metadata required to reconstruct. The underlying
@@ -21,9 +27,10 @@ struct Packet {
 	ftl::codecs::definition_t definition;
 	uint8_t block_total;	// Packets expected per frame
 	uint8_t block_number; 	// This packets number within a frame
+	uint8_t flags;			// Codec dependent flags
 	std::vector<uint8_t> data;
 
-	MSGPACK_DEFINE(codec, definition, block_total, block_number, data);
+	MSGPACK_DEFINE(codec, definition, block_total, block_number, flags, data);
 };
 
 /**
@@ -33,9 +40,10 @@ struct Packet {
  */
 struct StreamPacket {
 	int64_t timestamp;
+	uint8_t streamID;  // Source number...
 	uint8_t channel;  // first bit = channel, second bit indicates second channel being sent
 
-	MSGPACK_DEFINE(timestamp, channel);
+	MSGPACK_DEFINE(timestamp, streamID, channel);
 };
 
 }
-- 
GitLab