strawberry-audio-player-win.../3rdparty/taglib/ogg/oggpageheader.h

218 lines
6.8 KiB
C
Raw Normal View History

2018-05-10 15:29:28 +02:00
/***************************************************************************
copyright : (C) 2002 - 2008 by Scott Wheeler
email : wheeler@kde.org
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_OGGPAGEHEADER_H
#define TAGLIB_OGGPAGEHEADER_H
#include "tlist.h"
#include "tbytevector.h"
#include "taglib_export.h"
2019-04-26 01:12:42 +02:00
namespace Strawberry_TagLib {
namespace TagLib {
2020-06-13 19:02:42 +02:00
namespace Ogg {
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
class File;
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
//! An implementation of the page headers associated with each Ogg::Page
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* This class implements Ogg page headers which contain the information about Ogg pages needed to break them into packets which can be passed on to the codecs.
*/
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
class TAGLIB_EXPORT PageHeader {
public:
/*!
* Reads a PageHeader from \a file starting at \a pageOffset.
* The defaults create a page with no (and as such, invalid) data that must be set later.
*/
2020-06-26 23:30:30 +02:00
explicit PageHeader(File *file = nullptr, long long pageOffset = -1);
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* Deletes this instance of the PageHeader.
*/
2020-06-13 19:02:42 +02:00
virtual ~PageHeader();
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* Returns true if the header parsed properly and is valid.
*/
2020-06-13 19:02:42 +02:00
bool isValid() const;
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* Ogg pages contain a list of packets (which are used by the contained codecs).
* The sizes of these pages is encoded in the page header. This returns a list of the packet sizes in bytes.
*
* \see setPacketSizes()
*/
2020-06-13 19:02:42 +02:00
List<int> packetSizes() const;
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* Sets the sizes of the packets in this page to \a sizes. Internally this updates the lacing values in the header.
*
* \see packetSizes()
*/
2020-06-13 19:02:42 +02:00
void setPacketSizes(const List<int> &sizes);
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* Some packets can be <i>continued</i> across multiple pages.
* If the first packet in the current page is a continuation this will return true.
* If this is page starts with a new packet this will return false.
*
* \see lastPacketCompleted()
* \see setFirstPacketContinued()
*/
2020-06-13 19:02:42 +02:00
bool firstPacketContinued() const;
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* Sets the internal flag indicating if the first packet in this page is continued to \a continued.
*
* \see firstPacketContinued()
*/
2020-06-13 19:02:42 +02:00
void setFirstPacketContinued(bool continued);
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* Returns true if the last packet of this page is completely contained in this page.
*
* \see firstPacketContinued()
* \see setLastPacketCompleted()
*/
2020-06-13 19:02:42 +02:00
bool lastPacketCompleted() const;
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* Sets the internal flag indicating if the last packet in this page is complete to \a completed.
*
* \see lastPacketCompleted()
*/
2020-06-13 19:02:42 +02:00
void setLastPacketCompleted(bool completed);
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* This returns true if this is the first page of the Ogg (logical) stream.
*
* \see setFirstPageOfStream()
*/
2020-06-13 19:02:42 +02:00
bool firstPageOfStream() const;
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* Marks this page as the first page of the Ogg stream.
*
* \see firstPageOfStream()
*/
2020-06-13 19:02:42 +02:00
void setFirstPageOfStream(bool first);
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* This returns true if this is the last page of the Ogg (logical) stream.
*
* \see setLastPageOfStream()
*/
2020-06-13 19:02:42 +02:00
bool lastPageOfStream() const;
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* Marks this page as the last page of the Ogg stream.
*
* \see lastPageOfStream()
*/
2020-06-13 19:02:42 +02:00
void setLastPageOfStream(bool last);
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* A special value of containing the position of the packet to be interpreted by the codec.
* In the case of Vorbis this contains the PCM value and is used to calculate the length of the stream.
*
* \see setAbsoluteGranularPosition()
*/
2020-06-13 19:02:42 +02:00
long long absoluteGranularPosition() const;
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* A special value of containing the position of the packet to be interpreted by the codec.
* It is only supported here so that it may be copied from one page to another.
*
* \see absoluteGranularPosition()
*/
2020-06-13 19:02:42 +02:00
void setAbsoluteGranularPosition(long long agp);
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* Every Ogg logical stream is given a random serial number which is common to every page in that logical stream.
* This returns the serial number of the stream associated with this packet.
*
* \see setStreamSerialNumber()
*/
2020-06-13 19:02:42 +02:00
unsigned int streamSerialNumber() const;
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* Every Ogg logical stream is given a random serial number which is common to every page in that logical stream.
* This sets this pages serial number.
* This method should be used when adding new pages to a logical stream.
*
* \see streamSerialNumber()
*/
2020-06-13 19:02:42 +02:00
void setStreamSerialNumber(unsigned int n);
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* Returns the index of the page within the Ogg stream. This helps make it possible to determine if pages have been lost.
*
* \see setPageSequenceNumber()
*/
2020-06-13 19:02:42 +02:00
int pageSequenceNumber() const;
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* Sets the page's position in the stream to \a sequenceNumber.
*
* \see pageSequenceNumber()
*/
2020-06-13 19:02:42 +02:00
void setPageSequenceNumber(int sequenceNumber);
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* Returns the complete header size.
*/
2020-06-13 19:02:42 +02:00
int size() const;
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* Returns the size of the data portion of the page -- i.e. the size of the page less the header size.
*/
2020-06-13 19:02:42 +02:00
int dataSize() const;
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
/*!
* Render the page header to binary data.
*
* \note The checksum -- bytes 22 - 25 -- will be left empty and must be filled in when rendering the entire page.
*/
2020-06-13 19:02:42 +02:00
ByteVector render() const;
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
private:
2020-06-26 23:30:30 +02:00
PageHeader(const PageHeader&);
PageHeader &operator=(const PageHeader&);
2018-05-10 15:29:28 +02:00
2020-06-26 23:30:30 +02:00
void read(Ogg::File *file, long long pageOffset);
2020-06-13 19:02:42 +02:00
ByteVector lacingValues() const;
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
class PageHeaderPrivate;
PageHeaderPrivate *d;
};
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
} // namespace Ogg
} // namespace TagLib
} // namespace Strawberry_TagLib
2018-05-10 15:29:28 +02:00
#endif