Changeset 421 for dsfilters/demux_mpc/src/mpc_filter.cpp
- Timestamp:
- 01/18/09 18:17:12 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
dsfilters/demux_mpc/src/mpc_filter.cpp
r379 r421 54 54 rtStop(0xFFFFFFFFFFFFFF), 55 55 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 58 67 input = new CMPCInputPin(NAME("MPC Input Pin"), this, phr, L"In"); 59 68 output.RemoveAll(); … … 78 87 retired.RemoveAll(); 79 88 if (input) { delete input; input = NULL; } 89 90 // done with ... 91 if (content) content->Release(); 80 92 } 81 93 … … 92 104 if (riid == IID_IMediaSeeking) { 93 105 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 } 94 116 } else { 95 117 return CBaseFilter::NonDelegatingQueryInterface(riid,ppv); … … 178 200 // 179 201 //--------------------------------------------------------------------- 202 CAutoLock lck(&lock_filter); 203 180 204 reader = new CMPCReader(input->Reader()); 181 205 file = new CMPCFile(); … … 610 634 } 611 635 636 int 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) 661 STDMETHODIMP 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 676 STDMETHODIMP 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 715 STDMETHODIMP 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.