Exemple #1
0
HRESULT CSubtitleSourceASCII::GetMediaType(CMediaType* pmt)
{
	CAutoLock cAutoLock(pStateLock());

	pmt->InitMediaType();
	pmt->SetType(&MEDIATYPE_Text);
	pmt->SetSubtype(&MEDIASUBTYPE_NULL);
	pmt->SetFormatType(&FORMAT_None);
	pmt->ResetFormatBuffer();

	return NOERROR;
}
//
// If the format changes, we need to reconnect
//
void CSynthFilter::ReconnectWithNewFormat(void) 
{
    // The caller must hold the state lock because this
    // function calls IsConnected().
    ASSERT(CritCheckIn(pStateLock()));

    // The synth filter's only has one pin.  The pin is an output pin.
    CDynamicSourceStream* pOutputPin = (CDynamicSourceStream*)GetPin(0);

    if( pOutputPin->IsConnected() ) {
        pOutputPin->OutputPinNeedsToBeReconnected();
    }
}
Exemple #3
0
HRESULT CSubtitleSourceUTF8::GetMediaType(CMediaType* pmt)
{
	CAutoLock cAutoLock(pStateLock());

	pmt->InitMediaType();
	pmt->SetType(&MEDIATYPE_Subtitle);
	pmt->SetSubtype(&MEDIASUBTYPE_UTF8);
	pmt->SetFormatType(&FORMAT_SubtitleInfo);
	SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO));
	memset(psi, 0, pmt->FormatLength());
	strcpy_s(psi->IsoLang, "eng");

	return NOERROR;
}
STDMETHODIMP CSynthFilter::put_OutputFormat(SYNTH_OUTPUT_FORMAT ofOutputFormat) 
{
    // This function holds the state lock because it does not want
    // the filter's format type state or its' connection state
    // to change between the call to put_OutputFormat() and the call to
    // ReconnectWithNewFormat().
    CAutoLock lStateLock(pStateLock());    

    HRESULT hr = m_Synth->put_OutputFormat(ofOutputFormat);
    if (FAILED(hr)) {
        return hr;
    }

    ReconnectWithNewFormat();
    return S_OK;
}
//
// put_SamplesPerSec
//
STDMETHODIMP CSynthFilter::put_SamplesPerSec(int SamplesPerSec) 
{
    // This function holds the state lock because it does not want
    // the filter's format type state or its' connection state
    // to change between the call to put_SamplesPerSec() and the call to
    // ReconnectWithNewFormat().
    CAutoLock lStateLock(pStateLock());

    HRESULT hr = m_Synth->put_SamplesPerSec(SamplesPerSec);
    if( FAILED( hr ) ) {
        return hr;
    }

    ReconnectWithNewFormat ();

    DbgLog((LOG_TRACE, 3, TEXT("put_SamplesPerSec: %d"), SamplesPerSec));
    return NOERROR;
}
Exemple #6
0
HRESULT CSubtitleSourcePreview::GetMediaType(CMediaType* pmt)
{
	CAutoLock cAutoLock(pStateLock());

	pmt->InitMediaType();
	pmt->SetType(&MEDIATYPE_Video);
	pmt->SetSubtype(&MEDIASUBTYPE_RGB32);
	pmt->SetFormatType(&FORMAT_VideoInfo);
	VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
	memset(pvih, 0, pmt->FormatLength());
	pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
	pvih->bmiHeader.biWidth = _WIDTH;
	pvih->bmiHeader.biHeight = _HEIGHT;
	pvih->bmiHeader.biBitCount = 32;
	pvih->bmiHeader.biCompression = BI_RGB;
	pvih->bmiHeader.biPlanes = 1;
	pvih->bmiHeader.biSizeImage = pvih->bmiHeader.biWidth*abs(pvih->bmiHeader.biHeight)*pvih->bmiHeader.biBitCount>>3;

	return NOERROR;
}
Exemple #7
0
HRESULT CSubtitleSourceSSA::GetMediaType(CMediaType* pmt)
{
	CAutoLock cAutoLock(pStateLock());

	pmt->InitMediaType();
	pmt->SetType(&MEDIATYPE_Subtitle);
	pmt->SetSubtype(&MEDIASUBTYPE_SSA);
	pmt->SetFormatType(&FORMAT_SubtitleInfo);

	CSimpleTextSubtitle sts;
	sts.Open(CString(m_fn), DEFAULT_CHARSET);
	sts.RemoveAll();

	CFile f;
	TCHAR path[_MAX_PATH], fn[_MAX_PATH];
	if (!GetTempPath(MAX_PATH, path) || !GetTempFileName(path, _T("mpc_sts"), 0, fn)) {
		return E_FAIL;
	}

	_tremove(fn);

	_tcscat_s(fn, _T(".ssa"));

	if (!sts.SaveAs(fn, EXTSSA, -1, CTextFile::UTF8) || !f.Open(fn, CFile::modeRead)) {
		return E_FAIL;
	}

	int len = (int)f.GetLength()-3;
	f.Seek(3, CFile::begin);

	SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO) + len);
	memset(psi, 0, pmt->FormatLength());
	psi->dwOffset = sizeof(SUBTITLEINFO);
	strcpy_s(psi->IsoLang, "eng");
	f.Read(pmt->pbFormat + psi->dwOffset, len);
	f.Close();

	_tremove(fn);

	return NOERROR;
}
Exemple #8
0
HRESULT CSubtitleSourceARGB::GetMediaType(CMediaType* pmt)
{
    CAutoLock cAutoLock(pStateLock());

    pmt->InitMediaType();
    pmt->SetType(&MEDIATYPE_Video);
    pmt->SetSubtype(&MEDIASUBTYPE_ARGB32);
    pmt->SetFormatType(&FORMAT_VideoInfo);
    VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
    ZeroMemory(pvih, pmt->FormatLength());
    pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
    // TODO: read w,h,fps from a config file or registry
    pvih->bmiHeader.biWidth = _WIDTH;
    pvih->bmiHeader.biHeight = _HEIGHT;
    pvih->bmiHeader.biBitCount = 32;
    pvih->bmiHeader.biCompression = BI_RGB;
    pvih->bmiHeader.biPlanes = 1;
    pvih->bmiHeader.biSizeImage = pvih->bmiHeader.biWidth * abs(pvih->bmiHeader.biHeight) * pvih->bmiHeader.biBitCount >> 3;

    return NOERROR;
}