Gets the caching filter object.
public object GetCacheObject(
TargetFormatObject ObjType
)
Public Function GetCacheObject( _
ByVal ObjType As TargetFormatObject _
) As Object
public:
Object^ GetCacheObject(
TargetFormatObject ObjType
)
ObjType
Value that indicates which caching object to retrieve. This must be one of the TargetFormatObject constants.
A System.Object of the type specified by the TargetFormatObject and represents the caching filter object.
Use the UseFilterCache property to get a value that indicates whether the toolkit is currently caching filters, or set a value that indicates whether to enable or disable the caching of filters. Use the ShowCacheDialog method to display a specific property dialog for the caching filter. Use the HasCacheDialog method to query whether the specified property dialog for the caching filter is available.
using Leadtools;
using Leadtools.Multimedia;
using LeadtoolsMultimediaExamples.Fixtures;
public bool _result = false;
public CaptureCtrlForm _form = new CaptureCtrlForm();
public LMMpg2MxTLib.LMMpg2MxT _pMpgMux;
// This example will show you the correct way to set up a muxer's properties during capture
// Normally, the muxer is added only after the capture graph has been build with ReadyCapture or StartCapture
// But at this point, the graph is in running mode, so some muxer operations might fail
// If you need to make changes to the muxer in stopped state (like adding KLV data stream, for example),
// then you need to change the muxer before the graph is fully built. You can do so by instructing the toolkit
// to cache the target filters by setting the TargetFormat.UseFilterCache property to true
// In this situation, the filters used to implement a certain target format are created and used whenever
// you set that target format.
//
// This example will show you how to add KLV data to a MPEG-2 Transport Stream in a capture situation.
public void UseFilterCacheExample()
{
// reference the capture control
CaptureCtrl capturectrl = _form.CaptureCtrl;
string outFile = Path.Combine(LEAD_VARS.MediaDir, "CaptureKLV.mpg");
try
{
// select the capture device
capturectrl.VideoDevices.Selection = 0; /* Use a different video device if you want */
/* capturectrl.Preview = true; -- enable this if you want */
/* set the video compressor (only if the capture device is not already capturing compressed video) */
capturectrl.VideoCompressors.Mpeg2.Selected = true;
// set the target output file
capturectrl.TargetFile = outFile;
// subscribe to the started event
capturectrl.Started += new System.EventHandler(this.CaptureCtrl_Started);
// just 10 seconds of capture time
capturectrl.TimeLimit = 10;
capturectrl.UseTimeLimit = true;
// subscribe to the complete event
capturectrl.Complete += new EventHandler(CaptureCtrl_Complete);
// IN a capture situation
//in order to get the mux in a capture situation, set the UseFilterCache property for the target format to TRUE
// This tells the toolkit to create a Mux object and keep it around when building or rebuilding graphs
capturectrl.TargetFormats[Leadtools.Multimedia.TargetFormatType.MPEG2Transport].UseFilterCache = true;
capturectrl.TargetFormat = Leadtools.Multimedia.TargetFormatType.MPEG2Transport;
_pMpgMux = (LMMpg2MxTLib.LMMpg2MxT)capturectrl.TargetFormats[Leadtools.Multimedia.TargetFormatType.MPEG2Transport].GetCacheObject(TargetFormatObject.Mux);
if (_pMpgMux != null)
{
_pMpgMux.PrivateDataPID = 0x70;
_pMpgMux.PrivateDataFormatID = 0x41564c4b;
_pMpgMux.EnablePrivateData = true;
}
// start capture
capturectrl.StartCapture(Leadtools.Multimedia.CaptureMode.Video);
_result = true;
}
catch (Exception)
{
_result = false;
}
}
private void WriteKLVData(LMMpg2MxTLib.LMMpg2MxT pMpgMux)
{
// get the current time since Jan 1, 1970
TimeSpan basetime = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0);
// get the number of microseconds since Jan 1, 1970
Int64 timestamp = (Int64)basetime.TotalSeconds * 1000000;
// do not really need to do this, since I am writing only one item
pMpgMux.KlvBuilder.Clear();
// write the UDS timestamp (number of microseconds since Jan 1, 1970)
pMpgMux.KlvBuilder.InsertUInt64(-1, "06 0E 2B 34 01 01 01 03 07 02 01 01 01 05 00 00", (ulong)timestamp);
// write one KLV data at the beginning
pMpgMux.WritePrivateData((int)LMMpg2MxTLib.Mpg2MxT_WriteFlags.Mpg2MxT_WriteFlag_PTSValid |
(int)LMMpg2MxTLib.Mpg2MxT_WriteFlags.Mpg2MxT_WriteFlag_PTSInSeconds,
0.0, pMpgMux.KlvBuilder.GetData(),
-1);
// close the stream
pMpgMux.ClosePrivateData();
}
private void CaptureCtrl_Started(object sender, EventArgs e)
{
WriteKLVData(_pMpgMux);
}
private void CaptureCtrl_Complete(object sender, EventArgs e)
{
// set result
_result = true;
}
static class LEAD_VARS
{
public const string MediaDir = @"C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 20\Media";
}
Imports Leadtools
Imports Leadtools.Multimedia
Imports LeadtoolsMultimediaExamples.Fixtures
Public _result As Boolean = False
Public _form As CaptureCtrlForm = New CaptureCtrlForm()
Public _pMpgMux As LMMpg2MxTLib.LMMpg2MxT
' This example will show you the correct way to set up a muxer's properties during capture
' Normally, the muxer is added only after the capture graph has been build with ReadyCapture or StartCapture
' But at this point, the graph is in running mode, so some muxer operations might fail
' If you need to make changes to the muxer in stopped state (like adding KLV data stream, for example),
' then you need to change the muxer before the graph is fully built. You can do so by instructing the toolkit
' to cache the target filters by setting the TargetFormat.UseFilterCache property to true
' In this situation, the filters used to implement a certain target format are created and used whenever
' you set that target format.
' This example will show you how to add KLV data to a MPEG-2 Transport Stream in a capture situation.
Public Sub UseFilterCacheExample()
' reference the capture control
Dim capturectrl As CaptureCtrl = _form.CaptureCtrl
Dim outFile As String = Path.Combine(LEAD_VARS.MediaDir, "CaptureKLV.mpg")
Try
' select the capture device
capturectrl.VideoDevices.Selection = 0 ' Use a different video device if you want
' capturectrl.Preview = true; -- enable this if you want
' set the video compressor (only if the capture device is not already capturing compressed video)
capturectrl.VideoCompressors.Mpeg2.Selected = True
' set the target output file
capturectrl.TargetFile = outFile
' subscribe to the compete event
AddHandler capturectrl.Started, AddressOf CaptureCtrl_Started
' just 10 seconds of capture time
capturectrl.TimeLimit = 10
capturectrl.UseTimeLimit = True
' subscribe to the compete event
AddHandler capturectrl.Complete, AddressOf CaptureCtrl_Complete
' IN a capture situation
'in order to get the mux in a capture situation, set the UseFilterCache property for the target format to TRUE
' This tells the toolkit to create a Mux object and keep it around when building or rebuilding graphs
capturectrl.TargetFormats(Leadtools.Multimedia.TargetFormatType.MPEG2Transport).UseFilterCache = True
capturectrl.TargetFormat = Leadtools.Multimedia.TargetFormatType.MPEG2Transport
_pMpgMux = DirectCast(capturectrl.TargetFormats(Leadtools.Multimedia.TargetFormatType.MPEG2Transport).GetCacheObject(TargetFormatObject.Mux), LMMpg2MxTLib.LMMpg2MxT)
If _pMpgMux IsNot Nothing Then
_pMpgMux.PrivateDataPID = &H70
_pMpgMux.PrivateDataFormatID = &H41564C4B
_pMpgMux.EnablePrivateData = True
End If
' start capture
capturectrl.StartCapture(Leadtools.Multimedia.CaptureMode.Video)
_result = True
Catch generatedExceptionName As Exception
_result = False
End Try
End Sub
Private Sub WriteKLVData(ByVal pMpgMux As LMMpg2MxTLib.LMMpg2MxT)
' get the current time since Jan 1, 1970
Dim basetime As TimeSpan = DateTime.UtcNow - New DateTime(1970, 1, 1, 0, 0, 0)
' get the number of microseconds since Jan 1, 1970
Dim timestamp As Int64 = CLng(basetime.TotalSeconds) * 1000000
' don't really need to do this, since I am writing only one item
pMpgMux.KlvBuilder.Clear()
' write the UDS timestamp (number of microseconds since Jan 1, 1970)
pMpgMux.KlvBuilder.InsertUInt64(-1, "06 0E 2B 34 01 01 01 03 07 02 01 01 01 05 00 00", CULng(timestamp))
' write one KLV data at the beginning
pMpgMux.WritePrivateData(CInt(LMMpg2MxTLib.Mpg2MxT_WriteFlags.Mpg2MxT_WriteFlag_PTSValid) _
Or CInt(LMMpg2MxTLib.Mpg2MxT_WriteFlags.Mpg2MxT_WriteFlag_PTSInSeconds),
0.0, pMpgMux.KlvBuilder.GetData(), -1)
' close the stream
pMpgMux.ClosePrivateData()
End Sub
Public Sub CaptureCtrl_Started(ByVal sender As Object, ByVal e As EventArgs)
WriteKLVData(_pMpgMux)
End Sub
Public Sub CaptureCtrl_Complete(ByVal sender As Object, ByVal e As EventArgs)
' set result
_result = True
End Sub
Public NotInheritable Class LEAD_VARS
Public Const MediaDir As String = "C:\Program Files (x86)\LEAD Technologies\LEADTOOLS 20\Media"
End Class
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.