OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MEDIA_REMOTING_METRICS_H_ |
| 6 #define MEDIA_REMOTING_METRICS_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/optional.h" |
| 10 #include "base/time/time.h" |
| 11 #include "media/base/pipeline_metadata.h" |
| 12 #include "media/remoting/triggers.h" |
| 13 #include "ui/gfx/geometry/size.h" |
| 14 |
| 15 namespace media { |
| 16 namespace remoting { |
| 17 |
| 18 class SessionMetricsRecorder { |
| 19 public: |
| 20 SessionMetricsRecorder(); |
| 21 ~SessionMetricsRecorder(); |
| 22 |
| 23 // When attempting to start a remoting session, WillStartSession() is called, |
| 24 // followed by either OnSessionStartSucceeded() or OnSessionStop() to indicate |
| 25 // whether the start succeeded. Later, OnSessionStop() is called when the |
| 26 // session ends. |
| 27 void WillStartSession(StartTrigger trigger); |
| 28 void DidStartSession(); |
| 29 void WillStopSession(StopTrigger trigger); |
| 30 |
| 31 // These may be called before, during, or after a remoting session. |
| 32 void OnPipelineMetadataChanged(const PipelineMetadata& metadata); |
| 33 void OnRemotePlaybackDisabled(bool disabled); |
| 34 void OnPosterImageDownloaded(const base::TimeDelta download_duration, |
| 35 bool success); |
| 36 |
| 37 private: |
| 38 // Whether audio only, video only, or both were played during the session. |
| 39 // |
| 40 // NOTE: Never re-number or re-use numbers here. These are used in UMA |
| 41 // histograms, and must remain backwards-compatible for all time. However, |
| 42 // *do* change TRACK_CONFIGURATION_MAX to one after the greatest value when |
| 43 // adding new ones. Also, don't forget to update histograms.xml! |
| 44 enum TrackConfiguration { |
| 45 NEITHER_AUDIO_NOR_VIDEO = 0, |
| 46 AUDIO_ONLY = 1, |
| 47 VIDEO_ONLY = 2, |
| 48 AUDIO_AND_VIDEO = 3, |
| 49 |
| 50 TRACK_CONFIGURATION_MAX = 3, |
| 51 }; |
| 52 |
| 53 // Helper methods to record media configuration at relevant times. |
| 54 void RecordAudioConfiguration(); |
| 55 void RecordVideoConfiguration(); |
| 56 void RecordTrackConfiguration(); |
| 57 |
| 58 // |start_trigger_| is set while a remoting session is active. |
| 59 base::Optional<StartTrigger> start_trigger_; |
| 60 |
| 61 // When the current (or last) remoting session started. |
| 62 base::TimeTicks start_time_; |
| 63 |
| 64 // Last known audio and video configuration. These can change before/after a |
| 65 // remoting session as well as during one. |
| 66 AudioCodec last_audio_codec_; |
| 67 ChannelLayout last_channel_layout_; |
| 68 int last_sample_rate_; |
| 69 VideoCodec last_video_codec_; |
| 70 VideoCodecProfile last_video_profile_; |
| 71 gfx::Size last_natural_size_; |
| 72 |
| 73 // Last known disabled playback state. This can change before/after a remoting |
| 74 // session as well as during one. |
| 75 bool remote_playback_is_disabled_; |
| 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(SessionMetricsRecorder); |
| 78 }; |
| 79 |
| 80 class RendererMetricsRecorder { |
| 81 public: |
| 82 RendererMetricsRecorder(); |
| 83 ~RendererMetricsRecorder(); |
| 84 |
| 85 // Called when an "initialize success" message is received from the remote. |
| 86 void OnRendererInitialized(); |
| 87 |
| 88 // Called whenever there is direct (or indirect, but close-in-time) evidence |
| 89 // that playout has occurred. |
| 90 void OnEvidenceOfPlayoutAtReceiver(); |
| 91 |
| 92 // These are called at regular intervals throughout the session to provide |
| 93 // estimated data flow rates. |
| 94 void OnAudioRateEstimate(int kilobits_per_second); |
| 95 void OnVideoRateEstimate(int kilobits_per_second); |
| 96 |
| 97 private: |
| 98 const base::TimeTicks start_time_; |
| 99 bool did_record_first_playout_; |
| 100 |
| 101 DISALLOW_COPY_AND_ASSIGN(RendererMetricsRecorder); |
| 102 }; |
| 103 |
| 104 } // namespace remoting |
| 105 } // namespace media |
| 106 |
| 107 #endif // MEDIA_REMOTING_METRICS_H_ |
OLD | NEW |