RetroArch
|
#include "netplay.h"
#include <net/net_compat.h>
#include <net/net_natt.h>
#include <features/features_cpu.h>
#include <streams/trans_stream.h>
#include "../../msg_hash.h"
#include "../../verbosity.h"
#include "netplay_keys.h"
Go to the source code of this file.
Classes | |
struct | netplay_input_state |
struct | delta_frame |
struct | socket_buffer |
struct | netplay_connection |
struct | compression_transcoder |
struct | netplay |
Typedefs | |
typedef uint32_t | client_bitmap_t |
typedef struct netplay_input_state * | netplay_input_state_t |
Variables | |
const uint16_t | netplay_key_ntoh_mapping [] |
#define CATCH_UP_CHECK_TIME_USEC (500*1000) |
#define K | ( | k | ) | NETPLAY_KEY_ ## k, |
#define MAX_CLIENT_STALL_TIME_USEC (10*1000*1000) |
#define MAX_CLIENTS 32 |
#define MAX_INPUT_DEVICES 16 |
#define MAX_RETRIES 16 |
#define MAX_SERVER_STALL_TIME_USEC (5*1000*1000) |
#define NETPLAY_CMD_MODE_BIT_PLAYING (1U<<30) |
#define NETPLAY_CMD_MODE_BIT_SLAVE (1U<<29) |
#define NETPLAY_CMD_MODE_BIT_YOU (1U<<31) |
#define NETPLAY_CMD_PLAY_BIT_SLAVE (1U<<31) |
#define NETPLAY_CMD_SYNC_BIT_PAUSED (1U<<31) |
#define NETPLAY_COMPRESSION_SUPPORTED 0 |
#define NETPLAY_COMPRESSION_ZLIB (1<<0) |
#define NETPLAY_FRAME_RUN_TIME_WINDOW 120 |
#define netplay_key_ntoh | ( | k | ) | (netplay_key_ntoh_mapping[k]) |
#define NETPLAY_MAX_REQ_STALL_FREQUENCY 120 |
#define NETPLAY_MAX_REQ_STALL_TIME 60 |
#define NETPLAY_MAX_STALL_FRAMES 60 |
#define NETPLAY_NICK_LEN 32 |
#define NETPLAY_PASS_LEN 128 |
#define NETPLAY_PROTOCOL_VERSION 5 |
#define NETPLAY_QUIRK_ENDIAN_DEPENDENT (1<<3) |
#define NETPLAY_QUIRK_INITIALIZATION (1<<2) |
#define NETPLAY_QUIRK_MAP_ENDIAN_DEPENDENT (RETRO_SERIALIZATION_QUIRK_ENDIAN_DEPENDENT) |
#define NETPLAY_QUIRK_MAP_INITIALIZATION (RETRO_SERIALIZATION_QUIRK_MUST_INITIALIZE) |
#define NETPLAY_QUIRK_MAP_NO_SAVESTATES (RETRO_SERIALIZATION_QUIRK_INCOMPLETE) |
#define NETPLAY_QUIRK_MAP_NO_TRANSMISSION (RETRO_SERIALIZATION_QUIRK_SINGLE_SESSION) |
#define NETPLAY_QUIRK_MAP_PLATFORM_DEPENDENT (RETRO_SERIALIZATION_QUIRK_PLATFORM_DEPENDENT) |
#define NETPLAY_QUIRK_MAP_UNDERSTOOD |
#define NETPLAY_QUIRK_NO_SAVESTATES (1<<0) |
#define NETPLAY_QUIRK_NO_TRANSMISSION (1<<1) |
#define NETPLAY_QUIRK_PLATFORM_DEPENDENT (1<<4) |
#define RARCH_DEFAULT_NICK "Anonymous" |
#define RARCH_DEFAULT_PORT 55435 |
#define RETRO_DEVICE_NETPLAY_KEYBOARD RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_KEYBOARD, 65535) |
#define RETRY_MS 500 |
typedef uint32_t client_bitmap_t |
typedef struct netplay_input_state * netplay_input_state_t |
enum netplay_cmd |
enum netplay_keys |
input_poll_net
Poll the network if necessary.
netplay_announce_nat_traversal
Announce successful NAT traversal.
bool netplay_cmd_crc | ( | netplay_t * | netplay, |
struct delta_frame * | delta | ||
) |
netplay_cmd_crc
Send a CRC command to all active clients.
bool netplay_cmd_mode | ( | netplay_t * | netplay, |
enum rarch_netplay_connection_mode | mode | ||
) |
netplay_cmd_mode
Send a mode change request. As a server, the request is to ourself, and so honored instantly.
netplay_cmd_request_savestate
Send a savestate request command.
bool netplay_cmd_stall | ( | netplay_t * | netplay, |
struct netplay_connection * | connection, | ||
uint32_t | frames | ||
) |
netplay_cmd_stall
Send a stall command.
void netplay_deinit_socket_buffer | ( | struct socket_buffer * | sbuf | ) |
netplay_deinit_socket_buffer
Free a socket buffer.
netplay_delayed_state_change:
Handle any pending state changes which are ready as of the beginning of the current frame.
uint32_t netplay_delta_frame_crc | ( | netplay_t * | netplay, |
struct delta_frame * | delta | ||
) |
netplay_delta_frame_crc
Get the CRC for the serialization of this frame.
void netplay_delta_frame_free | ( | struct delta_frame * | delta | ) |
netplay_delta_frame_free
Free a delta frame's dependencies
bool netplay_delta_frame_ready | ( | netplay_t * | netplay, |
struct delta_frame * | delta, | ||
uint32_t | frame | ||
) |
netplay_delta_frame_ready
Prepares, if possible, a delta frame for input, and reports whether it is ready.
Returns: True if the delta frame is ready for input at the given frame, false otherwise.
netplay_expected_input_size
Size in words for a given set of devices.
netplay_free : pointer to netplay object
Frees netplay data/
netplay_handle_slaves
Handle any slave connections
bool netplay_handshake | ( | netplay_t * | netplay, |
struct netplay_connection * | connection, | ||
bool * | had_input | ||
) |
netplay_handshake
Data receiver for all handshake states.
bool netplay_handshake_init_send | ( | netplay_t * | netplay, |
struct netplay_connection * | connection | ||
) |
netplay_handshake_init_send
Initialize our handshake and send the first part of the handshake protocol.
void netplay_hangup | ( | netplay_t * | netplay, |
struct netplay_connection * | connection | ||
) |
netplay_hangup:
Disconnects an active Netplay connection due to an error
netplay_init_nat_traversal
Initialize the NAT traversal library and try to open a port
bool netplay_init_socket_buffer | ( | struct socket_buffer * | sbuf, |
size_t | size | ||
) |
netplay_init_socket_buffer
Initialize a new socket buffer.
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 | ||
) |
netplay_input_state_for
Get an input state for a particular client
uint32_t netplay_key_hton | ( | unsigned | key | ) |
netplay_lan_ad_server
Respond to any LAN ad queries that the netplay server has received.
void netplay_load_savestate | ( | netplay_t * | netplay, |
retro_ctx_serialize_info_t * | serial_info, | ||
bool | save | ||
) |
netplay_load_savestate : pointer to netplay object : the savestate being loaded, NULL means "load it yourself" : Whether to save the provided serial_info into the frame buffer
Inform Netplay of a savestate load and send it to the other side
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 | ||
) |
netplay_new: : Netplay host discovered from scanning. : IP address of server. : Port of server. : Shall we run in stateless mode? : Frequency with which to check CRCs. : Libretro callbacks. : If true, attempt NAT traversal. : Nickname of user. : Netplay quirks required for this session.
Creates a new netplay handle. A NULL server means we're hosting.
Returns: new netplay data.
netplay_new: : Netplay host discovered from scanning. : IP address of server. : Port of server. : Shall we use stateless mode? : Frequency with which to check CRCs. : Libretro callbacks. : If true, attempt NAT traversal. : Nickname of user. : Netplay quirks required for this session.
Creates a new netplay handle. A NULL server means we're hosting.
Returns: new netplay data.
netplay_poll_net_input
Poll input from the network
ssize_t netplay_recv | ( | struct socket_buffer * | sbuf, |
int | sockfd, | ||
void * | buf, | ||
size_t | len, | ||
bool | block | ||
) |
netplay_recv
Receive buffered or fresh data.
Returns number of bytes returned, which may be short or 0, or -1 on error.
void netplay_recv_flush | ( | struct socket_buffer * | sbuf | ) |
netplay_recv_flush
Flush our recv buffer, so a future netplay_recv_reset will reset to this point.
void netplay_recv_reset | ( | struct socket_buffer * | sbuf | ) |
netplay_recv_reset
Reset our recv buffer so that future netplay_recvs will read the same data again.
bool netplay_resize_socket_buffer | ( | struct socket_buffer * | sbuf, |
size_t | newsize | ||
) |
netplay_resize_socket_buffer
Resize the given socket_buffer's buffer to the requested size.
netplay_resolve_input : pointer to netplay object : frame pointer for which to resolve input : are we resimulating, or simulating this frame for the first time?
"Simulate" input by assuming it hasn't changed since the last read input. Returns true if the resolved input changed from the last time it was resolved.
bool netplay_send | ( | struct socket_buffer * | sbuf, |
int | sockfd, | ||
const void * | buf, | ||
size_t | len | ||
) |
netplay_send
Queue the given data for sending.
bool netplay_send_cur_input | ( | netplay_t * | netplay, |
struct netplay_connection * | connection | ||
) |
netplay_send_cur_input
Send the current input frame to a given connection.
Returns true if successful, false otherwise.
bool netplay_send_flush | ( | struct socket_buffer * | sbuf, |
int | sockfd, | ||
bool | block | ||
) |
netplay_send_flush
Flush unsent data in the given socket buffer, blocking to do so if requested.
Returns false only on socket failures, true otherwise.
bool netplay_send_raw_cmd | ( | netplay_t * | netplay, |
struct netplay_connection * | connection, | ||
uint32_t | cmd, | ||
const void * | data, | ||
size_t | size | ||
) |
netplay_send_raw_cmd
Send a raw Netplay command to the given connection.
Returns true on success, false on failure.
void netplay_send_raw_cmd_all | ( | netplay_t * | netplay, |
struct netplay_connection * | except, | ||
uint32_t | cmd, | ||
const void * | data, | ||
size_t | size | ||
) |
netplay_send_raw_cmd_all
Send a raw Netplay command to all connections, optionally excluding one (typically the client that the relevant command came from)
netplay_settings_share_mode
Get the preferred share mode
netplay_sync_post_frame : pointer to netplay object : true if we're currently stalled
Post-frame for Netplay synchronization. We check if we have new input and replay from recorded input.
netplay_sync_post_frame : pointer to netplay object
Post-frame for Netplay synchronization. We check if we have new input and replay from recorded input.
netplay_sync_pre_frame : pointer to netplay object
Pre-frame for Netplay synchronization.
netplay_try_init_serialization
Try to initialize serialization. For quirky cores.
Returns true if serialization is now ready, false otherwise.
netplay_update_unread_ptr
Update the global unread_ptr and unread_frame_count to correspond to the earliest unread frame count of any connected player
netplay_wait_and_init_serialization
Try very hard to initialize serialization, simulating multiple frames if necessary. For quirky cores.
Returns true if serialization is now ready, false otherwise.