Skip to content

Simple android app that can connect to a specified address and stream data to it

Notifications You must be signed in to change notification settings

SleepyDevelopersTeam/AndroidVideoStreamer

Repository files navigation

AndroidVideoStreamer

Simple android app that can connect to a specified address and stream data to it

Connection protocol

Application uses ultra-modern communication protocol SDTUDTP3K (SDevTeam Ultra Data Transfer Protocol 3000). Here is its specification:

Commands

Server and client exchange with raw binary data (not strings!). Commands may be of 2 types: control command and data command. Control command is one single byte of data with following values (INPORTANT! Following constants are of type signed byte, sbyte, char in C++ or byte in Java):

(client can send following commands):

  • 0x1E: "Hello server" message;
  • 0x31: client is to change data command length (IMPORTANT! This command is followed with 4 bytes of length!);
  • 0x3F: "Fone reset" command;
  • 0x45: "Goodbye server" message;

(server can send following commands):

  • 0x1A: "Hello client" message;
  • 0x2D: "Data received" server response;
  • 0x3E: "Command executed" message;
  • 0x4C: "Goodbye client" message;

(both server and client can send following commands):

  • 0x66: some error occured;

Data command is a bulk array of image data bytes, following the single byte with value 0x00 (to differ data command from control command). First 2 bytes of this array represent image width (as a Java short variable), and second ones represent image height. This type of command can be sent only from client side. See more in part Data Format

Communication

  1. Handshaking:
  2. Client (who starts the connection) sends "Hello server" message (0x1E).
  3. Server sends "Hello client" message (0x1A).
  4. Client sends 4 bytes that represent data command data length (without considering 0x00 byte!).

NOTICE: there is a SDTUDTP3Km version of protocol, which does not includes data sending into handshake, but the first command after handshake is always length change command (0x31), that is followed with 4 bytes of value of new data length.

  1. After handshaking, data exchange starts:

  2. Client sends data command.

  3. Server sends "Data received" (0x2D) message.

  4. Can be repeated till the end of days.

  5. If client answers with not a data command (first byte is not zero), it is a control command:

  6. Client sends a command (see list above).

  7. Server executes the command and sends "Command executed" message (0x3E) if succeeded.

  8. Server sends error message (0x66) if some error has occured while executing the command. Communication SHOULD NOT stop in this case.

  9. Closing the connection:

  10. Client is always the initiator of closing the connection.

  11. Client sends "Goodbye server" message (0x45).

  12. Server sends "Goodbye client" message (0x4C).

  13. Server closes the connection (socket).

  14. Error handling:

  15. If server has some internal error (important: not during execution of client command (3.2)), it sends error message 0x66.

  16. If client has some internal error, it sends error message 0x66.

  17. Crashed device doesn't have to close socket or send any other data. The other device should properly handle this situation.

  18. If client crashes, server returns to "wait mode", awaiting a client to connect.

  19. If server crashes, client returns to "connect" screen and should be ready for further attempts to connect to server.

Data Format

Image is sent as raw byte sequence in format YUV NV_21. For an appropriate conversion from it to RGB, see this class (the last method in the file).

Raw image data follows 4 bytes representing image width and height, 2 bytes per value. They are stored as signed short integers (short in Java).

About

Simple android app that can connect to a specified address and stream data to it

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages