File indexing completed on 2025-01-18 10:04:15
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,
0045 int64_t theTimeUnits);
0046
0047
0048
0049
0050
0051 Standard_EXPORT static double StreamUnitsToSeconds (const AVStream& theStream,
0052 int64_t theTimeUnits);
0053
0054
0055
0056
0057 Standard_EXPORT static int64_t SecondsToUnits (double theTimeSeconds);
0058
0059
0060
0061
0062
0063 Standard_EXPORT static int64_t SecondsToUnits (const AVRational& theTimeBase,
0064 double theTimeSeconds);
0065
0066
0067
0068
0069
0070 Standard_EXPORT static int64_t StreamSecondsToUnits (const AVStream& theStream,
0071 double theTimeSeconds);
0072
0073
0074 Standard_EXPORT static TCollection_AsciiString FormatTime (double theSeconds);
0075
0076
0077 Standard_EXPORT static TCollection_AsciiString FormatTimeProgress (double theProgress,
0078 double theDuration);
0079
0080 public:
0081
0082
0083 Standard_EXPORT Media_FormatContext();
0084
0085
0086 Standard_EXPORT virtual ~Media_FormatContext();
0087
0088
0089 AVFormatContext* Context() const { return myFormatCtx; }
0090
0091
0092 Standard_EXPORT bool OpenInput (const TCollection_AsciiString& theInput);
0093
0094
0095 Standard_EXPORT void Close();
0096
0097
0098 Standard_EXPORT unsigned int NbSteams() const;
0099
0100
0101 Standard_EXPORT const AVStream& Stream (unsigned int theIndex) const;
0102
0103
0104 Standard_EXPORT TCollection_AsciiString StreamInfo (unsigned int theIndex,
0105 AVCodecContext* theCodecCtx = NULL) const;
0106
0107
0108 double PtsStartBase() const { return myPtsStartBase; }
0109
0110
0111 double Duration() const { return myDuration; }
0112
0113
0114 Standard_EXPORT bool ReadPacket (const Handle(Media_Packet)& thePacket);
0115
0116
0117 Standard_EXPORT bool SeekStream (unsigned int theStreamId,
0118 double theSeekPts,
0119 bool toSeekBack);
0120
0121
0122 Standard_EXPORT bool Seek (double theSeekPts,
0123 bool toSeekBack);
0124
0125 protected:
0126
0127 AVFormatContext* myFormatCtx;
0128 double myPtsStartBase;
0129 double myDuration;
0130
0131 };
0132
0133 #endif