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 #include "pvmf_protocol_engine_port.h"
20
21 #include "oscl_mem_basic_functions.h"
22
23 #include "pv_mime_string_utils.h"
24
25 #include "pvmf_node_interface.h"
26
27 #include "pvmf_protocol_engine_defs.h"
28
29
30
31 ////////////////////////////////////////////////////////////////////////////
PVMFProtocolEnginePort(int32 aTag,PVMFNodeInterface * aNode,const char * name)32 PVMFProtocolEnginePort::PVMFProtocolEnginePort(int32 aTag, PVMFNodeInterface* aNode, const char*name)
33 : PvmfPortBaseImpl(aTag, aNode, name)
34 {
35 Construct();
36 }
37
38 ////////////////////////////////////////////////////////////////////////////
PVMFProtocolEnginePort(int32 aTag,PVMFNodeInterface * aNode,uint32 aInCapacity,uint32 aInReserve,uint32 aInThreshold,uint32 aOutCapacity,uint32 aOutReserve,uint32 aOutThreshold,const char * name)39 PVMFProtocolEnginePort::PVMFProtocolEnginePort(int32 aTag, PVMFNodeInterface* aNode,
40 uint32 aInCapacity,
41 uint32 aInReserve,
42 uint32 aInThreshold,
43 uint32 aOutCapacity,
44 uint32 aOutReserve,
45 uint32 aOutThreshold, const char*name) :
46 PvmfPortBaseImpl(aTag, aNode, aInCapacity, aInReserve, aInThreshold, aOutCapacity, aOutReserve, aOutThreshold, name)
47 {
48 Construct();
49 }
50
51 ////////////////////////////////////////////////////////////////////////////
Construct()52 void PVMFProtocolEnginePort::Construct()
53 {
54 iLogger = PVLogger::GetLoggerObject("PVMFProtocolEnginePort");
55 oscl_memset(&iStats, 0, sizeof(PvmfPortBaseImplStats));
56 iNumFramesGenerated = 0;
57 iNumFramesConsumed = 0;
58 PvmiCapabilityAndConfigPortFormatImpl::Construct(
59 PVMF_PROTOCOLENGINE_PORT_INPUT_FORMATS,
60 PVMF_PROTOCOLENGINE_PORT_INPUT_FORMATS_VALTYPE);
61 }
62
63 ////////////////////////////////////////////////////////////////////////////
~PVMFProtocolEnginePort()64 PVMFProtocolEnginePort::~PVMFProtocolEnginePort()
65 {
66 Disconnect();
67 ClearMsgQueues();
68 }
69
70 ////////////////////////////////////////////////////////////////////////////
IsFormatSupported(PVMFFormatType aFmt)71 bool PVMFProtocolEnginePort::IsFormatSupported(PVMFFormatType aFmt)
72 {
73 bool formatSupported = false;
74 if (aFmt == PVMF_MIME_INET_TCP)
75 {
76 formatSupported = true;
77 }
78 return formatSupported;
79 }
80
81 ////////////////////////////////////////////////////////////////////////////
FormatUpdated()82 void PVMFProtocolEnginePort::FormatUpdated()
83 {
84 PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
85 , (0, "PVMFProtocolEnginePort::FormatUpdated() %s", iFormat.getMIMEStrPtr()));
86 }
87
88 ////////////////////////////////////////////////////////////////////////////
QueueOutgoingMsg(PVMFSharedMediaMsgPtr aMsg)89 PVMFStatus PVMFProtocolEnginePort::QueueOutgoingMsg(PVMFSharedMediaMsgPtr aMsg)
90 {
91 uint32 aOutgoingQueueSizeBefore = OutgoingMsgQueueSize();
92 PVMFStatus status = PvmfPortBaseImpl::QueueOutgoingMsg(aMsg);
93 if (status != PVMFSuccess) return status;
94 uint32 aOutgoingQueueSizeAfter = OutgoingMsgQueueSize();
95 if (aOutgoingQueueSizeBefore == aOutgoingQueueSizeAfter) return PVMFSuccessOutgoingMsgSent;
96 return PVMFSuccess;
97 }
98
99
100 ////////////////////////////////////////////////////////////////////////////
PeekOutgoingMsg(PVMFSharedMediaMsgPtr & aMsg)101 bool PVMFProtocolEnginePort::PeekOutgoingMsg(PVMFSharedMediaMsgPtr& aMsg)
102 {
103 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
104 (0, "0x%x PVMFProtocolEnginePort::PeekOutgoingMsg", this));
105
106 if (iOutgoingQueue.iQ.empty())
107 {
108 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
109 (0, "0x%x PVMFProtocolEnginePort::PeekOutgoingMsg: Error - Incoming queue is empty", this));
110 return false;
111 }
112
113 // Save message to output parameter and erase it from queue
114 aMsg = iOutgoingQueue.iQ.front();
115 return true;
116 }
117
118