live
MP3StreamState.hh
Go to the documentation of this file.
1/**********
2This library is free software; you can redistribute it and/or modify it under
3the terms of the GNU Lesser General Public License as published by the
4Free Software Foundation; either version 3 of the License, or (at your
5option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6
7This library is distributed in the hope that it will be useful, but WITHOUT
8ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10more details.
11
12You should have received a copy of the GNU Lesser General Public License
13along with this library; if not, write to the Free Software Foundation, Inc.,
1451 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15**********/
16// "liveMedia"
17// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
18// A class encapsulating the state of a MP3 stream
19// C++ header
20
21#ifndef _MP3_STREAM_STATE_HH
22#define _MP3_STREAM_STATE_HH
23
24#ifndef _USAGE_ENVIRONMENT_HH
25#include "UsageEnvironment.hh"
26#endif
27#ifndef _BOOLEAN_HH
28#include "Boolean.hh"
29#endif
30#ifndef _MP3_INTERNALS_HH
31#include "MP3Internals.hh"
32#endif
33#ifndef _NET_COMMON_H
34#include "NetCommon.h"
35#endif
36
37#include <stdio.h>
38
39#define XING_TOC_LENGTH 100
40
42public:
44 virtual ~MP3StreamState();
45
46 void assignStream(FILE* fid, unsigned fileSize);
47
48 unsigned findNextHeader(struct timeval& presentationTime);
49 Boolean readFrame(unsigned char* outBuf, unsigned outBufSize,
50 unsigned& resultFrameSize,
51 unsigned& resultDurationInMicroseconds);
52 // called after findNextHeader()
53
54 void getAttributes(char* buffer, unsigned bufferSize) const;
55
56 float filePlayTime() const; // in seconds
57 unsigned fileSize() const { return fFileSize; }
58 void setPresentationTimeScale(unsigned scale) { fPresentationTimeScale = scale; }
59 unsigned getByteNumberFromPositionFraction(float fraction); // 0.0 <= fraction <= 1.0
60 void seekWithinFile(unsigned seekByteNumber);
61
62 void checkForXingHeader(); // hack for Xing VBR files
63
64protected: // private->protected requested by Pierre l'Hussiez
65 unsigned readFromStream(unsigned char* buf, unsigned numChars);
66
67private:
69 MP3FrameParams const& fr() const {return fCurrentFrame;}
70
71 struct timeval currentFramePlayTime() const;
72
74
75private:
76 FILE* fFid;
78 unsigned fFileSize;
81 // used if we're streaming at other than the normal rate
83 u_int8_t fXingTOC[XING_TOC_LENGTH]; // set iff "fHasXingTOC" is True
84
87};
88
89#endif
unsigned char Boolean
Definition: Boolean.hh:25
#define XING_TOC_LENGTH
float filePlayTime() const
MP3FrameParams fCurrentFrame
unsigned readFromStream(unsigned char *buf, unsigned numChars)
unsigned fFileSize
Boolean findNextFrame()
Boolean fFidIsReallyASocket
u_int8_t fXingTOC[XING_TOC_LENGTH]
MP3FrameParams & fr()
unsigned fPresentationTimeScale
void checkForXingHeader()
virtual ~MP3StreamState()
struct timeval fNextFramePresentationTime
MP3FrameParams const & fr() const
void getAttributes(char *buffer, unsigned bufferSize) const
void setPresentationTimeScale(unsigned scale)
unsigned findNextHeader(struct timeval &presentationTime)
Boolean readFrame(unsigned char *outBuf, unsigned outBufSize, unsigned &resultFrameSize, unsigned &resultDurationInMicroseconds)
void seekWithinFile(unsigned seekByteNumber)
unsigned getByteNumberFromPositionFraction(float fraction)
unsigned fileSize() const
unsigned fNumFramesInFile
struct timeval currentFramePlayTime() const
void assignStream(FILE *fid, unsigned fileSize)