/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * 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 = "proto2";

package perfetto.protos;

message ObservableEvents {
  enum Type {
    TYPE_UNSPECIFIED = 0;

    // State changes of data source instances associated with the consumer's
    // session. Note that not all data sources may support these notifications.
    // See |will_notify_on_start/stop| in DataSourceDescriptor.
    TYPE_DATA_SOURCES_INSTANCES = 1;

    // State change triggered when all data sources are in the STARTED state.
    // For data sources that registered with |will_notify_on_start| this happens
    // only after the data source has acked the start. This allows the consumer
    // to synchronize with the data sources and to perform actions (e.g. start a
    // test binary) only after trace recording is actually started.
    // Introduced in Android 11 (R).
    TYPE_ALL_DATA_SOURCES_STARTED = 2;

    // Note: internally these are used as OR flags. Next values: 4, 8, 16, ...

    // TODO(eseckler): Extend this for producer & data source registrations.
  }

  enum DataSourceInstanceState {
    // A data source is created in stopped state.
    DATA_SOURCE_INSTANCE_STATE_STOPPED = 1;
    DATA_SOURCE_INSTANCE_STATE_STARTED = 2;
  }

  message DataSourceInstanceStateChange {
    optional string producer_name = 1;
    optional string data_source_name = 2;
    optional DataSourceInstanceState state = 3;
  }

  repeated DataSourceInstanceStateChange instance_state_changes = 1;
  optional bool all_data_sources_started = 2;
}
