Skip to content

Protocol

Dominik Trusiński edited this page Jun 12, 2018 · 16 revisions

Header structure

Field Description Length in characters Range of values
Message type Type of message 2 From 0 to 99
Body length Length of body in bytes 8 From 0 to 99999999
Number of columns Number of columns in one frame 4 From 0 to 9999
Number of rows Number of rows in one frame 4 From 0 to 9999
Number of frames Number of frames 8 From 0 to 99999999
Frame number Number of transmitted frame 8 From 0 to 99999999
Is key frame Is this frame a key frame 1 0 or 1

Additional information for Frame number field:

  • When send from server to client this field contains number of sent frame
  • When send from client to server this field contains number of desired frame

Therefore header length is 35 bytes

Messages

Each message type is encoded using number. This number is provided below, in parenthesis

Type Sender Description In body
GET MOVIE LIST(0) Client Asks server to present list of available movies EMPTY
GIVE MOVIE LIST(1) Server Gives movie list to client Movie list
GET MOVIE(2) Client Asks server to send movie data Movie name
GIVE FRAME(3) Server Gives frame to client Frame
GET FRAME(4) Client Asks server for particular frame EMPTY
MOVIE FINISHED(5) Client Informs server that client has displayed last frame EMPTY
DISCONNECT(6) Client Informs server that client will disconnect EMPTY
SPEED CONTROL INIT(7) Client Client informs server that it can start speed control EMPTY
SPEED CONTROL FIN(8) Client Informs client that his speed has been just updated Empty
GIVE SAMPLE (9) Server Sends sample of audio Sample

Additional information for speed control mechanism

Normally when body is empty receiving side does not send confirmation. However in case of SPEED CONTROL INIT, server does send a confirmation with extra garbage so that size of this packet is similar to size of frame data. After receiving this confirmation client sends SPEED CONTROL FIN with timestamp. This message does have a body but confirmation is not send because timestamp has constant width. This width is equal to 20 characters padded with zeros if needed.

Additional information for GIVE MOVIE LIST body

Movies are separated by delimeter \n.

Typical conversation

  1. Client connects
  2. Clients sends GET MOVIE LIST
  3. Server sends GIVE MOVIE LIST
  4. Client sends GET MOVIE
  5. Server sends GIVE FRAME
  6. Client sends GET FRAME
  7. When movie finishes, client sends MOVIE FINISHED
  8. When client disconnects it sends DISCONNECT