xref: /haiku/src/add-ons/media/plugins/ape_reader/MAClib/WAVInputSource.h (revision 03187b607b2b5eec7ee059f1ead09bdba14991fb)
1 #ifndef APE_WAVINPUTSOURCE_H
2 #define APE_WAVINPUTSOURCE_H
3 
4 #include "All.h"
5 #include "IO.h"
6 #include "NoWindows.h"
7 #include "SmartPtr.h"
8 
9 /*************************************************************************************
10 CInputSource - base input format class (allows multiple format support)
11 *************************************************************************************/
12 class CInputSource
13 {
14 public:
15 
16     // construction / destruction
17     CInputSource(CIO * pIO, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL) { }
18     CInputSource(const wchar_t * pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL) { }
19     virtual ~CInputSource() { }
20 
21     // get data
22     virtual int GetData(unsigned char * pBuffer, int nBlocks, int * pBlocksRetrieved) = 0;
23 
24     // get header / terminating data
25     virtual int GetHeaderData(unsigned char * pBuffer) = 0;
26     virtual int GetTerminatingData(unsigned char * pBuffer) = 0;
27 };
28 
29 /*************************************************************************************
30 CWAVInputSource - wraps working with WAV files (could be extended to any format)
31 *************************************************************************************/
32 class CWAVInputSource : public CInputSource
33 {
34 public:
35 
36     // construction / destruction
37     CWAVInputSource(CIO * pIO, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL);
38     CWAVInputSource(const wchar_t * pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL);
39     ~CWAVInputSource();
40 
41     // get data
42     int GetData(unsigned char * pBuffer, int nBlocks, int * pBlocksRetrieved);
43 
44     // get header / terminating data
45     int GetHeaderData(unsigned char * pBuffer);
46     int GetTerminatingData(unsigned char * pBuffer);
47 
48 private:
49 
50     int AnalyzeSource();
51 
52     CSmartPtr<CIO> m_spIO;
53 
54     WAVEFORMATEX m_wfeSource;
55     int m_nHeaderBytes;
56     int m_nDataBytes;
57     int m_nTerminatingBytes;
58     int m_nFileBytes;
59     BOOL m_bIsValid;
60 };
61 
62 /*************************************************************************************
63 Input souce creation
64 *************************************************************************************/
65 extern "C" {	// SHINTA: export
66 	DLLEXPORT CInputSource* __stdcall	CreateInputSource(const wchar_t * pSourceName, WAVEFORMATEX * pwfeSource, int * pTotalBlocks, int * pHeaderBytes, int * pTerminatingBytes, int * pErrorCode = NULL);
67 }
68 
69 #endif // #ifndef APE_WAVINPUTSOURCE_H
70