Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-10 10:23:50

0001 /* Sound.h - an object that holds the sound structure
0002  * Copyright (C) 2006-2007, Pino Toscano <pino@kde.org>
0003  * Copyright (C) 2017-2021, Albert Astals Cid <aacid@kde.org>
0004  * Copyright (C) 2020, Oliver Sander <oliver.sander@tu-dresden.de>
0005  *
0006  * This program is free software; you can redistribute it and/or modify
0007  * it under the terms of the GNU General Public License as published by
0008  * the Free Software Foundation; either version 2, or (at your option)
0009  * any later version.
0010  *
0011  * This program is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014  * GNU General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU General Public License
0017  * along with this program; if not, write to the Free Software
0018  * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
0019  */
0020 
0021 #ifndef Sound_H
0022 #define Sound_H
0023 
0024 #include <memory>
0025 
0026 class Object;
0027 class Stream;
0028 
0029 //------------------------------------------------------------------------
0030 
0031 enum SoundKind
0032 {
0033     soundEmbedded, // embedded sound
0034     soundExternal // external sound
0035 };
0036 
0037 enum SoundEncoding
0038 {
0039     soundRaw, // raw encoding
0040     soundSigned, // twos-complement values
0041     soundMuLaw, // mu-law-encoded samples
0042     soundALaw // A-law-encoded samples
0043 };
0044 
0045 class POPPLER_PRIVATE_EXPORT Sound
0046 {
0047 public:
0048     // Try to parse the Object obj
0049     static std::unique_ptr<Sound> parseSound(Object *obj);
0050 
0051     // Destructor
0052     ~Sound();
0053 
0054     Sound(const Sound &) = delete;
0055     Sound &operator=(const Sound &) = delete;
0056 
0057     const Object *getObject() const { return &streamObj; }
0058     Stream *getStream();
0059 
0060     SoundKind getSoundKind() const { return kind; }
0061     const std::string &getFileName() const { return fileName; }
0062     double getSamplingRate() const { return samplingRate; }
0063     int getChannels() const { return channels; }
0064     int getBitsPerSample() const { return bitsPerSample; }
0065     SoundEncoding getEncoding() const { return encoding; }
0066 
0067     Sound *copy() const;
0068 
0069 private:
0070     // Create a sound. The Object obj is ensured to be a Stream with a Dict
0071     explicit Sound(const Object *obj, bool readAttrs = true);
0072 
0073     Object streamObj;
0074     SoundKind kind;
0075     std::string fileName;
0076     double samplingRate;
0077     int channels;
0078     int bitsPerSample;
0079     SoundEncoding encoding;
0080 };
0081 
0082 #endif