1 // Created by: Kirill GAVRILOV
2 // Copyright (c) 2019 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 // activate some C99 macros like UINT64_C in "stdint.h" which used by FFmpeg
16 #ifndef __STDC_CONSTANT_MACROS
17 #define __STDC_CONSTANT_MACROS
20 #include <Media_Packet.hxx>
23 #include <Standard_WarningsDisable.hxx>
26 #include <libavcodec/avcodec.h>
28 #include <Standard_WarningsRestore.hxx>
31 IMPLEMENT_STANDARD_RTTIEXT(Media_Packet, Standard_Transient)
33 // =======================================================================
34 // function : Media_Packet
36 // =======================================================================
37 Media_Packet::Media_Packet()
41 myPacket = av_packet_alloc();
45 // =======================================================================
46 // function : ~Media_Packet
48 // =======================================================================
49 Media_Packet::~Media_Packet()
52 av_packet_free (&myPacket);
56 // =======================================================================
59 // =======================================================================
60 void Media_Packet::Unref()
63 av_packet_unref (myPacket);
67 // =======================================================================
70 // =======================================================================
71 const uint8_t* Media_Packet::Data() const
74 return myPacket->data;
80 // =======================================================================
81 // function : ChangeData
83 // =======================================================================
84 uint8_t* Media_Packet::ChangeData()
87 return myPacket->data;
93 // =======================================================================
96 // =======================================================================
97 int Media_Packet::Size() const
100 return myPacket->size;
106 // =======================================================================
109 // =======================================================================
110 int64_t Media_Packet::Pts() const
113 return myPacket->pts;
119 // =======================================================================
122 // =======================================================================
123 int64_t Media_Packet::Dts() const
126 return myPacket->dts;
132 // =======================================================================
133 // function : Duration
135 // =======================================================================
136 int64_t Media_Packet::Duration() const
139 return myPacket->duration;
145 // =======================================================================
146 // function : StreamIndex
148 // =======================================================================
149 int Media_Packet::StreamIndex() const
152 return myPacket->stream_index;
158 // =======================================================================
159 // function : IsKeyFrame
161 // =======================================================================
162 bool Media_Packet::IsKeyFrame() const
165 return (myPacket->flags & AV_PKT_FLAG_KEY) != 0;
171 // =======================================================================
172 // function : SetKeyFrame
174 // =======================================================================
175 void Media_Packet::SetKeyFrame()
178 myPacket->flags |= AV_PKT_FLAG_KEY;