• 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 #ifndef PVMF_JB_FIREWALL_PKTS_IMPL_H_INCLUDED
19 #define PVMF_JB_FIREWALL_PKTS_IMPL_H_INCLUDED
20 
21 #ifndef OSCL_BASE_H_INCLUDED
22 #include "oscl_base.h"
23 #endif
24 #ifndef OSCL_VECTOR_H_INCLUDED
25 #include "oscl_vector.h"
26 #endif
27 #ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
28 #include "oscl_string_containers.h"
29 #endif
30 #ifndef PVMF_RETURN_CODES_H_INCLUDED
31 #include "pvmf_return_codes.h"
32 #endif
33 #ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
34 #include "oscl_mem_mempool.h"
35 #endif
36 
37 #ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
38 #include "pvmf_simple_media_buffer.h"
39 #endif
40 
41 #ifndef PVMF_MEDIA_MSG_H_INCLUDED
42 #include "pvmf_media_msg.h"
43 #endif
44 
45 #ifndef PVMF_MEDIA_DATA_H_INCLUDED
46 #include "pvmf_media_data.h"
47 #endif
48 
49 #ifndef PVLOGGER_H_INCLUDED
50 #include "pvlogger.h"
51 #endif
52 
53 #ifndef PVMF_SM_TUNABLES_H_INCLUDED
54 #include "pvmf_sm_tunables.h"
55 #endif
56 
57 #ifndef PVMF_JITTER_BUFFER_COMMON_TYPES_H_INCLUDED
58 #include "pvmf_jitter_buffer_common_types.h"
59 #endif
60 
61 #ifndef PVMF_JB_EVENT_NOTIFIER_H
62 #include "pvmf_jb_event_notifier.h"
63 #endif
64 
65 /* Firewall packet related */
66 #define PVMF_DEFAULT_FIREWALL_PKT_ATTEMPTS 3
67 #define PVMF_MAX_FIREWALL_PKT_SIZE       8
68 #define PVMF_MAX_RTP_FIREWALL_PKT_SIZE   12
69 #define PVMF_FIREWALL_PKT_MEMPOOL_SIZE   256
70 #define PVMF_FIREWALL_PKT_DEFAULT_SERVER_RESPONSE_TIMEOUT_IN_MS 1000
71 class PVMFJBEventNotifier;
72 ///////////////////////////////////////////////////////////////////////////////
73 //PVMFFireWallPacketFormat
74 ///////////////////////////////////////////////////////////////////////////////
75 enum PVMFFireWallPacketFormat
76 {
77     PVMF_FW_PKT_FORMAT_RTP,
78     PVMF_FW_PKT_FORMAT_PV
79 };
80 
81 ///////////////////////////////////////////////////////////////////////////////
82 //PVMFJitterBufferFireWallPacketInfo
83 ///////////////////////////////////////////////////////////////////////////////
84 
85 class PVFirewallPacketExchanger
86 {
87     public:
88         static PVFirewallPacketExchanger* New(const RTPSessionInfoForFirewallExchange& aRTPSessionInfo);
89         ~PVFirewallPacketExchanger();
90         bool ComposeFirewallPacket(PVMFJitterBufferFireWallPacketFormat aFormat, uint32 aPacketCnt, PVMFPortInterface*& aRTPJitterBufferPort, PVMFSharedMediaMsgPtr& aSharedMediaMsg);
91         bool IsFirewallPacketResponseValid(PVMFSharedMediaMsgPtr& aMsg);//not implementated as of now
92         bool DecodeFirewallPacketResponse(PVMFSharedMediaMsgPtr& aMsg);//not implementated as of now
93         const RTPSessionInfoForFirewallExchange& GetRTPSessionInfo() const;
94         void SetRTPSessionInfo(const RTPSessionInfoForFirewallExchange& aRTPSessionInfo);
95     private:
PVFirewallPacketExchanger(const RTPSessionInfoForFirewallExchange & aRTPSessionInfo)96         PVFirewallPacketExchanger(const RTPSessionInfoForFirewallExchange& aRTPSessionInfo)
97         {
98             iRTPSessionInfoForFirewallExchange.ipRTPDataJitterBufferPort = aRTPSessionInfo.ipRTPDataJitterBufferPort;
99             iRTPSessionInfoForFirewallExchange.iSSRC = aRTPSessionInfo.iSSRC;
100             ipMediaDataAlloc    =   NULL;
101             ipMediaDataImplAlloc    =   NULL;
102             ipMediaMsgAlloc =   NULL;
103         }
104         void Construct();
105         void CreateMemAllocators();
106         void DestroyMemoryAllocators();
107         bool Allocate(PVMFSharedMediaDataPtr& aFireWallPkt, OsclSharedPtr<PVMFMediaDataImpl>& aMediaDataImpl, const int aSize);
108 
109         //Mem allocators
110         /* allocator for memory fragment */
111         OsclMemPoolFixedChunkAllocator* ipMediaDataAlloc;
112         /* allocator for media data impl */
113         PVMFSimpleMediaBufferCombinedAlloc* ipMediaDataImplAlloc;
114         /* Memory pool for simple media data */
115         OsclMemPoolFixedChunkAllocator* ipMediaMsgAlloc;
116 
117         RTPSessionInfoForFirewallExchange   iRTPSessionInfoForFirewallExchange;
118 };
119 
120 ///////////////////////////////////////////////////////////////////////////////
121 //PVFirewallPacketExchanger
122 ///////////////////////////////////////////////////////////////////////////////
123 class PVMFJitterBufferMiscObserver;
124 
125 class PVFirewallPacketExchangeImpl: public PVMFJBEventNotifierObserver
126 {
127     public:
128         OSCL_IMPORT_REF static PVFirewallPacketExchangeImpl* New(PVMFJitterBufferFireWallPacketInfo& aFireWallPacketExchangeInfo, PVMFJBEventNotifier& aEventNotifier, PVMFJitterBufferMiscObserver* aObserver);
129         OSCL_IMPORT_REF ~PVFirewallPacketExchangeImpl();
130         OSCL_IMPORT_REF void SetRTPSessionInfoForFirewallExchange(const RTPSessionInfoForFirewallExchange& aRTPSessionInfo);
131         OSCL_IMPORT_REF PVMFStatus InitiateFirewallPacketExchange();
132         OSCL_IMPORT_REF PVMFStatus CancelFirewallPacketExchange();
133         void ProcessCallback(CLOCK_NOTIFICATION_INTF_TYPE aClockNotificationInterfaceType, uint32 aCallBkId, const OsclAny* aContext, PVMFStatus aStatus);
134     private:
PVFirewallPacketExchangeImpl(PVMFJitterBufferFireWallPacketInfo & aFireWallPacketExchangeInfo,PVMFJBEventNotifier & aEventNotifier,PVMFJitterBufferMiscObserver * aObserver)135         PVFirewallPacketExchangeImpl(PVMFJitterBufferFireWallPacketInfo& aFireWallPacketExchangeInfo, PVMFJBEventNotifier& aEventNotifier, PVMFJitterBufferMiscObserver* aObserver)
136                 : irEventNotifier(aEventNotifier)
137                 , ipObserver(aObserver)
138         {
139             iFireWallPacketExchangeInfo.iServerRoundTripDelayInMS = aFireWallPacketExchangeInfo.iServerRoundTripDelayInMS;
140             iFireWallPacketExchangeInfo.iNumAttempts = aFireWallPacketExchangeInfo.iNumAttempts;
141             iFireWallPacketExchangeInfo.iFormat = aFireWallPacketExchangeInfo.iFormat;
142             iCallBackId = 0;
143             iCallBackPending = false;
144             iNumAttemptsDone = 0;
145         }
146         void Construct();
147         void SendFirewallPackets();
148 
149         uint32 iCallBackId;
150         bool iCallBackPending;
151         uint32 iNumAttemptsDone;
152 
153         PVMFJBEventNotifier&    irEventNotifier;
154         PVMFJitterBufferMiscObserver*   ipObserver;
155         PVMFJitterBufferFireWallPacketInfo iFireWallPacketExchangeInfo;
156         Oscl_Vector<PVFirewallPacketExchanger*, OsclMemAllocator> iFirewallPacketExchangers;
157         PVLogger*   ipDataPathLoggerFireWall;
158 };
159 
160 #endif//end of PVMF_JB_FIREWALL_PKTS_IMPL_H_INCLUDED
161