Skip to content

Commit

Permalink
ipc: add Windows implementation with named pipes
Browse files Browse the repository at this point in the history
This implements the JSON IPC protocol with named pipes, which are
probably the closest Windows equivalent to Unix domain sockets in terms
of functionality. Like with Unix sockets, this will allow mpv to listen
for IPC connections and handle multiple IPC clients at once. A few cross
platform libraries and frameworks (Qt, node.js) use named pipes for IPC
on Windows and Unix sockets on Linux and Unix, so hopefully this will
ease the creation of portable JSON IPC clients.

Unlike the Unix implementation, this doesn't share code with
--input-file, meaning --input-file on Windows won't understand JSON
commands (yet.) Sharing code and removing the separate implementation in
pipe-win32.c is definitely a possible future improvement.
  • Loading branch information
rossy committed Mar 23, 2016
1 parent ba4569c commit 5bf473d
Show file tree
Hide file tree
Showing 6 changed files with 881 additions and 430 deletions.
9 changes: 9 additions & 0 deletions input/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,13 @@ struct mp_ipc_ctx *mp_init_ipc(struct mp_client_api *client_api,
struct mpv_global *global);
void mp_uninit_ipc(struct mp_ipc_ctx *ctx);

// Serialize the given mpv_event structure to JSON. Returns an allocated string.
struct mpv_event;
char *mp_json_encode_event(struct mpv_event *event);

// Given the raw IPC input buffer "buf", remove the first newline-separated
// command, execute it and return the result (if any) as an allocated string.
struct mpv_handle;
char *mp_ipc_consume_next_command(struct mpv_handle *client, void *ctx, bstr *buf);

#endif /* MPLAYER_INPUT_H */
Loading

0 comments on commit 5bf473d

Please sign in to comment.