chromium/media/base/pipeline_status.h

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_BASE_PIPELINE_STATUS_H_
#define MEDIA_BASE_PIPELINE_STATUS_H_

#include <stdint.h>

#include <iosfwd>
#include <optional>
#include <string>

#include "base/functional/callback.h"
#include "base/time/time.h"
#include "media/base/decoder.h"
#include "media/base/media_export.h"
#include "media/base/status.h"
#include "media/base/timestamp_constants.h"

namespace media {

// Status states for pipeline.  All codes except PIPELINE_OK indicate errors.
// Logged to UMA, so never reuse a value, always add new/greater ones!
// When adding a new one, also update enums.xml.
enum PipelineStatusCodes : StatusCodeType {};

struct PipelineStatusTraits {};

PipelineStatus;

// Returns a string version of the status, unique to each PipelineStatus, and
// not including any ':'. This makes it suitable for usage in
// MediaError.message as the UA-specific-error-code.
MEDIA_EXPORT std::string PipelineStatusToString(const PipelineStatus& status);

MEDIA_EXPORT std::ostream& operator<<(std::ostream& out,
                                      const PipelineStatus& status);

// TODO(crbug.com/40649615): Delete PipelineStatusCB once all callbacks are
//                          converted to PipelineStatusCallback.
PipelineStatusCB;
PipelineStatusCallback;

// Information on how an audio/video stream is encrypted.
// Warning: Reported to UKM. Do not reuse or change existing values.
// Note: A stream can be marked as clear (unencrypted) or encrypted in the
// config. In a clear stream, all buffers must be clear. In an encrypted stream,
// buffers can be clear or encrypted. The term "clear lead" generally indicates
// the case where an encrypted stream starts with one or more clear buffers. In
// implementation, since a playback can start from the middle of a stream, the
// playback may not hit clear lead even if the stream has clear lead, so it'll
// be reported as `kEncrypted`, which is okay for metrics' purpose.
enum class EncryptionType {};

template <typename DecoderType>
struct PipelineInfo {};

AudioPipelineInfo;
VideoPipelineInfo;

template <typename DecoderType>
MEDIA_EXPORT inline bool operator==(const PipelineInfo<DecoderType>& first,
                                    const PipelineInfo<DecoderType>& second) {}

template <typename DecoderType>
MEDIA_EXPORT inline bool operator!=(const PipelineInfo<DecoderType>& first,
                                    const PipelineInfo<DecoderType>& second) {}

template <typename DecoderType>
MEDIA_EXPORT inline std::ostream& operator<<(
    std::ostream& out,
    const PipelineInfo<DecoderType>& info) {}

// Statistics for the media pipeline.
// Note: Different classes may have different interpretation on the fields.
// RendererClient.OnStatisticsUpdate() expects *_decoded*, *_dropped and
// *memory_usage to be the delta since the last OnStatisticsUpdate() call.
// WebMediaPlayerImpl expects them to be cumulation since playback start.
// TODO(crbug.com/40207229): Make the meaning consistent.
struct MEDIA_EXPORT PipelineStatistics {};

MEDIA_EXPORT bool operator==(const PipelineStatistics& first,
                             const PipelineStatistics& second);
MEDIA_EXPORT bool operator!=(const PipelineStatistics& first,
                             const PipelineStatistics& second);

// Used for updating pipeline statistics; the passed value should be a delta
// of all attributes since the last update.
StatisticsCB;

}  // namespace media

#endif  // MEDIA_BASE_PIPELINE_STATUS_H_