Medialooks Knowledge Base Support Center

Contact Us

SCTE-35 triggers

Triggers detection

MPlatform SDK

You can detect SCTE-35 triggers embed into local files, network streams or live feeds with MPlatform SDK. For detection, you should use OnEvent events. MFile and MPlaylist objects support a special event - "SCTE35". The event is raised the moment an SCTE-35 trigger has been received. As a parameter bsEventParam, the event has a parsed SCTE-35 message.

void m_objFile_OnEvent(string bsChannelID, string bsEventName, string bsEventParam, object pEventObject)         
{    
         if (bsEventName == "SCTE-35")    
         {
              string strSCTE35_Msg = bsEventParam;
              // manage a playback based on the information
         }         
}

In general, OnEvent and OnEventSafe events are not synchronous with the main object - they are raised in a separated thread to not affect playback. But in the case of SCTE-35 triggers, time is critical. So you should set the event to be synchronous. For this, you should set "on_event.sync" property to "true" via the system registry or with the PropsSet method.

For example, for MFile:

m_objFile.PropsSet("object::on_event.sync", "true");

MFormats SDK

With MFReader object you can detect SCTE-35 triggers by checking the data of a received MFFrame object with MFStrGet method:

MFFrame pFrame;
m_objMFReader.SourceFrameGetByNumber(_nFrameNumber, -1, out pFrame, "");    // Get next frame from file
string strTrigger;
pFrame.MFStrGet("SCTE-35", out strTrigger);
if (!string.IsNullOrEmpty(strTrigger))
{
    MessageBox.Show(strTrigger); // process the received data
}

You can use a frame-based approach in MPlatform SDK too. For this, you should use OnFrame or OnFrameSafe events:

private void M_objFile_OnFrameSafe(string bsChannelID, object pMFrame)
{
    string strTriggers;
    (pMFrame as IMFFrame).MFStrGet("SCTE-35", out strTriggers);
    if (!string.IsNullOrEmpty(strTriggers))
    {
        MessageBox.Show(strTriggers);
    }
}

Example of a trigger

<SpliceInfoSection protocolVersion='0' ptsAdjustment='3929533022' tier='4095'>
    <TimeSignal>
        <SpliceTime ptsTime='4668253151'/>
    </TimeSignal>
    <SegmentationDescriptor segmentationEventId='1' segmentationEventCancelIndicator='0' segmentationTypeId='1' segmentNum='1' segmentsExpected='1'>
        <SegmentationUpid segmentationUpidType='1'>000093551531446</SegmentationUpid>
    </SegmentationDescriptor>
</SpliceInfoSection>

Triggers insertion

You should enable embedding triggers data for MWriter or MFWriter objects. In the system registry it is:

MPlatform SDK

HKEY_CURRENT_USER\Software\Medialooks\MPlatform\MWriter\MWriterFFM
embed_scte = true

MFormats SDK

HKEY_CURRENT_USER\Software\Medialooks\MFormats\MFWriter
embed_scte = true

With PropsSet method for both SDKs:

(myWriter as IMProps).PropsSet("embed_scte", "true");

The insertion of triggers should be processed on a frame basis, so it is more MFormats-like style.

MPlatform SDK

To process frames, you should use OnFrame or OnFrameSafe events. And the events should be synchronous to update a frame on its pipeline:

m_objFile.PropsSet("object::on_frame.sync", "true");

Then within the OnFrame event, you should use MFStrSet method using the XML configuration of a trigger you need to insert. Let's use the example of a trigger from the above.

private void M_objFile_OnFrameSafe(string bsChannelID, object pMFrame)
{
    string strTriggers;
    (pMFrame as IMFFrame).MFStrSet("SCTE-35", strTriggers);
}

A modified frame will be encoded by MWriter object according to your encoding settings, e.g. UDP stream or TS file.

MFormats SDK

The same approach with MFStrSet method is correct for MFormats SDK:

myFrame.MFStrSet("SCTE-35", strTriggers);

Transcoding of triggers

If a source contains SCTE-35 triggers (MFReader or MFile, for instance) then the triggers will be encoded by default without any operations - just enable embedding the triggers with the "embed_scte" property.