Index: dsfilters/demux_mpc/src/mpc_filter.cpp
===================================================================
--- dsfilters/demux_mpc/src/mpc_filter.cpp	(revision 379)
+++ dsfilters/demux_mpc/src/mpc_filter.cpp	(revision 421)
@@ -54,6 +54,15 @@
 	rtStop(0xFFFFFFFFFFFFFF),
 	rate(1.0),
-	ev_abort(TRUE)
-{
+	ev_abort(TRUE),
+	content(NULL)
+{
+	// new instance of media content
+	CAMMediaContent	*amc = new CAMMediaContent(this, NULL);
+	HRESULT hr = amc->NonDelegatingQueryInterface(IID_IAMMediaContent, (void**)&content);
+	if (FAILED(hr)) {
+		delete amc;
+		content = NULL;
+	}
+
 	input = new CMPCInputPin(NAME("MPC Input Pin"), this, phr, L"In");
 	output.RemoveAll();
@@ -78,4 +87,7 @@
 	retired.RemoveAll();
 	if (input) { delete input; input = NULL; }
+
+	// done with ...
+	if (content) content->Release();
 }
 
@@ -92,4 +104,14 @@
     if (riid == IID_IMediaSeeking) {
         return GetInterface((IMediaSeeking*)this, ppv);
+	} else 
+    if (riid == IID_IAMStreamSelect) {
+        return GetInterface((IAMStreamSelect*)this, ppv);
+	} else 
+	if (riid == IID_IAMMediaContent) {
+		if (content) {
+			return content->QueryInterface(riid, ppv);
+		} else {
+			return E_NOINTERFACE;
+		}
 	} else {
 		return CBaseFilter::NonDelegatingQueryInterface(riid,ppv);
@@ -178,4 +200,6 @@
 		//
 		//---------------------------------------------------------------------
+		CAutoLock		lck(&lock_filter);
+
 		reader = new CMPCReader(input->Reader());
 		file = new CMPCFile();
@@ -610,2 +634,120 @@
 }
 
+int CMPCDemux::GetContentString(CString key, CString &value)
+{
+	CAutoLock		lck(&lock_filter);
+
+	if (!file) return -1;
+	
+	if (key == _T("author")) {	
+		value = file->tag.FindName(_T("artist")); 
+	} else
+	if (key == _T("title"))	{	
+		value = file->tag.FindName(_T("title"));
+	} else
+	if (key == _T("description")) {	
+		value = file->tag.FindName(_T("album"));
+		CString	year = file->tag.FindName(_T("year"));
+		if (year != _T("")) {
+			CString		tmp;
+			tmp.Format(_T("(%s) %s"), year, value);
+			value = tmp;
+		}
+	}
+	return (value == _T("") ? -1 : 0);
+}
+
+// IAMStreamSelect (chapters hack)
+STDMETHODIMP CMPCDemux::Count(DWORD *pcStreams)
+{
+	if (!pcStreams) return E_POINTER;
+
+	CAutoLock		lck(&lock_filter);
+	if (!file) {
+		*pcStreams = 0;
+		return NOERROR;
+	}
+
+	// pocet chaptersov
+	*pcStreams = file->chapters.size();
+	return 0;
+}
+
+STDMETHODIMP CMPCDemux::Info(long lIndex, AM_MEDIA_TYPE **ppmt, DWORD *pdwFlags,
+					  LCID *plcid, DWORD *pdwGroup, LPWSTR *ppszName, 
+					  IUnknown **ppObject, IUnknown **ppUnk)
+{
+	CAutoLock		lck(&lock_filter);
+
+	// correct range ?
+	if (lIndex < 0) return E_INVALIDARG;
+	if (!file) return S_FALSE;
+	if (lIndex >= file->chapters.size()) return S_FALSE;
+
+	CMPCChapter		*chap = file->chapters[lIndex];
+	if (!chap) return S_FALSE;
+
+	// all chapters are in the same group
+	if (pdwFlags) pdwFlags = 0; //AMSTREAMSELECTINFO_EXCLUSIVE;
+	if (plcid) *plcid = 0;
+	if (pdwGroup) *pdwGroup = 0;
+
+	if (ppszName) {
+		int		len = chap->caption.GetLength() * sizeof(WCHAR);
+
+		LPWSTR		str = (LPWSTR)CoTaskMemAlloc(len+ sizeof(WCHAR));
+		if (!str) return E_OUTOFMEMORY;
+
+		// copy the string
+		memset(str, 0, len+sizeof(WCHAR));
+		memcpy(str, chap->caption.GetBuffer(), len);
+		*ppszName = str;
+	}
+
+	// ignore these
+	if (ppmt) *ppmt = NULL;
+	if (ppObject) *ppObject = NULL;
+	if (ppUnk) *ppUnk = NULL;
+
+	return NOERROR;
+}
+
+STDMETHODIMP CMPCDemux::Enable(long lIndex, DWORD dwFlags)
+{
+	/*
+		we fake the stream selection by seeking to the desired position.
+	*/
+
+	REFERENCE_TIME				seek_time = 0;
+	CComPtr<IMediaSeeking>		ms;
+
+	{
+		CAutoLock		lck(&lock_filter);
+
+		if (!m_pGraph) return NOERROR;
+
+		HRESULT hr = m_pGraph->QueryInterface(IID_IMediaSeeking, (void**)&ms);
+		if (FAILED(hr)) return E_UNEXPECTED;
+
+		// correct range ?
+		if (lIndex < 0) return E_INVALIDARG;
+		if (!file) return S_FALSE;
+		if (lIndex >= file->chapters.size()) return S_FALSE;
+
+		CMPCChapter		*chap = file->chapters[lIndex];
+		if (!chap) return S_FALSE;
+
+		// this is the time
+		seek_time = llMulDiv(chap->sample_offset, 10000000, file->sample_rate, 0);
+	}
+
+	// now let's do the seeking
+	ASSERT(ms);
+
+	// make the seek
+	ms->SetPositions(&seek_time, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
+	ms = NULL;
+
+	return NOERROR;
+}
+
