RDK Documentation (Open Sourced RDK Components)
TunerState.h
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 /**
21  * @defgroup TRM_STATES Tuner States
22  * @ingroup TRM_MAIN
23  *
24  * @par Tuner States
25  * State | Meaning
26  * ------------| -----------
27  * Free | The Tuner is available for allocation.
28  * Live | Currently tuned to a service and in use for viewing the live TV channel.
29  * Record | Currently tuned to a service and recording a program.
30  * Hybrid | Live view of recording in progress.
31  * EAS | Emergency Alert Service.
32  *
33  * @n The Client device can take one tuner in case there is a Free tuner, or in case the client device
34  * requests a tuner for channel that currently is recording by some of the tuners
35  * (in this case this tuner becomes to Hybrid mode).
36  *
37  * @par Tuner State Diagram
38  * @image html trm_state1.png
39  * - User makes a request from the tuner in a @b Free state which is not allocated.
40  * - If the user wants to view the live video, the tuner @b Live state is accessed.
41  * - If the user wants to record a program, the tuner @b Recording state is accessed.
42  * - If the user wants to record a program as well as view the live, the @b Hybrid state is accessed.
43  * - If the user wishes to view a recorded program, the @b Hybrid state is allowed to this as well.
44  * - If there is any alert, the tuner will use the Emergency Alert State.
45  *
46  * @par Tuner Conflict States
47  * - <b> Live playback in conflict </b>
48  * @n When a client device currently uses Hybrid tuner and requests a channel that is not recording presently
49  * and there is Free tuner at that moment. Let's say tuner states are
50  * @n Live(Xi3) - Hybrid(recording and Xi3) - Record - Record
51  * @n In this case user gets an overlay posting to tune to requested channel and cancel one of the recordings.
52  * Or to leave current channel and keep the recording.
53  * @n
54  * - <b> Hot recording conflict </b>
55  * @n When there is no @b Free tuners and user schedules a hot recording, lets say tuner states are
56  * @n Live(Xi3) - Live (Xi3) - Live(Xi3) - Record - Record
57  * @user tries to schedule a recording on a channel that is not currently streamed. So since there is no
58  * @b Free tuner user will get an overlay proposing to switch the channel and record the program. Or to
59  * cancel the Hot recording and stay watching current channel.
60  * @n
61  * - <b> Future recording conflict </b>
62  * @n It is almost same as Hot recording conflict, the difference is that the recording is a future recording and is
63  * about to start STB sends a conflict in a minute before the recording starts.
64  *
65  * @par Tuner State Messages format
66  * Tuner State object represents state of the tuner.
67  * @n
68  * @code
69  * State :=
70  * {
71  * "state" : [String] state,
72  * }
73  * @endcode
74  * @n
75  * The state field indicates the activity state of a tuner:
76  * - @b Live: the tuner is reserved for Live activity (Streaming or Playback).
77  * - @b Record: the tuner is reserved for Record activity.
78  * - @b Hybrid: the tuner is reserved for Live and Record activity.
79  * - @b EAS: the tuner is reserved for EAS.
80  * - @b Free: the Tuner is not reserved.
81  *
82  * @par Message format for DetailedTunerState
83  * @n
84  * @code
85  * DetailedTunerState :=
86  * {
87  * "state" : <State>
88  * "serviceLocator" : [String] sourceLocator
89  * "owners" :
90  * {
91  * <Activity> : {
92  * "device" : [String] device
93  * }
94  * ...
95  * }
96  * "reservedDeviceId" : [String]
97  * }
98  * @endcode
99  * @n
100  * - @b reservedDeviceId: If this value is present in the detailedStates,
101  * the corresponding tuner can only be used for the following usages.
102  * - @b LIVE streaming for the device represented by the reservedDeviceId.
103  * - @b RECORD for any recording request, regardless of the recording.s originating device.
104  *
105  * @par Message format for AllTunerState
106  * @n
107  * @code
108  * AllTunerStates :=
109  * {
110  * <tunerId> : <State>
111  * ...
112  * }
113  * @endcode
114  *
115  * @defgroup TRM_STATES_IFACE Tuner State Classes
116  * @ingroup TRM_STATES
117  */
118 
119 /**
120 * @defgroup trm
121 * @{
122 * @defgroup common
123 * @{
124 **/
125 
126 
127 #ifndef TRM_TUNER_STATE_H_
128 #define TRM_TUNER_STATE_H_
129 
130 #include "Enum.h"
131 #include "trm/Activity.h"
132 #include "Klass.h"
133 
134 TRM_BEGIN_NAMESPACE
135 
136 
137 /**
138  * @brief The TunerState class represents state of the tuner.
139  * The state field in the class indicates the activity state of a tuner:
140  * - Live : the tuner is reserved for Live activity (Streaming or Playback)
141  * - Record : the tuner is reserved for Record activity.
142  * - Hybrid : the tuner is reserved for Live and Record activity.
143  * - EAS : the tuner is reserved for EAS.
144  * - Free : the Tuner is not reserved.
145  * @ingroup TRM_STATES_IFACE
146  */
148 {
149 public:
150  static const char *klassName(void) { return Klass::kTunerState; }
151 
152  typedef int EnumType;
153 
154  static const Enum<TunerState> kFree;
155  static const Enum<TunerState> kLive;
156  static const Enum<TunerState> kRecord;
157  static const Enum<TunerState> kHybrid;
158  static const Enum<TunerState> kEAS;
159 
160  static const std::vector<const Enum<TunerState> * > & getEnums(void);
161 
162  TunerState(const Enum<TunerState> &state);
163  TunerState(const char *);
164  virtual ~TunerState(void);
165 
166  const Enum<TunerState> & getState(void) const;
167 
168  virtual TunerState operator + (const Enum<Activity> &activity);
169 // virtual TunerState operator - (const Enum<Activity> &activity);
170  bool operator == (const TunerState &that) const;
171  bool operator != (const TunerState &that) const;
172 
173  void print(void) const;
174 
175 protected:
176  Enum<TunerState> state;
177 };
178 
179 
180 /**
181  * @brief This class is responsible for managing the Free state of a tuner.
182  * @ingroup TRM_STATES_IFACE
183  */
184 class FreeState : public Enum<TunerState>
185 {
186 public:
187  FreeState(void);
188  ~FreeState(void);
189  Enum<TunerState> operator + (const Enum<Activity> &activity);
190 
191 };
192 
193 /**
194  * @brief This class is responsible for handling the Live activity (Streaming or Playback) of a tuner.
195  * @ingroup TRM_STATES_IFACE
196  */
197 class LiveState : public Enum<TunerState>
198 {
199 public:
200  LiveState(void);
201  ~LiveState(void);
202  Enum<TunerState> operator + (const Enum<Activity> &activity);
203  Enum<TunerState> operator - (const Enum<Activity> &activity);
204 
205 };
206 
207 /**
208  * @brief This class is responsible for handling the Record activity of a tuner.
209  * @ingroup TRM_STATES_IFACE
210  */
211 class RecordState : public Enum<TunerState>
212 {
213 public:
214  RecordState(void);
215  ~RecordState(void);
216  Enum<TunerState> operator + (const Enum<Activity> &activity);
217  Enum<TunerState> operator - (const Enum<Activity> &activity);
218 };
219 
220 /**
221  * @brief The tuner is reserved for Live or Record activity.
222  * @brief This class is responsible for handling the Hybrid activity (Playback and Record simultaneously) of a tuner.
223  * @ingroup TRM_STATES_IFACE
224  */
225 class HybridState : public Enum<TunerState>
226 {
227 public:
228  HybridState(void);
229  ~HybridState(void);
230  Enum<TunerState> operator - (const Enum<Activity> &activity);
231 };
232 
233 TRM_END_NAMESPACE
234 #endif
235 
236 
237 
238 /** @} */
239 /** @} */
TRM::RecordState
This class is responsible for handling the Record activity of a tuner.
Definition: TunerState.h:211
TRM::HybridState
The tuner is reserved for Live or Record activity.
Definition: TunerState.h:225
TRM::Enum< TunerState >
TRM::FreeState
This class is responsible for managing the Free state of a tuner.
Definition: TunerState.h:184
TRM::TunerState
The TunerState class represents state of the tuner. The state field in the class indicates the activi...
Definition: TunerState.h:147
TRM::LiveState
This class is responsible for handling the Live activity (Streaming or Playback) of a tuner.
Definition: TunerState.h:197