Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:55

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 _AIS_MediaPlayer_HeaderFile
0016 #define _AIS_MediaPlayer_HeaderFile
0017 
0018 #include <AIS_InteractiveObject.hxx>
0019 #include <Graphic3d_MediaTextureSet.hxx>
0020 
0021 class Media_PlayerContext;
0022 
0023 //! Presentation for video playback.
0024 class AIS_MediaPlayer : public AIS_InteractiveObject
0025 {
0026   DEFINE_STANDARD_RTTIEXT(AIS_MediaPlayer, AIS_InteractiveObject)
0027 public:
0028 
0029   //! Empty constructor.
0030   Standard_EXPORT AIS_MediaPlayer();
0031 
0032   //! Destructor.
0033   Standard_EXPORT virtual ~AIS_MediaPlayer();
0034 
0035   //! Setup callback to be called on queue progress (e.g. when new frame should be displayed).
0036   void SetCallback (Graphic3d_MediaTextureSet::CallbackOnUpdate_t theCallbackFunction, void* theCallbackUserPtr)
0037   {
0038     myFramePair->SetCallback (theCallbackFunction, theCallbackUserPtr);
0039   }
0040 
0041   //! Open specified file.
0042   Standard_EXPORT void OpenInput (const TCollection_AsciiString& thePath,
0043                                   Standard_Boolean theToWait);
0044 
0045   //! Display new frame.
0046   Standard_EXPORT bool PresentFrame (const Graphic3d_Vec2i& theLeftCorner,
0047                                      const Graphic3d_Vec2i& theMaxSize);
0048 
0049   //! Return player context.
0050   const Handle(Media_PlayerContext)& PlayerContext() const { return myFramePair->PlayerContext(); }
0051 
0052   //! Switch playback state.
0053   Standard_EXPORT void PlayPause();
0054 
0055   //! Schedule player to be closed.
0056   void SetClosePlayer()
0057   {
0058     myToClosePlayer = true;
0059     myFramePair->Notify();
0060   }
0061 
0062   //! Return duration.
0063   double Duration() const { return myFramePair->Duration(); }
0064 
0065 //! @name AIS_InteractiveObject interface
0066 protected:
0067 
0068   //! Accept only display mode 0.
0069   virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
0070 
0071   //! Compute presentation.
0072   Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
0073                                         const Handle(Prs3d_Presentation)& thePrs,
0074                                         const Standard_Integer theMode) Standard_OVERRIDE;
0075 
0076   //! Compute selection
0077   Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSel,
0078                                                  const Standard_Integer theMode) Standard_OVERRIDE;
0079 
0080 protected:
0081 
0082   //! Update frame size.
0083   Standard_EXPORT bool updateSize (const Graphic3d_Vec2i& theLeftCorner,
0084                                    const Graphic3d_Vec2i& theMaxSize);
0085 
0086 protected:
0087 
0088   Handle(Graphic3d_MediaTextureSet)  myFramePair;
0089   Handle(Graphic3d_AspectFillArea3d) myFrameAspect;
0090   Graphic3d_Vec2i     myFrameBottomLeft;
0091   Graphic3d_Vec2i     myFrameSize;
0092   bool                myToClosePlayer;
0093 
0094 };
0095 
0096 #endif // _AIS_MediaPlayer_HeaderFile