blob: 1ac9ede0367ba1075c691c14547ca8c656ee66ea (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
#ifndef MP3_HPP
#define MP3_HPP
//______________________________________________________________________________
//
// MP3.hpp
//
//______________________________________________________________________________
//
#pragma warning(disable:4786)
#include "mp3header.hpp"
#include <windows.h>
#include <string>
#include <exception>
#include <iosfwd>
namespace MP3
{
//______________________________________________________________________________
//
typedef __int64 offset_t;
//--------------------------------------
class Exception : public std::exception
{
public:
Exception(DWORD dwMessage);
Exception(const char* szMessage);
const char* what() const;
private:
std::string m_strMessage;
};
//--------------------------------------
struct Header
{
unsigned long m_ulChannels;
unsigned long m_ulSamplesPerSecond;
unsigned long m_ulSamplesPerBlock;
unsigned long m_ulBytesPerBlock;
unsigned long m_ulBlocks;
void clear();
};
std::ostream& operator<<(std::ostream& os, const Header& h);
//--------------------------------------
class File
{
public:
enum mode_t {in, out, inout};
File();
File(const char* szName, mode_t mode);
~File();
void open(const char* szName, mode_t mode, DWORD dwFlags = 0);
void close();
bool isOpen() const;
bool eof() const;
const char* name() const;
mode_t mode() const;
unsigned long channels() const;
unsigned long samplesPerSecond() const;
unsigned long samplesPerBlock() const;
unsigned long bytesPerBlock() const;
unsigned long blocks() const;
const Header& header() const;
void read(void* pBuffer, size_t size) const;
void write(const void* pBuffer, size_t size);
void seek(offset_t) const;
private:
File(const File& f); // Not implemented
File& operator=(const File& f); // Not implemented
int readHeader();
offset_t size() const;
offset_t tell() const;
HANDLE m_handle;
std::string m_strName;
mode_t m_mode;
Header m_header;
offset_t m_fileSize;
offset_t m_fileOffset;
};
} // namespace MP3
#endif // MP3_HPP
|