From ae407d226ae8172f867e3facd079f0c499568cfb Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 2 Dec 2006 18:56:00 +0000 Subject: [PATCH] Fixes for w2k --- command.cc | 5 +- dssourcepin.cc | 726 +++++++++++++++++++++++++------------------------ vlivebanner.cc | 6 +- wwss.cc | 36 ++- 4 files changed, 394 insertions(+), 379 deletions(-) diff --git a/command.cc b/command.cc index 3311a43..3aa3672 100644 --- a/command.cc +++ b/command.cc @@ -772,11 +772,12 @@ void Command::doJustConnected(VConnect* vconnect) // Enter pre-keys here // handleCommand(Remote::THREE); // handleCommand(Remote::UP); -// handleCommand(Remote::OK); -// handleCommand(Remote::OK); // handleCommand(Remote::PLAY); // handleCommand(Remote::DOWN); // handleCommand(Remote::DOWN); +// handleCommand(Remote::DOWN); +// handleCommand(Remote::OK); +// handleCommand(Remote::OK); // handleCommand(Remote::OK); } } diff --git a/dssourcepin.cc b/dssourcepin.cc index 63812a1..ed9780a 100644 --- a/dssourcepin.cc +++ b/dssourcepin.cc @@ -25,428 +25,430 @@ class DsSFEnumMediaTypes: public IEnumMediaTypes { public: - DsSFEnumMediaTypes(DsSourcePin* papa,ULONG pos=0); - virtual ~DsSFEnumMediaTypes(); - virtual HRESULT STDMETHODCALLTYPE Next(ULONG nummedia, AM_MEDIA_TYPE **pins,ULONG *fetched); - virtual HRESULT STDMETHODCALLTYPE Skip(ULONG numpin); - virtual HRESULT STDMETHODCALLTYPE Reset(); - virtual HRESULT STDMETHODCALLTYPE Clone(IEnumMediaTypes **enuma); - virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id,void ** object); - virtual ULONG STDMETHODCALLTYPE AddRef(); + DsSFEnumMediaTypes(DsSourcePin* papa,ULONG pos=0); + virtual ~DsSFEnumMediaTypes(); + virtual HRESULT STDMETHODCALLTYPE Next(ULONG nummedia, AM_MEDIA_TYPE **pins,ULONG *fetched); + virtual HRESULT STDMETHODCALLTYPE Skip(ULONG numpin); + virtual HRESULT STDMETHODCALLTYPE Reset(); + virtual HRESULT STDMETHODCALLTYPE Clone(IEnumMediaTypes **enuma); + virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id,void ** object); + virtual ULONG STDMETHODCALLTYPE AddRef(); virtual ULONG STDMETHODCALLTYPE Release(); protected: - DsSourcePin* parent; - ULONG curpos; - volatile long refs; + DsSourcePin* parent; + ULONG curpos; + volatile long refs; }; DsSFEnumMediaTypes::DsSFEnumMediaTypes(DsSourcePin* papa,ULONG pos){ - parent=papa; - curpos=pos; - parent->AddRef(); - refs=0; + parent=papa; + curpos=pos; + parent->AddRef(); + refs=0; } DsSFEnumMediaTypes::~DsSFEnumMediaTypes(){ - parent->Release(); + parent->Release(); } -HRESULT STDMETHODCALLTYPE DsSFEnumMediaTypes::Next(ULONG numpin, AM_MEDIA_TYPE **pins,ULONG *fetched) { - int i; - if (fetched==NULL) return E_POINTER; - if (pins==NULL) return E_POINTER; - *fetched=0; - - for (i=0;(iGetMediaType(curpos+i,pins[i])!=S_OK) return S_FALSE; - curpos++; - (*fetched)++; - } - return S_OK; -} +HRESULT STDMETHODCALLTYPE DsSFEnumMediaTypes::Next(ULONG numpin, AM_MEDIA_TYPE **pins,ULONG *fetched) { + int i; + + if (pins==NULL) return E_POINTER; + if (numpin!=1 && fetched==NULL) return E_INVALIDARG; + *fetched=0; + + for (i=0;(iGetMediaType(curpos+i,pins[i])!=S_OK) return S_FALSE; + curpos++; + if (fetched!=NULL) (*fetched)++; + } + return S_OK; +} HRESULT STDMETHODCALLTYPE DsSFEnumMediaTypes::Skip(ULONG numpin){ - curpos+=numpin; - if (curpos>1) return S_FALSE; - return S_OK; + curpos+=numpin; + if (curpos>1) return S_FALSE; + return S_OK; } HRESULT STDMETHODCALLTYPE DsSFEnumMediaTypes::Reset(){ - curpos=0; - return S_OK; + curpos=0; + return S_OK; } HRESULT STDMETHODCALLTYPE DsSFEnumMediaTypes::Clone(IEnumMediaTypes **enuma){ - if (enuma==NULL) return E_POINTER; - *enuma=new DsSFEnumMediaTypes(parent,curpos); - (*enuma)->AddRef(); - return S_OK; + if (enuma==NULL) return E_POINTER; + *enuma=new DsSFEnumMediaTypes(parent,curpos); + (*enuma)->AddRef(); + return S_OK; } HRESULT STDMETHODCALLTYPE DsSFEnumMediaTypes::QueryInterface(REFIID id,void ** object){ - if (object==NULL) return E_POINTER; - if (id==IID_IUnknown ||id == IID_IEnumMediaTypes) { - *object=(IUnknown*)this; - ((IUnknown*)object)->AddRef(); - return NOERROR; - } else { - *object=NULL; - return E_NOINTERFACE; - } + if (object==NULL) return E_POINTER; + if (id==IID_IUnknown ||id == IID_IEnumMediaTypes) { + *object=(IUnknown*)this; + ((IUnknown*)object)->AddRef(); + return NOERROR; + } else { + *object=NULL; + return E_NOINTERFACE; + } } ULONG STDMETHODCALLTYPE DsSFEnumMediaTypes::AddRef(){ - InterlockedIncrement(&refs); - long tempref=refs; - if (tempref>1) return tempref; - else return 1; + InterlockedIncrement(&refs); + long tempref=refs; + if (tempref>1) return tempref; + else return 1; } ULONG STDMETHODCALLTYPE DsSFEnumMediaTypes::Release(){ - long tempref=InterlockedDecrement(&refs); - - if (tempref==0) { - refs++; - delete this; - return NULL; - } else { - if (tempref>1) return tempref; - else return 1; - } + long tempref=InterlockedDecrement(&refs); + + if (tempref==0) { + refs++; + delete this; + return NULL; + } else { + if (tempref>1) return tempref; + else return 1; + } } void CopyMType(AM_MEDIA_TYPE* dest,const AM_MEDIA_TYPE*source) { - memcpy(dest,source,sizeof(AM_MEDIA_TYPE)); - if (source->pbFormat!=NULL) { - dest->pbFormat=(BYTE*)CoTaskMemAlloc(dest->cbFormat); - memcpy(dest->pbFormat,source->pbFormat,dest->cbFormat); - } + memcpy(dest,source,sizeof(AM_MEDIA_TYPE)); + if (source->pbFormat!=NULL) { + dest->pbFormat=(BYTE*)CoTaskMemAlloc(dest->cbFormat); + memcpy(dest->pbFormat,source->pbFormat,dest->cbFormat); + } } void ReleaseMType(AM_MEDIA_TYPE* free) { - if (free->cbFormat!=NULL) CoTaskMemFree(free->pbFormat); - free->pbFormat=NULL; + if (free->cbFormat!=NULL) CoTaskMemFree(free->pbFormat); + free->pbFormat=NULL; } DsSourcePin::DsSourcePin(DsSourceFilter *pFilter, - HRESULT *phr,LPCWSTR pName,bool audio) + HRESULT *phr,LPCWSTR pName,bool audio) { - isaudiopin=audio; - m_pFilter=pFilter; - connected=NULL; - connectedinput=NULL; - allocator=NULL; + isaudiopin=audio; + m_pFilter=pFilter; + connected=NULL; + connectedinput=NULL; + allocator=NULL; + - } DsSourcePin::~DsSourcePin() { - - + + } HRESULT STDMETHODCALLTYPE DsSourcePin::QueryInterface(REFIID id,void ** object){ - if (object==NULL) return E_POINTER; - if (id==IID_IUnknown) { - *object=(IUnknown*)this; - ((IUnknown*)object)->AddRef(); - return NOERROR; - } else if (id==IID_IPin) { - *object=(IPin*)this; - ((IPin*)object)->AddRef(); - return NOERROR; - } else { - *object=NULL; - return E_NOINTERFACE; - } + if (object==NULL) return E_POINTER; + if (id==IID_IUnknown) { + *object=(IUnknown*)this; + ((IUnknown*)object)->AddRef(); + return NOERROR; + } else if (id==IID_IPin) { + *object=(IPin*)this; + ((IPin*)object)->AddRef(); + return NOERROR; + } else { + *object=NULL; + return E_NOINTERFACE; + } } ULONG STDMETHODCALLTYPE DsSourcePin::AddRef(){ - return m_pFilter->AddRef(); + return m_pFilter->AddRef(); } ULONG STDMETHODCALLTYPE DsSourcePin::Release(){ - return m_pFilter->Release(); + return m_pFilter->Release(); } /*IPin*/ HRESULT STDMETHODCALLTYPE DsSourcePin::Connect(IPin *pinempf,const AM_MEDIA_TYPE *mtype) { - if (pinempf==NULL) return E_POINTER; - EnterCriticalSection(&m_pFilter->filterlock); - - if (connected!=NULL) {LeaveCriticalSection(&m_pFilter->filterlock);return VFW_E_ALREADY_CONNECTED;} - if (m_pFilter->mystate!=State_Stopped) {LeaveCriticalSection(&m_pFilter->filterlock);return VFW_E_NOT_STOPPED;} - - - bool gotmt=false; - - if (mtype!=NULL) { - if (CheckMediaType(mtype)==S_OK){ - pinempf->AddRef(); - if (pinempf->ReceiveConnection((IPin*)this,mtype)==S_OK) { - CopyMType(&medtype,mtype); - LeaveCriticalSection(&m_pFilter->filterlock); - } else { - LeaveCriticalSection(&m_pFilter->filterlock); - CoTaskMemFree(mtype->pbFormat); - pinempf->Release(); - return VFW_E_TYPE_NOT_ACCEPTED; - } - - } else { - LeaveCriticalSection(&m_pFilter->filterlock); - CoTaskMemFree(mtype->pbFormat); - return VFW_E_TYPE_NOT_ACCEPTED; - } - CoTaskMemFree(mtype->pbFormat); - }else { - IEnumMediaTypes * emt; - EnumMediaTypes(&emt); - AM_MEDIA_TYPE emtype_np; - AM_MEDIA_TYPE * emtype; - emtype=&emtype_np; - ULONG fetched=0; - pinempf->AddRef(); - while (emt->Next(1,&emtype,&fetched)==S_OK) { - if (CheckMediaType(emtype)==S_OK){ - if (pinempf->ReceiveConnection((IPin*)this,emtype)==S_OK) { - connected=pinempf; - CopyMType(&medtype,emtype); - CoTaskMemFree(emtype->pbFormat); - gotmt=true; - break; - } - - } - CoTaskMemFree(emtype->pbFormat); - } - emt->Release(); - if (gotmt==false) { - pinempf->EnumMediaTypes(&emt); - while (emt->Next(1,&emtype,&fetched)==S_OK) { - if (CheckMediaType(emtype)==S_OK){ - if (pinempf->ReceiveConnection((IPin*)this,emtype)==S_OK) { - connected=pinempf; - CopyMType(&medtype,emtype); - CoTaskMemFree(emtype->pbFormat); - gotmt=true; - break; - } - - } - CoTaskMemFree(emtype->pbFormat); - } - emt->Release(); - if (gotmt==false) { - pinempf->Release(); - LeaveCriticalSection(&m_pFilter->filterlock); - return VFW_E_NO_ACCEPTABLE_TYPES; - } - } - } - - if (pinempf->QueryInterface(IID_IMemInputPin,(void**)&connectedinput)!=S_OK) { - LeaveCriticalSection(&m_pFilter->filterlock); - connected->Release(); - connected=NULL; - /* connectedinput->Release(); - connectedinput=NULL;*/ - return VFW_E_NO_TRANSPORT; - } - ALLOCATOR_PROPERTIES eigenall; - ZeroMemory(&eigenall,sizeof(eigenall)); - connectedinput->GetAllocatorRequirements(&eigenall); - if (eigenall.cbAlign==0) eigenall.cbAlign=1; - connectedinput->GetAllocator(&allocator); - if (DecideBufferSize(allocator,&eigenall)==S_OK) { - if (connectedinput->NotifyAllocator(allocator,FALSE)==S_OK){ - connected=pinempf; - LeaveCriticalSection(&m_pFilter->filterlock); - return S_OK; - } - } - if (allocator!=NULL) allocator->Release(); - allocator=NULL; - - if (CoCreateInstance(CLSID_MemoryAllocator,0,CLSCTX_INPROC_SERVER, - IID_IMemAllocator,(void **)allocator)==S_OK) { - if (DecideBufferSize(allocator,&eigenall)==S_OK) { - if (connectedinput->NotifyAllocator(allocator,FALSE)==S_OK){ - connected=pinempf; - LeaveCriticalSection(&m_pFilter->filterlock); - return S_OK; - } - } - } - if (allocator!=NULL) allocator->Release(); - allocator=NULL; - connected->Release(); - connected=NULL; - connectedinput->Release(); - connectedinput=NULL; - LeaveCriticalSection(&m_pFilter->filterlock); - return VFW_E_NO_TRANSPORT; - - - + if (pinempf==NULL) return E_POINTER; + EnterCriticalSection(&m_pFilter->filterlock); + + if (connected!=NULL) {LeaveCriticalSection(&m_pFilter->filterlock);return VFW_E_ALREADY_CONNECTED;} + if (m_pFilter->mystate!=State_Stopped) {LeaveCriticalSection(&m_pFilter->filterlock);return VFW_E_NOT_STOPPED;} + + + bool gotmt=false; + + if (mtype!=NULL) { + if (CheckMediaType(mtype)==S_OK){ + pinempf->AddRef(); + if (pinempf->ReceiveConnection((IPin*)this,mtype)==S_OK) { + CopyMType(&medtype,mtype); + LeaveCriticalSection(&m_pFilter->filterlock); + } else { + LeaveCriticalSection(&m_pFilter->filterlock); + CoTaskMemFree(mtype->pbFormat); + pinempf->Release(); + return VFW_E_TYPE_NOT_ACCEPTED; + } + + } else { + LeaveCriticalSection(&m_pFilter->filterlock); + CoTaskMemFree(mtype->pbFormat); + return VFW_E_TYPE_NOT_ACCEPTED; + } + CoTaskMemFree(mtype->pbFormat); + }else { + IEnumMediaTypes * emt; + EnumMediaTypes(&emt); + AM_MEDIA_TYPE emtype_np; + AM_MEDIA_TYPE * emtype; + emtype=&emtype_np; + ULONG fetched=0; + pinempf->AddRef(); + while (emt->Next(1,&emtype,&fetched)==S_OK) { + if (CheckMediaType(emtype)==S_OK){ + if (pinempf->ReceiveConnection((IPin*)this,emtype)==S_OK) { + connected=pinempf; + CopyMType(&medtype,emtype); + CoTaskMemFree(emtype->pbFormat); + gotmt=true; + break; + } + + } + CoTaskMemFree(emtype->pbFormat); + } + emt->Release(); + if (gotmt==false) { + pinempf->EnumMediaTypes(&emt); + while (emt->Next(1,&emtype,&fetched)==S_OK) { + if (CheckMediaType(emtype)==S_OK){ + if (pinempf->ReceiveConnection((IPin*)this,emtype)==S_OK) { + connected=pinempf; + CopyMType(&medtype,emtype); + CoTaskMemFree(emtype->pbFormat); + gotmt=true; + break; + } + + } + CoTaskMemFree(emtype->pbFormat); + } + emt->Release(); + if (gotmt==false) { + pinempf->Release(); + LeaveCriticalSection(&m_pFilter->filterlock); + return VFW_E_NO_ACCEPTABLE_TYPES; + } + } + } + + if (pinempf->QueryInterface(IID_IMemInputPin,(void**)&connectedinput)!=S_OK) { + LeaveCriticalSection(&m_pFilter->filterlock); + connected->Release(); + connected=NULL; + /* connectedinput->Release(); + connectedinput=NULL;*/ + return VFW_E_NO_TRANSPORT; + } + ALLOCATOR_PROPERTIES eigenall; + ZeroMemory(&eigenall,sizeof(eigenall)); + connectedinput->GetAllocatorRequirements(&eigenall); + if (eigenall.cbAlign==0) eigenall.cbAlign=1; + connectedinput->GetAllocator(&allocator); + if (DecideBufferSize(allocator,&eigenall)==S_OK) { + if (connectedinput->NotifyAllocator(allocator,FALSE)==S_OK){ + connected=pinempf; + LeaveCriticalSection(&m_pFilter->filterlock); + return S_OK; + } + } + if (allocator!=NULL) allocator->Release(); + allocator=NULL; + + if (CoCreateInstance(CLSID_MemoryAllocator,0,CLSCTX_INPROC_SERVER, + IID_IMemAllocator,(void **)allocator)==S_OK) { + if (DecideBufferSize(allocator,&eigenall)==S_OK) { + if (connectedinput->NotifyAllocator(allocator,FALSE)==S_OK){ + connected=pinempf; + LeaveCriticalSection(&m_pFilter->filterlock); + return S_OK; + } + } + } + if (allocator!=NULL) allocator->Release(); + allocator=NULL; + connected->Release(); + connected=NULL; + connectedinput->Release(); + connectedinput=NULL; + LeaveCriticalSection(&m_pFilter->filterlock); + return VFW_E_NO_TRANSPORT; + + + } HRESULT STDMETHODCALLTYPE DsSourcePin::ReceiveConnection(IPin *connect, - const AM_MEDIA_TYPE *mtype){ - return VFW_E_TYPE_NOT_ACCEPTED; //We have only output pins + const AM_MEDIA_TYPE *mtype){ + return VFW_E_TYPE_NOT_ACCEPTED; //We have only output pins } HRESULT STDMETHODCALLTYPE DsSourcePin::Disconnect() { - EnterCriticalSection(&m_pFilter->filterlock); - if (connected!=NULL) { - if (m_pFilter->mystate!=State_Stopped) {LeaveCriticalSection(&m_pFilter->filterlock);return VFW_E_NOT_STOPPED;} - /*TODO: Decommit allocator*/ - allocator->Decommit(); - allocator->Release(); - allocator=NULL; - ReleaseMType(&medtype); - connectedinput->Release(); - connectedinput=NULL; - connected->Release(); - connected=NULL; - LeaveCriticalSection(&m_pFilter->filterlock); - return S_OK; - } - LeaveCriticalSection(&m_pFilter->filterlock); - return S_FALSE; + EnterCriticalSection(&m_pFilter->filterlock); + if (connected!=NULL) { + if (m_pFilter->mystate!=State_Stopped) {LeaveCriticalSection(&m_pFilter->filterlock);return VFW_E_NOT_STOPPED;} + /*TODO: Decommit allocator*/ + allocator->Decommit(); + allocator->Release(); + allocator=NULL; + ReleaseMType(&medtype); + connectedinput->Release(); + connectedinput=NULL; + connected->Release(); + connected=NULL; + LeaveCriticalSection(&m_pFilter->filterlock); + return S_OK; + } + LeaveCriticalSection(&m_pFilter->filterlock); + return S_FALSE; } HRESULT STDMETHODCALLTYPE DsSourcePin::ConnectedTo(IPin **pin){ - if (pin==NULL) return E_POINTER; - IPin* pinn=connected; - *pin=pinn; - if (pinn!=NULL) { - pinn->AddRef(); - return S_OK; - } else { - return VFW_E_NOT_CONNECTED; - } + if (pin==NULL) return E_POINTER; + IPin* pinn=connected; + *pin=pinn; + if (pinn!=NULL) { + pinn->AddRef(); + return S_OK; + } else { + return VFW_E_NOT_CONNECTED; + } } HRESULT STDMETHODCALLTYPE DsSourcePin::ConnectionMediaType(AM_MEDIA_TYPE *mtype){ - if (mtype==NULL) return E_POINTER; - if (connected!=NULL){ - CopyMType(mtype,&medtype); - return S_OK; - } else { - ZeroMemory(mtype,sizeof(mtype)); - return VFW_E_NOT_CONNECTED; - } + if (mtype==NULL) return E_POINTER; + if (connected!=NULL){ + CopyMType(mtype,&medtype); + return S_OK; + } else { + ZeroMemory(mtype,sizeof(mtype)); + return VFW_E_NOT_CONNECTED; + } } HRESULT STDMETHODCALLTYPE DsSourcePin::QueryPinInfo(PIN_INFO *info){ - if (info==NULL) return E_POINTER; - info->dir=PINDIR_OUTPUT; - info->pFilter=(IBaseFilter*)m_pFilter; - if (m_pFilter) m_pFilter->AddRef(); - if (isaudiopin) wcscpy(info->achName,L"Audio"); - else wcscpy(info->achName,L"Video"); - return S_OK; + if (info==NULL) return E_POINTER; + info->dir=PINDIR_OUTPUT; + info->pFilter=(IBaseFilter*)m_pFilter; + if (m_pFilter) m_pFilter->AddRef(); + if (isaudiopin) wcscpy(info->achName,L"Audio"); + else wcscpy(info->achName,L"Video"); + return S_OK; } HRESULT STDMETHODCALLTYPE DsSourcePin::QueryDirection(PIN_DIRECTION *dir){ - if (dir==NULL) return E_POINTER; - *dir=PINDIR_OUTPUT; - return S_OK; + if (dir==NULL) return E_POINTER; + *dir=PINDIR_OUTPUT; + return S_OK; } HRESULT STDMETHODCALLTYPE DsSourcePin::QueryId(LPWSTR *id){ - if (id==NULL) return E_POINTER; - *id=(LPWSTR)CoTaskMemAlloc(12); - if (*id==NULL) return E_OUTOFMEMORY; - - - if (isaudiopin) wcscpy(*id,L"Audio"); - else wcscpy(*id, L"Video"); - return S_OK; + if (id==NULL) return E_POINTER; + *id=(LPWSTR)CoTaskMemAlloc(12); + if (*id==NULL) return E_OUTOFMEMORY; + + + if (isaudiopin) wcscpy(*id,L"Audio"); + else wcscpy(*id, L"Video"); + return S_OK; } HRESULT STDMETHODCALLTYPE DsSourcePin::QueryAccept(const AM_MEDIA_TYPE *mtype) { - if (mtype==NULL) return S_FALSE; - if (CheckMediaType(mtype)==S_OK) return S_OK; - else return S_FALSE; + if (mtype==NULL) return S_FALSE; + if (CheckMediaType(mtype)==S_OK) return S_OK; + else return S_FALSE; } HRESULT STDMETHODCALLTYPE DsSourcePin::EnumMediaTypes(IEnumMediaTypes **enuma){ if (enuma==NULL) return E_POINTER; - *enuma=new DsSFEnumMediaTypes( this); - (*enuma)->AddRef(); - return S_OK; + *enuma=new DsSFEnumMediaTypes( this); + (*enuma)->AddRef(); + return S_OK; } HRESULT STDMETHODCALLTYPE DsSourcePin::QueryInternalConnections(IPin **pin,ULONG *numpin){ - return E_NOTIMPL; + return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE DsSourcePin::EndOfStream(){ - return E_UNEXPECTED; //we are a output pin! + return E_UNEXPECTED; //we are a output pin! } HRESULT STDMETHODCALLTYPE DsSourcePin::NewSegment(REFERENCE_TIME start,REFERENCE_TIME stop,double rate){ - return E_UNEXPECTED;//we are a output pin! + return E_UNEXPECTED;//we are a output pin! } HRESULT DsSourcePin::getCurrentMediaSample(IMediaSample**ms){ - if (allocator!=NULL) return allocator->GetBuffer(ms,NULL,NULL,0); - else return E_NOINTERFACE; + if (allocator!=NULL) return allocator->GetBuffer(ms,NULL,NULL,0); + else return E_NOINTERFACE; } HRESULT DsSourcePin::deliver(IMediaSample * ms){ - //EnterCriticalSection(&m_pFilter->filterlock); - HRESULT hres; - if (connectedinput!=NULL)hres= connectedinput->Receive(ms); - else hres= VFW_E_NOT_CONNECTED; - //LeaveCriticalSection(&m_pFilter->filterlock); - return hres; + //EnterCriticalSection(&m_pFilter->filterlock); + HRESULT hres; + if (connectedinput!=NULL)hres= connectedinput->Receive(ms); + else hres= VFW_E_NOT_CONNECTED; + //LeaveCriticalSection(&m_pFilter->filterlock); + return hres; } HRESULT DsSourcePin::GetMediaType(int iPosition, AM_MEDIA_TYPE *pmt) { - HRESULT hr; - - if (isaudiopin){ - if (iPosition==0) { - ZeroMemory(pmt,sizeof(*pmt)); - pmt->lSampleSize = 1; - pmt->bFixedSizeSamples = TRUE; - pmt->majortype=MEDIATYPE_Audio; - MPEG1WAVEFORMAT wfe; - ZeroMemory(&wfe,sizeof(wfe)); - wfe.wfx.cbSize=22; - wfe.wfx.nSamplesPerSec=48000; - wfe.wfx.nChannels=2; - wfe.wfx.nAvgBytesPerSec=32000; - wfe.wfx.nBlockAlign=768; - wfe.wfx.wFormatTag=WAVE_FORMAT_MPEG; - wfe.fwHeadLayer=2; - wfe.dwHeadBitrate=256000; - wfe.fwHeadMode=ACM_MPEG_STEREO; - wfe.fwHeadModeExt=1; - wfe.wHeadEmphasis=1; - wfe.fwHeadFlags=ACM_MPEG_ID_MPEG1 |ACM_MPEG_ORIGINALHOME | ACM_MPEG_PROTECTIONBIT; - pmt->subtype=MEDIASUBTYPE_MPEG2_AUDIO; - pmt->formattype=FORMAT_WaveFormatEx; - pmt->cbFormat=sizeof(wfe); - pmt->pbFormat=(BYTE*)CoTaskMemAlloc(sizeof(wfe)); - memcpy(pmt->pbFormat,&wfe,sizeof(wfe)); - pmt->lSampleSize=0; - hr=S_OK; - - + HRESULT hr; + + if (isaudiopin){ + if (iPosition==0) { + ZeroMemory(pmt,sizeof(*pmt)); + pmt->lSampleSize = 1; + pmt->bFixedSizeSamples = TRUE; + pmt->majortype=MEDIATYPE_Audio; + MPEG1WAVEFORMAT wfe; + ZeroMemory(&wfe,sizeof(wfe)); + wfe.wfx.cbSize=22; + wfe.wfx.nSamplesPerSec=48000; + wfe.wfx.nChannels=2; + wfe.wfx.nAvgBytesPerSec=32000; + wfe.wfx.nBlockAlign=768; + wfe.wfx.wFormatTag=WAVE_FORMAT_MPEG; + wfe.fwHeadLayer=2; + wfe.dwHeadBitrate=256000; + wfe.fwHeadMode=ACM_MPEG_STEREO; + wfe.fwHeadModeExt=1; + wfe.wHeadEmphasis=1; + wfe.fwHeadFlags=ACM_MPEG_ID_MPEG1 |ACM_MPEG_ORIGINALHOME | ACM_MPEG_PROTECTIONBIT; + pmt->subtype=MEDIASUBTYPE_MPEG2_AUDIO; + pmt->formattype=FORMAT_WaveFormatEx; + pmt->cbFormat=sizeof(wfe); + pmt->pbFormat=(BYTE*)CoTaskMemAlloc(sizeof(wfe)); + memcpy(pmt->pbFormat,&wfe,sizeof(wfe)); + pmt->lSampleSize=0; + hr=S_OK; + + } else { - hr=VFW_S_NO_MORE_ITEMS ; - } - } else { - if (iPosition == 0) { - ZeroMemory(pmt,sizeof(*pmt)); - pmt->lSampleSize = 1; - pmt->bFixedSizeSamples = TRUE; - pmt->majortype=MEDIATYPE_Video; - hr=S_OK; - pmt->subtype=MEDIASUBTYPE_MPEG2_VIDEO; + hr=VFW_S_NO_MORE_ITEMS ; + } + } else { + if (iPosition == 0) { + ZeroMemory(pmt,sizeof(*pmt)); + pmt->lSampleSize = 1; + pmt->bFixedSizeSamples = TRUE; + pmt->majortype=MEDIATYPE_Video; + hr=S_OK; + pmt->subtype=MEDIASUBTYPE_MPEG2_VIDEO; pmt->formattype=FORMAT_MPEG2Video; MPEG2VIDEOINFO hdr; @@ -456,87 +458,87 @@ HRESULT DsSourcePin::GetMediaType(int iPosition, AM_MEDIA_TYPE *pmt) hdr.hdr.bmiHeader.biSize = sizeof(hdr.hdr.bmiHeader); hdr.hdr.bmiHeader.biWidth = 720; hdr.hdr.bmiHeader.biHeight = 568; - pmt->cbFormat=sizeof(hdr); - pmt->pbFormat=(BYTE*)CoTaskMemAlloc(sizeof(hdr)); - memcpy(pmt->pbFormat,&hdr,sizeof(hdr)); - - } else { - hr=VFW_S_NO_MORE_ITEMS; - } - } - return hr ; + pmt->cbFormat=sizeof(hdr); + pmt->pbFormat=(BYTE*)CoTaskMemAlloc(sizeof(hdr)); + memcpy(pmt->pbFormat,&hdr,sizeof(hdr)); + + } else { + hr=VFW_S_NO_MORE_ITEMS; + } + } + return hr ; } HRESULT DsSourcePin::Inactive() { - if (allocator!=NULL) return allocator->Decommit(); - return VFW_E_NO_ALLOCATOR; + if (allocator!=NULL) return allocator->Decommit(); + return VFW_E_NO_ALLOCATOR; } HRESULT DsSourcePin::Active() { - if (allocator!=NULL) return allocator->Commit(); - return VFW_E_NO_ALLOCATOR; + if (allocator!=NULL) return allocator->Commit(); + return VFW_E_NO_ALLOCATOR; } HRESULT DsSourcePin::Run(REFERENCE_TIME reftime){ - return NOERROR; + return NOERROR; } // No description HRESULT DsSourcePin::CheckMediaType(const AM_MEDIA_TYPE *pmt) { HRESULT res; - + if (isaudiopin) { bool subtype=false; #if 0 /* For future demands ac3 */ - subtype=pmt->subtype==(MEDIASUBTYPE_DOLBY_AC3); + subtype=pmt->subtype==(MEDIASUBTYPE_DOLBY_AC3); #endif - subtype=(pmt->subtype==(MEDIASUBTYPE_MPEG2_AUDIO)); + subtype=(pmt->subtype==(MEDIASUBTYPE_MPEG2_AUDIO)); if (pmt->majortype==MEDIATYPE_Audio && subtype) { - res = S_OK ; + res = S_OK ; } else { res = S_FALSE ; - } + } } else { if (pmt->majortype==MEDIATYPE_Video && pmt-> subtype==MEDIASUBTYPE_MPEG2_VIDEO) { - res = S_OK ; + res = S_OK ; } else { res = S_FALSE ; - } + } } return res; } HRESULT DsSourcePin::DecideBufferSize(IMemAllocator *pa,ALLOCATOR_PROPERTIES *all_pp){ - HRESULT hr; - + HRESULT hr; + if (pa==NULL)return E_POINTER; if (all_pp==NULL) return E_POINTER; - if (isaudiopin) { - if (all_pp->cBuffers*all_pp->cbBuffer < 300*64*1024) - { - //all_pp->cBuffers = 300;//old - all_pp->cBuffers = 10; - all_pp->cbBuffer = 64*1024; - } - } else { - if (all_pp->cBuffers*all_pp->cbBuffer < 300*64*1024) - { - //all_pp->cBuffers = 300;//old - all_pp->cBuffers = 30; - all_pp->cbBuffer = 64*1024; - } - } + if (isaudiopin) { + if (all_pp->cBuffers*all_pp->cbBuffer < 300*64*1024) + { + //all_pp->cBuffers = 300;//old + all_pp->cBuffers = 10; + all_pp->cbBuffer = 64*1024; + } + } else { + if (all_pp->cBuffers*all_pp->cbBuffer < 300*64*1024) + { + //all_pp->cBuffers = 300;//old + all_pp->cBuffers = 30; + all_pp->cbBuffer = 64*1024; + } + } ALLOCATOR_PROPERTIES all_pp_cur; hr =pa->SetProperties(all_pp,&all_pp_cur); - if (FAILED(hr)) + if (FAILED(hr)) { return hr; } - if (all_pp_cur.cbBuffer*all_pp_cur.cBuffers < all_pp->cBuffers*all_pp->cbBuffer) + if (all_pp_cur.cbBuffer*all_pp_cur.cBuffers < all_pp->cBuffers*all_pp->cbBuffer) { return E_FAIL; } diff --git a/vlivebanner.cc b/vlivebanner.cc index eb445e3..6ab28c5 100644 --- a/vlivebanner.cc +++ b/vlivebanner.cc @@ -116,11 +116,13 @@ void VLiveBanner::setChannel(Channel* tChannel) { event = (*eventList)[i]; - btime = localtime((time_t*)&event->time); + //btime = localtime((time_t*)&event->time); + time_t etime = event->time; + btime = localtime(&etime); #ifndef _MSC_VER strftime(tempString2, 299, "%0H:%0M ", btime); #else - strftime(tempString2, 299, "%H:%M ", btime); + strftime(tempString2, 299, "%H:%M ", btime); #endif SNPRINTF(tempString, 299, "%s %s", tempString2, event->title); sl.addOption(tempString, (ULONG)event, first); diff --git a/wwss.cc b/wwss.cc index 9bc81d6..f1a6bb1 100644 --- a/wwss.cc +++ b/wwss.cc @@ -113,6 +113,7 @@ void Wwss::drawPAL() Colour c; UINT value; + for(UINT q = 0; q < Nd; q++) { value = (UINT)(dst[q] * 182); // Apparently this is a better number than 255 for the colour value @@ -123,13 +124,14 @@ void Wwss::drawPAL() void Wwss::drawNTSC() { - static UCHAR startCode[] = {1,0}; - static UCHAR aspect43[] = {0,0}; - static UCHAR aspect169[] = {1,0}; - static UCHAR theRest[] = {0,0,0,0,0,0,0,0,0,0,0,0}; +/* + static UCHAR startCode[] = {1,0,0,0,0,0,0}; + static UCHAR aspect43[] = {0}; + static UCHAR aspect169[] = {1}; + static UCHAR theRest[] = {0,0,0,0,0,0,0,0}; static UCHAR crc43[] = {0,0,0,0,0,0}; - static UCHAR crc169[] = {1,0,0,1,0,1}; - + static UCHAR crc169[] = {0,0,1,1,0,0}; +*/ /* Real NTSC pixel frequency: 13.5 MHz WSS bit frequency: 447.443125 kHz @@ -144,17 +146,23 @@ void Wwss::drawNTSC() const UINT Ns = 22; // Num pix src const UINT Nd = 664; // Num pix dst +// const UINT Nd = 518; // Num pix dst UINT Nl = lcm(Ns, Nd); // Num pix in lcm UINT Ss = Nl / Ns; // Source split (how many lcm px = 1 src px) UINT Sd = Nl / Nd; // Dst split - UCHAR src[Ns]; +// UCHAR src[Ns]; - memcpy(&src[0], startCode, 2); - if (wide) memcpy(&src[2], aspect169, 2); - else memcpy(&src[2], aspect43, 2); - memcpy(&src[4], theRest, 12); +/* + memcpy(&src[0], startCode, 7); + if (wide) memcpy(&src[7], aspect169, 1); + else memcpy(&src[7], aspect43, 1); + memcpy(&src[8], theRest, 8); if (wide) memcpy(&src[16], crc169, 6); else memcpy(&src[16], crc43, 6); +*/ + +static UCHAR src[22] = {1,0, 0,0,0,0,1,1, 0,0,0,0, 0,0,0,0, 0,0,1,0,0,1 }; + float dst[Nd]; UINT lcmpxbase = 0; @@ -172,6 +180,7 @@ void Wwss::drawNTSC() Colour c; UINT value; +// This one is the real one /* for(UINT q = 0; q < Nd; q++) { @@ -181,13 +190,14 @@ void Wwss::drawNTSC() } */ +// This one is testing active for(int yy = 0; yy < 100; yy++) { for(UINT q = 0; q < Nd; q++) { value = (UINT)(dst[q] * 182); // Apparently this is a better number than 255 for the colour value c.set(value, value, value); - drawPixel(q+20, yy, c); + drawPixel(q+0, yy, c); } } @@ -210,7 +220,7 @@ static UCHAR aspect43[] = {0,0}; static UCHAR aspect169[] = {1,0}; static UCHAR theRest[] = {0,0,0,0,0,0,0,0,0,0,0,0}; static UCHAR crc43[] = {0,0,0,0,0,0}; -static UCHAR crc169[] = {1,0,0,1,0,1}; +static UCHAR crc169[] = {0,0,1,0,0,1}; Message 4:3 -- 2.39.5