Home | History | Annotate | Download | only in include
      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_component.h                                   */
     30 /*  file contents        :                                                   */
     31 /*  draw                 : '96.10.09                                         */
     32 /*---------------------------------------------------------------------------*/
     33 /*  amendment                                                                */
     34 /*              Copyright (C) 1996 NTT DoCoMo                                */
     35 /*****************************************************************************/
     36 
     37 #ifndef TSCCOMPONENT_H_INCLUDED
     38 #define TSCCOMPONENT_H_INCLUDED
     39 
     40 
     41 
     42 #ifndef PVLOGGER_H_INCLUDED
     43 #include "pvlogger.h"
     44 #endif
     45 
     46 #ifndef TSC_H_INCLUDED
     47 #include "tsc.h"
     48 #endif
     49 
     50 #ifndef H245_H_INCLUDED
     51 #include "h245.h"
     52 #endif
     53 
     54 #ifndef TSC_NODE_INTERFACE_H_INCLUDED
     55 #include "tsc_node_interface.h"
     56 #endif
     57 
     58 #ifndef TSC_CHANNELCONTROL_H_INCLUDED
     59 #include "tsc_channelcontrol.h"
     60 #endif
     61 
     62 #ifndef TSC_H324M_CONFIG_INTERFACE_H_INCLUDED
     63 #include "tsc_h324m_config_interface.h"
     64 #endif
     65 
     66 class TSC_statemanager;
     67 class TSC_capability;
     68 class TSC_mt;
     69 class TSC_lc;
     70 class TSC_blc;
     71 class TSC_clc;
     72 
     73 
     74 
     75 class TSC_component : public OsclTimerObserver,
     76         public PVMFComponentInterface
     77 {
     78     public:
     79         TSC_component(TSC_statemanager& aTSCStateManager,
     80                       TSC_capability& aTSCcapability,
     81                       TSC_lc& aTSClc,
     82                       TSC_blc& aTSCblc,
     83                       TSC_clc& aTSCclc,
     84                       TSC_mt& aTSCmt);
     85 
     86         void SetMembers(H245* aH245, H223* aH223, TSCObserver* aTSCObserver);
     87         bool queryInterface(const PVUuid& aUuid, PVInterface*& aInterfacePtr);
     88 
     89         void Init()
     90         {
     91             InitVarsLocal();
     92             InitVarsSession();
     93         }
     94         bool CEStart();
     95         virtual void InitVarsSession();
     96         virtual void InitVarsLocal();
     97         virtual void MembersSet() {};
     98         void InitTsc();
     99         void ResetTsc();
    100         void Disconnect();
    101 
    102         void GetTerminalParam(CPVH324MParam& ah324param);
    103         TPVStatusCode SetTerminalParam(CPVTerminalParam& params);
    104 
    105         bool IsSupported(TPVDirection dir, PV2WayMediaType media, CodecCapabilityInfo& codec_info);
    106         bool IsSupported(TPVDirection dir, PVCodecType_t codec, FormatCapabilityInfo& capability_info);
    107 
    108         virtual void ExtractTcsParameters(PS_TerminalCapabilitySet pTcs);
    109         void CETransferIndication(OsclSharedPtr<S_TerminalCapabilitySet> tcs, uint32 aTerminalStatus);
    110         TPVAdaptationLayer GetVideoLayer()
    111         {
    112             return iVideoLayer;
    113         }
    114 
    115         void ClipCodecs(PS_TerminalCapabilitySet pTcs);         // (RAN-32K)
    116 
    117         // mux descriptors
    118         CPVMultiplexEntryDescriptor* GenerateSingleDescriptor(uint8 entry_num, TPVChannelId lcn1);
    119         void SetAlConfig(PV2WayMediaType media_type,
    120                          TPVAdaptationLayer layer,
    121                          bool allow);
    122 
    123         void SetAl2Al3VideoFlags(int32 userInput);
    124         int32 GetAl2Al3VideoFlags();
    125         Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>* GetChannelConfig(TPVDirection dir);
    126         void SetAl3ControlFieldOctets(unsigned cfo);
    127 
    128         void SetAl2Sn(int width);
    129         uint32 LcEtbIdc(PS_ControlMsgHeader pReceiveInf);
    130         uint32 BlcEtbIdc(PS_ControlMsgHeader pReceiveInf);
    131         PVMFStatus ValidateOlcsWithTcs();
    132         OsclAny TcsMsdComplete();
    133 
    134         virtual void SetOutgoingChannelConfig(Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>& out_channel_config);
    135         virtual void SetIncomingChannelConfig(Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>& in_channel_config);
    136         virtual uint32 LcEtbCfm(PS_ControlMsgHeader pReceiveInf);
    137         unsigned GetOutgoingBitrate(PVCodecType_t codecType);
    138         void GetChannelFormatAndCapabilities(TPVDirection dir,
    139                                              Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>& formats);
    140 
    141 
    142         bool HasOlc(TPVDirection direction, TPVChannelId id, unsigned state = 0);
    143         OlcParam* FindOlcGivenChannel(TPVDirection direction, TPVChannelId id);
    144         OlcParam* FindOlc(TPVDirection direction, PV2WayMediaType media_type, unsigned state = 0);
    145 
    146         virtual void LcnDataDetected(TPVChannelId lcn);
    147         OsclAny AcceptBLCRequest(TPVChannelId OpenLcnF,
    148                                  TPVChannelId OpenLcnB,
    149                                  PS_ForwardReverseParam forRevParams);
    150         uint32 LcRlsIdc(PS_ControlMsgHeader pReceiveInf);
    151         uint32 BlcRlsIdc(PS_ControlMsgHeader pReceiveInf);
    152         OsclAny MuxTableSendComplete(uint32 sn, PVMFStatus status);
    153         OsclAny StopData();
    154         void Start();
    155         virtual void StartDisconnect(bool terminate);
    156         virtual bool Connect1LevelKnown();
    157         virtual void Connect2();
    158         void TimeoutOccurred(int32 timerID, int32 timeoutInfo);
    159         virtual bool ProcessCommand(Tsc324mNodeCommand& aCmd)
    160         {
    161             OSCL_UNUSED_ARG(aCmd);
    162             return false;
    163         }
    164         virtual void MuxSetupComplete(PVMFStatus status, TPVH223Level level)
    165         {
    166             OSCL_UNUSED_ARG(status);
    167             OSCL_UNUSED_ARG(level);
    168         };
    169         virtual Tsc324mNodeCommand* GetCommand()
    170         {
    171             return NULL;
    172         };
    173         virtual bool IsEnabled()
    174         {
    175             return true;
    176         };
    177         uint32 Status08Event19(PS_ControlMsgHeader pReceiveInf);
    178         uint32 BlcEtbCfm(PS_ControlMsgHeader pReceiveInf);
    179         uint32 BlcEtbCfm2(PS_ControlMsgHeader pReceiveInf);
    180         uint32 LcRlsCfm(PS_ControlMsgHeader pReceiveInf);
    181         uint32 BlcRlsCfm(PS_ControlMsgHeader pReceiveInf);
    182         void CloseChannels();
    183         LogicalChannelInfo* GetLogicalChannelInfo(PVMFPortInterface& port);
    184         virtual void Timeout() {};
    185 
    186         void ReceivedFormatSpecificInfo(TPVChannelId channel_id, uint8* fsi, uint32 fsi_len);
    187         bool IsEstablishedLogicalChannel(TPVDirection aDir, TPVChannelId aChannelId);
    188 #ifdef MEM_TRACK
    189         void MemStats();
    190 #endif
    191     protected:
    192         virtual bool Pausable()
    193         {
    194             return true;
    195         }
    196         void CheckOutgoingChannel(OlcParam* olc_param, PVMFStatus status);
    197         void ChannelReleased(TPVDirection dir, TPVChannelId lcn, PVMFStatus status);
    198         OlcParam* OpenLogicalChannel(TPVDirection dir,
    199                                      TPVChannelId lcn,
    200                                      TPVChannelId lcnRvs = CHANNEL_ID_UNKNOWN,
    201                                      PS_DataType dt = NULL,
    202                                      PS_H223LogicalChannelParameters lcp = NULL,
    203                                      PS_DataType dtRvs = NULL,
    204                                      PS_H223LogicalChannelParameters lcpRvs = NULL);
    205         void RemoveOlc(TPVDirection dir, TPVChannelId id);
    206         virtual void ReleasePendingIncomingChannel(TPVChannelId aOpenLcn)
    207         {
    208             OSCL_UNUSED_ARG(aOpenLcn);
    209         };
    210         virtual bool ReleasedPendingIncomingChannel(OlcParam* aPendingParam)
    211         {
    212             OSCL_UNUSED_ARG(aPendingParam);
    213             return false;
    214         };
    215         PS_AdaptationLayerType GetOutgoingLayer(PV2WayMediaType media_type, uint32 max_sample_size);
    216         OlcParam* OpenOutgoingChannelWithTcsCheck(PVCodecType_t codec,
    217                 PS_AdaptationLayerType adaptation_layer,
    218                 PVCodecType_t in_codec);
    219 
    220         virtual void SetCustomMultiplex(PS_ControlMsgHeader pReceiveInf,
    221                                         PV2WayMediaType media_type)
    222         {
    223             OSCL_UNUSED_ARG(pReceiveInf);
    224             OSCL_UNUSED_ARG(media_type);
    225         };
    226         virtual void RemoveMultiplex(OlcParam* olc_param)
    227         {
    228             OSCL_UNUSED_ARG(olc_param);
    229         };
    230         virtual bool AlreadyAssigned(PV2WayMediaType media_type)
    231         {
    232             OSCL_UNUSED_ARG(media_type);
    233             return false;
    234         };
    235         virtual void StartOlc(OlcParam* olc_param,
    236                               PV2WayMediaType media_type,
    237                               CPVMultiplexEntryDescriptorVector descriptors)
    238         {
    239             OSCL_UNUSED_ARG(olc_param);
    240             OSCL_UNUSED_ARG(media_type);
    241             OSCL_UNUSED_ARG(descriptors);
    242         };
    243         virtual bool FinishTcsMsdComplete(CPVMultiplexEntryDescriptorVector descriptors)
    244         {
    245             OSCL_UNUSED_ARG(descriptors);
    246             return true;
    247         };
    248         virtual void CustomGenerateTcs(PS_TerminalCapabilitySet& ret)
    249         {
    250             OSCL_UNUSED_ARG(ret);
    251         };
    252         virtual bool IsRemovable(TPVChannelId lcn)
    253         {
    254             OSCL_UNUSED_ARG(lcn);
    255             return true;
    256         };
    257         virtual PS_DataType GetOutgoingDataType(PVCodecType_t codecType,
    258                                                 uint32 bitrate);
    259 
    260         OlcParam* OpenOutgoingChannel(PVCodecType_t codec,
    261                                       PS_AdaptationLayerType adaptation_layer,
    262                                       PS_DataType pDataTypeRvs = NULL,
    263                                       PS_H223LogicalChannelParameters pH223ParamsRvs = NULL);
    264 
    265         OlcList iOlcs;
    266 
    267 
    268         TSC_statemanager& iTSCstatemanager;
    269         TSC_capability& iTSCcapability;
    270         TSC_lc& iTSClc;
    271         TSC_blc& iTSCblc;
    272         TSC_clc& iTSCclc;
    273         TSC_mt& iTSCmt;
    274 
    275         H245* iH245;
    276         H223* iH223;
    277 
    278         PS_TerminalCapabilitySet iLocalTcs;
    279         OsclTimer<OsclMemAllocator>* iWaitingForOblcTimer;
    280         // Configuration of outgoing channels
    281         Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>* iOutgoingChannelConfig;
    282         // Configuration of incoming channels
    283         Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>* iIncomingChannelConfig;
    284         TSCObserver* iTSCObserver;
    285         TSC_channelcontrol iTSCchannelcontrol;
    286 
    287 
    288         PVLogger* iLogger;
    289 
    290         bool iAllowAl1Video;
    291         bool iAllowAl2Video;
    292         bool iAllowAl3Video;
    293         bool iAllowAl1Audio;
    294         bool iAllowAl2Audio;
    295         bool iAllowAl3Audio;        /*   (These are sent in outgoing CE) */
    296         bool iUseAl1Video;
    297         bool iUseAl2Video;
    298         bool iUseAl3Video;
    299     private:
    300         uint32 OpenLogicalChannel(TPVChannelId OpenLcn,
    301                                   PS_DataType pDataType,
    302                                   PS_H223LogicalChannelParameters pH223Lcp);
    303         PVMFStatus VerifyReverseParameters(PS_ForwardReverseParam forRevParams,
    304                                            TSCObserver* aObserver);
    305         void ReleaseOlc(OlcParam* olc, uint16 cause);
    306         void SignalChannelClose(TPVDirection dir, TPVChannelId lcn, TPVDirectionality directionality);
    307         void OpenPort(TPVDirection dir, TPVChannelId lcn, H223ChannelParam* param);
    308 
    309     private:
    310 
    311 
    312         /* AL3 control field octets */
    313         unsigned iAl3ControlFieldOctets;
    314         /* AL2 with/without sequence numbers */
    315         bool iAl2WithSn;
    316 
    317         unsigned iRemoteAl1Audio;           /* Remote terminal */
    318         unsigned iRemoteAl2Audio;           /* Remote terminal */
    319         unsigned iRemoteAl3Audio;           /*   (These are received in incoming CE) */
    320         unsigned iRemoteAl1Video;           /* Remote terminal */
    321         unsigned iRemoteAl2Video;           /* Remote terminal */
    322         unsigned iRemoteAl3Video;           /*   (These are received in incoming CE) */
    323 
    324         TPVAdaptationLayer iVideoLayer;         /* Layer to use, decided by local terminal */
    325         /*   (0=undetermined, 2=AL2, 3=AL3) */
    326         OsclSharedPtr<S_TerminalCapabilitySet> iRemoteTcs;
    327 
    328         Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator> iOutCodecList;
    329         bool iWaitingForOblc;
    330         PVCodecType_t iWaitingForOblcCodec;
    331 };
    332 
    333 #endif
    334 
    335