Mir
screencast_stream.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2016 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Kevin DuBois <kevin.dubois@canonical.com>
17  */
18 
19 #ifndef MIR_CLIENT_SCREENCAST_STREAM_H
20 #define MIR_CLIENT_SCREENCAST_STREAM_H
21 
22 #include "mir_wait_handle.h"
24 #include "mir/egl_native_surface.h"
25 #include "mir/client_buffer.h"
26 #include "client_buffer_stream.h"
28 #include "mir/geometry/size.h"
29 
31 
32 #include <EGL/eglplatform.h>
33 
34 #include <queue>
35 #include <memory>
36 #include <mutex>
37 
38 namespace google
39 {
40 namespace protobuf
41 {
42 class Closure;
43 }
44 }
45 namespace mir
46 {
47 namespace logging
48 {
49 class Logger;
50 }
51 namespace protobuf
52 {
53 class BufferStream;
54 class BufferStreamParameters;
55 class Void;
56 }
57 namespace client
58 {
59 namespace rpc
60 {
61 class DisplayServer;
62 }
63 class ClientBufferFactory;
64 class ClientBuffer;
65 class ClientPlatform;
66 class PerfReport;
67 struct MemoryRegion;
69 {
70 public:
72  MirConnection* connection,
74  std::shared_ptr<ClientPlatform> const& native_window_factory,
75  mir::protobuf::BufferStream const& protobuf_bs);
76 
77  MirSurfaceParameters get_parameters() const override;
78  MirWaitHandle* next_buffer(std::function<void()> const& done) override;
79  std::shared_ptr<mir::client::ClientBuffer> get_current_buffer() override;
80  uint32_t get_current_buffer_id() override;
81  int swap_interval() const override;
82  MirWaitHandle* set_swap_interval(int interval) override;
83  void set_buffer_cache_size(unsigned int) override;
84 
85  EGLNativeWindowType egl_native_window() override;
86  std::shared_ptr<MemoryRegion> secure_for_cpu_write() override;
87 
88  void request_and_wait_for_next_buffer() override;
89  void request_and_wait_for_configure(MirSurfaceAttrib attrib, int) override;
90  MirNativeBuffer* get_current_buffer_package() override;
91  MirPlatformType platform_type() override;
92 
93  frontend::BufferStreamId rpc_id() const override;
94  bool valid() const override;
95 
96  void buffer_available(mir::protobuf::Buffer const& buffer) override;
97  void buffer_unavailable() override;
98  void set_size(geometry::Size) override;
99  MirWaitHandle* set_scale(float scale) override;
100  char const* get_error_message() const override;
101  MirConnection* connection() const override;
102 
103 private:
104  void process_buffer(protobuf::Buffer const& buffer);
105  void process_buffer(protobuf::Buffer const& buffer, std::unique_lock<std::mutex>&);
106  void screencast_buffer_received(std::function<void()> done);
107 
108  mutable std::mutex mutex;
109 
110  MirConnection* connection_;
111  mir::client::rpc::DisplayServer& display_server;
112  std::shared_ptr<ClientPlatform> const client_platform;
113  std::shared_ptr<ClientBufferFactory> const factory;
114  std::unique_ptr<mir::protobuf::BufferStream> protobuf_bs;
115  int const swap_interval_{1};
116 
117  std::shared_ptr<void> egl_native_window_;
118 
119  MirWaitHandle create_wait_handle;
120  MirWaitHandle release_wait_handle;
121  MirWaitHandle screencast_wait_handle;
122  MirWaitHandle interval_wait_handle;
123  std::unique_ptr<mir::protobuf::Void> protobuf_void;
124 
125  std::shared_ptr<MemoryRegion> secured_region;
126 
127  geometry::Size buffer_size;
128  std::string error_message;
129  ClientBufferDepository buffer_depository;
130 };
131 
132 }
133 }
134 
135 #endif // MIR_CLIENT_SCREENCAST_STREAM_H
Definition: size.h:30
All things Mir.
Definition: atomic_callback.h:25
Definition: mir_wait_handle.h:31
Responsible for taking the buffer data sent from the server and wrapping it in a ClientBuffer.
Definition: client_buffer_depository.h:46
Definition: mir_native_buffer.h:30
Definition: screencast_stream.h:68
Definition: egl_native_surface.h:31
MirSurfaceAttrib
Attributes of a surface that the client and server/shell may wish to get or set over the wire...
Definition: common.h:34
Definition: client_buffer_stream.h:68
Definition: mir_connection.h:96
Definition: buffer_stream.h:37
#define EGLNativeWindowType
Definition: client_buffer_stream.h:55
MirPlatformType
The native buffer type for the system the client is connected on.
Definition: client_types.h:200
Definition: mir_display_server.h:33
MirSurfaceParameters is the structure of minimum required information that you must provide to Mir in...
Definition: client_types.h:169

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Sep 8 14:50:19 UTC 2016