1. 10 8月, 2018 1 次提交
    • R
      Add crop feature · caa9e300
      Romain Vimont 提交于
      Add an option to crop the screen on the server. This allows to mirror
      only part of the device screen.
      caa9e300
  2. 29 5月, 2018 2 次提交
  3. 25 3月, 2018 4 次提交
  4. 22 3月, 2018 1 次提交
    • R
      Disable custom SDL signal handlers · f00c6c5b
      Romain Vimont 提交于
      Request SDL not to replace the SIGINT and SIGTERM handlers, so that the
      process is immediately terminated on Ctrl+C.
      
      This avoids process hanging on Ctrl+C during network calls on
      initialization.
      
      Some of them accepted a timeout, but it was not used since
      commit 9b056f50 anymore.
      f00c6c5b
  5. 15 3月, 2018 1 次提交
  6. 14 3月, 2018 2 次提交
  7. 12 3月, 2018 1 次提交
    • R
      Store serial in server instance · 2b3ed5bc
      Romain Vimont 提交于
      The serial is needed for many server actions, but this is an
      implementation detail, so the caller should not have to provide it on
      every call.
      
      Instead, store the serial in the server instance on server_start().
      
      This paves the way to implement the "adb forward" fallback properly.
      2b3ed5bc
  8. 16 2月, 2018 2 次提交
    • R
      Terminate the device process gracefully · ad6209f6
      Romain Vimont 提交于
      Call shutdown() on the device socket to make the device process finish
      its execution quickly and gracefully, without killing it.
      ad6209f6
    • R
      Replace SDL_net by custom implementation · 9b056f50
      Romain Vimont 提交于
      SDL_net is not very suitable for scrcpy.
      
      For example, SDLNet_TCP_Accept() is non-blocking, so we have to wrap it
      by calling many SDL_Net-specific functions to make it blocking.
      
      But above all, SDLNet_TCP_Open() is a server socket only when no IP is
      provided; otherwise, it's a client socket. Therefore, it is not possible
      to create a server socket bound to localhost, so it accepts connections
      from anywhere.
      
      This is a problem for scrcpy, because on start, the application listens
      for nearly 1 second until it accepts the first connection, supposedly
      from the device. If someone on the local network manages to connect to
      the server socket first, then they can stream arbitrary H.264 video.
      This may be troublesome, for example during a public presentation ;-)
      
      Provide our own simplified API (net.h) instead, implemented for the
      different platforms.
      9b056f50
  9. 15 2月, 2018 3 次提交
    • R
      Add Ctrl+i shortcut to enable/disable FPS counter · d9772022
      Romain Vimont 提交于
      Disable FPS counter on start, and use Ctrl+i to enable/disable it.
      d9772022
    • R
      Refactor screencontrol to inputmanager · 000ced9b
      Romain Vimont 提交于
      The "screen control" handled user input, which happened to be only
      used to control the screen.
      
      The controller and screen were passed to every function. Instead, group
      them in a struct input_manager.
      
      The purpose is to add a new shortcut to enable/disable FPS counter. This
      feature is not related to "screen control", and will require access to
      the "frames" instance.
      000ced9b
    • R
      Add FPS counter · 38e66828
      Romain Vimont 提交于
      Remove frame counter from scrcpy.c and add a new FPS counter, logging as
      INFO the measured frame rate every second (on new frame).
      38e66828
  10. 13 2月, 2018 1 次提交
  11. 09 2月, 2018 12 次提交
    • R
      Timeout the server socket connection · eb09fefd
      Romain Vimont 提交于
      Wait no more than 2 seconds for accepting the connection from the
      device, since it blocks the event loop, preventing to react to SIGTERM
      (Ctrl+C).
      eb09fefd
    • R
      Improve startup time · 90a46b4c
      Romain Vimont 提交于
      On startup, the client has to:
       1. listen on a port
       2. push and start the server to the device
       3. wait for the server to connect (accept)
       4. read device name and size
       5. initialize SDL
       6. initialize the window and renderer
       7. show the window
      
      From the execution of the app_process command to start the server on the
      device, to the execution of the java main method, it takes ~800ms. As a
      consequence, step 3 also takes ~800ms on the client.
      
      Once complete, the client initializes SDL, which takes ~500ms.
      
      These two expensive actions are executed sequentially:
      
                           HOST              DEVICE
      listen on port        |                  |
      push/start the server |----------------->|| app_process loads the jar
      accept the connection .   ^              ||
                            .   |              ||
                            .   | WASTE        ||
                            .   |  OF          ||
                            .   | TIME         ||
                            .   |              ||
                            .   |              ||
                            .   v              X execution of our java main
      connection accepted   |<-----------------| connect to the host
      init SDL             ||                  |
                           || ,----------------| send frames
                           || |,---------------|
                           || ||,--------------|
                           || |||,-------------|
                           || ||||,------------|
      init window/renderer  | |||||,-----------|
      display frames        |<++++++-----------|
      (many frames skipped)
      
      The rationale for step 3 occuring before step 5 is that initializing
      SDL replaces the SIGTERM handler to receive the event in the event loop,
      so pressing Ctrl+C during step 5 would not work (since it blocks the
      event loop).
      
      But this is not so important; let's parallelize the SDL initialization
      with the app_process execution (we'll just add a timeout to the
      connection):
      
                           HOST              DEVICE
      listen on port        |                  |
      push/start the server |----------------->||app_process loads the jar
      init SDL             ||                  ||
                           ||                  ||
                           ||                  ||
                           ||                  ||
                           ||                  ||
                           ||                  ||
      accept the connection .                  ||
                            .                  X execution of our java main
      connection accepted   |<-----------------| connect to the host
      init window/renderer  |                  |
      display frames        |<-----------------| send frames
                            |<-----------------|
      
      In addition, show the window only once the first frame is available to
      avoid flickering (opening a black window for 100~200ms).
      
      Note: the window and renderer are initialized after the connection is
      accepted because they use the device information received from the
      device.
      90a46b4c
    • R
      Provide decoder_init() · 523097ea
      Romain Vimont 提交于
      Expose an initializer so that the caller does not have to guess what
      fields must be initialized.
      523097ea
    • R
      Do not release TCP sockets while still in use · 46621982
      Romain Vimont 提交于
      SDLNet_TCP_Close() not only closes, but also release the resources.
      
      Therefore, we must not close the socket if another thread attempts to
      read it.
      
      For that purpose, move socket closing from server_stop() to
      server_destroy().
      46621982
    • R
      Move frame updating to screen.c · fe21d9df
      Romain Vimont 提交于
      Replace screen_update() by a higher-level screen_update_frame() handling
      the whole frame updating, so that scrcpy.c just call it without managing
      implementation details.
      fe21d9df
    • R
      Fix deadlock on exit if SKIP_FRAMES disabled · 127e5678
      Romain Vimont 提交于
      On exit, the renderer will not consume frames anymore, so signal the
      condition variable to wake up the decoder.
      127e5678
    • R
      Move frame swapping logic to frame.c · 629c2962
      Romain Vimont 提交于
      Expose frames_offer_decoded_frame() and frames_consume_rendered_frame()
      so that callers are not exposed to frame swapping (between the decoding
      and rendering frames) details.
      629c2962
    • R
      Unlock mutex on screen update failure · 0d7f0503
      Romain Vimont 提交于
      The mutex was not unlocked on all code paths.
      0d7f0503
    • R
      Move control-related code to screencontrol.c · e8dfb723
      Romain Vimont 提交于
      Move the code handling user input from scrcpy.c to a separate file,
      screencontrol.c.
      e8dfb723
    • R
      Remove the "adb reverse" tunnel immediately · e1749a0c
      Romain Vimont 提交于
      As soon as we accepted a connection, we can remove the "adb reverse"
      tunnel.
      e1749a0c
    • R
      Move device-related code to device.c · 3b06e7d5
      Romain Vimont 提交于
      Move the code to read the initial device info from scrcpy.c to a
      separate file, device.c.
      3b06e7d5
    • R
      Move server-related code to server.c · 28c5cc03
      Romain Vimont 提交于
      The file server.c already existed, but exposed a low-level API. Make it
      higher-level, so that scrcpy.c does not handle server details directly.
      28c5cc03
  12. 08 2月, 2018 3 次提交
  13. 07 2月, 2018 3 次提交
  14. 06 2月, 2018 1 次提交
    • R
      Parse XPM without SDL_image · 71c2bfdd
      Romain Vimont 提交于
      We encounter some problems with SDL2_image on MSYS2 (Windows), so
      implement our own XPM parsing which does not depend on SDL_image.
      
      The input XPM is considered safe (it's in our source repo), so do not
      check XPM format errors. This implies that read_xpm() is not safe to
      call on any unsafe input.
      
      Although less straightforward, use SDL_CreateRGBSurfaceFrom() instead of
      SDL_CreateRGBSurfaceWithFormatFrom() because it is available with SDL
      versions older than 2.0.5.
      71c2bfdd
  15. 05 2月, 2018 2 次提交
  16. 04 2月, 2018 1 次提交
    • R
      Fix scrcpy() return value · 5eb91a4c
      Romain Vimont 提交于
      The scrcpy() function returns a SDL_bool to indicate its success, but
      was initialized to 0 (SDL_FALSE) instead of SDL_TRUE.
      5eb91a4c