|
| 1 | +syntax = "proto3"; |
| 2 | + |
| 3 | +package thamesflix.streaming.v1alpha1; |
| 4 | + |
| 5 | +import "google/protobuf/timestamp.proto"; |
| 6 | + |
| 7 | +// The streaming service is responsible for managing the playback of titles. |
| 8 | +service StreamingService { |
| 9 | + // Creates a new playback session for a title. |
| 10 | + rpc CreatePlaybackSession(CreatePlaybackSessionRequest) returns (CreatePlaybackSessionResponse); |
| 11 | + // TODO: Implement these methods. |
| 12 | + // |
| 13 | + // // Retrieves the playback session for a title. |
| 14 | + // rpc GetPlaybackSession(GetPlaybackSessionRequest) returns (GetPlaybackSessionResponse) { |
| 15 | + // option idempotency_level = NO_SIDE_EFFECTS; |
| 16 | + // } |
| 17 | + // // Lists the playback sessions for a user. |
| 18 | + // rpc ListPlaybackSessions(ListPlaybackSessionsRequest) returns (ListPlaybackSessionsResponse) { |
| 19 | + // option idempotency_level = NO_SIDE_EFFECTS; |
| 20 | + // } |
| 21 | + // Sends a heartbeat to keep the playback session alive. |
| 22 | + rpc SendHeartbeat(SendHeartbeatRequest) returns (SendHeartbeatResponse); |
| 23 | + // Pauses the playback of a title. |
| 24 | + rpc PausePlayback(PausePlaybackRequest) returns (PausePlaybackResponse); |
| 25 | + // Resumes the playback of a title. |
| 26 | + rpc ResumePlayback(ResumePlaybackRequest) returns (ResumePlaybackResponse); |
| 27 | + // Restarts the playback of a title. |
| 28 | + rpc RestartPlayback(RestartPlaybackRequest) returns (RestartPlaybackResponse); |
| 29 | +} |
| 30 | + |
| 31 | +// CreatePlaybackSessionRequest defines the request message for CreatePlaybackSession. |
| 32 | +message CreatePlaybackSessionRequest { |
| 33 | + // The playback session to create. |
| 34 | + PlaybackSession playback_session = 1; |
| 35 | +} |
| 36 | + |
| 37 | +// CreatePlaybackSessionResponse defines the response message for CreatePlaybackSession. |
| 38 | +message CreatePlaybackSessionResponse { |
| 39 | + // The playback session that was started or resumed. |
| 40 | + PlaybackSession playback_session = 1; |
| 41 | +} |
| 42 | + |
| 43 | +// SendHeartbeatRequest defines the request message for SendHeartbeat. |
| 44 | +message SendHeartbeatRequest { |
| 45 | + // The ID of the playback session. |
| 46 | + string playback_session_id = 1; |
| 47 | + // The position in the title in seconds. |
| 48 | + // This can be used to update the position of the playback session, for example, when the user seeks. |
| 49 | + uint64 position_seconds = 2; |
| 50 | +} |
| 51 | + |
| 52 | +// SendHeartbeatResponse defines the response message for SendHeartbeat. |
| 53 | +message SendHeartbeatResponse {} |
| 54 | + |
| 55 | +// PausePlaybackRequest defines the request message for PausePlayback. |
| 56 | +message PausePlaybackRequest { |
| 57 | + // The ID of the playback session. |
| 58 | + string playback_session_id = 1; |
| 59 | +} |
| 60 | + |
| 61 | +// PausePlaybackResponse defines the response message for PausePlayback. |
| 62 | +message PausePlaybackResponse {} |
| 63 | + |
| 64 | +// ResumePlaybackRequest defines the request message for ResumePlayback. |
| 65 | +message ResumePlaybackRequest { |
| 66 | + // The ID of the playback session. |
| 67 | + string playback_session_id = 1; |
| 68 | +} |
| 69 | + |
| 70 | +// ResumePlaybackResponse defines the response message for ResumePlayback. |
| 71 | +message ResumePlaybackResponse {} |
| 72 | + |
| 73 | +// RestartPlaybackRequest defines the request message for RestartPlayback. |
| 74 | +message RestartPlaybackRequest { |
| 75 | + // The ID of the playback session. |
| 76 | + string playback_session_id = 1; |
| 77 | +} |
| 78 | + |
| 79 | +// RestartPlaybackResponse defines the response message for RestartPlayback. |
| 80 | +message RestartPlaybackResponse {} |
| 81 | + |
| 82 | +// PlaybackSession represents an active session of a title being played. |
| 83 | +message PlaybackSession { |
| 84 | + // The unique identifier of the playback session. |
| 85 | + // For create requests, this field is set by the server and cannot be changed. |
| 86 | + // For update requests, users must provide a valid ID of an existing title. |
| 87 | + string id = 1; |
| 88 | + // The id of the user who created the playback session. |
| 89 | + // This field is set by the server and cannot be changed. |
| 90 | + string user_id = 2; |
| 91 | + // When the playback session was created in the system. |
| 92 | + // This field is set by the server and cannot be changed. |
| 93 | + google.protobuf.Timestamp create_time = 3; |
| 94 | + // When the playback session was last updated in the system. |
| 95 | + // This field is set by the server and cannot be changed. |
| 96 | + google.protobuf.Timestamp update_time = 4; |
| 97 | + // When the playback session was completed. |
| 98 | + // This field will be set by the server when the playback session is completed. |
| 99 | + google.protobuf.Timestamp complete_time = 5; |
| 100 | + // The ID of the title being played. |
| 101 | + // Required for create requests. |
| 102 | + // Must be a valid title ID in the system and the title must be available to the user. |
| 103 | + // This field cannot be changed after the playback session is created. |
| 104 | + string title_id = 6; |
| 105 | + // How far into the title the playback session is. |
| 106 | + // The position is maintained by an internal timer and can only be updated via the SendHeartbeat method. |
| 107 | + uint64 position_seconds = 7; |
| 108 | + // The status of the playback session. |
| 109 | + // Users can only update the status of the playback session via the PausePlayback and ResumePlayback methods. |
| 110 | + PlaybackStatus status = 8; |
| 111 | + // The interval in seconds to send heartbeats. |
| 112 | + // If a heartbeat is not received within the interval, the playback session is considered inactive and will be paused. |
| 113 | + // The default value is 15 seconds. |
| 114 | + uint64 heartbeat_interval_seconds = 9; |
| 115 | + // How many times the user has watched the title. |
| 116 | + // This field is incremented each time the user completes the title and cannot be changed by the user. |
| 117 | + uint64 watch_count = 10; |
| 118 | +} |
| 119 | + |
| 120 | +// PlaybackStatus represents the status of a playback session. |
| 121 | +enum PlaybackStatus { |
| 122 | + // Unspecified playback status. |
| 123 | + PLAYBACK_STATUS_UNSPECIFIED = 0; |
| 124 | + // The title is currently playing. |
| 125 | + PLAYBACK_STATUS_PLAYING = 1; |
| 126 | + // The playback of the title is paused. |
| 127 | + PLAYBACK_STATUS_PAUSED = 2; |
| 128 | + // The playback of the title has completed. |
| 129 | + PLAYBACK_STATUS_COMPLETED = 3; |
| 130 | +} |
0 commit comments