当前位置: 代码迷 >> 多媒体/流媒体开发 >> 哪位高手能讲讲GetMediaType中如何设置参数
  详细解决方案

哪位高手能讲讲GetMediaType中如何设置参数

热度:7484   发布时间:2013-02-26 00:00:00.0
谁能讲讲GetMediaType中怎么设置参数
已经没分了,还请多指教!
这是SDK示例里面ball filter里的一段程序:
HRESULT CBallStream::GetMediaType(int iPosition, CMediaType *pmt)
{
  CheckPointer(pmt,E_POINTER);

  CAutoLock cAutoLock(m_pFilter->pStateLock());
  if(iPosition < 0)
  {
  return E_INVALIDARG;
  }

  // Have we run off the end of types?

  if(iPosition > 4)
  {
  return VFW_S_NO_MORE_ITEMS;
  }

  VIDEOINFO *pvi = (VIDEOINFO *) pmt->AllocFormatBuffer(sizeof(VIDEOINFO));
  if(NULL == pvi)
  return(E_OUTOFMEMORY);

  ZeroMemory(pvi, sizeof(VIDEOINFO));

  switch(iPosition)
  {
  case 0:
  case 1:
  case 2:
  case 3:
  case 4:
  }

  // (Adjust the parameters common to all formats...)

  // put the optimal palette in place
  for(int i = 0; i < iPALETTE_COLORS; i++)
  {
  pvi->TrueColorInfo.bmiColors[i].rgbRed = m_Palette[i].peRed;
  pvi->TrueColorInfo.bmiColors[i].rgbBlue = m_Palette[i].peBlue;
  pvi->TrueColorInfo.bmiColors[i].rgbGreen = m_Palette[i].peGreen;
  pvi->TrueColorInfo.bmiColors[i].rgbReserved = 0;
  }

  pvi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
  pvi->bmiHeader.biWidth = m_iImageWidth;
  pvi->bmiHeader.biHeight = m_iImageHeight;
  pvi->bmiHeader.biPlanes = 1;
  pvi->bmiHeader.biSizeImage = GetBitmapSize(&pvi->bmiHeader);
  pvi->bmiHeader.biClrImportant = 0;

  SetRectEmpty(&(pvi->rcSource)); // we want the whole image area rendered.
  SetRectEmpty(&(pvi->rcTarget)); // no particular destination rectangle

  pmt->SetType(&MEDIATYPE_Video);
  pmt->SetFormatType(&FORMAT_VideoInfo);
  pmt->SetTemporalCompression(FALSE);

  // Work out the GUID for the subtype from the header info.
  const GUID SubTypeGUID = GetBitmapSubtype(&pvi->bmiHeader);
  pmt->SetSubtype(&SubTypeGUID);
  pmt->SetSampleSize(pvi->bmiHeader.biSizeImage);

  return NOERROR;

} // GetMediaType

GetMediaType就是为了得到pin口所支持的媒体类型嘛,为什么这个函数后面要设置一些参数呢,设置这些参数的目的是什么?这些参数的设置是根据什么来的呢,是随便设的吗?

------解决方案--------------------------------------------------------
除了 MEDIATYPE_Video
还需要具体到 size 等信息的
------解决方案--------------------------------------------------------
GetMediaType就是为了得到pin口所支持的媒体类型嘛?
是的

为什么这个函数后面要设置一些参数呢,设置这些参数的目的是什么?
告诉别人你的pin支持哪些类型

这些参数的设置是根据什么来的呢,是随便设的吗?
根据你的输出pin支持输出哪种格式来设置。
------解决方案--------------------------------------------------------
探讨
主要就是不知道该如何设置参数,是可以主观的随便设呢,还是必须遵循一个标准?
  相关解决方案