1 | /* Sound.h - an object that holds the sound structure |
2 | * Copyright (C) 2006-2007, Pino Toscano <pino@kde.org> |
3 | * Copyright (C) 2017-2021, Albert Astals Cid <aacid@kde.org> |
4 | * Copyright (C) 2020, Oliver Sander <oliver.sander@tu-dresden.de> |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2, or (at your option) |
9 | * any later version. |
10 | * |
11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU General Public License |
17 | * along with this program; if not, write to the Free Software |
18 | * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #ifndef Sound_H |
22 | #define Sound_H |
23 | |
24 | #include <memory> |
25 | |
26 | class Object; |
27 | class Stream; |
28 | |
29 | //------------------------------------------------------------------------ |
30 | |
31 | enum SoundKind |
32 | { |
33 | soundEmbedded, // embedded sound |
34 | soundExternal // external sound |
35 | }; |
36 | |
37 | enum SoundEncoding |
38 | { |
39 | soundRaw, // raw encoding |
40 | soundSigned, // twos-complement values |
41 | soundMuLaw, // mu-law-encoded samples |
42 | soundALaw // A-law-encoded samples |
43 | }; |
44 | |
45 | class POPPLER_PRIVATE_EXPORT Sound |
46 | { |
47 | public: |
48 | // Try to parse the Object obj |
49 | static std::unique_ptr<Sound> parseSound(Object *obj); |
50 | |
51 | // Destructor |
52 | ~Sound(); |
53 | |
54 | Sound(const Sound &) = delete; |
55 | Sound &operator=(const Sound &) = delete; |
56 | |
57 | const Object *getObject() const { return &streamObj; } |
58 | Stream *getStream(); |
59 | |
60 | SoundKind getSoundKind() const { return kind; } |
61 | const std::string &getFileName() const { return fileName; } |
62 | double getSamplingRate() const { return samplingRate; } |
63 | int getChannels() const { return channels; } |
64 | int getBitsPerSample() const { return bitsPerSample; } |
65 | SoundEncoding getEncoding() const { return encoding; } |
66 | |
67 | Sound *copy() const; |
68 | |
69 | private: |
70 | // Create a sound. The Object obj is ensured to be a Stream with a Dict |
71 | explicit Sound(const Object *obj, bool readAttrs = true); |
72 | |
73 | Object streamObj; |
74 | SoundKind kind; |
75 | std::string fileName; |
76 | double samplingRate; |
77 | int channels; |
78 | int bitsPerSample; |
79 | SoundEncoding encoding; |
80 | }; |
81 | |
82 | #endif |
83 | |