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_PlayerContext_HeaderFile
0016 #define _Media_PlayerContext_HeaderFile
0017
0018 #include <Media_IFrameQueue.hxx>
0019 #include <Media_Timer.hxx>
0020 #include <OSD_Thread.hxx>
0021 #include <Standard_Condition.hxx>
0022 #include <Standard_Mutex.hxx>
0023 #include <Standard_Transient.hxx>
0024 #include <Standard_Type.hxx>
0025 #include <TCollection_AsciiString.hxx>
0026
0027 class Media_BufferPool;
0028 class Media_CodecContext;
0029 class Media_FormatContext;
0030 class Media_Scaler;
0031
0032
0033 class Media_PlayerContext : public Standard_Transient
0034 {
0035 DEFINE_STANDARD_RTTIEXT(Media_PlayerContext, Standard_Transient)
0036 public:
0037
0038
0039
0040
0041 Standard_EXPORT static Handle(Media_Frame) DumpFirstFrame (const TCollection_AsciiString& theSrcVideo,
0042 TCollection_AsciiString& theMediaInfo);
0043
0044
0045
0046
0047
0048
0049 Standard_EXPORT static bool DumpFirstFrame (const TCollection_AsciiString& theSrcVideo,
0050 const TCollection_AsciiString& theOutImage,
0051 TCollection_AsciiString& theMediaInfo,
0052 int theMaxSize = 0);
0053
0054 public:
0055
0056
0057
0058
0059 Standard_EXPORT Media_PlayerContext (Media_IFrameQueue* theFrameQueue);
0060
0061
0062 Standard_EXPORT virtual ~Media_PlayerContext();
0063
0064 public:
0065
0066
0067 Standard_EXPORT void SetInput (const TCollection_AsciiString& theInputPath,
0068 Standard_Boolean theToWait);
0069
0070
0071 Standard_EXPORT void PlaybackState (Standard_Boolean& theIsPaused,
0072 Standard_Real& theProgress,
0073 Standard_Real& theDuration);
0074
0075
0076 Standard_EXPORT void PlayPause (Standard_Boolean& theIsPaused,
0077 Standard_Real& theProgress,
0078 Standard_Real& theDuration);
0079
0080
0081 Standard_EXPORT void Seek (Standard_Real thePosSec);
0082
0083
0084 void Pause() { pushPlayEvent (Media_PlayerEvent_PAUSE); }
0085
0086
0087 void Resume() { pushPlayEvent (Media_PlayerEvent_RESUME); }
0088
0089
0090 bool ToForceRgb() const { return myToForceRgb; }
0091
0092
0093 void SetForceRgb (bool theToForce) { myToForceRgb = theToForce; }
0094
0095 private:
0096
0097
0098 enum Media_PlayerEvent
0099 {
0100 Media_PlayerEvent_NONE = 0,
0101 Media_PlayerEvent_PAUSE,
0102 Media_PlayerEvent_RESUME,
0103 Media_PlayerEvent_SEEK,
0104 Media_PlayerEvent_NEXT,
0105 };
0106
0107 private:
0108
0109
0110 Standard_EXPORT void doThreadLoop();
0111
0112
0113 Standard_EXPORT void pushPlayEvent (Media_PlayerEvent thePlayEvent);
0114
0115
0116 Standard_EXPORT bool popPlayEvent (Media_PlayerEvent& thePlayEvent,
0117 const Handle(Media_FormatContext)& theFormatCtx,
0118 const Handle(Media_CodecContext)& theVideoCtx,
0119 const Handle(Media_Frame)& theFrame);
0120
0121
0122 bool receiveFrame (const Handle(Media_Frame)& theFrame,
0123 const Handle(Media_CodecContext)& theVideoCtx);
0124
0125
0126 static Standard_Address doThreadWrapper (Standard_Address theData)
0127 {
0128 Media_PlayerContext* aThis = (Media_PlayerContext* )theData;
0129 aThis->doThreadLoop();
0130 return 0;
0131 }
0132
0133 private:
0134
0135 Media_IFrameQueue* myFrameQueue;
0136 OSD_Thread myThread;
0137 Standard_Mutex myMutex;
0138 Standard_Condition myWakeEvent;
0139 Standard_Condition myNextEvent;
0140 Media_Timer myTimer;
0141 Standard_Real myDuration;
0142
0143 Handle(Media_BufferPool) myBufferPools[4];
0144 Handle(Media_Frame) myFrameTmp;
0145 Handle(Media_Scaler) myScaler;
0146 bool myToForceRgb;
0147
0148 volatile bool myToShutDown;
0149 TCollection_AsciiString myInputPath;
0150 volatile Standard_Real mySeekTo;
0151 volatile Media_PlayerEvent myPlayEvent;
0152
0153 };
0154
0155 #endif