Method GetFrame

From AVObjects Knowledge Base
Revision as of 15:36, 8 July 2014 by Rod (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page is a copy of the original page on the AVObjects' web site and can also be viewed here.

Method to get data from AV object

Contents

HRESULT GetFrame(
    [in] int nStream,
    [in] BYTE* pbBuffer,
    [in] DWORD cbBuffer,
    [out] DWORD* pcbActual, 
    [out] DWORD* pdwFlags,
    [out] REFERENCE_TIME* ptS,
    [out] REFERENCE_TIME* ptE,
    [out] BYTE** pbReserved
    );

Parameters:

nStream     Number of stream
pbBuffer    Buffer for data
cbBuffer    Size of data in buffer in bytes.
pcbActual   Size of received data buffer in bytes.
pdwFlags    Library specific bitmap (see library description)
ptS         Start time
ptE         End time
ppbReserved Library specific variable (see library description)

Returns:

S_OK           Data in pbBuffer returned
E_INVALIDARG   One or more arguments are invalid
E_FAIL         Object not initialized yet or other failure.

Copy frames for all streams from source object to dest object

for(int n = 0; n < nStreams; n++)
{
  HRESULT hr = spDest->CanPutFrame(n, 0);
  if ( FAILED(hr) )
     return hr;
   else if (hr != S_OK)
     continue;
 
  hr = spSource->CanGetFrame(n, 0);
  if ( FAILED(hr) )
    return hr;
  else if (hr != S_OK)
    continue;
 
  DWORD cbActual = 0;
  REFERENCE_TIME tS = 0, tE = 0;
  DWORD dwFlags = 0;
 
  hr = spSource->GetFrame(n, m_pbBuffer, m_cbBuffer, &cbActual, &dwFlags, &tS, &tE, NULL);
  if (hr == S_OK)
  {
     hr = spDest->PutFrame(n, m_pbBuffer, cbActual, dwFlags, tS, tE, NULL);
  }
  else if (hr == HRESULT_FROM_WIN32(ERROR_HANDLE_EOF))
  {
     hr = spDest->PutFrame(n, NULL, 0, 0, 0, 0, NULL);
  }  
  if (FAILED(hr))
    return hr;
}
Personal tools