Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-19 09:27:01

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