예제 #1
0
HRESULT CMpaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
	CheckPointer(pAsyncReader, E_POINTER);

	HRESULT hr = E_FAIL;

	m_pFile.Free();

	m_pFile.Attach(DNew CMpaSplitterFile(pAsyncReader, hr));
	if (!m_pFile) {
		return E_OUTOFMEMORY;
	}
	if (FAILED(hr)) {
		m_pFile.Free();
		return hr;
	}

	CAtlArray<CMediaType> mts;
	mts.Add(m_pFile->GetMediaType());

	CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, L"Audio", this, this, &hr));
	AddOutputPin(0, pPinOut);

	m_rtNewStart = m_rtCurrent = 0;
	m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->GetDuration();

	SetID3TagProperties(this, m_pFile->ID3Tag);

	return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
}
예제 #2
0
HRESULT CMpaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
	CheckPointer(pAsyncReader, E_POINTER);

	HRESULT hr = E_FAIL;

	m_pFile.Free();

	m_pFile.Attach(DNew CMpaSplitterFile(pAsyncReader, hr));
	if(!m_pFile) return E_OUTOFMEMORY;
	if(FAILED(hr)) {m_pFile.Free(); return hr;}

	CAtlArray<CMediaType> mts;
	mts.Add(m_pFile->GetMediaType());

	CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, L"Audio", this, this, &hr));
	AddOutputPin(0, pPinOut);

	m_rtNewStart = m_rtCurrent = 0;
	m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->GetDuration();

	CStringW str, title;
	if(m_pFile->m_tags.Lookup('TIT2', str)) title = str;
	if(m_pFile->m_tags.Lookup('TYER', str) && !title.IsEmpty() && !str.IsEmpty()) title += L" (" + str + L")";
	if(!title.IsEmpty()) SetProperty(L"TITL", title);
	if(m_pFile->m_tags.Lookup('TPE1', str)) SetProperty(L"AUTH", str);
	if(m_pFile->m_tags.Lookup('TCOP', str)) SetProperty(L"CPYR", str);
	if(m_pFile->m_tags.Lookup('COMM', str)) SetProperty(L"DESC", str);

	return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
}
예제 #3
0
HRESULT CDSMSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
    CheckPointer(pAsyncReader, E_POINTER);

    HRESULT hr = E_FAIL;

    m_pFile.Free();
    m_pFile.Attach(DEBUG_NEW CDSMSplitterFile(pAsyncReader, hr, *this, *this));
    if (!m_pFile) {
        return E_OUTOFMEMORY;
    }
    if (FAILED(hr)) {
        m_pFile.Free();
        return hr;
    }

    m_rtNewStart = m_rtCurrent = 0;
    m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->m_rtDuration;

    CAtlArray<BYTE> ids;

    POSITION pos = m_pFile->m_mts.GetStartPosition();
    while (pos) {
        BYTE id;
        CMediaType mt;
        m_pFile->m_mts.GetNextAssoc(pos, id, mt);
        ids.Add(id);
    }

    qsort(ids.GetData(), ids.GetCount(), sizeof(BYTE), compare_id);

    for (size_t i = 0; i < ids.GetCount(); i++) {
        BYTE id = ids[i];
        CMediaType& mt = m_pFile->m_mts[id];

        CStringW name, lang;
        name.Format(L"Output %02u", id);

        CAtlArray<CMediaType> mts;
        mts.Add(mt);

        CAutoPtr<CBaseSplitterOutputPin> pPinOut(DEBUG_NEW CBaseSplitterOutputPin(mts, name, this, this, &hr));

        name.Empty();

        pos = m_pFile->m_sim[id].GetStartPosition();
        while (pos) {
            CStringA key;
            CStringW value;
            m_pFile->m_sim[id].GetNextAssoc(pos, key, value);
            pPinOut->SetProperty(CStringW(key), value);

            if (key == "NAME") {
                name = value;
            }
            if (key == "LANG") {
                lang = ISOLang::ISO6392ToLanguage(CStringA(value));
                if (lang.IsEmpty()) {
                    lang = value;
                }
            }
        }

        if (!name.IsEmpty() || !lang.IsEmpty()) {
            if (!name.IsEmpty()) {
                if (!lang.IsEmpty()) {
                    name += L" (" + lang + L")";
                }
            } else if (!lang.IsEmpty()) {
                name = lang;
            }
            pPinOut->SetName(name);
        }

        EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(id, pPinOut)));
    }

    pos = m_pFile->m_fim.GetStartPosition();
    while (pos) {
        CStringA key;
        CStringW value;
        m_pFile->m_fim.GetNextAssoc(pos, key, value);
        SetProperty(CStringW(key), value);
    }

    for (size_t i = 0; i < m_resources.GetCount(); i++) {
        const CDSMResource& r = m_resources[i];
        if (r.mime == L"application/x-truetype-font" ||
                r.mime == L"application/x-font-ttf" ||
                r.mime == L"application/vnd.ms-opentype") {
            //m_fontinst.InstallFont(r.data);
            m_fontinst.InstallFontMemory(r.data.GetData(), (UINT)r.data.GetCount());
        }
    }

    return !m_pOutputs.IsEmpty() ? S_OK : E_FAIL;
}