From 0c8261bf2f90179b4d025089c89e244de75d6b43 Mon Sep 17 00:00:00 2001
From: Thulinma <jaron@vietors.com>
Date: Mon, 15 Feb 2021 15:13:10 +0100
Subject: [PATCH] Added timeoffset URL param to RTMP push input, for pushing
 with forced time offset

---
 src/output/output_rtmp.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/output/output_rtmp.cpp b/src/output/output_rtmp.cpp
index 3bd590f9..972dd8be 100644
--- a/src/output/output_rtmp.cpp
+++ b/src/output/output_rtmp.cpp
@@ -1407,12 +1407,16 @@ namespace Mist{
         F.toMeta(meta, *amf_storage, reTrackToID[reTrack], targetParams);
         if (F.getDataLen() && !(F.needsInitData() && F.isInitData())){
           uint64_t tagTime = next.timestamp;
+          uint64_t timeOffset = 0;
+          if (targetParams.count("timeoffset")){
+            timeOffset = JSON::Value(targetParams["timeoffset"]).asInt();
+          }
           if (!M.getBootMsOffset()){
             meta.setBootMsOffset(Util::bootMS() - tagTime);
-            rtmpOffset = 0;
+            rtmpOffset = timeOffset;
             setRtmpOffset = true;
           }else if (!setRtmpOffset){
-            rtmpOffset = (Util::bootMS() - tagTime) - M.getBootMsOffset();
+            rtmpOffset = (Util::bootMS() - tagTime) - M.getBootMsOffset() + timeOffset;
             setRtmpOffset = true;
           }
           tagTime += rtmpOffset;