Using KlvStreamer SDK

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();
Activate Streamer's license with your license file and key. Use 'KlvStreamer' as application name.
m_Streamer.Activate("KlvStreamer", @"C:\Streamer\LicenseStr.lic", @"AD3E42A8-4F54DB47-46D37457-85ADB574");
We can set Id for the session (can be passed as an argument to the constructor) if there is a need for multi-instance streaming.
Some additional properties and events can be also set.
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:

  • CBR
  • VBR

In CBR mode files are transmitted with constant bitrate that either calculated at the beginning or provided as a 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 continues 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 a desired operation mode.

m_Streamer.SetMode(STREAMING_MODE.VBR);
Add files that should be streamed out and a Network target (NIC, ip and port).
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);
We're ready to go. Initialize the streamer and start streaming....
// 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);
In order to get a current position in the playlist, use Position.TotalSeconds property.
double val = m_Streamer.Position.TotalSeconds;
Random access functionality can be achieved using Seek method.
m_Streamer.Seek(TimeSpan.FromSeconds(25));
That's it, in this article, we showed how to easily stream STANAG files over the IP network.
More info on the KlvStreamer SDK here.

 

No Comments

Post a Comment