00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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;
00044
00045 public:
00046 CAsyncFileReader(CString fn, HRESULT& hr);
00047
00048 DECLARE_IUNKNOWN;
00049 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
00050
00051
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
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
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
00087
00088 STDMETHODIMP Length(LONGLONG* pTotal, LONGLONG* pAvailable);
00089 };