• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 // ----------------------------------------------------------------------
19 //
20 // This Software is an original work of authorship of PacketVideo Corporation.
21 // Portions of the Software were developed in collaboration with NTT  DoCoMo,
22 // Inc. or were derived from the public domain or materials licensed from
23 // third parties.  Title and ownership, including all intellectual property
24 // rights in and to the Software shall remain with PacketVideo Corporation
25 // and NTT DoCoMo, Inc.
26 //
27 // -----------------------------------------------------------------------
28 // ============================================================
29 // FILE: TSC_statemanager.c
30 //
31 // DESCRIPTION: Terminal state management and initiation
32 //   of TSC events.
33 //
34 // Written by Ralph Neff, PacketVideo, 3/16/2000
35 // (c) 2000 PacketVideo Corp.
36 // ============================================================
37 
38 #define TSC_statemanager_SRC
39 #include "tsc_statemanager.h"
40 #include "tsc_constants.h"
41 
InitVarsSession()42 void TSC_statemanager::InitVarsSession()
43 {
44     iLogger = PVLogger::GetLoggerObject("3g324m");
45 }
46 
InitVarsLocal()47 void TSC_statemanager::InitVarsLocal()
48 {
49     iN100 = N100_DEFAULT;
50     iSkipMsd = false;
51 }
52 
SetTerminalParam(CPVTerminalParam * params)53 TPVStatusCode TSC_statemanager::SetTerminalParam(CPVTerminalParam* params)
54 {
55     CPVH324MParam* h324params = (CPVH324MParam*)params;
56     iSkipMsd = h324params->iSkipMsd;
57     return EPVT_Success;
58 }
59 
MSDDetermineIndication(MSDStatus type)60 void TSC_statemanager::MSDDetermineIndication(MSDStatus type)
61 {
62     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
63                     (0, "TSC_statemanager: MSD indication received.\n"));
64 
65     //Master slave determination(R)...Start
66     if (ReadState(TSC_MSD_RECEIVE) != STARTED)
67     {
68         WriteState(TSC_MSD_RECEIVE, COMPLETE);
69     }
70     WriteState(TSC_MSD_DECISION, (type == MSD_MASTER) ? MASTER : SLAVE);
71 }
72 
MSDStart(TPVLoopbackMode iLoopbackMode)73 bool TSC_statemanager::MSDStart(TPVLoopbackMode iLoopbackMode)
74 {
75     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
76                     (0, "TSC_statemanager: MSD Start indication\n"));
77 
78     WriteState(TSC_MSD, STARTED);
79     WriteState(TSC_MSD_RECEIVE, STARTED);
80     if (iLoopbackMode != PV_LOOPBACK_NONE)
81     {
82         SkipMsd(); // Skip MSD for loopback
83         return false;
84     }
85     return true;
86 }
87 
88 
89 // *********************************************************
90 // =========================================================
91 //                STATE AND EVENT PRIORITY I/O
92 // =========================================================
93 // *********************************************************
94 
95 // =========================================================
96 // Tsc_StateInitialize()
97 //
98 // Set all terminal states to initial values.
99 // =========================================================
StateInitialize(void)100 void TSC_statemanager::StateInitialize(void)
101 {
102     // Exceptions
103     iTerminalState[TSC_MSD_RETRYCOUNT] = iN100;
104 
105 }
106 
107 // =========================================================
108 // ReadState()
109 //
110 // Read a terminal state variable.
111 // =========================================================
ReadState(uint32 stateIndex)112 int32 TSC_statemanager::ReadState(uint32 stateIndex)
113 {
114     return iTerminalState[stateIndex];
115 }
116 
117 // =========================================================
118 // WriteState()
119 //
120 // Write to a terminal state variable.
121 // =========================================================
WriteState(uint32 stateIndex,uint32 value)122 void TSC_statemanager::WriteState(uint32 stateIndex, uint32 value)
123 {
124     StatusShow(stateIndex, value);
125     iTerminalState[stateIndex] = value;
126 }
127 
128 // =========================================================
129 // Tsc_StatusShow()
130 //
131 // Display the new value of a terminal state.
132 // =========================================================
StatusShow(uint32 stateIndex,uint32 value)133 void TSC_statemanager::StatusShow(uint32 stateIndex, uint32 value)
134 {
135     OSCL_UNUSED_ARG(stateIndex);
136     OSCL_UNUSED_ARG(value);
137     return;
138 }
139 
140 // =========================================================
141 // Tsc_IncrementState()
142 //
143 // Increment a terminal state variable.
144 // =========================================================
IncrementState(uint32 stateIndex)145 void TSC_statemanager::IncrementState(uint32 stateIndex)
146 {
147     ++iTerminalState[stateIndex];
148 }
149 
150 // =========================================================
151 // Tsc_DecrementState()
152 //
153 // Decrement a terminal state variable.
154 // =========================================================
DecrementState(uint32 stateIndex)155 void TSC_statemanager::DecrementState(uint32 stateIndex)
156 {
157     --iTerminalState[stateIndex];
158 }
159 
160 
161 // *********************************************************
162 // =========================================================
163 //                   PRE-REQUISITE CHECKS
164 // =========================================================
165 // *********************************************************
166 
167 // =========================================================
168 // Tsc_PreReq_CeSend()
169 //
170 // Check pre-requisites for initiating CE Send procedure.
171 //
172 // SPECIFICS: CE Send may be started at any time.
173 // =========================================================
PreReq_CeSend()174 uint32 TSC_statemanager::PreReq_CeSend()
175 {
176     if (ReadState(TSC_CE_SEND) == NOT_STARTED)
177     {
178         return true;
179     }
180     else
181     {
182         return false;
183     }
184 }
185 
186 // =========================================================
187 // Tsc_PreReq_MsdSend()
188 //
189 // Check pre-requisites for initiating the MSD procedure.
190 //
191 // SPECIFICS: MSD may be started any time after completion of
192 //            the CE Send procedure.
193 // =========================================================
PreReq_MsdSend()194 uint32 TSC_statemanager::PreReq_MsdSend()
195 {
196     if ((ReadState(TSC_MSD) == NOT_STARTED) &&
197             (ReadState(TSC_CE_SEND) == COMPLETE))
198     {
199         return true;
200     }
201     else
202     {
203         return false;
204     }
205 }
206 
207 // =========================================================
208 // PreReq_MtSend()
209 //
210 // Check pre-requisites for initiating the MT Send procedure.
211 //
212 // SPECIFICS: MT Send may be started at any time after
213 //   the remote terminal's capabilities have been received
214 // =========================================================
PreReq_MtSend()215 uint32 TSC_statemanager::PreReq_MtSend()
216 {
217     if ((ReadState(TSC_MT_SEND) == NOT_STARTED) &&
218             (ReadState(TSC_CE_RECEIVE) == COMPLETE))
219     {
220         return true;
221     }
222     else
223     {
224         return false;
225     }
226 }
227 
228 // =========================================================
229 // PreReq_LcAudioSend()
230 //
231 // Check pre-requisites for initiating LC Audio Send.
232 //
233 // SPECIFICS: LC Audio Send may be started at any time after
234 //   the remote terminal's capabilities have been received.
235 //   We additionally require MSD to be complete.
236 // =========================================================
PreReq_LcMediaSend()237 bool TSC_statemanager::PreReq_LcMediaSend()
238 {
239     if ((ReadState(TSC_CE_RECEIVE) == COMPLETE)  &&
240             (ReadState(TSC_MSD) == COMPLETE))
241     {
242         return true;
243     }
244     else
245     {
246         return false;
247     }
248 }
249 
SkipMsd()250 void TSC_statemanager::SkipMsd()
251 {
252     // Make us a slave so BLC can succeed in loopback mode
253     WriteState(TSC_MSD_RECEIVE, COMPLETE);
254     WriteState(TSC_MSD_DECISION, SLAVE);
255     WriteState(TSC_MSD, COMPLETE);
256 }
257 
258 
259 
260