Exemple #1
0
STDAPI
ImplAAFCreateRawStorageCached2
  (IAAFRawStorage * pRawStorage,
   aafUInt32  pageCount,
   aafUInt32  pageSize,
   IAAFCachePageAllocator * pCachePageAllocator,
   ImplAAFRawStorage ** ppNewRawStorage)
{
  if (! pRawStorage)
	return AAFRESULT_NULL_PARAM;
  if (! pCachePageAllocator)
	return AAFRESULT_NULL_PARAM;
  if (! ppNewRawStorage)
	return AAFRESULT_NULL_PARAM;

  CHECK_CLIENT_IMPLEMENTED_QI(pRawStorage, IID_IAAFRawStorage);
  CHECK_CLIENT_IMPLEMENTED_QI(pCachePageAllocator, IID_IAAFCachePageAllocator);

  HRESULT hr;
  aafBoolean_t isReadable;
  hr = pRawStorage->IsReadable(&isReadable);
  if (FAILED(hr)) return hr;

  aafBoolean_t isWriteable;
  hr = pRawStorage->IsWriteable(&isWriteable);
  if (FAILED(hr)) return hr;

  aafFileAccess_t access = kAAFFileAccess_none;
  if (isReadable && isWriteable)
    access = kAAFFileAccess_modify;
  else if (isReadable)
    access = kAAFFileAccess_read;
  else if (isWriteable)
    access = kAAFFileAccess_write;

  hr = pCachePageAllocator->Initialize(pageCount, pageSize);
  if (FAILED(hr)) return hr;

  OMCachePageAllocator* pAllocator = new ImplAAFOMCachePageAllocator(pCachePageAllocator, pageCount, pageSize);
  ASSERTU(pAllocator);
  ImplAAFOMCachedRawStorage* pStg = new ImplAAFOMCachedRawStorage(pRawStorage,
                                                                  pageCount,
                                                                  pageSize,
                                                                  pAllocator);
  ASSERTU(pStg);


  ImplAAFRawStorage * prs = static_cast<ImplAAFRawStorage *>
	  (::CreateImpl(CLSID_AAFRandomRawStorage));
  prs->Initialize (pStg, access);
  *ppNewRawStorage = prs;
  return AAFRESULT_SUCCESS;
}
Exemple #2
0
STDAPI
ImplAAFSetDiagnosticOutput
  (IAAFDiagnosticOutput* pOutput)
{
  if (pOutput == 0)
  {
    return AAFRESULT_NULL_PARAM;
  }

  CHECK_CLIENT_IMPLEMENTED_QI(pOutput, IID_IAAFDiagnosticOutput);

  HRESULT   hr = AAFRESULT_SUCCESS;


  ImplAAFClientDiagnostics* pDiagnosticStream =
      new ImplAAFClientDiagnostics (pOutput);
  ASSERTU (pDiagnosticStream);

  // Set the pDiagnosticStream to be the toolkit's
  // default diagnostic output stream.
  // Note that omlog::setStream() takes over the ownership
  // of the pDiagnosticStream pointer.
  omlog.setStream (pDiagnosticStream);


  return hr;
}
Exemple #3
0
STDAPI
ImplAAFSetProgressCallback
  (IAAFProgress * pProgress)
{
  if (pProgress == 0)
    return AAFRESULT_NULL_PARAM;

  AAFRESULT	hr = AAFRESULT_SUCCESS;

  CHECK_CLIENT_IMPLEMENTED_QI(pProgress, IID_IAAFProgress);

  ImplAAFContext	*context = ImplAAFContext::GetInstance();
  ASSERTU(context != 0);
  hr = context->SetProgressCallback(pProgress);
  return hr;
}
AAFRESULT STDMETHODCALLTYPE
  ImplAAFTypeDefStream::SetCallback
		(
		ImplAAFPropertyValue * pPropertyValue,
        IAAFStreamAccess*  pCallbackIF,
        aafMemPtr_t  pUserData)
{
  ImplAAFOMDataStreamAccess	*access;
  IAAFPropertyValue		*pvalInterface;

  CHECK_CLIENT_IMPLEMENTED_QI(pCallbackIF, IID_IAAFStreamAccess);

  PROPERTYVALUE_TO_STREAMPROPERTYVALUE(pPropertyValue, pStreamPropertyValue);
  IUnknown *iUnk = static_cast<IUnknown *> (pPropertyValue->GetContainer());
  iUnk->QueryInterface(IID_IAAFPropertyValue, (void **)&pvalInterface); //This call increments the reference counter
  access = new ImplAAFOMDataStreamAccess(pvalInterface, pCallbackIF, pUserData);
  pvalInterface->Release(); //Decrement reference counter 
 
  pStreamPropertyValue->setStreamAccess(access);

  return AAFRESULT_SUCCESS;
}
Exemple #5
0
//***********************************************************
//
// ImplAAFRawStorageIsAAFFileKind()
//
//
STDAPI ImplAAFRawStorageIsAAFFileKind (
  IAAFRawStorage *  pRawStorage,
  aafUID_constptr pAAFFileKind,
  aafBool *  pRawStorageIsAAFFile)
{
  if (pRawStorage == 0)
    return AAFRESULT_NULL_PARAM;

  if (pAAFFileKind == 0)
    return AAFRESULT_NULL_PARAM;

  if (pRawStorageIsAAFFile == 0)
    return AAFRESULT_NULL_PARAM;

  CHECK_CLIENT_IMPLEMENTED_QI(pRawStorage, IID_IAAFRawStorage);

  HRESULT hr = S_OK;
  aafBool is_file_kind = kAAFFalse;


  // Obtain OM representation of pRawStorage.
  IAAFRoot* p_root_object = 0;
  hr = pRawStorage->QueryInterface( IID_IAAFRoot,
                               reinterpret_cast<void**>(&p_root_object));
  ASSERTU(p_root_object != 0);

  ImplAAFRoot* p_impl_root_object = 0;
  p_root_object->GetImplRep( reinterpret_cast<void**>(&p_impl_root_object) );
  ASSERTU(p_impl_root_object != 0);

  p_root_object->Release();
  p_root_object = 0;

  ImplAAFRawStorage* p_impl_raw_storage =
                        dynamic_cast<ImplAAFRawStorage*>(p_impl_root_object);
  ASSERTU(p_impl_raw_storage != 0);

  OMRawStorage*  p_om_raw_storage = p_impl_raw_storage->GetOMStorage();
  ASSERTU(p_om_raw_storage != 0);


  const OMStoredObjectEncoding* p_om_encoding =
      reinterpret_cast<const OMStoredObjectEncoding*>(pAAFFileKind);

  const bool has_factory = OMFile::hasFactory (*p_om_encoding);
  if (has_factory)
  {
    OMStoredObjectFactory* p_factory =
        OMFile::findFactory (*p_om_encoding);

    // Does the factory recognize this file?
    if( p_factory->isRecognized( p_om_raw_storage ) )
    {
      is_file_kind = kAAFTrue;
    }
    else
    {
      is_file_kind = kAAFFalse;
    }

    hr = S_OK;
  }
  else
  {
    is_file_kind = false;
    hr = AAFRESULT_FILEKIND_NOT_REGISTERED;
  }


  if( hr == S_OK )
  {
    *pRawStorageIsAAFFile = is_file_kind;
  }


  return hr;
}
Exemple #6
0
STDAPI
ImplAAFCreateAAFFileOnRawStorage
  (IAAFRawStorage * pRawStorage,
   aafFileExistence_t existence,
   aafFileAccess_t access,
   aafUID_constptr pFileKind,
   aafUInt32 modeFlags,
   aafProductIdentification_constptr pIdent,
   ImplAAFFile ** ppNewFile)
{
  if (! pRawStorage)
	return AAFRESULT_NULL_PARAM;

  if (! ppNewFile)
	return AAFRESULT_NULL_PARAM;

  CHECK_CLIENT_IMPLEMENTED_QI(pRawStorage, IID_IAAFRawStorage);

  HRESULT hr = S_OK;
  ImplAAFFileSP pFile;

  // Create an instance of an uninitialized file object.  Check the
  // raw storage to determine if this should be an AAFFile, or an
  // AAFRandomFile.  If the RawStorage is a RandomRawStorage, create
  // an AAFRandomFile.
  IAAFRandomRawStorage * prrs = 0;
  hr = pRawStorage->QueryInterface (IID_IAAFRandomRawStorage,
									(void **) &prrs);
  if (SUCCEEDED (hr))
	pFile = static_cast<ImplAAFFile *>(::CreateImpl(CLSID_AAFRandomFile));
  else
	pFile = static_cast<ImplAAFFile *>(::CreateImpl(CLSID_AAFFile));

  if (prrs)
	{
	  prrs->Release ();
	  prrs = 0;
	}

  if(!pFile)
	return AAFRESULT_NOMEMORY;

  // Smart pointer had already incremented reference count, so bump it
  // back down to 1 here...
  pFile->ReleaseReference ();

  // Make sure the file is initialized (not open yet...)
  hr = pFile->Initialize();
  if (SUCCEEDED(hr))
	{
	  // Attempt to open the file for modification.
	  hr = pFile->CreateAAFFileOnRawStorage(pRawStorage,
											existence,
											access,
											pFileKind,
											modeFlags,
											pIdent);
	  if (SUCCEEDED(hr))
		{
		  *ppNewFile = pFile;
		  (*ppNewFile)->AcquireReference ();
		}
	}

  return hr;
}