direct show,filter,elecard_demux做网络播放器,主要格式:h264/avc,

direct show,filter,elecard_demux做网络播放器,主要格式:h264/avc,

 用的elecard的ax文件,自己写source filter,播放mpeg2还可以,h264就不行了,关键请问题如下:

source仿照系统的asyncflt。cpp。.h :

 问题出在elecard的demux上面,
 首先,elecard公司写demux filter的时候,肯定只是基于文件的--->  to h264来说,

to, mpeg2来说,都是可以的,
 原因如下: 如果是mpeg2, demux filter 先读取一段数据去parse,找psi,如果找到了,就可以connect了,

因为是读文件的,读了一些数据为了connect, 所以connect 以后,必需调用 SetFilePointer(*g_pHFile,0,NULL,FILE_BEGIN);
 要不然,开头的那一段就无法播放了

但是: 如果是h264, 他先读取一段数据去parse,找psi,就算找到了,也不connect: 如果找到了,而且也是文件末尾了,那就connect

成功, 奶奶的,可是我的这个是网络数据流,那有文件末尾,

他有个 set position的函数,connect 后,就 set 0 了

 建立完整个 graph 之后继续播放,不在乎之前的那点数据的---你知道, 前面的那个数据是多大呢16M

 DVB 标清的话,用不了多少就可以搜完台,用不了 16MB

关键是我怎么知道它到底读多少数据就 parse完了呢,难道让我一直等么?,

最早,标清我只要3M的数据,就必需建立graph了,现在h264,高清的,4M,根本不够了,

于是,我的code这样写了,呵呵:HRESULT SetPointer(LONGLONG llPos)
 {
  
   if (g_bIsConnect == 0)
   {
    if (llPos >= (1024 * 1024 * 14))
    {
     //DbgLog((LOG_TRACE, 1, TEXT("\n--Set File Pointer = ld"),llPos));
     return S_FALSE;
    }
 如果connect成功: SetPointer就 永远返回ok
 这样就可以播放了,
 不过,浪费了我14M的数据,唉,
code如后:

if (SUCCEEDED(hr)) 
  hr = CoCreateInstance(CLSID_CEleCardMpegMultiplexer, NULL, CLSCTX_INPROC,
  IID_IBaseFilter, (LPVOID *)&pMPG2Splitter) ;

 if (SUCCEEDED(hr)) 
  hr = m_pGraph->AddFilter(pMPG2Splitter,L"EleCard Mpeg2 DeMultiplexer");

 pPinInTSSplitter = xMyFindPin(pMPG2Splitter,L"Input",0,CLSID_NULL_USER1);

 if (SUCCEEDED(hr)) 
  hr = m_pGraph->Connect(pPinOutSTWrapper,pPinInTSSplitter);


 if (strcmp(m_strFileFormat,"H264") == 0)
 {
  pPinOutTSSplitter_V= xMyFindPin(pMPG2Splitter,L"264",1,MEDIATYPE_Video);
 }
 else
 {  
  pPinOutTSSplitter_V= xMyFindPin(pMPG2Splitter,L"Video",1,MEDIATYPE_Video);
 }

if (strcmp(m_strFileFormat,"H264") == 0)
 {
  if (SUCCEEDED(hr))
   hr = CoCreateInstance(CLSID_CH264VideoDecoder, NULL, CLSCTX_INPROC,    

IID_IBaseFilter, (LPVOID *)&pFIDVDVideoDecorder) ;
  if (SUCCEEDED(hr)) 
   hr = m_pGraph->AddFilter(pFIDVDVideoDecorder,L"EleCard MPEG2 Video Decoder");

  if (SUCCEEDED(hr)) 
   pIDVDVideoDecorderInpin = xMyFindPin(pFIDVDVideoDecorder,L"In",0,MEDIATYPE_Video);

  if(pIDVDVideoDecorderInpin)
   hr = m_pGraph->Connect(pPinOutTSSplitter_V,pIDVDVideoDecorderInpin);

  if (SUCCEEDED(hr)) 
   pIDVDVideoDecorderOutpin = xMyFindPin(pFIDVDVideoDecorder,L"Out",1,MEDIATYPE_Video);
 }
 else
 {
  if (SUCCEEDED(hr))  
   hr = CoCreateInstance(CLSID_CEleCardVideoDec, NULL, CLSCTX_INPROC,
   IID_IBaseFilter, (LPVOID *)&pFIDVDVideoDecorder) ;
  if (SUCCEEDED(hr)) 
   hr = m_pGraph->AddFilter(pFIDVDVideoDecorder,L"EleCard MPEG2 Video Decoder");

  if (SUCCEEDED(hr)) 
   pIDVDVideoDecorderInpin = xMyFindPin(pFIDVDVideoDecorder,L"MPEG In",0,MEDIATYPE_Video);

  if(pIDVDVideoDecorderInpin)
   hr = m_pGraph->Connect(pPinOutTSSplitter_V,pIDVDVideoDecorderInpin);


  if (SUCCEEDED(hr)) 
   pIDVDVideoDecorderOutpin = xMyFindPin(pFIDVDVideoDecorder,L"Video Out",1,MEDIATYPE_Video);

 }

 


static const GUID CLSID_CEleCardMpegMultiplexer =
{0x136DCBF5,0x3874,0x4B70,0xAE,0x3E,0x15,0x99,0x7d,0x63,0x34,0xf7};
 //  136DCBF5-  3874 - 4B70 - AE   3E - 15   99   7D   63   34   F7

static const GUID CLSID_CEleCardVideoDec=
{0xf50b3f13,0x19c4,0x11cf,0xaa,0x9a,0x02,0x60,0x8c,0x9b,0xab,0xa2};
//{F50B3F13-19C4-11CF-  AA9A-         02   60   8C   9B   AB   A2}

static const GUID CLSID_CMoonlightAudioDec=
{0xe32c3b01,0xc81b,0x4d01,0x8a,0xd4,0x2b,0x93,0xf7,0xfa,0x54,0x4c};

static const GUID CLSID_CH264VideoDecoder=
{0x6A270473,0x9994,0x4aeb,0x80,0x1f,0xbb,0x2c,0x4e,0x56,0xee,0x38};
// 6A270473-  9994-  4AEB-  80   1F-  BB   2C   4E   56   EE   38}

你可能感兴趣的:(direct show,filter,elecard_demux做网络播放器,主要格式:h264/avc,)