1 // Created by: Kirill GAVRILOV
2 // Copyright (c) 2019 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #ifndef _AIS_MediaPlayer_HeaderFile
16 #define _AIS_MediaPlayer_HeaderFile
18 #include <AIS_InteractiveObject.hxx>
19 #include <Graphic3d_MediaTextureSet.hxx>
21 class Media_PlayerContext;
23 //! Presentation for video playback.
24 class AIS_MediaPlayer : public AIS_InteractiveObject
26 DEFINE_STANDARD_RTTIEXT(AIS_MediaPlayer, AIS_InteractiveObject)
29 //! Empty constructor.
30 Standard_EXPORT AIS_MediaPlayer();
33 Standard_EXPORT virtual ~AIS_MediaPlayer();
35 //! Setup callback to be called on queue progress (e.g. when new frame should be displayed).
36 void SetCallback (Graphic3d_MediaTextureSet::CallbackOnUpdate_t theCallbackFunction, void* theCallbackUserPtr)
38 myFramePair->SetCallback (theCallbackFunction, theCallbackUserPtr);
41 //! Open specified file.
42 Standard_EXPORT void OpenInput (const TCollection_AsciiString& thePath,
43 Standard_Boolean theToWait);
45 //! Display new frame.
46 Standard_EXPORT bool PresentFrame (const Graphic3d_Vec2i& theLeftCorner,
47 const Graphic3d_Vec2i& theMaxSize);
49 //! Return player context.
50 const Handle(Media_PlayerContext)& PlayerContext() const { return myFramePair->PlayerContext(); }
52 //! Switch playback state.
53 Standard_EXPORT void PlayPause();
55 //! Schedule player to be closed.
58 myToClosePlayer = true;
59 myFramePair->Notify();
63 double Duration() const { return myFramePair->Duration(); }
65 //! @name AIS_InteractiveObject interface
68 //! Accept only display mode 0.
69 virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
71 //! Compute presentation.
72 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
73 const Handle(Prs3d_Presentation)& thePrs,
74 const Standard_Integer theMode) Standard_OVERRIDE;
77 Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSel,
78 const Standard_Integer theMode) Standard_OVERRIDE;
82 //! Update frame size.
83 Standard_EXPORT bool updateSize (const Graphic3d_Vec2i& theLeftCorner,
84 const Graphic3d_Vec2i& theMaxSize);
88 Handle(Graphic3d_MediaTextureSet) myFramePair;
89 Handle(Graphic3d_AspectFillArea3d) myFrameAspect;
90 Graphic3d_Vec2i myFrameBottomLeft;
91 Graphic3d_Vec2i myFrameSize;
96 #endif // _AIS_MediaPlayer_HeaderFile