• 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 name            : tsc_msd.c                                         */
30 /*  file contents        : Terminal State Control routine                    */
31 /*  draw                 : '96.10.04                                         */
32 /*---------------------------------------------------------------------------*/
33 /*  amendment                                                                */
34 /*              Copyright (C) 1996 NTT DoCoMo                                */
35 /*****************************************************************************/
36 #include    "tscmain.h"
37 #include    "tsc_statemanager.h"
38 #include    "tsc_constants.h"
39 
MSDStart()40 void TSC_324m::MSDStart()
41 {
42     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
43                     (0, "TSC_324m::MSDStart()\n"));
44     iTSCstatemanager.MSDStart(iLoopbackMode);
45     if (iLoopbackMode == PV_LOOPBACK_NONE && Msd)
46     {
47         Msd->DetermineRequest();
48     }
49 }
50 
MSDDetermineConfirm(MSDStatus type)51 void TSC_324m::MSDDetermineConfirm(MSDStatus type)
52 {
53     if (type == MSD_MASTER)
54     {
55         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
56                         (0, "TSC: MSD complete. decision MASTER."));
57     }
58     else
59     {
60         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
61                         (0, "TSC: MSD complete. decision SLAVE."));
62     }
63     // Master/Slave Determination... Complete
64     iTSCstatemanager.WriteState(TSC_MSD_DECISION, (type == MSD_MASTER) ?
65                                 MASTER : SLAVE);
66     iTSCstatemanager.WriteState(TSC_MSD, COMPLETE);
67     if (iTerminalStatus == PhaseD_CSUP)
68     {
69         if (iTSCstatemanager.ReadState(TSC_CE_RECEIVE) == COMPLETE)
70         {
71             int leave_status = 0;
72             OSCL_TRY(leave_status, TcsMsdComplete());
73             OSCL_FIRST_CATCH_ANY(leave_status, void());
74             if (leave_status != 0)
75             {
76                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
77                                 (0, "TSC_324m::MSDDetermineConfirm - Memory Allocation Failed."));
78                 SignalCsupComplete(PVMFErrNoMemory);
79                 return;
80             }
81         }
82     }
83     else
84     {
85         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
86                         (0, "TSC_324m::MSDDetermineConfirm Invalid state(%d)",
87                          iTerminalStatus));
88     }
89 }
90 
MSDDetermineIndication(MSDStatus type)91 void TSC_324m::MSDDetermineIndication(MSDStatus type)
92 {
93     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
94                     (0, "TSC: MSD indication received.\n"));
95 
96     iTSCstatemanager.MSDDetermineIndication(type);
97 }
98 
MSDRejectIndication()99 void TSC_324m::MSDRejectIndication()
100 {
101     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
102                     (0, "TSC: MSD reject indication.\n"));
103 
104     // Retry TSC_MSD several times, then give up (RAN)
105     iTSCstatemanager.DecrementState(TSC_MSD_RETRYCOUNT);
106     if (iTSCstatemanager.ReadState(TSC_MSD_RETRYCOUNT) > 0)
107     {
108         MSDStart();
109     }
110     else
111     {
112         iConnectFailReason = EPVT_FailedToNegotiate;
113         SessionClose_CSUP();
114 
115         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
116                         (0, "TSC: MSD failed after retries.\n"));
117     }
118 }
119 
MSDErrorIndication(MSDErrCode errCode)120 void TSC_324m::MSDErrorIndication(MSDErrCode errCode)
121 {
122     OSCL_UNUSED_ARG(errCode);
123     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
124                     (0, "TSC: MSD Error %d.\n", errCode));
125 }
126 
127