• 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  * @file pvmf_loopback_ioport.h
21  * @brief Input/Output port for simple loopback node
22  *
23  */
24 
25 #ifndef PVMF_LOOPBACK_IOPORT_H_INCLUDED
26 #define PVMF_LOOPBACK_IOPORT_H_INCLUDED
27 
28 #ifndef OSCL_BASE_H_INCLUDED
29 #include "oscl_base.h"
30 #endif
31 
32 #ifndef PVMF_PORT_INTERFACE_H_INCLUDED
33 #include "pvmf_port_interface.h"
34 #endif
35 
36 #ifndef PVMF_NODE_INTERFACE_H_INCLUDED
37 #include "pvmf_node_interface.h"
38 #endif
39 
40 #ifndef PVLOGGER_H_INCLUDED
41 #include "pvlogger.h"
42 #endif
43 
44 #ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
45 #include "pvmf_port_base_impl.h"
46 #endif
47 
48 #ifndef PVMI_CONFIG_AND_CAPABILITY_UTILS_H_INCLUDED
49 #include "pvmi_config_and_capability_utils.h"
50 #endif
51 
52 #ifndef OSCL_SCHEDULER_AO_H_INCLUDED
53 #include "oscl_scheduler_ao.h"
54 #endif
55 
56 // Capability mime strings
57 #define PVMF_LOOPBACK_PORT_INPUT_FORMATS ".../input_formats"
58 #define PVMF_LOOPBACK_PORT_INPUT_FORMATS_VALTYPE ".../input_formats;valtype=uint32"
59 
60 class PVLogger;
61 class PVMFLoopbackNode;
62 
63 class PVMFLoopbackIOPort : public PvmfPortBaseImpl
64         , public PvmiCapabilityAndConfigPortFormatImpl
65         , public OsclActiveObject
66         , public PVMFPortActivityHandler
67 {
68     public:
69         PVMFLoopbackIOPort(int32 aTag
70                            , PVMFLoopbackNode* aNode);
71 
72         PVMFLoopbackIOPort(int32 aTag
73                            , PVMFLoopbackNode* aNode
74                            , uint32 aInCapacity
75                            , uint32 aInReserve
76                            , uint32 aInThreshold
77                            , uint32 aOutCapacity
78                            , uint32 aOutReserve
79                            , uint32 aOutThreshold);
80 
81         ~PVMFLoopbackIOPort();
82 
83         // from PvmiCapabilityAndConfigPortFormatImpl
84         bool IsFormatSupported(PVMFFormatType);
85         void FormatUpdated();
86 
87 
88 // this port supports config interface
QueryInterface(const PVUuid & aUuid,OsclAny * & aPtr)89         void QueryInterface(const PVUuid &aUuid, OsclAny*&aPtr)
90         {
91             if (aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
92                 aPtr = (PvmiCapabilityAndConfig*)this;
93             else
94                 aPtr = NULL;
95         }
96 
97         void Reset();
98 
SetDestNode(PVMFLoopbackNode * aNode)99         void SetDestNode(PVMFLoopbackNode* aNode)
100         {
101             iNode = aNode;
102         }
103 
104     private:
105 
106         void Construct(PVMFLoopbackNode*);
107         PVMFLoopbackNode* iNode;
108 
109         uint32 iTimedSendBytes;
110         uint32 iWriteDataLength;
111         uint32 iFirstSendStartTime;
112 
113         PVLogger *iLogger;
114 
115         //from OsclActiveObject
116         void Run();
117 
118         //from PVMFPortActivityHandler
119         void HandlePortActivity(const PVMFPortActivity &);
120 
121         //for port data processing.
122         bool iWaiting;
123         PVMFStatus ProcessIncomingMsg();
124 
125         friend class PVMFLoopbackNode;
126 
127         friend class Oscl_TAlloc<PVMFLoopbackIOPort, OsclMemAllocator>;
128 
129 };
130 
131 #endif // PVMF_LOOPBACK_IOPORT_H_INCLUDED
132