CDDAReader.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 #include <atlbase.h>
00025 #include "..\..\..\..\include\winddk\devioctl.h"
00026 #include "..\..\..\..\include\winddk\ntddcdrm.h"
00027 #include <qnetwork.h>
00028 #include "..\asyncreader\asyncio.h"
00029 #include "..\asyncreader\asyncrdr.h"
00030 
00031 typedef struct {UINT chunkID; long chunkSize;} ChunkHeader;
00032 
00033 #define RIFFID 'FFIR' 
00034 #define WAVEID 'EVAW' 
00035 typedef struct {ChunkHeader hdr; UINT WAVE;} RIFFChunk;
00036 
00037 #define FormatID ' tmf' 
00038 typedef struct {ChunkHeader hdr; PCMWAVEFORMAT pcm;} FormatChunk;
00039 
00040 #define DataID 'atad'
00041 typedef struct {ChunkHeader hdr;} DataChunk;
00042 
00043 typedef struct {RIFFChunk riff; FormatChunk frm; DataChunk data;} WAVEChunck;
00044 
00045 class CCDDAStream : public CAsyncStream
00046 {
00047 private:
00048     CCritSec m_csLock;
00049 
00050         LONGLONG m_llPosition, m_llLength;
00051 
00052         HANDLE m_hDrive;
00053         CDROM_TOC m_TOC;
00054         UINT m_nFirstSector, m_nStartSector, m_nStopSector;
00055 
00056         WAVEChunck m_header;
00057 
00058 public:
00059         CCDDAStream();
00060         virtual ~CCDDAStream();
00061 
00062         CString m_discTitle, m_trackTitle;
00063         CString m_discArtist, m_trackArtist;
00064 
00065         bool Load(const WCHAR* fnw);
00066 
00067         // overrides
00068     HRESULT SetPointer(LONGLONG llPos);
00069     HRESULT Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWORD pdwBytesRead);
00070     LONGLONG Size(LONGLONG* pSizeAvailable);
00071     DWORD Alignment();
00072     void Lock();
00073         void Unlock();
00074 };
00075 
00076 [uuid("54A35221-2C8D-4a31-A5DF-6D809847E393")]
00077 class CCDDAReader 
00078         : public CAsyncReader
00079         , public IFileSourceFilter
00080         , public IAMMediaContent
00081 {
00082     CCDDAStream m_stream;
00083         CStringW m_fn;
00084 
00085 public:
00086     CCDDAReader(IUnknown* pUnk, HRESULT* phr);
00087         ~CCDDAReader();
00088 
00089         DECLARE_IUNKNOWN;
00090     STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
00091 
00092         // IFileSourceFilter
00093 
00094         STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
00095         STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
00096 
00097         // IAMMediaContent
00098 
00099     STDMETHODIMP GetTypeInfoCount(UINT* pctinfo);
00100         STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo);
00101         STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid);
00102     STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr);
00103 
00104     STDMETHODIMP get_AuthorName(BSTR* pbstrAuthorName);
00105     STDMETHODIMP get_Title(BSTR* pbstrTitle);
00106     STDMETHODIMP get_Rating(BSTR* pbstrRating);
00107     STDMETHODIMP get_Description(BSTR* pbstrDescription);
00108     STDMETHODIMP get_Copyright(BSTR* pbstrCopyright);
00109     STDMETHODIMP get_BaseURL(BSTR* pbstrBaseURL);
00110     STDMETHODIMP get_LogoURL(BSTR* pbstrLogoURL);
00111     STDMETHODIMP get_LogoIconURL(BSTR* pbstrLogoURL);
00112     STDMETHODIMP get_WatermarkURL(BSTR* pbstrWatermarkURL);
00113     STDMETHODIMP get_MoreInfoURL(BSTR* pbstrMoreInfoURL);
00114     STDMETHODIMP get_MoreInfoBannerImage(BSTR* pbstrMoreInfoBannerImage);
00115     STDMETHODIMP get_MoreInfoBannerURL(BSTR* pbstrMoreInfoBannerURL);
00116     STDMETHODIMP get_MoreInfoText(BSTR* pbstrMoreInfoText);
00117 };
00118 

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