/*
 * Created by jonathan.jesperson@pluto.tv on 10/21/2020.
 * Copyright (c) PlutoTV Inc 2020.
 */

syntax = "proto3";

package subclippackage;

option go_package = "github.com/Pluto-tv/service-dal/golang_client";
option java_package = "tv.pluto.ip.dal.subclip";

service SubClipManager {
  // GetById (Unary)
  //
  rpc GetById(GetByIdRequest) returns (GetByIdResponse) {}

  // GetByIds (Unary)
  //
  rpc GetByIds(GetByIdsRequest) returns (GetByIdsResponse) {}

  // Create (Unary)
  //
  rpc Create(CreateRequest) returns (CreateResponse) {}
}

message GetByIdRequest {
  string id = 1;
}

message GetByIdResponse {
  SubClip document = 1;
}

message GetByIdsRequest {
  repeated string ids = 1;
  repeated GetAllPagedSort sort = 2;
}

message GetAllPagedSort {
  // field to sort on
  string field = 1;
  // sort direction 1 | -1
  int32 value = 2;
}

message GetByIdsResponse {
  repeated SubClip documents = 1;
}

message CreateRequest {
  SubClip document = 1;
}

message CreateResponse {
  SubClip document = 1;
}

message SubClip {
  string id = 1;
  string created_at = 2;
  string updated_at = 3;
  int32 start_at = 4;
  string url = 5;
  repeated Transcode transcodes = 6;
  Origin origin = 7;
  double duration = 8;
  string content_status = 9;
  repeated Source sources = 10;
}

message Source {
  string file = 1;
  string id = 2;
  string type = 3;
  string encryption = 4;
}

message Transcode {
  string finished_at = 1;
  string external_i_d = 2;
  string transcoder_name = 3;
  string transcode_mode = 4;
  string id = 5;
  repeated Output output = 6;
}

message Origin {
  string url = 1;
  string src_url = 2;
  string type = 3; /// options: 'MP4', 'WebM', 'FLV', 'HLS', 'DASH', 'RTMP', 'MOV', 'video/mp4', 'video/webm', 'video/x-flv', 'application/x-mpegURL', 'application/octet-stream', 'video/mpeg', 'video/quicktime', 'video/x-msvideo', 'video/x-ms-wmv', 'binary/octet-stream',
  int32 in_point = 4; /// Used to crop video, in seconds
  int32 out_point = 5; /// Used to crop video, in seconds
  int32 bitrate = 6; /// Bitrate in kbps
  int32 duration = 7; /// Seconds
  int32 height = 8;
  int32 width = 9;
  optional int32 size = 10; /// Optional. Size in bytes,
  optional string md5 = 11; /// Optional, 32-character MD5 digest of video
  bool generatingFile = 12; /// Used to flag when the origin file is being generated by the worker-hls-to-mp4
}

message Output {
  string url = 1;
  string type = 2;
  string id = 3;
  Dimensions dimensions = 4;
}

message Dimensions {
  string width = 1;
  string height = 2;
}
