Ocean
FrameMediumView.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_PLATFORM_APPLE_MACOS_FRAME_MEDIUM_VIEW_H
9 #define META_OCEAN_PLATFORM_APPLE_MACOS_FRAME_MEDIUM_VIEW_H
10 
13 
14 #include "ocean/base/Timestamp.h"
15 #include "ocean/base/Thread.h"
16 
18 
19 #ifndef __OBJC__
20  #error Platform::Apple::MacOS::FrameMediumView.h needs to be included from an ObjectiveC++ file
21 #endif
22 
23 namespace Ocean
24 {
25 
26 namespace Platform
27 {
28 
29 namespace Apple
30 {
31 
32 namespace MacOS
33 {
34 
35 /**
36  * This class implements a view displaying a frame medium.
37  * In general, the display performance/efficiency is not very good,<br>
38  * use GPU optimized solutions instead whenever performance matters.<br>
39  * This class can be seen as a OpenGLFrameMediumViewController equivalent not using OpenGLES.
40  * @ingroup platformapplemacos
41  */
43  public FrameView,
44  protected Thread
45 {
46  public:
47 
48  /**
49  * Default constructor creating an invalid media view object.
50  */
51  FrameMediumView() = default;
52 
53  /**
54  * Destructs this media view object and releases the medium object.
55  */
56  ~FrameMediumView() override;
57 
58  /**
59  * Move constructor.
60  * @param view View object to move
61  */
62  FrameMediumView(FrameMediumView&& view) noexcept;
63 
64  /**
65  * Creates a new view object with specified size and dimension.
66  * @param rect The rect defining the size and dimension
67  */
68  explicit FrameMediumView(const NSRect& rect);
69 
70  /**
71  * Creates a new view object with specified size and dimension.
72  * @param left The horizontal start position of this view, with range (-infinity, infinity)
73  * @param top The vertical start position of this view in pixel, with range (-infinity, infinity)
74  * @param width The width of the view in pixel, with range [0, infinity)
75  * @param height The height of the view in pixel, with range [0, infinity)
76  */
77  FrameMediumView(const int left, const int top, const unsigned int width, const unsigned int height);
78 
79  /**
80  * Sets or replaces the frame medium to be displayed in the view.
81  * @param frameMedium The frame medium to be displayed, an invalid object to remove the current frame medium
82  */
83  void setFrameMedium(const Media::FrameMediumRef& frameMedium);
84 
85  /**
86  * Move operator.
87  * @param view View object to be moved
88  * @return Reference to this object
89  */
90  inline FrameMediumView& operator=(FrameMediumView&& view) noexcept;
91 
92  protected:
93 
94  /**
95  * Thread run function.
96  */
97  void threadRun() override;
98 
99  protected:
100 
101  /// The frame medium delivering the frames to be displayed.
103 
104  /// The timestamp of the most recent frame that has been displyed.
106 };
107 
109 {
110  if (this != &view)
111  {
112  setFrameMedium(view.frameMedium_);
113  frameTimestamp_ = view.frameTimestamp_;
114 
115  FrameView::operator=(std::move(view));
116 
117  view.frameMedium_.release();
118  view.frameTimestamp_.toInvalid();
119  }
120 
121  return *this;
122 }
123 
124 }
125 
126 }
127 
128 }
129 
130 }
131 
132 #endif // META_OCEAN_PLATFORM_APPLE_MACOS_FRAME_MEDIUM_VIEW_H
This class implements a view displaying a frame medium.
Definition: FrameMediumView.h:45
FrameMediumView & operator=(FrameMediumView &&view) noexcept
Move operator.
Definition: FrameMediumView.h:108
void threadRun() override
Thread run function.
void setFrameMedium(const Media::FrameMediumRef &frameMedium)
Sets or replaces the frame medium to be displayed in the view.
Media::FrameMediumRef frameMedium_
The frame medium delivering the frames to be displayed.
Definition: FrameMediumView.h:102
FrameMediumView()=default
Default constructor creating an invalid media view object.
FrameMediumView(FrameMediumView &&view) noexcept
Move constructor.
FrameMediumView(const int left, const int top, const unsigned int width, const unsigned int height)
Creates a new view object with specified size and dimension.
Timestamp frameTimestamp_
The timestamp of the most recent frame that has been displyed.
Definition: FrameMediumView.h:105
~FrameMediumView() override
Destructs this media view object and releases the medium object.
FrameMediumView(const NSRect &rect)
Creates a new view object with specified size and dimension.
This class implements a view displaying a frame.
Definition: FrameView.h:40
FrameView & operator=(FrameView &&view) noexcept
Move operator.
This class implements a thread.
Definition: Thread.h:115
This class implements a timestamp.
Definition: Timestamp.h:36
SmartMediumRef< FrameMedium > FrameMediumRef
Definition of a smart medium reference holding a frame medium object.
Definition: FrameMedium.h:32
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15