Exemplo n.º 1
0
HRESULT CAMRSplitter::CompleteConnect(PIN_DIRECTION Dir, CBasePin *pCaller, IPin *pReceivePin)
{
	if (Dir == PINDIR_INPUT) {
		// when our input pin gets connected we have to scan
		// the input file if it is really musepack.
		ASSERT(input && input->Reader());
		ASSERT(!reader);
		ASSERT(!file);

		reader	= DNew CAMRReader(input->Reader());
		file	= DNew CAMRFile();

		// try to open the file
		int ret	= file->Open(reader);
		if (ret < 0) {
			delete file;
			file = NULL;
			delete reader;
			reader = NULL;

			return E_FAIL;
		}

		HRESULT hr = NOERROR;
		
		CAMROutputPin *opin = DNew CAMROutputPin(_T("Outpin"), this, &hr, L"Out", 5);
		ConfigureMediaType(opin);
		AddOutputPin(opin);
	}
	return NOERROR;
}
Exemplo n.º 2
0
HRESULT CMpaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
	CheckPointer(pAsyncReader, E_POINTER);

	HRESULT hr = E_FAIL;

	m_pFile.Free();

	m_pFile.Attach(new 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(new 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;
}
Exemplo n.º 3
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;
}
Exemplo n.º 4
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;
}
Exemplo n.º 5
0
HRESULT CEASpliterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
	SVP_LogMsg5(L" CEASpliterFilter::CreateOutputs");
	CheckPointer(pAsyncReader, E_POINTER);

	HRESULT hr = E_FAIL;

	m_pFile.Free();

	m_pFile.Attach(new CEAFile(pAsyncReader, hr));
	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 = 0;

	m_pFile->Seek(0);
	DWORD EAFileTag = bswap_32((DWORD)m_pFile->BitRead(32));

	switch(EAFileTag)
	{
		case ISNh_TAG:
		case SCHl_TAG:
		case SEAD_TAG:
		case SHEN_TAG:
		case kVGT_TAG:
		case MADk_TAG:
		case MPCh_TAG:
		case MVhd_TAG:
		case MVIh_TAG:
			SVP_LogMsg5(L"GotEA Tag");
			break;
		default:
			return hr;
	}

	m_pFile->Seek(0);
	EaDemuxContext *ea = (EaDemuxContext *)m_pea;
	SVP_LogMsg5(L"EABefore Info %x %x", ea->audio_codec, ea->video_codec);;
	process_header();
	SVP_LogMsg5(L"GotEA Info  %d %d", ea->audio_codec, ea->video_codec);;
	int idPin = 0;
	while(ea->video_codec){
		CMediaType mt;
		mt.SetSampleSize(1);
		mt.subtype = GUID_NULL;
		switch(ea->video_codec){

			case CODEC_ID_VP6:
				{
					mt.majortype = MEDIATYPE_Video;
					mt.formattype = FORMAT_VideoInfo;
					VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
					memset(vih, 0, sizeof(VIDEOINFOHEADER));
					BITMAPINFOHEADER* bih = &vih->bmiHeader;
					vih->bmiHeader.biWidth = ea->width;
					vih->bmiHeader.biHeight = ea->height;
					bih->biCompression = '26PV';
					mt.subtype = MEDIASUBTYPE_VP62;
				}
				break;
			case CODEC_ID_MPEG2VIDEO:
				//TODO: handle MPEG2 in vp6
				/*mt.formattype = FORMAT_MPEG2Video;
				MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + headerSize);
				memset(vih, 0, mt.FormatLength());
				vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
				vih->hdr.bmiHeader.biPlanes = 1;
				vih->hdr.bmiHeader.biBitCount = 24;
				vih->hdr.bmiHeader.biWidth =  ea->width;
				vih->hdr.bmiHeader.biHeight = ea->height;
				*/
			case CODEC_ID_MDEC:
			case CODEC_ID_CMV:
			case CODEC_ID_TGV:
			case CODEC_ID_TGQ:
			case CODEC_ID_TQI:
			case CODEC_ID_MAD:
				SVP_LogMsg5(L"sorry we cant handle this now");
				break;
		}
		
		if(mt.subtype == GUID_NULL)
			break;
		CAtlArray<CMediaType> mts;
		mts.Add(mt);
		CAutoPtr<CBaseSplitterOutputPin> pPinOut(new CBaseSplitterOutputPin(mts, L"Video", this, this, &hr));
		EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(idPin, pPinOut)));
		
		idPin++;
		break;
	}
	if(ea->audio_codec){
		CMediaType mt;
		mt.SetSampleSize(1);
		

		mt.majortype = MEDIATYPE_Audio;
		mt.formattype = FORMAT_WaveFormatEx;
		
		switch(ea->audio_codec){
			case CODEC_ID_MP3:
				mt.subtype = MEDIASUBTYPE_MP3;
				{
					WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX));
					memset(wfe, 0, sizeof(WAVEFORMATEX));
					wfe->nSamplesPerSec = ea->sample_rate;
					wfe->wBitsPerSample = ea->bytes * 8;
					wfe->nChannels = ea->num_channels;
				}
				break;
			case CODEC_ID_ADPCM_EA:
			case CODEC_ID_ADPCM_EA_R1:
			case CODEC_ID_ADPCM_EA_R2:
			case CODEC_ID_ADPCM_EA_R3:
			case CODEC_ID_PCM_S16LE_PLANAR:
			case CODEC_ID_PCM_S8:
			case CODEC_ID_PCM_S16LE:
			case CODEC_ID_PCM_MULAW:
			case CODEC_ID_ADPCM_IMA_EA_EACS:
			case CODEC_ID_ADPCM_IMA_EA_SEAD:
				break;
		}
		
		if(mt.subtype != GUID_NULL){

			CAtlArray<CMediaType> mts;
			mts.Add(mt);
			CAutoPtr<CBaseSplitterOutputPin> pPinOut(new CBaseSplitterOutputPin(mts, L"Audio", this, this, &hr));
			EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(idPin, pPinOut)));
		}

	}
	
	SVP_LogMsg5(L"EA Out %d", m_pOutputs.GetCount());
	m_rtNewStop = m_rtStop = m_rtDuration ;

	return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
}
Exemplo n.º 6
0
HRESULT CNutSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
	CheckPointer(pAsyncReader, E_POINTER);

	HRESULT hr = E_FAIL;

	m_pFile.Free();

	m_pFile.Attach(new CNutFile(pAsyncReader, hr));
	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 = 0;

	// pins

	POSITION pos = m_pFile->m_streams.GetHeadPosition();
	while(pos)
	{
		CNutFile::stream_header* sh = m_pFile->m_streams.GetNext(pos);

		CAtlArray<CMediaType> mts;
		CMediaType mt;

		if(sh->stream_class == CNutFile::SC_VIDEO)
		{
			CNutFile::video_stream_header& vsh = sh->vsh;

			mt.majortype = MEDIATYPE_Video;
			mt.subtype = FOURCCMap(*(DWORD*)sh->fourcc.GetData());
			mt.formattype = FORMAT_VideoInfo;

			VIDEOINFOHEADER vih;
			memset(&vih, 0, sizeof(vih));
			vih.dwBitRate = (DWORD)sh->average_bitrate;
			vih.AvgTimePerFrame = 10000000i64 * sh->time_base_nom / sh->time_base_denom;
			vih.bmiHeader.biSize = sizeof(vih.bmiHeader);
			vih.bmiHeader.biCompression = mt.subtype.Data1;
			vih.bmiHeader.biWidth = (LONG)vsh.width;
			vih.bmiHeader.biHeight = (LONG)vsh.height;
			mt.SetFormat((BYTE*)&vih, sizeof(vih));

			mts.Add(mt);

			if(vsh.sample_width && vsh.sample_height)
			{
				VIDEOINFOHEADER2 vih2;
				memset(&vih2, 0, sizeof(vih2));
				vih2.dwBitRate = vih.dwBitRate;
				vih2.AvgTimePerFrame = vih.AvgTimePerFrame;
				vih2.dwPictAspectRatioX = (DWORD)vsh.sample_width;
				vih2.dwPictAspectRatioY = (DWORD)vsh.sample_height;
				vih2.bmiHeader = vih.bmiHeader;
				mt.SetFormat((BYTE*)&vih2, sizeof(vih2));

				mts.InsertAt(0, mt);
			}
		}
		else if(sh->stream_class == CNutFile::SC_AUDIO)
		{
			CNutFile::audio_stream_header& ash = sh->ash;
			// TODO
		}
		else if(sh->stream_class == CNutFile::SC_SUBTITLE)
		{
			// TODO
		}

		if(mts.GetCount() > 0)
		{
			CAutoPtr<CBaseSplitterOutputPin> pPinOut(new CBaseSplitterOutputPin(mts, L"Video", this, this, &hr));
			AddOutputPin((DWORD)sh->stream_id, pPinOut);
		}
	}

	// TODO
	m_rtNewStop = m_rtStop = m_rtDuration = 0;

	return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
}