File indexing completed on 2026-09-20 09:18:21
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef _Media_FormatContext_HeaderFile
0016 #define _Media_FormatContext_HeaderFile
0017
0018 #include <Media_Packet.hxx>
0019
0020 #include <TCollection_AsciiString.hxx>
0021
0022 struct AVCodecContext;
0023 struct AVFormatContext;
0024 struct AVStream;
0025 struct AVRational;
0026
0027
0028 class Media_FormatContext : public Standard_Transient
0029 {
0030 DEFINE_STANDARD_RTTIEXT(Media_FormatContext, Standard_Transient)
0031 public:
0032
0033 Standard_EXPORT static TCollection_AsciiString FormatAVErrorDescription(int theErrCodeAV);
0034
0035
0036
0037
0038 Standard_EXPORT static double FormatUnitsToSeconds(int64_t theTimeUnits);
0039
0040
0041
0042
0043
0044 Standard_EXPORT static double UnitsToSeconds(const AVRational& theTimeBase, int64_t theTimeUnits);
0045
0046
0047
0048
0049
0050 Standard_EXPORT static double StreamUnitsToSeconds(const AVStream& theStream,
0051 int64_t theTimeUnits);
0052
0053
0054
0055
0056 Standard_EXPORT static int64_t SecondsToUnits(double theTimeSeconds);
0057
0058
0059
0060
0061
0062 Standard_EXPORT static int64_t SecondsToUnits(const AVRational& theTimeBase,
0063 double theTimeSeconds);
0064
0065
0066
0067
0068
0069 Standard_EXPORT static int64_t StreamSecondsToUnits(const AVStream& theStream,
0070 double theTimeSeconds);
0071
0072
0073 Standard_EXPORT static TCollection_AsciiString FormatTime(double theSeconds);
0074
0075
0076 Standard_EXPORT static TCollection_AsciiString FormatTimeProgress(double theProgress,
0077 double theDuration);
0078
0079 public:
0080
0081 Standard_EXPORT Media_FormatContext();
0082
0083
0084 Standard_EXPORT ~Media_FormatContext() override;
0085
0086
0087 AVFormatContext* Context() const { return myFormatCtx; }
0088
0089
0090 Standard_EXPORT bool OpenInput(const TCollection_AsciiString& theInput);
0091
0092
0093 Standard_EXPORT void Close();
0094
0095
0096 Standard_EXPORT unsigned int NbSteams() const;
0097
0098
0099 Standard_EXPORT const AVStream& Stream(unsigned int theIndex) const;
0100
0101
0102 Standard_EXPORT TCollection_AsciiString StreamInfo(unsigned int theIndex,
0103 AVCodecContext* theCodecCtx = nullptr) const;
0104
0105
0106 double PtsStartBase() const { return myPtsStartBase; }
0107
0108
0109 double Duration() const { return myDuration; }
0110
0111
0112 Standard_EXPORT bool ReadPacket(const occ::handle<Media_Packet>& thePacket);
0113
0114
0115 Standard_EXPORT bool SeekStream(unsigned int theStreamId, double theSeekPts, bool toSeekBack);
0116
0117
0118 Standard_EXPORT bool Seek(double theSeekPts, bool toSeekBack);
0119
0120 protected:
0121 AVFormatContext* myFormatCtx;
0122 double myPtsStartBase;
0123 double myDuration;
0124 };
0125
0126 #endif