98e6c6d1 |
1 | // Created by: Kirill GAVRILOV |
2 | // Copyright (c) 2019 OPEN CASCADE SAS |
3 | // |
4 | // This file is part of Open CASCADE Technology software library. |
5 | // |
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. |
11 | // |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
14 | |
15 | #ifndef _AIS_MediaPlayer_HeaderFile |
16 | #define _AIS_MediaPlayer_HeaderFile |
17 | |
18 | #include <AIS_InteractiveObject.hxx> |
19 | #include <Graphic3d_MediaTextureSet.hxx> |
20 | |
21 | class Media_PlayerContext; |
22 | |
23 | //! Presentation for video playback. |
24 | class AIS_MediaPlayer : public AIS_InteractiveObject |
25 | { |
26 | DEFINE_STANDARD_RTTIEXT(AIS_MediaPlayer, AIS_InteractiveObject) |
27 | public: |
28 | |
29 | //! Empty constructor. |
30 | Standard_EXPORT AIS_MediaPlayer(); |
31 | |
32 | //! Destructor. |
33 | Standard_EXPORT virtual ~AIS_MediaPlayer(); |
34 | |
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) |
37 | { |
38 | myFramePair->SetCallback (theCallbackFunction, theCallbackUserPtr); |
39 | } |
40 | |
41 | //! Open specified file. |
42 | Standard_EXPORT void OpenInput (const TCollection_AsciiString& thePath, |
43 | Standard_Boolean theToWait); |
44 | |
45 | //! Display new frame. |
46 | Standard_EXPORT bool PresentFrame (const Graphic3d_Vec2i& theLeftCorner, |
47 | const Graphic3d_Vec2i& theMaxSize); |
48 | |
49 | //! Return player context. |
50 | const Handle(Media_PlayerContext)& PlayerContext() const { return myFramePair->PlayerContext(); } |
51 | |
52 | //! Switch playback state. |
53 | Standard_EXPORT void PlayPause(); |
54 | |
55 | //! Schedule player to be closed. |
56 | void SetClosePlayer() |
57 | { |
58 | myToClosePlayer = true; |
59 | myFramePair->Notify(); |
60 | } |
61 | |
62 | //! Return duration. |
63 | double Duration() const { return myFramePair->Duration(); } |
64 | |
65 | //! @name AIS_InteractiveObject interface |
66 | protected: |
67 | |
68 | //! Accept only display mode 0. |
69 | virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; } |
70 | |
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; |
75 | |
76 | //! Compute selection |
77 | Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSel, |
78 | const Standard_Integer theMode) Standard_OVERRIDE; |
79 | |
80 | protected: |
81 | |
82 | //! Update frame size. |
83 | Standard_EXPORT bool updateSize (const Graphic3d_Vec2i& theLeftCorner, |
84 | const Graphic3d_Vec2i& theMaxSize); |
85 | |
86 | protected: |
87 | |
88 | Handle(Graphic3d_MediaTextureSet) myFramePair; |
89 | Handle(Graphic3d_AspectFillArea3d) myFrameAspect; |
90 | Graphic3d_Vec2i myFrameBottomLeft; |
91 | Graphic3d_Vec2i myFrameSize; |
92 | bool myToClosePlayer; |
93 | |
94 | }; |
95 | |
96 | #endif // _AIS_MediaPlayer_HeaderFile |