当前位置: 首页>>代码示例>>C++>>正文


C++ ComPtr::Attach方法代码示例

本文整理汇总了C++中ComPtr::Attach方法的典型用法代码示例。如果您正苦于以下问题:C++ ComPtr::Attach方法的具体用法?C++ ComPtr::Attach怎么用?C++ ComPtr::Attach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ComPtr的用法示例。


在下文中一共展示了ComPtr::Attach方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetRate

IFACEMETHODIMP CGeometricMediaSource::SetRate(BOOL fThin, float flRate)
{
    if (fThin)
    {
        return MF_E_THINNING_UNSUPPORTED;
    }
    if (!IsRateSupported(flRate, &flRate))
    {
        return MF_E_UNSUPPORTED_RATE;
    }

    AutoLock lock(_critSec);
    HRESULT hr = S_OK;

    if (flRate == _flRate)
    {
        return S_OK;
    }

    ComPtr<CSourceOperation> spSetRateOp;
    spSetRateOp.Attach(new CSetRateOperation(fThin, flRate));
    if (!spSetRateOp)
    {
        hr = E_OUTOFMEMORY;
    }

    if (SUCCEEDED(hr))
    {
        // Queue asynchronous stop
        hr = QueueOperation(spSetRateOp.Get());
    }

    return hr;
}
开发者ID:ckc,项目名称:WinApp,代码行数:34,代码来源:GeometricMediaSource.cpp

示例2: CreateInstance

HRESULT CMediaStream::CreateInstance(StspStreamDescription *pStreamDescription, IBufferPacket *pAttributesBuffer, CMediaSource *pSource, CMediaStream **ppStream)
{
    if (pStreamDescription == nullptr || pSource == nullptr || ppStream == nullptr)
    {
        return E_INVALIDARG;
    }

    HRESULT hr = S_OK;
    try
    {
        ComPtr<CMediaStream> spStream;
        spStream.Attach(new (std::nothrow) CMediaStream(pSource));
        if (!spStream)
        {
            Throw(E_OUTOFMEMORY);
        }

        spStream->Initialize(pStreamDescription, pAttributesBuffer);


        (*ppStream) = spStream.Detach();
    }
    catch(Exception ^exc)
    {
        hr = exc->HResult;
    }

    TRACEHR_RET(hr);
}
开发者ID:01bui,项目名称:Windows-universal-samples,代码行数:29,代码来源:StspMediaStream.cpp

示例3: CGeometricMediaSource

ComPtr<CGeometricMediaSource> CGeometricMediaSource::CreateInstance()
{
    ComPtr<CGeometricMediaSource> spSource;
    spSource.Attach(new(std::nothrow) CGeometricMediaSource());
    if (!spSource)
    {
        throw ref new OutOfMemoryException();
    }

    spSource->Initialize();

    return spSource;
}
开发者ID:ckc,项目名称:WinApp,代码行数:13,代码来源:GeometricMediaSource.cpp

示例4: new

ComPtr<HDMediaSource> HDMediaSource::CreateMediaSource(int QueueSize)
{
	ComPtr<HDMediaSource> sp;
	
	auto p = new (std::nothrow)HDMediaSource(QueueSize);
	if (p != nullptr)
	{
		p->AddRef();
		sp.Attach(p);
	}

	return sp;
}
开发者ID:carlnome,项目名称:SYEngine,代码行数:13,代码来源:HDMediaSource.cpp

示例5: Create

/* static */
HRESULT CMarker::Create(
    MFSTREAMSINK_MARKER_TYPE eMarkerType,
    const PROPVARIANT *pvarMarkerValue,     // Can be NULL.
    const PROPVARIANT *pvarContextValue,    // Can be NULL.
    IMarker **ppMarker
    )
{
    if (ppMarker == nullptr)
    {
        return E_POINTER;
    }

    HRESULT hr = S_OK;
    ComPtr<CMarker> spMarker;
        
    spMarker.Attach(new (std::nothrow) CMarker(eMarkerType));

    if (spMarker == nullptr)
    {
        hr = E_OUTOFMEMORY;
    }

    // Copy the marker data.
    if (SUCCEEDED(hr))
    {
        if (pvarMarkerValue)
        {
            hr = PropVariantCopy(&spMarker->_varMarkerValue, pvarMarkerValue);
        }
    }

    if (SUCCEEDED(hr))
    {
        if (pvarContextValue)
        {
            hr = PropVariantCopy(&spMarker->_varContextValue, pvarContextValue);
        }
    }

    if (SUCCEEDED(hr))
    {
        *ppMarker = spMarker.Detach();
    }

    return hr;
}
开发者ID:StuartSmith,项目名称:Rasberry-Pi-Trebuchet,代码行数:47,代码来源:Marker.cpp

示例6: Stop

IFACEMETHODIMP CGeometricMediaSource::Stop()
{
    HRESULT hr = S_OK;
    ComPtr<CSourceOperation> spStopOp;
    spStopOp.Attach(new(std::nothrow) CSourceOperation(CSourceOperation::Operation_Stop));
    if (!spStopOp)
    {
        hr = E_OUTOFMEMORY;
    }

    if (SUCCEEDED(hr))
    {
        // Queue asynchronous stop
        hr = QueueOperation(spStopOp.Get());
    }

    return hr;
}
开发者ID:ckc,项目名称:WinApp,代码行数:18,代码来源:GeometricMediaSource.cpp

