📄 teletextinputpin.cpp
字号:
// DVBTeletextSubtitles.cpp
/*
(C) Luke Paton 2004.
Copyright notice:
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "stdafx.h"
#include "resource.h"
#include "DVBTeletextSubtitles.h"
#include "DVBSubtitlesFilter.h"
#include "DVBTeletextSubtitlesPropertiesPage1.h"
#include <ks.h>
#include <ksmedia.h>
#include <bdatypes.h>
#include <bdamedia.h>
HRESULT
CTeletextPIDInputPin::CheckMediaType(const CMediaType *mtIn)
{
if (*mtIn->Type() != KSDATAFORMAT_TYPE_MPEG2_SECTIONS)
{
return E_INVALIDARG;
}
return S_OK;
}
HRESULT
CTeletextPIDInputPin::SetMediaType(const CMediaType* mtIn)
{
// Set the base class media type (should always succeed)
HRESULT hr = CBaseInputPin::SetMediaType(mtIn);
if (FAILED(hr))
{
return hr;
}
// check the transform can be done (should always succeed)
ASSERT(SUCCEEDED(CheckMediaType(mtIn)));
return S_OK;
}
HRESULT CTeletextPIDInputPin::GetMediaType(int iPosition, CMediaType *pMediaType)
{
if (iPosition == 0)
{
pMediaType->InitMediaType();
pMediaType->SetType(&KSDATAFORMAT_TYPE_MPEG2_SECTIONS);
pMediaType->SetSubtype(&MEDIASUBTYPE_None);
return S_OK;
}
return VFW_S_NO_MORE_ITEMS;
}
STDMETHODIMP
CTeletextPIDInputPin::EnumMediaTypes( IEnumMediaTypes **ppEnum )
{
return CBasePin::EnumMediaTypes(ppEnum);
} // EnumMediaTypes
HRESULT
CTeletextPIDInputPin::CompleteConnect(IPin *pReceivePin)
{
((CDVBTeletextSubtitles*)m_pFilter)->StartFixTeletextInputPinThread();
return CBaseInputPin::CompleteConnect(pReceivePin);
}
HRESULT
CTeletextPIDInputPin::FixTeletextInputPin(void)
{
HRESULT hr = E_NOINTERFACE;
CComPtr<IPin> connected_pin;
if (SUCCEEDED(ConnectedTo(&connected_pin)))
{
CComQIPtr<IMPEG2PIDMap> mpeg2pidmap = connected_pin;
if (mpeg2pidmap != NULL)
{
ULONG pin_pid = ((CDVBTeletextSubtitles*)m_pFilter)->m_nTeletextPid;
hr = mpeg2pidmap->MapPID(1, &pin_pid, MEDIA_TRANSPORT_PACKET);
}
}
return hr;
}
HRESULT
CTeletextPIDInputPin::Run(REFERENCE_TIME tStart)
{
((CDVBTeletextSubtitles*)m_pFilter)->StartFixTeletextInputPinThread();
return CBaseInputPin::Run(tStart);
}
//
// Receive
//
// Here's the next block of data from the stream
//
HRESULT
CTeletextPIDInputPin::Receive(IMediaSample * pSample)
{
// Lock this with the filter-wide lock
CAutoLock lock(m_pLock);
// If we're stopped, then reject this call
// (the filter graph may be in mid-change)
if (m_pFilter->IsStopped())
{
return E_FAIL;
}
// Check all is well with the base class
HRESULT hr = CBaseInputPin::Receive(pSample);
if(FAILED(hr))
{
return hr;
}
// Send the sample to the video window object for rendering
((CDVBTeletextSubtitles*)m_pFilter)->ReadTeletextTransportStreamSample(pSample);
return S_OK;
} // Receive
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -