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"
23 #include "mir/egl_native_surface.h"
24 #include "mir/client_buffer.h"
25 #include "client_buffer_stream.h"
27 #include "mir/geometry/size.h"
28 
30 
31 #include <EGL/eglplatform.h>
32 
33 #include <queue>
34 #include <memory>
35 #include <mutex>
36 
37 namespace google
38 {
39 namespace protobuf
40 {
41 class Closure;
42 }
43 }
44 namespace mir
45 {
46 namespace logging
47 {
48 class Logger;
49 }
50 namespace protobuf
51 {
52 class BufferStream;
53 class BufferStreamParameters;
54 class Void;
55 }
56 namespace client
57 {
58 namespace rpc
59 {
60 class DisplayServer;
61 }
62 class ClientBufferFactory;
63 class ClientBuffer;
64 class ClientPlatform;
65 class PerfReport;
66 struct MemoryRegion;
68 {
69 public:
71  MirConnection* connection,
73  std::shared_ptr<ClientPlatform> const& native_window_factory,
74  mir::protobuf::BufferStream const& protobuf_bs);
75 
76  MirSurfaceParameters get_parameters() const override;
77  MirWaitHandle* next_buffer(std::function<void()> const& done) override;
78  std::shared_ptr<mir::client::ClientBuffer> get_current_buffer() override;
79  uint32_t get_current_buffer_id() override;
80  int swap_interval() const override;
81  MirWaitHandle* set_swap_interval(int interval) override;
82  void set_buffer_cache_size(unsigned int) override;
83 
84  EGLNativeWindowType egl_native_window() override;
85  std::shared_ptr<MemoryRegion> secure_for_cpu_write() override;
86 
87  void request_and_wait_for_next_buffer() override;
88  void request_and_wait_for_configure(MirSurfaceAttrib attrib, int) override;
89  MirNativeBuffer* get_current_buffer_package() override;
90  MirPlatformType platform_type() override;
91 
92  frontend::BufferStreamId rpc_id() const override;
93  bool valid() const override;
94 
95  void buffer_available(mir::protobuf::Buffer const& buffer) override;
96  void buffer_unavailable() override;
97  void set_size(geometry::Size) override;
98  MirWaitHandle* set_scale(float scale) override;
99  char const* get_error_message() const override;
100  MirConnection* connection() const override;
101 
102 private:
103  void process_buffer(protobuf::Buffer const& buffer);
104  void process_buffer(protobuf::Buffer const& buffer, std::unique_lock<std::mutex>&);
105  void screencast_buffer_received(std::function<void()> done);
106 
107  mutable std::mutex mutex;
108 
109  MirConnection* connection_;
110  mir::client::rpc::DisplayServer& display_server;
111  std::shared_ptr<ClientPlatform> const client_platform;
112  std::shared_ptr<ClientBufferFactory> const factory;
113  std::unique_ptr<mir::protobuf::BufferStream> protobuf_bs;
114  int const swap_interval_{1};
115 
116  std::shared_ptr<void> egl_native_window_;
117 
118  MirWaitHandle create_wait_handle;
119  MirWaitHandle release_wait_handle;
120  MirWaitHandle screencast_wait_handle;
121  MirWaitHandle interval_wait_handle;
122  std::unique_ptr<mir::protobuf::Void> protobuf_void;
123 
124  std::shared_ptr<MemoryRegion> secured_region;
125 
126  geometry::Size buffer_size;
127  std::string error_message;
128  std::shared_ptr<ClientBuffer> current_buffer;
129  int current_id {-1};
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
Definition: mir_native_buffer.h:30
Definition: screencast_stream.h:67
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:69
Definition: mir_connection.h:96
Definition: buffer_stream.h:37
#define EGLNativeWindowType
Definition: client_buffer_stream.h:56
MirPlatformType
The native buffer type for the system the client is connected on.
Definition: client_types.h:197
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:166

Copyright © 2012-2015 Canonical Ltd.
Generated on Wed Mar 30 00:29:56 UTC 2016