Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:48

0001 // Created by: Kirill GAVRILOV
0002 // Copyright (c) 2019 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014 
0015 #ifndef _Graphic3d_MediaTextureSet_HeaderFile
0016 #define _Graphic3d_MediaTextureSet_HeaderFile
0017 
0018 #include <Media_IFrameQueue.hxx>
0019 #include <Graphic3d_MediaTexture.hxx>
0020 #include <Graphic3d_TextureSet.hxx>
0021 
0022 class Graphic3d_ShaderProgram;
0023 class Media_PlayerContext;
0024 
0025 //! Texture adapter for Media_Frame.
0026 class Graphic3d_MediaTextureSet : public Graphic3d_TextureSet, public Media_IFrameQueue
0027 {
0028   DEFINE_STANDARD_RTTIEXT(Graphic3d_MediaTextureSet, Graphic3d_TextureSet)
0029 public:
0030 
0031   //! Callback definition.
0032   typedef void (*CallbackOnUpdate_t)(void* theUserPtr);
0033 
0034 public:
0035 
0036   //! Empty constructor.
0037   Standard_EXPORT Graphic3d_MediaTextureSet();
0038 
0039   //! Setup callback to be called on queue progress (e.g. when new frame should be displayed).
0040   Standard_EXPORT void SetCallback (CallbackOnUpdate_t theCallbackFunction, void* theCallbackUserPtr);
0041 
0042   //! Call callback.
0043   Standard_EXPORT void Notify();
0044 
0045   //! Return input media.
0046   const TCollection_AsciiString& Input() const { return myInput; }
0047 
0048   //! Open specified file.
0049   //! Passing an empty path would close current input.
0050   Standard_EXPORT void OpenInput (const TCollection_AsciiString& thePath,
0051                                   Standard_Boolean theToWait);
0052 
0053   //! Return player context; it can be NULL until first OpenInput().
0054   const Handle(Media_PlayerContext)& PlayerContext() const { return myPlayerCtx; }
0055 
0056   //! Swap front/back frames.
0057   Standard_EXPORT Standard_Boolean SwapFrames();
0058 
0059   //! Return front frame dimensions.
0060   Graphic3d_Vec2i FrameSize() const { return myFrameSize; }
0061 
0062   //! Return shader program for displaying texture set.
0063   Handle(Graphic3d_ShaderProgram) ShaderProgram() const
0064   {
0065     if (myIsPlanarYUV)
0066     {
0067       return myIsFullRangeYUV ? myShaderYUVJ : myShaderYUV;
0068     }
0069     return Handle(Graphic3d_ShaderProgram)();
0070   }
0071 
0072   //! Return TRUE if texture set defined 3 YUV planes.
0073   Standard_Boolean IsPlanarYUV() const { return myIsPlanarYUV; }
0074 
0075   //! Return TRUE if YUV range is full.
0076   Standard_Boolean IsFullRangeYUV() const { return myIsFullRangeYUV; }
0077 
0078   //! Return duration in seconds.
0079   double Duration() const { return myDuration; }
0080 
0081   //! Return playback progress in seconds.
0082   double Progress() const { return myProgress; }
0083 
0084 //! @name Media_IFrameQueue interface
0085 private:
0086 
0087   //! Lock the frame for decoding into.
0088   Standard_EXPORT virtual Handle(Media_Frame) LockFrame() Standard_OVERRIDE;
0089 
0090   //! Release the frame to present decoding results.
0091   Standard_EXPORT virtual void ReleaseFrame (const Handle(Media_Frame)& theFrame) Standard_OVERRIDE;
0092 
0093 protected:
0094 
0095   Handle(Media_PlayerContext)     myPlayerCtx;         //!< player context
0096   Handle(Media_Frame)             myFramePair[2];      //!< front/back frames pair
0097   Handle(Graphic3d_ShaderProgram) myShaderYUV;         //!< shader program for YUV  texture set
0098   Handle(Graphic3d_ShaderProgram) myShaderYUVJ;        //!< shader program for YUVJ texture set
0099   Handle(Standard_HMutex)         myMutex;             //!< mutex for accessing frames
0100   TCollection_AsciiString         myInput;             //!< input media
0101   CallbackOnUpdate_t              myCallbackFunction;  //!< callback function
0102   void*                           myCallbackUserPtr;   //!< callback data
0103   Graphic3d_Vec2i                 myFrameSize;         //!< front frame size
0104   Standard_Real                   myProgress;          //!< playback progress in seconds
0105   Standard_Real                   myDuration;          //!< stream duration
0106   Standard_Integer                myFront;             //!< index of front texture
0107   Standard_Boolean                myToPresentFrame;    //!< flag
0108   Standard_Boolean                myIsPlanarYUV;       //!< front frame contains planar YUV data or native texture format
0109   Standard_Boolean                myIsFullRangeYUV;    //!< front frame defines full-range or reduced-range YUV
0110 
0111 };
0112 
0113 #endif // _Graphic3d_MediaTextureSet_HeaderFile