In this article, I’ll show how to use a KlvStreamer SDK to re-stream a STANAG 4609 file over UDP,
KlvStreamerSDK is a .NET SDK used by KlvStreamer application for sending a STANAG / TS content over IP.
So, let's add a reference to the StreamerLib assembly and create a streamer instance.
using StreamerLib; var m_Streamer = new StreamingSession();
m_Streamer.Activate("KlvStreamer", @"C:\Streamer\LicenseStr.lic", @"AD3E42A8-4F54DB47-46D37457-85ADB574");
m_Streamer.Id = 0; m_Streamer.Loop = false; // or true // setup event to be fired when the streamer's internal state is changed. m_Streamer.SessionStatusChangedEvent += new SessionStatusChangeEventHandler(OnStreamerStateEvent); // setup event to be fired when the currently streaming segment is changed. m_Streamer.SessionSegmentChangedEvent += new SessionSegmentChangeEventHandler(OnStreamingSegmentChangedEvent); // setup event to be fired when error occurs. m_Streamer.SessionErrorEvent += new SessionErrorEventHandler(OnStreamerErrorEvent);
KlvStreamer can operate in two modes:
In CBR mode files are transmitted with a constant bitrate that is either calculated at the beginning or provided as an initialization parameter. During the streaming in CBR mode no parsing of the file is performed. VBR mode is suitable for VBR file steaming. This mode requires continuous file parsing in order to detect a proper streaming rate. This mode may be used for streaming CBR files as well. You can use a SetMode method in order to select the desired operation mode.
m_Streamer.Reset(); m_Streamer.AddSourceSegment(@"c:\Movie1.ts, TimeSpan.Zero, TimeSpan.Zero, 0); m_Streamer.AddSourceSegment(@"c:\Movie2.ts, TimeSpan.Zero, TimeSpan.Zero, 0); m_Streamer.AddTarget("172.16.106.2", "172.16.106.25", 1234, 1316);
// Initialize m_Streamer.Init(); // Start streaming m_Streamer.Start();
You can control a streaming rate by calling SetStreamingRate method
// Change streaming rate to x2 of real-time m_Streamer.SetStreamingRate(2.0);
double val = m_Streamer.Position.TotalSeconds;