AVPKit
IStream.h
1 /*******************************************************************************
2  * Copyright (c) 2024, 2026, Olivier Ayache. All rights reserved.
3  *
4  * This file is part of AVPKit.
5  *
6  * AVPKit is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * AVPKit 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 Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with AVPKit. If not, see <http://www.gnu.org/licenses/>.
18  *******************************************************************************/
19 
20 #ifndef ISTREAM_H_
21 #define ISTREAM_H_
22 #include <com/avpkit/ferry/RefCounted.h>
23 #include <com/avpkit/core/AVPKit.h>
24 #define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24))
25 namespace com { namespace avpkit { namespace core
26 {
27  class IStreamCoder;
28  class IContainer;
29  class IRational;
30  class IMetaData;
31  class IPacket;
32  class IIndexEntry;
33 
49  class VS_API_AVPKIT IStream : public com::avpkit::ferry::RefCounted
50  {
51  public:
59  typedef enum Direction {
60  INBOUND,
61  OUTBOUND,
62  } Direction;
63 
68  virtual Direction getDirection()=0;
74  virtual int getIndex()=0;
75 
80  virtual int getId()=0;
81 
91 
101  virtual IRational * getFrameRate()=0;
102 
112  virtual IRational * getTimeBase()=0;
113 
119  virtual int64_t getStartTime()=0;
120 
126  virtual int64_t getDuration()=0;
127 
133  virtual int64_t getCurrentDts()=0;
134 
140  virtual int getNumIndexEntries()=0;
141 
149  virtual int64_t getNumFrames()=0;
150 
151  protected:
152  virtual ~IStream()=0;
153  IStream();
155  public:
156 
168  virtual void setSampleAspectRatio(IRational* newRatio)=0;
169 
177  virtual const char* getLanguage()=0;
178 
189  virtual void setLanguage(const char* language)=0;
190 
197  virtual IContainer* getContainer()=0;
198 
199  /*
200  * Added for 1.22
201  */
202 
212  virtual int32_t setStreamCoder(IStreamCoder *newCoder)=0;
213 
214  /*
215  * Added for 3.0
216  */
217 
222  typedef enum ParseType {
223  PARSE_NONE,
228  PARSE_FULL_RAW,
231  } ParseType;
232 
239 
252  virtual void setParseType(ParseType type)=0;
253 
260  virtual int setBitstreamFilter(const char* name)=0;
261 
262  /*
263  * Added for 3.1
264  */
265 
285  virtual IMetaData* getMetaData()=0;
286 
297  virtual void setMetaData(IMetaData* data)=0;
298 
299  /*
300  * Added for 3.2
301  */
302 
313  virtual int32_t stampOutputPacket(IPacket* packet)=0;
314 
315 
330  virtual int32_t setStreamCoder(IStreamCoder *newCoder, bool assumeOnlyStream)=0;
331 
332  /*
333  * Added for 3.4
334  */
358  int64_t wantedTimeStamp, int32_t flags)=0;
359 
384  int64_t wantedTimeStamp, int32_t flags)=0;
385 
403  virtual IIndexEntry* getIndexEntry(int32_t position)=0;
404 
414  virtual int32_t addIndexEntry(IIndexEntry* entry)=0;
415 
423  virtual void setId(int32_t id) = 0;
424  };
425 }}}
426 
427 #endif /*ISTREAM_H_*/
A file (or network data source) that contains one or more IStream objects of audio and video data.
Definition: IContainer.h:100
An index entry for a IStream.
Definition: IIndexEntry.h:65
Get MetaData about a IContainer or IStream.
Definition: IMetaData.h:51
Represents an encoded piece of data that can be placed in an IContainer for a given IStream of data.
Definition: IPacket.h:50
This class wraps represents a Rational number for the AVPKit.
Definition: IRational.h:43
The work horse of the AVPKit: Takes IPacket data from an IContainer (representing an IStream) and an ...
Definition: IStreamCoder.h:45
Represents a stream of similar data (eg video) in a IContainer.
Definition: IStream.h:50
virtual IIndexEntry * getIndexEntry(int32_t position)=0
Get the IIndexEntry at the given position in this IStream object's index.
virtual IRational * getFrameRate()=0
Get the (sometimes estimated) frame rate of this container.
Direction
The direction this stream is going (based on the container).
Definition: IStream.h:59
virtual int32_t addIndexEntry(IIndexEntry *entry)=0
Adds an index entry into the stream's sorted index list.
ParseType
What types of parsing can we do on a call to IContainer#readNextPacket(IPacket).
Definition: IStream.h:222
@ PARSE_TIMESTAMPS
full parsing and interpolation of timestamps for frames not starting on a packet boundary
Definition: IStream.h:226
@ PARSE_FULL_ONCE
full parsing and repack of the first frame only, only implemented for H.264 currently
Definition: IStream.h:227
@ PARSE_HEADERS
Only parse headers, do not repack.
Definition: IStream.h:225
@ PARSE_FULL
full parsing and repack
Definition: IStream.h:224
virtual void setId(int32_t id)=0
Set the format-specific stream id.
virtual int64_t getNumFrames()=0
Returns the number of encoded frames if known.
virtual Direction getDirection()=0
Get the Direction this stream is pointing in.
virtual void setParseType(ParseType type)=0
Set the parse type the decoding codec should use.
virtual int32_t setStreamCoder(IStreamCoder *newCoder, bool assumeOnlyStream)=0
Sets the stream coder to use for this stream.
virtual int getIndex()=0
Get the relative position this stream has in the hosting IContainer object.
virtual int setBitstreamFilter(const char *name)=0
Set a bitstream filter on this stream.
virtual const char * getLanguage()=0
Get the 4-character language setting for this stream.
virtual void setMetaData(IMetaData *data)=0
Set the IMetaData on this object, overriding any previous meta data.
virtual IIndexEntry * findTimeStampEntryInIndex(int64_t wantedTimeStamp, int32_t flags)=0
Search for the given time stamp in the key-frame index for this IStream.
virtual int64_t getCurrentDts()=0
The current Decompression Time Stamp that will be used on this stream, in getTimeBase() units.
virtual IMetaData * getMetaData()=0
Get the IMetaData for this object, or null if none.
virtual int getId()=0
Return a container format specific id for this stream.
virtual int32_t stampOutputPacket(IPacket *packet)=0
Takes a packet destined for this stream, and stamps the stream index, and converts the time stamp to ...
virtual IContainer * getContainer()=0
Get the underlying container for this stream, or null if AVPKit doesn't know.
virtual int64_t getStartTime()=0
Return the start time, in getTimeBase() units, when this stream started.
virtual int64_t getDuration()=0
Return the duration, in getTimeBase() units, of this stream, or Global#NO_PTS if unknown.
virtual void setSampleAspectRatio(IRational *newRatio)=0
Sets the sample aspect ratio.
virtual IStreamCoder * getStreamCoder()=0
Get the StreamCoder than can manipulate this stream.
virtual IStream::ParseType getParseType()=0
Get how the decoding codec should parse data from this stream.
virtual int32_t setStreamCoder(IStreamCoder *newCoder)=0
Sets the stream coder to use for this stream.
virtual IRational * getTimeBase()=0
The time base in which all timestamps (e.g.
virtual IRational * getSampleAspectRatio()=0
Added in 1.17.
virtual int getNumIndexEntries()=0
Get the number of index entries in this stream.
virtual void setLanguage(const char *language)=0
Set the 4-character language setting for this stream.
virtual int32_t findTimeStampPositionInIndex(int64_t wantedTimeStamp, int32_t flags)=0
Search for the given time stamp in the key-frame index for this IStream.
Parent of all Ferry objects – it mains reference counts in native code.
Definition: RefCounted.h:85
WARNING: Do not use logging in this class, and do not set any static file variables to values other t...