AVPKit
IPacket.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 IPACKET_H_
21 #define IPACKET_H_
22 
23 #include <com/avpkit/core/AVPKit.h>
24 #include <com/avpkit/core/IMediaData.h>
25 namespace com { namespace avpkit { namespace core
26 {
27 
49  class VS_API_AVPKIT IPacket : public IMediaData
50  {
51  public:
56  virtual void reset()=0;
57 
62  virtual bool isComplete()=0;
63 
73  virtual int64_t getPts()=0;
74 
82  virtual void setPts(int64_t aPts)=0;
83 
102  virtual int64_t getDts()=0;
103 
109  virtual void setDts(int64_t aDts)=0;
110 
115  virtual int32_t getSize()=0;
116 
121  virtual int32_t getMaxSize()=0;
122 
128  virtual int32_t getStreamIndex()=0;
129 
136  virtual int32_t getFlags()=0;
137 
143  virtual bool isKeyPacket()=0;
144 
149  virtual int64_t getDuration()=0;
150 
156  virtual int64_t getPosition()=0;
157 
173  virtual int32_t allocateNewPayload(int32_t payloadSize)=0;
174 
185  static IPacket* make();
186 
193  static IPacket* make(com::avpkit::ferry::IBuffer* buffer);
194 
195  protected:
196  IPacket();
197  virtual ~IPacket();
198 
199  public:
200  /*
201  * Added for 1.19
202  *
203  */
204 
210  virtual void setKeyPacket(bool keyPacket)=0;
211 
217  virtual void setFlags(int32_t flags)=0;
218 
225  virtual void setComplete(bool complete, int32_t size)=0;
226 
232  virtual void setStreamIndex(int32_t streamIndex)=0;
233 
234  /*
235  * Added for 2.1
236  */
237 
243  virtual void setDuration(int64_t duration)=0;
244 
250  virtual void setPosition(int64_t position)=0;
251 
267  static IPacket* make(IPacket *packet, bool copyData);
268 
281  static IPacket* make(int32_t size);
282 
283 
284 
285  };
286 
287 }}}
288 
289 #endif /*IPACKET_H_*/
The parent class of all media objects than can be gotten from an IStream.
Definition: IMediaData.h:34
Represents an encoded piece of data that can be placed in an IContainer for a given IStream of data.
Definition: IPacket.h:50
virtual void reset()=0
Clear out any data in this packet, but leaves the buffer available for reuse.
virtual void setComplete(bool complete, int32_t size)=0
Set if this packet is complete, and what the total size of the data should be assumed to be.
virtual void setStreamIndex(int32_t streamIndex)=0
Set the stream index for this packet.
virtual int32_t getMaxSize()=0
Get the maximum size (in bytes) of payload this packet can hold.
virtual bool isKeyPacket()=0
Does this packet contain Key data? i.e.
virtual int64_t getDuration()=0
Return the duration of this packet, in units of getTimeBase().
virtual void setPosition(int64_t position)=0
Set the position.
virtual void setDts(int64_t aDts)=0
Set a new Decompression Time Stamp (DTS) for this packet.
virtual int64_t getPosition()=0
Return the position (in bytes) of this packet in the stream.
virtual int32_t getStreamIndex()=0
Get the container-specific index for the stream this packet is part of.
virtual int64_t getDts()=0
Get the Decompression Time Stamp (DTS) for this packet.
virtual void setPts(int64_t aPts)=0
Set a new Presentation Time Stamp (PTS) for this packet.
virtual void setDuration(int64_t duration)=0
Set the duration.
virtual bool isComplete()=0
Is this packet complete.
virtual int64_t getPts()=0
Get the Presentation Time Stamp (PTS) for this packet.
virtual int32_t allocateNewPayload(int32_t payloadSize)=0
Discard the current payload and allocate a new payload.
virtual int32_t getFlags()=0
Get any flags set on this packet, as a 4-byte binary-ORed bit-mask.
virtual void setFlags(int32_t flags)=0
Set any internal flags.
virtual int32_t getSize()=0
Get the size in bytes of the payload currently in this packet.
virtual void setKeyPacket(bool keyPacket)=0
Set if this is a key packet.
Allows Java code to get data from a native buffers, and optionally modify native memory directly.
Definition: IBuffer.h:54
WARNING: Do not use logging in this class, and do not set any static file variables to values other t...