AsyncReader.h

00001 /* 
00002  *      Copyright (C) 2003-2005 Gabest
00003  *      http://www.gabest.org
00004  *
00005  *  This Program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2, or (at your option)
00008  *  any later version.
00009  *   
00010  *  This Program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  *  GNU General Public License for more details.
00014  *   
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with GNU Make; see the file COPYING.  If not, write to
00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
00018  *  http://www.gnu.org/copyleft/gpl.html
00019  *
00020  */
00021 
00022 #pragma once
00023 
00024 [uuid("6DDB4EE7-45A0-4459-A508-BD77B32C91B2")]
00025 interface ISyncReader : public IUnknown
00026 {
00027         STDMETHOD_(void, SetBreakEvent) (HANDLE hBreakEvent) = 0;
00028         STDMETHOD_(bool, HasErrors) () = 0;
00029         STDMETHOD_(void, ClearErrors) () = 0;
00030 };
00031 
00032 [uuid("7D55F67A-826E-40B9-8A7D-3DF0CBBD272D")]
00033 interface IFileHandle : public IUnknown
00034 {
00035         STDMETHOD_(HANDLE, GetFileHandle)() = 0;
00036 };
00037 
00038 class CAsyncFileReader : public CUnknown, public CFile, public IAsyncReader, public ISyncReader, public IFileHandle
00039 {
00040 protected:
00041         ULONGLONG m_len;
00042         HANDLE m_hBreakEvent;
00043         LONG m_lOsError; // CFileException::m_lOsError
00044 
00045 public:
00046         CAsyncFileReader(CString fn, HRESULT& hr);
00047 
00048         DECLARE_IUNKNOWN;
00049         STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
00050 
00051         // IAsyncReader
00052 
00053         STDMETHODIMP RequestAllocator(IMemAllocator* pPreferred, ALLOCATOR_PROPERTIES* pProps, IMemAllocator** ppActual) {return E_NOTIMPL;}
00054     STDMETHODIMP Request(IMediaSample* pSample, DWORD_PTR dwUser) {return E_NOTIMPL;}
00055     STDMETHODIMP WaitForNext(DWORD dwTimeout, IMediaSample** ppSample, DWORD_PTR* pdwUser) {return E_NOTIMPL;}
00056         STDMETHODIMP SyncReadAligned(IMediaSample* pSample) {return E_NOTIMPL;}
00057         STDMETHODIMP SyncRead(LONGLONG llPosition, LONG lLength, BYTE* pBuffer);
00058         STDMETHODIMP Length(LONGLONG* pTotal, LONGLONG* pAvailable);
00059         STDMETHODIMP BeginFlush() {return E_NOTIMPL;}
00060         STDMETHODIMP EndFlush() {return E_NOTIMPL;}
00061 
00062         // ISyncReader
00063 
00064         STDMETHODIMP_(void) SetBreakEvent(HANDLE hBreakEvent) {m_hBreakEvent = hBreakEvent;}
00065         STDMETHODIMP_(bool) HasErrors() {return m_lOsError != 0;}
00066         STDMETHODIMP_(void) ClearErrors() {m_lOsError = 0;}
00067 
00068         // IFileHandle
00069 
00070         STDMETHODIMP_(HANDLE) GetFileHandle();
00071 
00072 };
00073 
00074 class CAsyncUrlReader : public CAsyncFileReader, protected CAMThread
00075 {
00076         CString m_url, m_fn;
00077 
00078 protected:
00079         enum {CMD_EXIT, CMD_INIT};
00080     DWORD ThreadProc();
00081 
00082 public:
00083         CAsyncUrlReader(CString url, HRESULT& hr);
00084         virtual ~CAsyncUrlReader();
00085 
00086         // IAsyncReader
00087 
00088         STDMETHODIMP Length(LONGLONG* pTotal, LONGLONG* pAvailable);
00089 };

Generated on Tue Dec 13 14:47:10 2005 for guliverkli by  doxygen 1.4.5