示例7: CreateInstance

HRESULT CBufferPacket::CreateInstance(IBufferPacket **ppBufferPacket)
{
    if (ppBufferPacket == nullptr)
    {
        return E_INVALIDARG;
    }

    ComPtr<IBufferPacket> spPacket;
    HRESULT hr = S_OK;

    spPacket.Attach(new CBufferPacket());

    if (!spPacket)
    {
        hr = E_OUTOFMEMORY;
    }

    if (SUCCEEDED(hr))
    {
        *ppBufferPacket = spPacket.Detach();
    }

    TRACEHR_RET(hr);
}
开发者ID:StuartSmith,项目名称:Rasberry-Pi-Trebuchet,代码行数:24,代码来源:BufferPacket.cpp

示例8: Render

bool CProcessorHD::Render(CRect src, CRect dst, ID3D11Resource* target, CRenderBuffer** views, DWORD flags, UINT frameIdx, UINT rotation, float contrast, float brightness)
{
  HRESULT hr;
  CSingleLock lock(m_section);

  // restore processor if it was lost
  if (!m_pVideoProcessor && !OpenProcessor())
    return false;

  if (!views[2])
    return false;

  RECT sourceRECT = { src.x1, src.y1, src.x2, src.y2 };
  RECT dstRECT    = { dst.x1, dst.y1, dst.x2, dst.y2 };

  D3D11_VIDEO_FRAME_FORMAT dxvaFrameFormat = D3D11_VIDEO_FRAME_FORMAT_PROGRESSIVE;

  unsigned int providedPast = 0;
  for (int i = 3; i < 8; i++)
  {
    if (views[i])
      providedPast++;
  }
  unsigned int providedFuture = 0;
  for (int i = 1; i >= 0; i--)
  {
    if (views[i])
      providedFuture++;
  }
  int futureFrames = std::min(providedFuture, m_rateCaps.FutureFrames);
  int pastFrames = std::min(providedPast, m_rateCaps.PastFrames);

  D3D11_VIDEO_PROCESSOR_STREAM stream_data = { 0 };
  stream_data.Enable = TRUE;
  stream_data.PastFrames = pastFrames;
  stream_data.FutureFrames = futureFrames;
  if (pastFrames)
    stream_data.ppPastSurfaces = new ID3D11VideoProcessorInputView*[pastFrames];
  if (futureFrames)
    stream_data.ppFutureSurfaces = new ID3D11VideoProcessorInputView*[futureFrames];

  std::vector<ComPtr<ID3D11VideoProcessorInputView>> comViews;
  int start = 2 - futureFrames;
  int end = 2 + pastFrames;
  int count = 0;

  for (int i = start; i <= end; i++)
  {
    if (!views[i])
      continue;

    ComPtr<ID3D11VideoProcessorInputView> view;
    view.Attach(GetInputView(views[i]));

    if (i > 2)
    {
      // frames order should be { ?, T-3, T-2, T-1 }
      stream_data.ppPastSurfaces[2 + pastFrames - i] = view.Get();
    }
    else if (i == 2)
    {
      stream_data.pInputSurface = view.Get();
    }
    else if (i < 2)
    {
      // frames order should be { T+1, T+2, T+3, .. }
      stream_data.ppFutureSurfaces[1 - i] = view.Get();
    }
    if (view)
    {
      count++;
      comViews.push_back(view);
    }
  }

  if (count != pastFrames + futureFrames + 1)
  {
    CLog::LogF(LOGERROR, "incomplete views set.");
    ReleaseStream(stream_data);
    return false;
  }

  if (flags & RENDER_FLAG_FIELD0 && flags & RENDER_FLAG_TOP)
    dxvaFrameFormat = D3D11_VIDEO_FRAME_FORMAT_INTERLACED_TOP_FIELD_FIRST;
  else if (flags & RENDER_FLAG_FIELD1 && flags & RENDER_FLAG_BOT)
    dxvaFrameFormat = D3D11_VIDEO_FRAME_FORMAT_INTERLACED_TOP_FIELD_FIRST;
  if (flags & RENDER_FLAG_FIELD0 && flags & RENDER_FLAG_BOT)
    dxvaFrameFormat = D3D11_VIDEO_FRAME_FORMAT_INTERLACED_BOTTOM_FIELD_FIRST;
  if (flags & RENDER_FLAG_FIELD1 && flags & RENDER_FLAG_TOP)
    dxvaFrameFormat = D3D11_VIDEO_FRAME_FORMAT_INTERLACED_BOTTOM_FIELD_FIRST;

  bool frameProgressive = dxvaFrameFormat == D3D11_VIDEO_FRAME_FORMAT_PROGRESSIVE;

  // Progressive or Interlaced video at normal rate.
  stream_data.InputFrameOrField = frameIdx;
  stream_data.OutputIndex = flags & RENDER_FLAG_FIELD1 && !frameProgressive ? 1 : 0;

  // input format
  m_pVideoContext->VideoProcessorSetStreamFrameFormat(m_pVideoProcessor.Get(), DEFAULT_STREAM_INDEX, dxvaFrameFormat);
  // Source rect
//.........这里部分代码省略.........
开发者ID:Arcko,项目名称:xbmc,代码行数:101,代码来源:DXVAHD.cpp


注:本文中的ComPtr::Attach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。