1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113

media / mojo / mojom / media_metrics_provider.mojom [blame]

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

module media.mojom;

import "media/learning/mojo/public/mojom/learning_task_controller.mojom";
import "media/mojo/mojom/media_types.mojom";
import "media/mojo/mojom/video_decode_stats_recorder.mojom";
import "media/mojo/mojom/playback_events_recorder.mojom";
import "media/mojo/mojom/watch_time_recorder.mojom";
import "mojo/public/mojom/base/time.mojom";

// Used for reporting to UMA and UKM. Represents the URL scheme of the src URL
// given to an <audio> or <video> tag. Always add new entries to the end.
enum MediaURLScheme {
  kUnknown = 0,
  kMissing,
  kHttp,
  kHttps,
  kFtp,
  kChromeExtension,
  kJavascript,
  kFile,
  kBlob,
  kData,
  kFileSystem,
  kChrome,
  kContent,
  kContentId,
};

// Provider interface used to avoid having one time setters on each interface.
// Each recorder will be stamped with an ID which can be used for linking UKM.
interface MediaMetricsProvider {
  // Assigns a playback ID and sets up this provider instance with information
  // needed to make UKM reports. No other methods may be called until after
  // Initialize() has been called. |url_scheme| is only used if |!is_mse|.
  // If |stream_type| is one of the MediaStream types (i.e., not kNone),
  // UMA metrics are not recorded.
  Initialize(bool is_mse,
             MediaURLScheme url_scheme,
             MediaStreamType stream_type);

  // Called when a playback is started, i.e., right after initializing the
  // demuxer and obtaining the metadata. The status is reported to UKM when the
  // provider is destructed.
  OnStarted(PipelineStatus status);

  // Called when a playback ends in error. The status is reported to UKM when
  // the provider is destructed.
  OnError(PipelineStatus status);

  // Called when some portion of the pipeline wants to report a non-fatal error,
  // such as hardware decode failure that falls back to a successful software
  // decoded playback session, or a failed hardware renderer path which falls
  // back to a successful software one.
  OnFallback(PipelineStatus status);

  // Setters for various one-time lazily generated metrics or properties.
  SetHasPlayed();
  SetHaveEnough();
  SetIsEME();
  SetTimeToMetadata(mojo_base.mojom.TimeDelta elapsed);
  SetTimeToFirstFrame(mojo_base.mojom.TimeDelta elapsed);
  SetTimeToPlayReady(mojo_base.mojom.TimeDelta elapsed);

  // Sets the RendererType used in the playback.
  SetRendererType(RendererType renderer_type);

  // Sets the DemuxerType used in the playback.
  SetDemuxerType(DemuxerType demuxer_type);

  // Sets the EME key system used for an EME playback. For clear playback, or if
  // the `key_system` is not recognized, value 0 (kUnknownKeySystemForUkm) will
  // be reported.
  SetKeySystem(string key_system);

  // Called when the EME playback has been blocked waiting for the CDM to be set
  // or waiting for decryption key.
  SetHasWaitingForKey();

  // Called when the EME playback uses a hardware secure pipeline.
  SetIsHardwareSecure();

  // For src= playbacks, this is the container (".mp4", ".webm", etc).
  SetContainerName(MediaContainerName container_name);

  // Creates a WatchTimeRecorder instance using |properties|. If any of those
  // properties changes, a new recorder should be requested.
  AcquireWatchTimeRecorder(PlaybackProperties properties,
                           pending_receiver<WatchTimeRecorder> recorder);

  // Creates a VideoDecodeStatsRecorder instance.
  AcquireVideoDecodeStatsRecorder(
      pending_receiver<VideoDecodeStatsRecorder> recorder);

  // Returns a LearningTaskController for the given |taskName|.
  AcquireLearningTaskController(
      string taskName,
      pending_receiver<media.learning.mojom.LearningTaskController> controller);

  // Returns a PlaybackEventsRecorder instance. Implementation may drop the
  // |receiver| if it's not interested in recording playback events.
  AcquirePlaybackEventsRecorder(
       pending_receiver<PlaybackEventsRecorder> receiver);

  // Can be called multiple times to set properties about a playback.
  SetHasAudio(AudioCodec codec);
  SetHasVideo(VideoCodec codec);
  SetVideoPipelineInfo(VideoPipelineInfo info);
  SetAudioPipelineInfo(AudioPipelineInfo info);
};