From a645dcc00449949e2e0ccb17d3683a07f14e8d88 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Thu, 30 Jan 2020 15:28:55 +0200
Subject: [PATCH] Allow stream frameset id

---
 components/streams/include/ftl/streams/stream.hpp | 2 +-
 components/streams/src/receiver.cpp               | 1 +
 components/streams/src/stream.cpp                 | 6 +++---
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/components/streams/include/ftl/streams/stream.hpp b/components/streams/include/ftl/streams/stream.hpp
index 04adcf4e8..c90b5ce4f 100644
--- a/components/streams/include/ftl/streams/stream.hpp
+++ b/components/streams/include/ftl/streams/stream.hpp
@@ -112,7 +112,7 @@ class Muxer : public Stream {
 	explicit Muxer(nlohmann::json &config);
 	virtual ~Muxer();
 
-	void add(Stream *);
+	void add(Stream *, int fsid=0);
 
 	bool onPacket(const StreamCallback &) override;
 
diff --git a/components/streams/src/receiver.cpp b/components/streams/src/receiver.cpp
index 37e6467f0..161188e9c 100644
--- a/components/streams/src/receiver.cpp
+++ b/components/streams/src/receiver.cpp
@@ -310,6 +310,7 @@ void Receiver::setStream(ftl::stream::Stream *s) {
 		//LOG(INFO) << "PACKET: " << spkt.timestamp << ", " << (int)spkt.channel << ", " << (int)pkt.codec << ", " << (int)pkt.definition;
 
 		// TODO: Allow for multiple framesets
+		if (spkt.frameSetID() > 0) LOG(INFO) << "Frameset " << spkt.frameSetID() << " received";
 		if (spkt.frameSetID() > 0) return;
 
 		// Too many frames, so ignore.
diff --git a/components/streams/src/stream.cpp b/components/streams/src/stream.cpp
index 2710dfdd2..8175a9a30 100644
--- a/components/streams/src/stream.cpp
+++ b/components/streams/src/stream.cpp
@@ -49,18 +49,18 @@ Muxer::~Muxer() {
 }
 
 
-void Muxer::add(Stream *s) {
+void Muxer::add(Stream *s, int fsid) {
 	UNIQUE_LOCK(mutex_,lk);
 
 	auto &se = streams_.emplace_back();
 	int i = streams_.size()-1;
 	se.stream = s;
 
-	s->onPacket([this,s,i](const ftl::codecs::StreamPacket &spkt, const ftl::codecs::Packet &pkt) {
+	s->onPacket([this,s,i,fsid](const ftl::codecs::StreamPacket &spkt, const ftl::codecs::Packet &pkt) {
 		//SHARED_LOCK(mutex_, lk);
 	
 		ftl::codecs::StreamPacket spkt2 = spkt;
-		spkt2.streamID = 0;
+		spkt2.streamID = fsid;
 
 		if (spkt2.frame_number < 255) {
 			int id = _lookup(i, spkt.frame_number);
-- 
GitLab