Ignore:
Timestamp:
01/18/09 18:17:12 (15 years ago)
Author:
radscorpion
Message:

Demuxer updated to 0.4.0.0
Support for APE 2.0 tags
Chapters are now supported

File:
1 edited

Legend:

Unmodified
Added
Removed
  • dsfilters/demux_mpc/src/mpc_filter.cpp

    r379 r421  
    5454        rtStop(0xFFFFFFFFFFFFFF),
    5555        rate(1.0),
    56         ev_abort(TRUE)
    57 {
     56        ev_abort(TRUE),
     57        content(NULL)
     58{
     59        // new instance of media content
     60        CAMMediaContent *amc = new CAMMediaContent(this, NULL);
     61        HRESULT hr = amc->NonDelegatingQueryInterface(IID_IAMMediaContent, (void**)&content);
     62        if (FAILED(hr)) {
     63                delete amc;
     64                content = NULL;
     65        }
     66
    5867        input = new CMPCInputPin(NAME("MPC Input Pin"), this, phr, L"In");
    5968        output.RemoveAll();
     
    7887        retired.RemoveAll();
    7988        if (input) { delete input; input = NULL; }
     89
     90        // done with ...
     91        if (content) content->Release();
    8092}
    8193
     
    92104    if (riid == IID_IMediaSeeking) {
    93105        return GetInterface((IMediaSeeking*)this, ppv);
     106        } else
     107    if (riid == IID_IAMStreamSelect) {
     108        return GetInterface((IAMStreamSelect*)this, ppv);
     109        } else
     110        if (riid == IID_IAMMediaContent) {
     111                if (content) {
     112                        return content->QueryInterface(riid, ppv);
     113                } else {
     114                        return E_NOINTERFACE;
     115                }
    94116        } else {
    95117                return CBaseFilter::NonDelegatingQueryInterface(riid,ppv);
     
    178200                //
    179201                //---------------------------------------------------------------------
     202                CAutoLock               lck(&lock_filter);
     203
    180204                reader = new CMPCReader(input->Reader());
    181205                file = new CMPCFile();
     
    610634}
    611635
     636int CMPCDemux::GetContentString(CString key, CString &value)
     637{
     638        CAutoLock               lck(&lock_filter);
     639
     640        if (!file) return -1;
     641       
     642        if (key == _T("author")) {     
     643                value = file->tag.FindName(_T("artist"));
     644        } else
     645        if (key == _T("title")) {       
     646                value = file->tag.FindName(_T("title"));
     647        } else
     648        if (key == _T("description")) {
     649                value = file->tag.FindName(_T("album"));
     650                CString year = file->tag.FindName(_T("year"));
     651                if (year != _T("")) {
     652                        CString         tmp;
     653                        tmp.Format(_T("(%s) %s"), year, value);
     654                        value = tmp;
     655                }
     656        }
     657        return (value == _T("") ? -1 : 0);
     658}
     659
     660// IAMStreamSelect (chapters hack)
     661STDMETHODIMP CMPCDemux::Count(DWORD *pcStreams)
     662{
     663        if (!pcStreams) return E_POINTER;
     664
     665        CAutoLock               lck(&lock_filter);
     666        if (!file) {
     667                *pcStreams = 0;
     668                return NOERROR;
     669        }
     670
     671        // pocet chaptersov
     672        *pcStreams = file->chapters.size();
     673        return 0;
     674}
     675
     676STDMETHODIMP CMPCDemux::Info(long lIndex, AM_MEDIA_TYPE **ppmt, DWORD *pdwFlags,
     677                                          LCID *plcid, DWORD *pdwGroup, LPWSTR *ppszName,
     678                                          IUnknown **ppObject, IUnknown **ppUnk)
     679{
     680        CAutoLock               lck(&lock_filter);
     681
     682        // correct range ?
     683        if (lIndex < 0) return E_INVALIDARG;
     684        if (!file) return S_FALSE;
     685        if (lIndex >= file->chapters.size()) return S_FALSE;
     686
     687        CMPCChapter             *chap = file->chapters[lIndex];
     688        if (!chap) return S_FALSE;
     689
     690        // all chapters are in the same group
     691        if (pdwFlags) pdwFlags = 0; //AMSTREAMSELECTINFO_EXCLUSIVE;
     692        if (plcid) *plcid = 0;
     693        if (pdwGroup) *pdwGroup = 0;
     694
     695        if (ppszName) {
     696                int             len = chap->caption.GetLength() * sizeof(WCHAR);
     697
     698                LPWSTR          str = (LPWSTR)CoTaskMemAlloc(len+ sizeof(WCHAR));
     699                if (!str) return E_OUTOFMEMORY;
     700
     701                // copy the string
     702                memset(str, 0, len+sizeof(WCHAR));
     703                memcpy(str, chap->caption.GetBuffer(), len);
     704                *ppszName = str;
     705        }
     706
     707        // ignore these
     708        if (ppmt) *ppmt = NULL;
     709        if (ppObject) *ppObject = NULL;
     710        if (ppUnk) *ppUnk = NULL;
     711
     712        return NOERROR;
     713}
     714
     715STDMETHODIMP CMPCDemux::Enable(long lIndex, DWORD dwFlags)
     716{
     717        /*
     718                we fake the stream selection by seeking to the desired position.
     719        */
     720
     721        REFERENCE_TIME                          seek_time = 0;
     722        CComPtr<IMediaSeeking>          ms;
     723
     724        {
     725                CAutoLock               lck(&lock_filter);
     726
     727                if (!m_pGraph) return NOERROR;
     728
     729                HRESULT hr = m_pGraph->QueryInterface(IID_IMediaSeeking, (void**)&ms);
     730                if (FAILED(hr)) return E_UNEXPECTED;
     731
     732                // correct range ?
     733                if (lIndex < 0) return E_INVALIDARG;
     734                if (!file) return S_FALSE;
     735                if (lIndex >= file->chapters.size()) return S_FALSE;
     736
     737                CMPCChapter             *chap = file->chapters[lIndex];
     738                if (!chap) return S_FALSE;
     739
     740                // this is the time
     741                seek_time = llMulDiv(chap->sample_offset, 10000000, file->sample_rate, 0);
     742        }
     743
     744        // now let's do the seeking
     745        ASSERT(ms);
     746
     747        // make the seek
     748        ms->SetPositions(&seek_time, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
     749        ms = NULL;
     750
     751        return NOERROR;
     752}
     753
Note: See TracChangeset for help on using the changeset viewer.