RetroArch
netplay_private.h
Go to the documentation of this file.
1 /* RetroArch - A frontend for libretro.
2  * Copyright (C) 2010-2014 - Hans-Kristian Arntzen
3  * Copyright (C) 2011-2017 - Daniel De Matteis
4  * Copyright (C) 2016-2017 - Gregor Richards
5  *
6  * RetroArch is free software: you can redistribute it and/or modify it under the terms
7  * of the GNU General Public License as published by the Free Software Found-
8  * ation, either version 3 of the License, or (at your option) any later version.
9  *
10  * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  * PURPOSE. See the GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along with RetroArch.
15  * If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __RARCH_NETPLAY_PRIVATE_H
19 #define __RARCH_NETPLAY_PRIVATE_H
20 
21 #include "netplay.h"
22 
23 #include <net/net_compat.h>
24 #include <net/net_natt.h>
25 #include <features/features_cpu.h>
26 #include <streams/trans_stream.h>
27 
28 #include "../../msg_hash.h"
29 #include "../../verbosity.h"
30 
31 #define NETPLAY_PROTOCOL_VERSION 5
32 
33 #define RARCH_DEFAULT_PORT 55435
34 #define RARCH_DEFAULT_NICK "Anonymous"
35 
36 #define NETPLAY_NICK_LEN 32
37 #define NETPLAY_PASS_LEN 128
38 #define NETPLAY_PASS_HASH_LEN 64 /* length of a SHA-256 hash */
39 
40 #define MAX_SERVER_STALL_TIME_USEC (5*1000*1000)
41 #define MAX_CLIENT_STALL_TIME_USEC (10*1000*1000)
42 #define CATCH_UP_CHECK_TIME_USEC (500*1000)
43 #define MAX_RETRIES 16
44 #define RETRY_MS 500
45 #define MAX_INPUT_DEVICES 16
46 
47 /* We allow only 32 clients to fit into a 32-bit bitmap */
48 #define MAX_CLIENTS 32
50 
51 /* Because the callback keyboard reverses some assumptions, when the keyboard
52  * callbacks are in use, we assign a pseudodevice for it */
53 #define RETRO_DEVICE_NETPLAY_KEYBOARD RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_KEYBOARD, 65535)
54 
55 #define NETPLAY_MAX_STALL_FRAMES 60
56 #define NETPLAY_FRAME_RUN_TIME_WINDOW 120
57 #define NETPLAY_MAX_REQ_STALL_TIME 60
58 #define NETPLAY_MAX_REQ_STALL_FREQUENCY 120
59 
60 #define PREV_PTR(x) ((x) == 0 ? netplay->buffer_size - 1 : (x) - 1)
61 #define NEXT_PTR(x) ((x + 1) % netplay->buffer_size)
62 
63 /* Quirks mandated by how particular cores save states. This is distilled from
64  * the larger set of quirks that the quirks environment can communicate. */
65 #define NETPLAY_QUIRK_NO_SAVESTATES (1<<0)
66 #define NETPLAY_QUIRK_NO_TRANSMISSION (1<<1)
67 #define NETPLAY_QUIRK_INITIALIZATION (1<<2)
68 #define NETPLAY_QUIRK_ENDIAN_DEPENDENT (1<<3)
69 #define NETPLAY_QUIRK_PLATFORM_DEPENDENT (1<<4)
70 
71 /* Mapping of serialization quirks to netplay quirks. */
72 #define NETPLAY_QUIRK_MAP_UNDERSTOOD \
73  (RETRO_SERIALIZATION_QUIRK_INCOMPLETE \
74  |RETRO_SERIALIZATION_QUIRK_CORE_VARIABLE_SIZE \
75  |RETRO_SERIALIZATION_QUIRK_MUST_INITIALIZE \
76  |RETRO_SERIALIZATION_QUIRK_SINGLE_SESSION \
77  |RETRO_SERIALIZATION_QUIRK_ENDIAN_DEPENDENT \
78  |RETRO_SERIALIZATION_QUIRK_PLATFORM_DEPENDENT)
79 #define NETPLAY_QUIRK_MAP_NO_SAVESTATES \
80  (RETRO_SERIALIZATION_QUIRK_INCOMPLETE)
81 #define NETPLAY_QUIRK_MAP_NO_TRANSMISSION \
82  (RETRO_SERIALIZATION_QUIRK_SINGLE_SESSION)
83 #define NETPLAY_QUIRK_MAP_INITIALIZATION \
84  (RETRO_SERIALIZATION_QUIRK_MUST_INITIALIZE)
85 #define NETPLAY_QUIRK_MAP_ENDIAN_DEPENDENT \
86  (RETRO_SERIALIZATION_QUIRK_ENDIAN_DEPENDENT)
87 #define NETPLAY_QUIRK_MAP_PLATFORM_DEPENDENT \
88  (RETRO_SERIALIZATION_QUIRK_PLATFORM_DEPENDENT)
89 
90 /* Compression protocols supported */
91 #define NETPLAY_COMPRESSION_ZLIB (1<<0)
92 #if HAVE_ZLIB
93 #define NETPLAY_COMPRESSION_SUPPORTED NETPLAY_COMPRESSION_ZLIB
94 #else
95 #define NETPLAY_COMPRESSION_SUPPORTED 0
96 #endif
97 
99 {
100  /* Basic commands */
101 
102  /* Acknowlegement response */
103  NETPLAY_CMD_ACK = 0x0000,
104 
105  /* Failed acknowlegement response */
106  NETPLAY_CMD_NAK = 0x0001,
107 
108  /* Gracefully disconnects from host */
110 
111  /* Input data */
113 
114  /* Non-input data */
116 
117  /* Initialization commands */
118 
119  /* Inform the other side of our nick (must be first command) */
121 
122  /* Give the connection password */
124 
125  /* Give core/content info */
127 
128  /* Initial synchronization info (frame, sram, player info) */
130 
131  /* Join spectator mode */
133 
134  /* Join play mode */
136 
137  /* Report player mode */
139 
140  /* Report player mode refused */
142 
143  /* Loading and synchronization */
144 
145  /* Send the CRC hash of a frame's state */
146  NETPLAY_CMD_CRC = 0x0040,
147 
148  /* Request a savestate */
150 
151  /* Send a savestate for the client to load */
153 
154  /* Pauses the game, takes no arguments */
156 
157  /* Resumes the game, takes no arguments */
159 
160  /* Request that a client stall because it's running fast */
162 
163  /* Request a core reset */
165 
166  /* Sends over cheats enabled on client (unsupported) */
168 
169  /* Misc. commands */
170 
171  /* Sends multiple config requests over,
172  * See enum netplay_cmd_cfg */
173  NETPLAY_CMD_CFG = 0x0061,
174 
175  /* CMD_CFG streamlines sending multiple
176  configurations. This acknowledges
177  each one individually */
179 };
180 
181 #define NETPLAY_CMD_SYNC_BIT_PAUSED (1U<<31)
182 #define NETPLAY_CMD_PLAY_BIT_SLAVE (1U<<31)
183 #define NETPLAY_CMD_MODE_BIT_YOU (1U<<31)
184 #define NETPLAY_CMD_MODE_BIT_PLAYING (1U<<30)
185 #define NETPLAY_CMD_MODE_BIT_SLAVE (1U<<29)
186 
187 /* These are the reasons given for mode changes to be rejected */
189 {
190  /* Other/unknown reason */
192 
193  /* You don't have permission to play */
195 
196  /* There are no free player slots */
198 
199  /* You're changing modes too fast */
201 
202  /* You requested a particular port but it's not available */
204 };
205 
206 /* Real preferences for sharing devices */
208 {
209  /* Prefer not to share, shouldn't be set as a sharing mode for an shared device */
211 
212  /* No preference. Only for requests. Set if sharing is requested but either
213  * digital or analog doesn't have a preference. */
215 
216  /* For digital devices */
221 
222  /* For analog devices */
226 };
227 
228 /* The current status of a connection */
230 {
232 
233  NETPLAY_CONNECTION_DELAYED_DISCONNECT, /* The connection is dead, but data
234  is still waiting to be forwarded */
235 
236  /* Initialization: */
237  NETPLAY_CONNECTION_INIT, /* Waiting for header */
238  NETPLAY_CONNECTION_PRE_NICK, /* Waiting for nick */
239  NETPLAY_CONNECTION_PRE_PASSWORD, /* Waiting for password */
240  NETPLAY_CONNECTION_PRE_INFO, /* Waiting for core/content info */
241  NETPLAY_CONNECTION_PRE_SYNC, /* Waiting for sync */
242 
243  /* Ready: */
244  NETPLAY_CONNECTION_CONNECTED, /* Modes above this are connected */
245  NETPLAY_CONNECTION_SPECTATING, /* Spectator mode */
246  NETPLAY_CONNECTION_SLAVE, /* Playing in slave mode */
247  NETPLAY_CONNECTION_PLAYING /* Normal ready state */
248 };
249 
251 {
253 
254  /* We're so far ahead that we can't read more data without overflowing the
255  * buffer */
257 
258  /* We're in spectator or slave mode and are running ahead at all */
260 
261  /* Our actual execution is catching up with latency-adjusted input frames */
263 
264  /* The server asked us to stall */
266 
267  /* We have no connection and must have one to proceed */
269 };
270 
271 /* Input state for a particular client-device pair */
272 typedef struct netplay_input_state
273 {
274  /* The next input state (forming a list) */
276 
277  /* Is this a buffer with real data? */
278  bool used;
279 
280  /* Whose data is this? */
282 
283  /* How many words of input data do we have? */
285 
286  /* The input data itself (note: should expand beyond 1 by overallocating). */
289 
291 {
292  bool used; /* a bit derpy, but this is how we know if the delta's been used at all */
294 
295  /* The serialized state of the core at this frame, before input */
296  void *state;
297 
298  /* The CRC-32 of the serialized state if we've calculated it, else 0 */
300 
301  /* The resolved input, i.e., what's actually going to the core. One input
302  * per device. */
304 
305  /* The real input */
307 
308  /* The simulated input. is_real here means the simulation is done, i.e.,
309  * it's a real simulation, not real input. */
311 
312  /* Have we read local input? */
314 
315  /* Have we read the real (remote) input? */
317 };
318 
320 {
321  unsigned char *data;
322  size_t bufsz;
323  size_t start, end;
324  size_t read;
325 };
326 
327 /* Each connection gets a connection struct */
329 {
330  /* Is this connection buffer in use? */
331  bool active;
332 
333  /* fd associated with this connection */
334  int fd;
335 
336  /* Address of peer */
338 
339  /* Nickname of peer */
341 
342  /* Salt associated with password transaction */
344 
345  /* Is this connection allowed to play (server only)? */
346  bool can_play;
347 
348  /* Buffers for sending and receiving data */
349  struct socket_buffer send_packet_buffer, recv_packet_buffer;
350 
351  /* Mode of the connection */
353 
354  /* If the mode is a DELAYED_DISCONNECT or SPECTATOR, the transmission of the
355  * mode change may have to wait for data to be forwarded. This is the frame
356  * to wait for, or 0 if no delay is active. */
358 
359  /* What compression does this peer support? */
361 
362  /* Is this player paused? */
363  bool paused;
364 
365  /* Is this connection stalling? */
368 
369  /* For the server: When was the last time we requested this client to stall?
370  * For the client: How many frames of stall do we have left? */
372 };
373 
374 /* Compression transcoder */
376 {
381 };
382 
383 struct netplay
384 {
385  /* Are we the server? */
386  bool is_server;
387 
388  /* Are we the connected? */
390 
391  /* Our nickname */
393 
394  /* TCP connection for listening (server only) */
396 
397  /* Our client number */
399 
400  /* Our mode and status */
402 
403  /* All of our connections */
406  struct netplay_connection one_connection; /* Client only */
407 
408  /* Bitmap of clients with input devices */
410 
411  /* Bitmap of clients playing in slave mode (should be a subset of
412  * connected_players) */
414 
415  /* For each client, the bitmap of devices they're connected to */
417 
418  /* For each device, the bitmap of clients connected */
420 
421  /* The sharing mode for each device */
423 
424  /* Our own device bitmap */
426 
427  /* Number of desync operations we're currently performing. If set, we don't
428  * attempt to stay in sync. */
430 
431  /* The device types for every connected device. We store them and ignore any
432  * menu changes, as netplay needs fixed devices. */
434 
435  /* Set to true if we have a device that most cores translate to "up/down"
436  * actions, typically a keyboard. We need to keep track of this because with
437  * such a device, we need to "fix" the input state to the frame BEFORE a
438  * state load, then perform the state load, and the up/down states will
439  * proceed as expected */
441 
443 
444  /* TCP port (only set if serving) */
446 
447  /* NAT traversal info (if NAT traversal is used and serving) */
450 
452  size_t buffer_size;
453 
454  /* Compression transcoder */
455  struct compression_transcoder compress_nil,
457 
458  /* A buffer into which to compress frames for transfer */
460  size_t zbuffer_size;
461 
462  /* The size of our packet buffers */
464 
465  /* The frame we're currently inputting */
466  size_t self_ptr;
468 
469  /* The frame we're currently running, which may be behind the frame we're
470  * currently inputting if we're using input latency */
471  size_t run_ptr;
473 
474  /* The first frame at which some data might be unreliable */
475  size_t other_ptr;
477 
478  /* Pointer to the first frame for which we're missing the data of at least
479  * one connected player excluding ourself.
480  * Generally, other_ptr <= unread_ptr <= self_ptr, but unread_ptr can get ahead
481  * of self_ptr if the peer is running fast. */
482  size_t unread_ptr;
484 
485  /* Pointer to the next frame to read from each client */
488 
489  /* Pointer to the next frame to read from the server (as it might not be a
490  * player but still synchronizes) */
491  size_t server_ptr;
493 
494  /* A pointer used temporarily for replay. */
495  size_t replay_ptr;
497 
498  /* Size of savestates */
499  size_t state_size;
500 
501  /* Are we replaying old frames? */
502  bool is_replay;
503 
504  /* We don't want to poll several times on a frame. */
505  bool can_poll;
506 
507  /* Force a rewind to other_frame_count/other_ptr. This is for synchronized
508  * events, such as restarting or savestate loading. */
510 
511  /* Force a reset */
513 
514  /* Quirks in the savestate implementation */
516 
517  /* Force our state to be sent to all connections */
519 
520  /* Have we requested a savestate as a sync point? */
522 
523  /* Our local socket info */
524  struct addrinfo *addr;
525 
526  /* Counter for timeouts */
527  unsigned timeout_cnt;
528 
529  /* Netplay pausing */
532 
533  /* If true, never progress without peer input (stateless/rewindless mode) */
535 
536  /* We stall if we're far enough ahead that we couldn't transparently rewind.
537  * To know if we could transparently rewind, we need to know how long
538  * running a frame takes. We record that every frame and get a running
539  * (window) average */
543 
544  /* Latency frames; positive to hide network latency, negative to hide input latency */
546 
547  /* Are we stalled? */
549 
550  /* How long have we been stalled? */
552 
553  /* Opposite of stalling, should we be catching up? */
554  bool catch_up;
555 
556  /* When did we start falling behind? */
558 
559  /* How far behind did we fall? */
561 
562  /* Frequency with which to check CRCs */
564 
565  /* Have we checked whether CRCs are valid at all? */
567 
568  /* Are they valid? */
570 };
571 
572 
573 /***************************************************************
574  * NETPLAY-BUF.C
575  **************************************************************/
576 
582 bool netplay_init_socket_buffer(struct socket_buffer *sbuf, size_t size);
583 
589 bool netplay_resize_socket_buffer(struct socket_buffer *sbuf, size_t newsize);
590 
597 
603 bool netplay_send(struct socket_buffer *sbuf, int sockfd, const void *buf,
604  size_t len);
605 
614 bool netplay_send_flush(struct socket_buffer *sbuf, int sockfd, bool block);
615 
623 ssize_t netplay_recv(struct socket_buffer *sbuf, int sockfd, void *buf,
624  size_t len, bool block);
625 
632 void netplay_recv_reset(struct socket_buffer *sbuf);
633 
640 void netplay_recv_flush(struct socket_buffer *sbuf);
641 
642 
643 /***************************************************************
644  * NETPLAY-DELTA.C
645  **************************************************************/
646 
657  uint32_t frame);
658 
665 
671 void netplay_delta_frame_free(struct delta_frame *delta);
672 
679  uint32_t client_num, size_t size, bool must_create, bool must_not_create);
680 
687 
688 
689 /***************************************************************
690  * NETPLAY-DISCOVERY.C
691  **************************************************************/
692 
699 
700 
701 /***************************************************************
702  * NETPLAY-FRONTEND.C
703  **************************************************************/
704 
716  retro_ctx_serialize_info_t *serial_info, bool save);
717 
724 
730 void input_poll_net(void);
731 
732 /***************************************************************
733  * NETPLAY-HANDSHAKE.C
734  **************************************************************/
735 
742  struct netplay_connection *connection);
743 
750  struct netplay_connection *connection, bool *had_input);
751 
752 
753 /***************************************************************
754  * NETPLAY-INIT.C
755  **************************************************************/
756 
765 
775 
793 netplay_t *netplay_new(void *direct_host, const char *server, uint16_t port,
794  bool stateless_mode, int check_frames,
795  const struct retro_callbacks *cb, bool nat_traversal, const char *nick,
796  uint64_t quirks);
797 
805 
806 
807 /***************************************************************
808  * NETPLAY-IO.C
809  **************************************************************/
810 
816 void netplay_hangup(netplay_t *netplay, struct netplay_connection *connection);
817 
825 
834  struct netplay_connection *connection);
835 
844  struct netplay_connection *connection, uint32_t cmd, const void *data,
845  size_t size);
846 
854  struct netplay_connection *except, uint32_t cmd, const void *data,
855  size_t size);
856 
862 bool netplay_cmd_crc(netplay_t *netplay, struct delta_frame *delta);
863 
870 
879 
886  struct netplay_connection *connection,
887  uint32_t frames);
888 
895 
902 
909 
916 
917 
918 /***************************************************************
919  * NETPLAY-KEYBOARD.C
920  **************************************************************/
921 
922 /* The keys supported by netplay */
925 #define K(k) NETPLAY_KEY_ ## k,
926 #define KL(k,l) K(k)
927 #include "netplay_keys.h"
928 #undef KL
929 #undef K
930  NETPLAY_KEY_LAST
931 };
932 
933 /* The mapping of keys from netplay (network) to libretro (host) */
934 extern const uint16_t netplay_key_ntoh_mapping[];
935 #define netplay_key_ntoh(k) (netplay_key_ntoh_mapping[k])
936 
937 /* The mapping of keys from libretro (host) to netplay (network) */
938 uint32_t netplay_key_hton(unsigned key);
939 
940 /* Because the hton keymapping has to be generated, call this before using
941  * netplay_key_hton */
942 void netplay_key_hton_init(void);
943 
944 
945 /***************************************************************
946  * NETPLAY-SYNC.C
947  **************************************************************/
948 
968 bool netplay_resolve_input(netplay_t *netplay, size_t sim_ptr, bool resim);
969 
977 
986 void netplay_sync_post_frame(netplay_t *netplay, bool stalled);
987 
988 #endif
enum rarch_netplay_stall_reason stall
Definition: netplay_private.h:366
bool local_paused
Definition: netplay_private.h:530
bool netplay_handshake_init_send(netplay_t *netplay, struct netplay_connection *connection)
Definition: netplay_handshake.c:205
bool have_local
Definition: netplay_private.h:313
enum rarch_netplay_connection_mode self_mode
Definition: netplay_private.h:401
bool netplay_send_flush(struct socket_buffer *sbuf, int sockfd, bool block)
Definition: netplay_buf.c:176
int check_frames
Definition: netplay_private.h:563
void * state
Definition: netplay_private.h:296
Definition: netplay_private.h:237
bool force_rewind
Definition: netplay_private.h:509
bool netplay_try_init_serialization(netplay_t *netplay)
Definition: netplay_init.c:318
retro_time_t stall_time
Definition: netplay_private.h:367
rarch_netplay_stall_reason
Definition: netplay_private.h:250
unsigned timeout_cnt
Definition: netplay_private.h:527
bool netplay_sync_pre_frame(netplay_t *netplay)
Definition: netplay_sync.c:545
Definition: core.h:145
GLenum mode
Definition: glext.h:6857
bool netplay_wait_and_init_serialization(netplay_t *netplay)
Definition: netplay_init.c:350
Definition: core.h:128
uint32_t netplay_key_hton(unsigned key)
Definition: netplay_keyboard.c:35
void netplay_update_unread_ptr(netplay_t *netplay)
Definition: netplay_sync.c:40
uint32_t unread_frame_count
Definition: netplay_private.h:483
Definition: netplay_private.h:106
Definition: netplay_private.h:217
uint32_t salt
Definition: netplay_private.h:343
Definition: netplay_private.h:141
void netplay_delta_frame_free(struct delta_frame *delta)
Definition: netplay_delta.c:105
uint32_t connected_players
Definition: netplay_private.h:409
size_t server_ptr
Definition: netplay_private.h:491
uint32_t self_devices
Definition: netplay_private.h:425
Definition: netplay_private.h:103
retro_time_t frame_run_time[NETPLAY_FRAME_RUN_TIME_WINDOW]
Definition: netplay_private.h:540
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:8418
Definition: netplay_private.h:239
Definition: ffmpeg_core.c:151
Definition: netplay_private.h:265
bool netplay_init_socket_buffer(struct socket_buffer *sbuf, size_t size)
Definition: netplay_buf.c:57
Definition: netplay_private.h:238
void netplay_free(netplay_t *netplay)
Definition: netplay_init.c:528
char nick[NETPLAY_NICK_LEN]
Definition: netplay_private.h:392
uint32_t connected_slaves
Definition: netplay_private.h:413
netplay_input_state_t real_input[MAX_INPUT_DEVICES]
Definition: netplay_private.h:306
int frame_run_time_ptr
Definition: netplay_private.h:541
Definition: netplay_private.h:138
size_t other_ptr
Definition: netplay_private.h:475
Definition: netplay_private.h:319
Definition: netplay_private.h:240
Definition: netplay_private.h:194
size_t packet_buffer_size
Definition: netplay_private.h:463
GLenum GLsizei len
Definition: glext.h:7389
bool can_play
Definition: netplay_private.h:346
uint32_t delay_frame
Definition: netplay_private.h:357
Definition: netplay_private.h:164
uint64_t quirks
Definition: netplay_private.h:515
void netplay_delayed_state_change(netplay_t *netplay)
Definition: netplay_io.c:178
Definition: netplay_private.h:120
GLsizeiptr size
Definition: glext.h:6559
Definition: netplay_private.h:123
bool netplay_cmd_mode(netplay_t *netplay, enum rarch_netplay_connection_mode mode)
Definition: netplay_io.c:472
size_t end
Definition: netplay_private.h:323
uint32_t replay_frame_count
Definition: netplay_private.h:496
includes all by default used to find thumbnails Please choose a single playlist first Add Entry Add Folder Select Files< multiple > Please fill out all required fields RetroArch updated successfully Please restart the application for the changes to take effect Contributors Move Down Load Remove Add Pass No shader passes Reset All Passes Download thumbnail Start on Download All Thumbnails This Playlist Configured in port
Definition: msg_hash_us.h:7699
Definition: netplay_private.h:245
int netplay_poll_net_input(netplay_t *netplay, bool block)
Definition: netplay_io.c:1846
bool is_connected
Definition: netplay_private.h:389
void netplay_key_hton_init(void)
Definition: netplay_keyboard.c:44
void netplay_handle_slaves(netplay_t *netplay)
Definition: netplay_io.c:1921
netplay_cmd
Definition: netplay_private.h:98
void netplay_recv_reset(struct socket_buffer *sbuf)
Definition: netplay_buf.c:342
int64_t retro_time_t
Definition: libretro.h:1610
uint32_t other_frame_count
Definition: netplay_private.h:476
bool remote_paused
Definition: netplay_private.h:531
uint8_t * zbuffer
Definition: netplay_private.h:459
uint32_t run_frame_count
Definition: netplay_private.h:472
retro_time_t catch_up_time
Definition: netplay_private.h:557
size_t state_size
Definition: netplay_private.h:499
Definition: ibxm.h:9
Definition: netplay_private.h:231
void netplay_sync_post_frame(netplay_t *netplay, bool stalled)
Definition: netplay_sync.c:738
int listen_fd
Definition: netplay_private.h:395
const struct trans_stream_backend * compression_backend
Definition: netplay_private.h:377
bool have_updown_device
Definition: netplay_private.h:440
Definition: netplay_private.h:146
Definition: net_natt.h:33
bool netplay_cmd_crc(netplay_t *netplay, struct delta_frame *delta)
Definition: netplay_io.c:431
Definition: netplay_private.h:158
uint32_t server_frame_count
Definition: netplay_private.h:492
netplay_keys
Definition: netplay_private.h:923
uint32_t client_num
Definition: netplay_private.h:281
#define sockaddr_storage
Definition: socket.h:49
struct netplay_connection one_connection
Definition: netplay_private.h:406
Definition: netplay_private.h:197
uint32_t self_client_num
Definition: netplay_private.h:398
bool force_send_savestate
Definition: netplay_private.h:518
rarch_netplay_connection_mode
Definition: netplay_private.h:229
bool crcs_valid
Definition: netplay_private.h:569
ubyte cmd
Definition: wiiuse_internal.h:319
uint32_t stall_frame
Definition: netplay_private.h:371
struct socket_buffer send_packet_buffer recv_packet_buffer
Definition: netplay_private.h:349
void input_poll_net(void)
Definition: netplay_frontend.c:532
Definition: netplay_private.h:241
Definition: netplay_private.h:375
bool netplay_send_cur_input(netplay_t *netplay, struct netplay_connection *connection)
Definition: netplay_io.c:290
bool is_replay
Definition: netplay_private.h:502
size_t replay_ptr
Definition: netplay_private.h:495
bool netplay_delta_frame_ready(netplay_t *netplay, struct delta_frame *delta, uint32_t frame)
Definition: netplay_delta.c:44
struct netplay_input_state * next
Definition: netplay_private.h:275
Definition: netplay_private.h:247
Definition: netplay_private.h:290
uint16_t tcp_port
Definition: netplay_private.h:445
struct retro_callbacks cbs
Definition: netplay_private.h:442
void netplay_announce_nat_traversal(netplay_t *netplay)
Definition: netplay_io.c:1990
GLenum const GLvoid * addr
Definition: glext.h:10528
void netplay_hangup(netplay_t *netplay, struct netplay_connection *connection)
Definition: netplay_io.c:93
Definition: netplay_private.h:268
Definition: netplay_private.h:233
struct compression_transcoder compress_nil compress_zlib
Definition: netplay_private.h:455
bool netplay_send(struct socket_buffer *sbuf, int sockfd, const void *buf, size_t len)
Definition: netplay_buf.c:127
bool crc_validity_checked
Definition: netplay_private.h:566
Definition: netplay_private.h:220
bool stateless_mode
Definition: netplay_private.h:534
bool is_server
Definition: netplay_private.h:386
Definition: netplay_private.h:256
Definition: netplay_private.h:132
size_t connections_size
Definition: netplay_private.h:405
client_bitmap_t device_clients[MAX_INPUT_DEVICES]
Definition: netplay_private.h:419
void netplay_send_raw_cmd_all(netplay_t *netplay, struct netplay_connection *except, uint32_t cmd, const void *data, size_t size)
Definition: netplay_io.c:378
void netplay_init_nat_traversal(netplay_t *netplay)
Definition: netplay_io.c:2035
enum rarch_netplay_connection_mode mode
Definition: netplay_private.h:352
bool used
Definition: netplay_private.h:278
const struct trans_stream_backend * decompression_backend
Definition: netplay_private.h:379
netplay_input_state_t resolved_input[MAX_INPUT_DEVICES]
Definition: netplay_private.h:303
bool force_reset
Definition: netplay_private.h:512
Definition: netplay_private.h:259
Definition: netplay_private.h:200
size_t bufsz
Definition: netplay_private.h:322
bool can_poll
Definition: netplay_private.h:505
static struct frame frames[2]
Definition: ffmpeg_core.c:162
uint8_t netplay_settings_share_mode(void)
Definition: netplay_frontend.c:1303
Definition: netplay_private.h:191
Definition: netplay_private.h:328
Definition: netplay_private.h:223
bool paused
Definition: netplay_private.h:363
Definition: netplay_private.h:272
Definition: netplay_private.h:149
bool nat_traversal
Definition: netplay_private.h:448
bool netplay_handshake(netplay_t *netplay, struct netplay_connection *connection, bool *had_input)
Definition: netplay_handshake.c:1136
bool nat_traversal_task_oustanding
Definition: netplay_private.h:448
size_t start
Definition: netplay_private.h:323
bool netplay_cmd_request_savestate(netplay_t *netplay)
Definition: netplay_io.c:453
Definition: netplay_private.h:244
static int block
Definition: psp2.c:31
Definition: trans_stream.h:53
size_t buffer_size
Definition: netplay_private.h:452
uint32_t self_frame_count
Definition: netplay_private.h:467
int fd
Definition: netplay_private.h:334
static void save(LexState *ls, int c)
Definition: llex.c:57
Definition: netplay_private.h:129
unsigned char * data
Definition: netplay_private.h:321
bool used
Definition: netplay_private.h:292
Definition: netplay_private.h:225
uint32_t read_frame_count[MAX_CLIENTS]
Definition: netplay_private.h:487
bool netplay_cmd_stall(netplay_t *netplay, struct netplay_connection *connection, uint32_t frames)
Definition: netplay_io.c:534
#define MAX_CLIENTS
Definition: netplay_private.h:48
Definition: netplay_private.h:109
bool have_real[MAX_CLIENTS]
Definition: netplay_private.h:316
bool netplay_resolve_input(netplay_t *netplay, size_t sim_ptr, bool resim)
Definition: netplay_sync.c:341
Definition: netplay_private.h:214
Definition: netplay_private.h:262
size_t read_ptr[MAX_CLIENTS]
Definition: netplay_private.h:486
Definition: netplay_private.h:383
int input_latency_frames
Definition: netplay_private.h:545
static char server[64]
Definition: net_retropad_core.c:73
netplay_input_state_t netplay_input_state_for(netplay_input_state_t *list, uint32_t client_num, size_t size, bool must_create, bool must_not_create)
Definition: netplay_delta.c:128
Definition: netplay_private.h:218
uint32_t netplay_delta_frame_crc(netplay_t *netplay, struct delta_frame *delta)
Definition: netplay_delta.c:77
struct natt_status nat_traversal_state
Definition: netplay_private.h:449
const uint16_t netplay_key_ntoh_mapping[]
Definition: netplay_keyboard.c:21
Definition: netplay_private.h:924
bool netplay_send_raw_cmd(netplay_t *netplay, struct netplay_connection *connection, uint32_t cmd, const void *data, size_t size)
Definition: netplay_io.c:352
uint32_t compression_supported
Definition: netplay_private.h:360
Definition: netplay_private.h:252
bool netplay_lan_ad_server(netplay_t *netplay)
Definition: netplay_discovery.c:238
struct netplay_connection * connections
Definition: netplay_private.h:404
Definition: netplay_private.h:246
bool savestate_request_outstanding
Definition: netplay_private.h:521
struct netplay_input_state * netplay_input_state_t
void netplay_recv_flush(struct socket_buffer *sbuf)
Definition: netplay_buf.c:353
struct delta_frame * buffer
Definition: netplay_private.h:451
netplay_cmd_mode_reasons
Definition: netplay_private.h:188
enum rarch_netplay_stall_reason stall
Definition: netplay_private.h:548
Definition: netplay_private.h:115
uint32_t desync
Definition: netplay_private.h:429
uint32_t crc
Definition: netplay_private.h:299
rarch_netplay_share_preference
Definition: netplay_private.h:207
void netplay_deinit_socket_buffer(struct socket_buffer *sbuf)
Definition: netplay_buf.c:111
void * decompression_stream
Definition: netplay_private.h:380
Definition: netplay_private.h:210
Definition: netplay_private.h:178
netplay_t * netplay_new(void *direct_host, const char *server, uint16_t port, bool stateless_mode, int check_frames, const struct retro_callbacks *cb, bool nat_traversal, const char *nick, uint64_t quirks)
Definition: netplay_init.c:418
bool catch_up
Definition: netplay_private.h:554
Definition: netplay_private.h:112
struct addrinfo * addr
Definition: netplay_private.h:524
size_t read
Definition: netplay_private.h:324
size_t zbuffer_size
Definition: netplay_private.h:460
Definition: netplay_private.h:219
char nick[NETPLAY_NICK_LEN]
Definition: netplay_private.h:340
Definition: netplay_private.h:167
uint32_t netplay_expected_input_size(netplay_t *netplay, uint32_t devices)
Definition: netplay_delta.c:170
Definition: netplay_private.h:224
Definition: netdb.h:21
#define NETPLAY_FRAME_RUN_TIME_WINDOW
Definition: netplay_private.h:56
netplay_input_state_t simlated_input[MAX_INPUT_DEVICES]
Definition: netplay_private.h:310
retro_time_t frame_run_time_sum
Definition: netplay_private.h:542
Definition: netplay_private.h:152
bool active
Definition: netplay_private.h:331
Definition: netplay_private.h:173
#define NETPLAY_NICK_LEN
Definition: netplay_private.h:36
void * compression_stream
Definition: netplay_private.h:378
retro_time_t stall_time
Definition: netplay_private.h:551
size_t unread_ptr
Definition: netplay_private.h:482
Definition: netplay_private.h:135
Definition: netplay_private.h:203
Definition: netplay_private.h:155
size_t self_ptr
Definition: netplay_private.h:466
uint32_t client_bitmap_t
Definition: netplay_private.h:49
#define MAX_INPUT_DEVICES
Definition: netplay_private.h:45
uint8_t device_share_modes[MAX_INPUT_DEVICES]
Definition: netplay_private.h:422
bool netplay_resize_socket_buffer(struct socket_buffer *sbuf, size_t newsize)
Definition: netplay_buf.c:72
unsigned short uint16_t
Definition: stdint.h:125
uint32_t config_devices[MAX_INPUT_DEVICES]
Definition: netplay_private.h:433
ssize_t netplay_recv(struct socket_buffer *sbuf, int sockfd, void *buf, size_t len, bool block)
Definition: netplay_buf.c:245
unsigned __int64 uint64_t
Definition: stdint.h:136
Definition: netplay_private.h:126
unsigned char uint8_t
Definition: stdint.h:124
unsigned int uint32_t
Definition: stdint.h:126
retro_time_t frame_run_time_avg
Definition: netplay_private.h:542
uint32_t frame
Definition: netplay_private.h:293
Definition: netplay_private.h:161
size_t run_ptr
Definition: netplay_private.h:471
void netplay_load_savestate(netplay_t *netplay, retro_ctx_serialize_info_t *serial_info, bool save)
Definition: netplay_frontend.c:1211
uint32_t catch_up_behind
Definition: netplay_private.h:560
uint32_t client_devices[MAX_CLIENTS]
Definition: netplay_private.h:416
uint32_t size
Definition: netplay_private.h:284