Internal change

PiperOrigin-RevId: 342117974
Change-Id: I9e15d3dfae41a06f5d06cd130e23bf9736676417
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/2586158
Reviewed-by: Ryan Keane <rwkeane@google.com>
Commit-Queue: Ryan Keane <rwkeane@google.com>
diff --git a/cast/cast_core/api/runtime/cast_audio_decoder_service.proto b/cast/cast_core/api/runtime/cast_audio_decoder_service.proto
index d11f8bd..60c3c43 100644
--- a/cast/cast_core/api/runtime/cast_audio_decoder_service.proto
+++ b/cast/cast_core/api/runtime/cast_audio_decoder_service.proto
@@ -110,6 +110,10 @@
   // Indicates if this is a special frame that indicates the end of the stream.
   // If true, functions to access the frame content cannot be called.
   bool end_of_stream = 3;
+
+  // Unique identifier.  This field should be greater than equal to 0 and
+  // incremented by one for each PushBuffeRequest.
+  int64 id = 4;
 }
 
 // Info on pipeline latency.
@@ -130,11 +134,20 @@
   // The end of stream has been rendered.
   bool end_of_stream = 2;
 
-  // Capture time (in microseconds) with respect to the system clock (must be
+  // Capture time with respect to the system clock (must be
   // CLOCK_MONOTONIC_RAW) at which the delay measurement was taken.
   google.protobuf.Timestamp capture_time = 3;
 }
 
+message TimestampInfo {
+  // System timestamp with respect to the systme clock that the corresponding
+  // buffer is expected to be rendered at.
+  google.protobuf.Timestamp system_timestamp = 1;
+
+  // AudioDecoderBuffer.id associated with the |system_timestamp|.
+  int64 buffer_id = 2;
+}
+
 message InitializeRequest {
   // Cast session ID.
   string cast_session_id = 1;
@@ -143,16 +156,35 @@
   CastAudioDecoderMode mode = 2;
 }
 
+message GetMinimumBufferingDelayResponse {
+  // The minimum buffering delay in microseconds.
+  int64 delay_micros = 1;
+}
+
 message StartRequest {
-  // The start playback timestamp in microseconds.
+  // The start presentation timestamp in microseconds.
   int64 pts_micros = 1;
+
+  // Timestamp information associated with the request.
+  // This field is optional and only used when this service is configured
+  // for CAST_AUDIO_DECODER_MODE_MULTIROOM_ONLY.
+  TimestampInfo timestamp_info = 2;
 }
 
 message StopRequest {}
 
 message PauseRequest {}
 
-message ResumeRequest {}
+message ResumeRequest {
+  // Timestamp information associated with the request.
+  // This field is optional and only used when this service is configured
+  // for CAST_AUDIO_DECODER_MODE_MULTIROOM_ONLY.
+  TimestampInfo resume_timestamp_info = 1;
+}
+
+message TimestampUpdateRequest {
+  TimestampInfo timestamp_info = 1;
+}
 
 message StateChangeRequest {
   oneof request {
@@ -160,6 +192,7 @@
     StopRequest stop = 2;
     PauseRequest pause = 3;
     ResumeRequest resume = 4;
+    TimestampUpdateRequest timestamp_update = 5;
   }
 }
 
@@ -212,11 +245,19 @@
   // may be sent prior to receiving this call's response.
   rpc Initialize(InitializeRequest) returns (google.protobuf.Empty);
 
+  // Returns the minimum buffering delay (min_delay) required by Cast.  This is
+  // a constant value and only needs to be queried once for each service.
+  // During a StartRequest or ResumeRequest, the system timestamp must be
+  // greater than this delay and the current time in order for the buffer to be
+  // successfully rendered on remote devices.
+  rpc GetMinimumBufferDelay(google.protobuf.Empty)
+      returns (GetMinimumBufferingDelayResponse);
+
   // Update the pipeline state.
   //
   // StartRequest:
-  //   Places pipeline into 'Playing' state. Playback will start at given time
-  //   once buffers are pushed.
+  //   Places pipeline into 'Playing' state. Playback will start at the
+  //   specified buffer and system timestamp.
   //
   //   May only be called in the 'Stopped' state, and following this call the
   //   state machine will be in the 'Playing' state.
@@ -229,17 +270,34 @@
   //   this call the state machine will be in the 'Stopped' state.
   //
   // PauseRequest
-  //   Pauses media playback
+  //   Pauses media playback.
   //
   //   May only be called in the 'Playing' state, and following this call the
   //   state machine will be in the 'Paused' state.
   //
   // ResumeRequest
-  //   Resumes media playback
+  //   Resumes media playback at the specified buffer and system timestamp.
   //
   //   May only be called in the 'Paused' state, and following this call the
   //   state machine will be in the 'Playing'' state.
   //
+  // TimestampUpdateRequest
+  //   Sends a timestamp update for a specified buffer for audio
+  //   synchronization. This should be called when operating in
+  //   CAST_AUDIO_DECODER_MODE_MULTIROOM_ONLY when the runtime has detected a
+  //   discrepancy in the system clock or pipeline delay from the original
+  //   playback schedule.  See example below:
+  //
+  //   Assume all buffers have duration of 100us.
+  //
+  //   StartRequest(id=1, system_timestamp=0);
+  //   -> Cast expects id=1 to play at 0, id=2 at 100us, id=3 at 200 us...
+  //
+  //   TimestampUpdateRequest(id=4, system_timestamp=405us);
+  //   -> Cast expects id=4 to play at 405, id=5 at 505us, id=6 at 605 us...
+  //
+  //   May be called from any state.
+  //
   // A state transition may only occur after a successful PushBuffer()
   // call has been made with a valid configuration.
   rpc StateChange(StateChangeRequest) returns (StateChangeResponse);