IltmmMediaSampleDisp::Clone

#include "ltmm.h"

C Syntax

HRESULT IltmmMediaSampleDisp_Clone(pMediaSampleDisp, ppCopy)

C++ Syntax

HRESULT Clone(ppCopy)

IltmmMediaSampleDisp *pMediaSampleDisp;

pointer to the interface

IltmmMediaSampleDisp **ppCopy;

pointer to new interface

Allocates a new IltmmMediaSampleDisp object containing a copy of the sample data and all the attributes.

Parameter

Description

pMediaSampleDisp

Pointer to the source IltmmMediaSampleDisp interface.

ppCopy

Pointer to the IltmmMediaSampleDisp interface that will contain a complete copy of the data and all the attributes.

Returns

S_OK

The function was successful.

<> S_OK

An error occurred. Refer to the Error Codes or the HRESULT error codes in the DirectShow documentation.

Required DLLs and Libraries

This function allows you to make a complete copy of the data and all the attributes contained in a IltmmMediaSampleDisp object. This is useful for keeping a IltmmMediaSampleDisp object for a while longer because getting multiple sample buffers will invalidate the previous buffers. For example, in this code, the second call invalidates the first sample:

void GetSamples(IltmmSampleSource *pSampleSource) 
{ 
   IltmmMediaSampleDisp *pSample1, *pSample2; 
   pSampleSource->GetSampleBuffer(1000, &pSample1); // pSample1 becomes valid 
   pSampleSource->GetSampleBuffer(1000, &pSample2); // pSample2 is valid but pSample1 is invalid 
   /* Do something with both samples */ 
} 

Can be changed to something like this:

void GetSamples(IltmmSampleSource *pSampleSource) 
{ 
   IltmmMediaSampleDisp *pSample1, *pSample2; 
   pSampleSource->GetSampleBuffer(1000, &pSample2); // pSample2 becomes valid 
   pSample2->Clone(&pSample1);                      // pSample1 is valid and a full copy of pSample2 
   pSample2->Release();                             // Release pSample2. pSample1 is still valid 
   pSampleSource->GetSampleBuffer(1000, &pSample2); // pSample1 and pSample2 are both valid 
   /* Do something with both samples */ 
} 

This function is similar to IltmmMediaSampleDisp::CopyTo, except that this function creates a new IltmmMediaSampleDisp interface, copies everything into it and then returns the newly created object.

Required DLLs and Libraries

LTMM

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Win32, x64

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

LEADTOOLS Multimedia C API Help