IltmmMediaSampleDisp::Clone

Summary

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

Syntax

#include "ltmm.h"

Language Syntax
C HRESULT IltmmMediaSampleDisp_Clone(pMediaSampleDisp, ppCopy)
C++ HRESULT Clone(ppCopy)

Parameters

IltmmMediaSampleDisp *pMediaSampleDisp

Pointer to the source IltmmMediaSampleDisp interface.

IltmmMediaSampleDisp **ppCopy

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

Returns

Value Meaning
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.

Comments

This function allows you to make a complete copy of the data and all the attributes contained in an IltmmMediaSampleDisp object. This is useful for keeping an 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

Platforms

Win32, x64.

See Also

Functions

Topics

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

LEADTOOLS Multimedia C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.