// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.cloud.video.livestream.logging.v1;

import "google/cloud/video/livestream/v1/resources.proto";
import "google/rpc/status.proto";

option go_package = "cloud.google.com/go/video/livestream/logging/apiv1/loggingpb;loggingpb";
option java_multiple_files = true;
option java_outer_classname = "LogsProto";
option java_package = "com.google.cloud.video.livestream.logging.v1";

// Logs of activities related to the Channels.
message ChannelActivity {
  // Message is for more details of the log and instructions to users.
  string message = 1;

  // Different types of the logs.
  oneof activity_type {
    // The channel streaming state changes.
    StreamingStateChange streaming_state_change = 2;

    // An error happens with the video pipeline.
    StreamingError streaming_error = 3;

    // The channel has accepted an input stream.
    InputAccept input_accept = 4;

    // An error happens with the input stream.
    InputError input_error = 5;

    // An input stream disconnects.
    InputDisconnect input_disconnect = 6;
  }
}

// StreamingStateChange records when the channel streaming state changes.
message StreamingStateChange {
  // New streaming state of the channel.
  google.cloud.video.livestream.v1.Channel.StreamingState new_state = 1;

  // Previous streaming state of the channel.
  google.cloud.video.livestream.v1.Channel.StreamingState previous_state = 2;
}

// StreamingError records when an error happens with the video pipeline.
message StreamingError {
  // A description of the reason for the streaming error.
  google.rpc.Status error = 1;
}

// InputAccept records when the channel has accepted an input stream.
message InputAccept {
  // ID of the input stream.
  string stream_id = 1;

  // The user-defined key for the input attachment.
  string input_attachment = 2;

  // Properties of the input stream.
  InputStreamProperty input_stream_property = 3;
}

// InputError records when an error happens with the input stream.
message InputError {
  // ID of the input stream.
  string stream_id = 1;

  // The user-defined key for the input attachment. If the stream doesn’t belong
  // to any input attachment, this field is empty.
  string input_attachment = 2;

  // Properties of the input stream.
  InputStreamProperty input_stream_property = 3;

  // A description of the reason for the error with the input stream.
  google.rpc.Status error = 4;
}

// Properties of the input stream.
message InputStreamProperty {
  // Properties of the video streams.
  repeated VideoStream video_streams = 1;

  // Properties of the audio streams.
  repeated AudioStream audio_streams = 2;
}

// Properties of the video stream.
message VideoStream {
  // Index of this video stream.
  int32 index = 1;

  // Properties of the video format.
  VideoFormat video_format = 2;
}

// Properties of the video format.
message VideoFormat {
  // Video codec used in this video stream.
  string codec = 1;

  // The width of the video stream in pixels.
  int32 width_pixels = 2;

  // The height of the video stream in pixels.
  int32 height_pixels = 3;

  // The frame rate of the input video stream.
  double frame_rate = 4;
}

// Properties of the audio stream.
message AudioStream {
  // Index of this audio stream.
  int32 index = 1;

  // Properties of the audio format.
  AudioFormat audio_format = 2;
}

// Properties of the audio format.
message AudioFormat {
  // Audio codec used in this audio stream.
  string codec = 1;

  // The number of audio channels.
  int32 channel_count = 2;

  // A list of channel names specifying the layout of the audio channels.
  repeated string channel_layout = 3;
}

// InputDisconnect records when an input stream disconnects.
message InputDisconnect {
  // ID of the input stream.
  string stream_id = 1;

  // The user-defined key for the input attachment.
  string input_attachment = 2;
}
