syntax = "proto2";

// Corresponds to struct Client.
message ClientProto {
	optional int32 sock = 1;
	optional string remote_addr = 8;
	optional int64 connect_time_sec = 13;
	optional int32 connect_time_nsec = 14;
	optional int32 state = 2;
	optional bytes request = 3;
	optional string url = 4;
	optional bytes header_or_short_response_old = 5;  // Only for pre-1.4.0 servers. Use header_or_short_response_index instead.
	optional int64 header_or_short_response_index = 21;  // Index into CubemapStateProto.short_response_pool.
	optional int64 header_or_short_response_bytes_sent = 6;
	optional int64 stream_pos = 7;
	optional int64 stream_pos_end = 20 [default=-1];
	optional int64 bytes_sent = 10;
	optional int64 bytes_lost = 11;
	optional int64 num_loss_events = 12;
	optional bytes referer = 15;
	optional bytes user_agent = 16;
	optional bytes tls_context = 17;  // If not present, then not using TLS for this client.
	optional int64 tls_output_bytes_already_consumed = 18;
	optional bool in_ktls_mode = 19;
	optional bytes x_playback_session_id = 22;
	optional bool close_after_response = 23 [default=true];
	optional bool http_11 = 24 [default=false];
};

// Corresponds to struct Stream::FragmentStart.
message FragmentStartProto {
	optional int64 byte_position = 1;
	optional double pts = 2;
	optional bool begins_header = 3 [default=false];
};

// Corresponds to struct Stream.
message StreamProto {
	optional bool unavailable = 14 [default=false];
	optional bytes http_header = 6;
	optional bytes stream_header = 7;
	repeated int32 data_fds = 8;
	optional int64 backlog_size = 5 [default=10485760];
	// Tag 10 is unused from 1.4.0 up (it used to be prebuffering_bytes).
	optional int64 bytes_received = 3;
	repeated int64 suitable_starting_point = 9;
	repeated FragmentStartProto fragment = 11;
	optional int64 first_fragment_index = 12;
	optional int64 discontinuity_counter = 13;
	optional string url = 4;
};

// Corresponds to class Input.
message InputProto {
	optional int32 state = 1;
	optional string url = 3;
	optional bytes request = 4;
	optional int32 request_bytes_sent = 5;
	optional bytes response = 6;
	optional bytes http_header = 10;
	optional bytes stream_header = 14;
	optional bytes pending_data = 7;
	optional bool has_metacube_header = 8;
	optional int32 sock = 9;
	optional int64 child_pid = 18 [default=-1];
	optional int64 bytes_received = 11;
	optional int64 data_bytes_received = 12;
	optional int64 metadata_bytes_received = 16;
	optional double latency_sec = 17;
	optional int64 connect_time = 13;
	optional bool is_metacube_encoded = 15 [default=true];
};

// Corresponds to class Acceptor.
message AcceptorProto {
	optional int32 server_sock = 1;
	optional int32 port = 2;
	optional string addr = 3;  // As a string. Empty is equivalent to "::".
	optional bytes certificate_chain = 4;
	optional bytes private_key = 5;
};

// For deduplicating strings in header_or_short_response.
message ShortResponsePool {
	optional bytes header_or_short_response = 1;
};

message HLSZombieProto {
        optional bytes key = 1;
        optional bytes remote_addr = 2;
        optional bytes url = 3;
        optional bytes referer = 4;
        optional bytes user_agent = 5;
        optional int64 expires_sec = 6;
        optional int64 expires_nsec = 7;
};

message CubemapStateProto {
	optional int64 serialize_start_sec = 6;
	optional int64 serialize_start_usec = 7;
	repeated ClientProto clients = 1;
	repeated StreamProto streams = 2;
	repeated InputProto inputs = 5;
	repeated AcceptorProto acceptors = 8;
	repeated ShortResponsePool short_response_pool = 9;
	repeated HLSZombieProto hls_zombies = 10;
};
