• 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 #include "pv_2way_enc_data_channel_datapath.h"
19 
NewL(PVLogger * aLogger,PVMFFormatType aFormat,CPV324m2Way * a2Way)20 CPV2WayEncDataChannelDatapath *CPV2WayEncDataChannelDatapath::NewL(PVLogger *aLogger,
21         PVMFFormatType aFormat,
22         CPV324m2Way *a2Way)
23 {
24     CPV2WayEncDataChannelDatapath *self = OSCL_NEW(CPV2WayEncDataChannelDatapath, (aLogger, aFormat, a2Way));
25     OsclError::LeaveIfNull(self);
26 
27     if (self)
28     {
29         OSCL_TRAPSTACK_PUSH(self);
30         self->ConstructL();
31     }
32 
33     OSCL_TRAPSTACK_POP();
34     return self;
35 }
36 
TSCPortClosed()37 void CPV2WayEncDataChannelDatapath::TSCPortClosed()
38 {
39     if (iState != EClosed)
40     {
41         iPortPairList.back().Disconnect();
42         iPortPairList.back().iDestPort.SetPort(NULL);
43         SetCmd(NULL);
44     }
45 }
46 
GetTSCPort()47 PVMFPortInterface *CPV2WayEncDataChannelDatapath::GetTSCPort()
48 {
49     return iPortPairList.empty() ? NULL : iPortPairList.back().iDestPort.GetPort();
50 }
51 
52 
GetSrcPort()53 PVMFPortInterface *CPV2WayEncDataChannelDatapath::GetSrcPort()
54 {
55     return iPortPairList.empty() ? NULL : iPortPairList.front().iSrcPort.GetPort();
56 }
57 
SetSourceInputPort(PVMFPortInterface * aPort)58 void CPV2WayEncDataChannelDatapath::SetSourceInputPort(PVMFPortInterface *aPort)
59 {
60     iSourceInputPort.SetPort(aPort);
61 }
62 
UseFilePlayPort(bool aUseFilePlayPort)63 void CPV2WayEncDataChannelDatapath::UseFilePlayPort(bool aUseFilePlayPort)
64 {
65     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayEncDataChannelDatapath::CheckPathSpecificOpen state %d, format %s, use play port %d, file play port %x\n", iState, iFormat.getMIMEStrPtr(), aUseFilePlayPort, iFilePlayPort));
66     if ((iState != EOpened) || (iFilePlayPort == NULL)) return;
67 
68     //If audio use mixing port (audio source node input port)
69     if (iFormat.isVideo())
70     {
71         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayEncDataChannelDatapath::CheckPathSpecificOpen audio source port status %d\n", iSourceInputPort.GetStatus()));
72         if (iSourceInputPort.GetStatus() == EHasPort)
73         {
74             if (aUseFilePlayPort)
75             {
76                 iSourceInputPort.GetPort()->Connect(iFilePlayPort);
77                 iFilePlayPort->Connect(iSourceInputPort.GetPort());
78             }
79             else
80             {
81                 iFilePlayPort->Disconnect();
82                 iSourceInputPort.GetPort()->Disconnect();
83             }
84         }
85     }
86     //Else video, use splitter port
87     else
88     {
89         if (aUseFilePlayPort)
90         {
91             iPortPairList.front().Disconnect();
92             iPortPairList.front().iDestPort.GetPort()->Connect(iFilePlayPort);
93             iFilePlayPort->Connect(iPortPairList.front().iDestPort.GetPort());
94         }
95         else
96         {
97             iFilePlayPort->Disconnect();
98             iPortPairList.front().iDestPort.GetPort()->Disconnect();
99             iPortPairList.front().Connect();
100         }
101     }
102 }
103 
OpenComplete()104 void CPV2WayEncDataChannelDatapath::OpenComplete()
105 {
106 
107     CommandComplete(PVMFSuccess);
108 }
109 
CheckPathSpecificOpen()110 bool CPV2WayEncDataChannelDatapath::CheckPathSpecificOpen()
111 {
112     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayEncDataChannelDatapath::CheckPathSpecificOpen\n"));
113     {
114         return true;
115     }
116 }
117 
PathSpecificClose()118 bool CPV2WayEncDataChannelDatapath::PathSpecificClose()
119 {
120     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayEncDataChannelDatapath::PathSpecificClose file port %x, input src port %d\n", iFilePlayPort, iSourceInputPort.GetStatus()));
121 
122     if (iFilePlayPort)
123     {
124         iFilePlayPort->Disconnect();
125     }
126 
127     switch (iSourceInputPort.GetStatus())
128     {
129         case EHasPort:
130             iSourceInputPort.GetPort()->Disconnect();
131             //i2Way->CheckAudioSourceMixingPort();
132             return false;
133 
134         case ENoPort:
135             //No mixing port, continue closing this datapath
136             return true;
137 
138         default:
139             break;
140     }
141 
142     return false;
143 }
144 
CheckPathSpecificStart()145 bool CPV2WayEncDataChannelDatapath::CheckPathSpecificStart()
146 {
147     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayEncDataChannelDatapath::CheckPathSpecificStart engine state=%d\n", i2Way->iState));
148     if (i2Way->iState == EConnecting || i2Way->iState == EConnected)
149     {
150         return true;
151     }
152     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayEncDataChannelDatapath::CheckPathSpecificStart engine not connecting yet."));
153     return false;
154 }
155