File indexing completed on 2025-01-05 04:32:39

0001 /***************************************************************************
0002     copyright            : (C) 2014 by Urs Fleisch
0003     email                : ufleisch@users.sourceforge.net
0004  ***************************************************************************/
0005 
0006 /***************************************************************************
0007  *   This library is free software; you can redistribute it and/or modify  *
0008  *   it  under the terms of the GNU Lesser General Public License version  *
0009  *   2.1 as published by the Free Software Foundation.                     *
0010  *                                                                         *
0011  *   This library is distributed in the hope that it will be useful, but   *
0012  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
0013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
0014  *   Lesser General Public License for more details.                       *
0015  *                                                                         *
0016  *   You should have received a copy of the GNU Lesser General Public      *
0017  *   License along with this library; if not, write to the Free Software   *
0018  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA         *
0019  *   02110-1301  USA                                                       *
0020  *                                                                         *
0021  *   Alternatively, this file is available under the Mozilla Public        *
0022  *   License Version 1.1.  You may obtain a copy of the License at         *
0023  *   http://www.mozilla.org/MPL/                                           *
0024  ***************************************************************************/
0025 
0026 #pragma once
0027 
0028 #include "id3v2frame.h"
0029 #include "tlist.h"
0030 
0031 namespace TagLib {
0032 
0033   namespace ID3v2 {
0034 
0035     //! ID3v2 event timing codes frame
0036     /*!
0037      * An implementation of ID3v2 event timing codes.
0038      */
0039     class TAGLIB_EXPORT EventTimingCodesFrame : public Frame
0040     {
0041       friend class FrameFactory;
0042 
0043     public:
0044 
0045       /*!
0046        * Specifies the timestamp format used.
0047        */
0048       enum TimestampFormat {
0049         //! The timestamp is of unknown format.
0050         Unknown              = 0x00,
0051         //! The timestamp represents the number of MPEG frames since
0052         //! the beginning of the audio stream.
0053         AbsoluteMpegFrames   = 0x01,
0054         //! The timestamp represents the number of milliseconds since
0055         //! the beginning of the audio stream.
0056         AbsoluteMilliseconds = 0x02
0057       };
0058 
0059       /*!
0060        * Event types defined in id3v2.4.0-frames.txt 4.5. Event timing codes.
0061        */
0062       enum EventType {
0063         Padding                = 0x00,
0064         EndOfInitialSilence    = 0x01,
0065         IntroStart             = 0x02,
0066         MainPartStart          = 0x03,
0067         OutroStart             = 0x04,
0068         OutroEnd               = 0x05,
0069         VerseStart             = 0x06,
0070         RefrainStart           = 0x07,
0071         InterludeStart         = 0x08,
0072         ThemeStart             = 0x09,
0073         VariationStart         = 0x0a,
0074         KeyChange              = 0x0b,
0075         TimeChange             = 0x0c,
0076         MomentaryUnwantedNoise = 0x0d,
0077         SustainedNoise         = 0x0e,
0078         SustainedNoiseEnd      = 0x0f,
0079         IntroEnd               = 0x10,
0080         MainPartEnd            = 0x11,
0081         VerseEnd               = 0x12,
0082         RefrainEnd             = 0x13,
0083         ThemeEnd               = 0x14,
0084         Profanity              = 0x15,
0085         ProfanityEnd           = 0x16,
0086         NotPredefinedSynch0    = 0xe0,
0087         NotPredefinedSynch1    = 0xe1,
0088         NotPredefinedSynch2    = 0xe2,
0089         NotPredefinedSynch3    = 0xe3,
0090         NotPredefinedSynch4    = 0xe4,
0091         NotPredefinedSynch5    = 0xe5,
0092         NotPredefinedSynch6    = 0xe6,
0093         NotPredefinedSynch7    = 0xe7,
0094         NotPredefinedSynch8    = 0xe8,
0095         NotPredefinedSynch9    = 0xe9,
0096         NotPredefinedSynchA    = 0xea,
0097         NotPredefinedSynchB    = 0xeb,
0098         NotPredefinedSynchC    = 0xec,
0099         NotPredefinedSynchD    = 0xed,
0100         NotPredefinedSynchE    = 0xee,
0101         NotPredefinedSynchF    = 0xef,
0102         AudioEnd               = 0xfd,
0103         AudioFileEnds          = 0xfe
0104       };
0105 
0106       /*!
0107        * Single entry of time stamp and event.
0108        */
0109       struct SynchedEvent {
0110         SynchedEvent(uint ms, EventType t) : time(ms), type(t) {}
0111         uint time;
0112         EventType type;
0113       };
0114 
0115       /*!
0116        * List of synchronized events.
0117        */
0118       typedef TagLib::List<SynchedEvent> SynchedEventList;
0119 
0120       /*!
0121        * Construct an empty event timing codes frame.
0122        */
0123       explicit EventTimingCodesFrame();
0124 
0125       /*!
0126        * Construct a event timing codes frame based on the data in \a data.
0127        */
0128       explicit EventTimingCodesFrame(const ByteVector &data);
0129 
0130       /*!
0131        * Destroys this EventTimingCodesFrame instance.
0132        */
0133       ~EventTimingCodesFrame() override;
0134 
0135       /*!
0136        * Returns a null string.
0137        */
0138       String toString() const override;
0139 
0140       /*!
0141        * Returns the timestamp format.
0142        */
0143       TimestampFormat timestampFormat() const;
0144 
0145       /*!
0146        * Returns the events with the time stamps.
0147        */
0148       SynchedEventList synchedEvents() const;
0149 
0150       /*!
0151        * Set the timestamp format.
0152        *
0153        * \see timestampFormat()
0154        */
0155       void setTimestampFormat(TimestampFormat f);
0156 
0157       /*!
0158        * Sets the text with the time stamps.
0159        *
0160        * \see text()
0161        */
0162       void setSynchedEvents(const SynchedEventList &e);
0163 
0164     protected:
0165       // Reimplementations.
0166 
0167       void parseFields(const ByteVector &data) override;
0168       ByteVector renderFields() const override;
0169 
0170     private:
0171       /*!
0172        * The constructor used by the FrameFactory.
0173        */
0174       EventTimingCodesFrame(const ByteVector &data, Header *h);
0175       EventTimingCodesFrame(const EventTimingCodesFrame &);
0176       EventTimingCodesFrame &operator=(const EventTimingCodesFrame &);
0177 
0178       class EventTimingCodesFramePrivate;
0179       EventTimingCodesFramePrivate *d;
0180     };
0181 
0182   }
0183 }