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_TRIGGERS_H_
6 #define MEDIA_REMOTING_TRIGGERS_H_
7 
8 namespace media {
9 namespace remoting {
10 
11 // Events and conditions that can trigger remoting to start.
12 //
13 // NOTE: Never re-number or re-use numbers for different triggers. These are
14 // used in UMA histograms, and must remain backwards-compatible for all time.
15 // However, *do* change START_TRIGGER_MAX to one after the greatest value when
16 // adding new ones. Also, don't forget to update histograms.xml!
17 enum StartTrigger {
18   UNKNOWN_START_TRIGGER = 0,
19 
20   // Local presentation changes.
21   ENTERED_FULLSCREEN = 1,  // The media element became the fullscreen element.
22   BECAME_DOMINANT_CONTENT = 2,  // Element now occupies most of the viewport.
23   ENABLED_BY_PAGE = 3,          // The page re-allowed remote playback.
24 
25   // User actions, such as connecting to a receiver or pressing play.
26   SINK_AVAILABLE = 4,  // A receiver (sink) became available.
27   PLAY_COMMAND = 5,    // The media element was issued a play command.
28 
29   // Met requirements for playback of the media.
30   SUPPORTED_AUDIO_CODEC = 6,  // Stream began using a supported audio codec.
31   SUPPORTED_VIDEO_CODEC = 7,  // Stream began using a supported video codec.
32   SUPPORTED_AUDIO_AND_VIDEO_CODECS = 8,  // Both now using a supported codec.
33   CDM_READY = 9,  // The CDM required for decrypting the content became ready.
34 
35   // Change this to the highest value.
36   START_TRIGGER_MAX = 9,
37 };
38 
39 // Events and conditions that can result in a start failure, or trigger remoting
40 // to stop.
41 //
42 // NOTE: Never re-number or re-use numbers for different triggers. These are
43 // used in UMA histograms, and must remain backwards-compatible for all time.
44 // However, *do* change STOP_TRIGGER_MAX to one after the greatest value when
45 // adding new ones. Also, don't forget to update histograms.xml!
46 enum StopTrigger {
47   UNKNOWN_STOP_TRIGGER = 0,
48 
49   // Normal shutdown triggers.
50   ROUTE_TERMINATED = 1,  // The route to the sink was terminated (user action?).
51   MEDIA_ELEMENT_DESTROYED = 2,   // The media element on the page was destroyed.
52   EXITED_FULLSCREEN = 3,         // The media element is no longer fullscreened.
53   BECAME_AUXILIARY_CONTENT = 4,  // Element no longer occupies the viewport.
54   DISABLED_BY_PAGE = 5,  // The web page blocked remoting during a session.
55 
56   // Content playback related errors forcing shutdown (or failing start).
57   START_RACE = 6,  // Multiple remoting sessions attempted to start.
58   UNSUPPORTED_AUDIO_CODEC = 7,  // Stream now using an unsupported audio codec.
59   UNSUPPORTED_VIDEO_CODEC = 8,  // Stream now using an unsupported video codec.
60   UNSUPPORTED_AUDIO_AND_VIDEO_CODECS = 9,  // Neither codec is supported.
61   DECRYPTION_ERROR = 10,  // Could not decrypt content or CDM was destroyed.
62   RECEIVER_INITIALIZE_FAILED = 11,  // The receiver reported a failed init.
63   RECEIVER_PIPELINE_ERROR = 12,  // The media pipeline on the receiver error'ed.
64 
65   // Environmental errors forcing shutdown.
66   FRAME_DROP_RATE_HIGH = 13,  // The receiver was dropping too many frames.
67   PACING_TOO_SLOWLY = 14,     // Play-out was too slow, indicating bottlenecks.
68 
69   // Communications errors forcing shutdown.
70   PEERS_OUT_OF_SYNC = 15,  // The local state disagrees with the remote.
71   RPC_INVALID = 16,        // An RPC field value is missing or has bad data.
72   DATA_PIPE_CREATE_ERROR = 17,  // Mojo data pipe creation failed (OOM?).
73   MOJO_PIPE_ERROR = 18,         // Mojo message/data pipe operation failed.
74 
75   // Message/Data sending errors forcing shutdown.
76   MESSAGE_SEND_FAILED = 19,  // Failed to send a RPC message to the sink.
77   DATA_SEND_FAILED = 20,     // Failed to pull from pipe or send to the sink.
78   UNEXPECTED_FAILURE = 21,   // Unexpected failure or inconsistent state.
79   SERVICE_GONE = 22,         // Mirror service disconnected.
80 
81   // User changing setting forcing shutdown.
82   USER_DISABLED = 23,  // Media Remoting was disabled by user.
83 
84   // Change this to the highest value.
85   STOP_TRIGGER_MAX = 23,
86 };
87 
88 }  // namespace remoting
89 }  // namespace media
90 
91 #endif  // MEDIA_REMOTING_TRIGGERS_H_
92