GetCacheObject Method

Summary
Gets the caching filter object.
Syntax
C#
C++/CLI
public object GetCacheObject( 
   TargetFormatObject ObjType 
) 
public: 
Object^ GetCacheObject(  
   TargetFormatObject ObjType 
)  

Parameters

ObjType
Value that indicates which caching object to retrieve. This must be one of the TargetFormatObject constants.

Return Value

A System.Object of the type specified by the TargetFormatObject and represents the caching filter object.

Remarks

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.

Example
C#
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:\LEADTOOLS23\Media"; 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Multimedia Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.