Home | History | Annotate | Download | only in src
      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_SM_FSP_RTSP_UNICAST_H
     19 #include "pvmf_sm_fsp_rtsp_unicast.h"
     20 #endif
     21 
     22 #ifndef OSCL_EXCLUSIVE_PTR_H_INCLUDED
     23 #include "oscl_exclusive_ptr.h"
     24 #endif
     25 
     26 #ifndef PVMF_SOCKET_NODE_H_INCLUDED
     27 #include "pvmf_socket_node.h"
     28 #endif
     29 #ifndef PVMF_RTSP_ENGINE_NODE_FACTORY_H_INCLUDED
     30 #include "pvrtsp_client_engine_factory.h"
     31 #endif
     32 #ifndef PVMF_JITTER_BUFFER_NODE_H_INCLUDED
     33 #include "pvmf_jitter_buffer_node.h"
     34 #endif
     35 #ifndef PVMF_MEDIALAYER_NODE_H_INCLUDED
     36 #include "pvmf_medialayer_node.h"
     37 #endif
     38 #ifndef PVRTSP_ENGINE_NODE_EXTENSION_INTERFACE_H_INCLUDED
     39 #include "pvrtspenginenodeextensioninterface.h"
     40 #endif
     41 #ifndef PVMF_MEDIA_PRESENTATION_INFO_H_INCLUDED
     42 #include "pvmf_media_presentation_info.h"
     43 #endif
     44 
     45 #ifndef PVMF_SM_FSP_BASE_METADATA_H_INCLUDED
     46 #include "pvmf_sm_fsp_base_metadata.h"
     47 #endif
     48 
     49 #ifndef SDP_PARSER_H
     50 #include "sdp_parser.h"
     51 #endif
     52 
     53 #ifndef OSCL_SNPRINTF_H_INCLUDED
     54 #include "oscl_snprintf.h"
     55 #endif
     56 
     57 #ifndef AMR_PAYLOAD_PARSER_FACTORY_H_INCLUDED
     58 #include "amr_payload_parser_factory.h"
     59 #endif
     60 #ifndef H263_PAYLOAD_PARSER_FACTORY_H_INCLUDED
     61 #include "h263_payload_parser_factory.h"
     62 #endif
     63 #ifndef H264_PAYLOAD_PARSER_FACTORY_H_INCLUDED
     64 #include "h264_payload_parser_factory.h"
     65 #endif
     66 #ifndef M4V_AUDIO_PAYLOAD_PARSER_FACTORY_H_INCLUDED
     67 #include "m4v_audio_payload_parser_factory.h"
     68 #endif
     69 #ifndef M4V_PAYLOAD_PARSER_FACTORY_H_INCLUDED
     70 #include "m4v_payload_parser_factory.h"
     71 #endif
     72 #ifndef PAYLOAD_PARSER_REGISTRY_H_INCLUDED
     73 #include "payload_parser_registry.h"
     74 #endif
     75 #ifndef RFC3640_PAYLOAD_PARSER_FACTORY_H_INCLUDED
     76 #include "rfc3640_payload_parser_factory.h"
     77 #endif
     78 
     79 #ifndef OSCL_MIME_STRING_UTILS_H
     80 #include "pv_mime_string_utils.h"
     81 #endif
     82 
     83 #ifndef PVMI_KVP_UTIL_H_INCLUDED
     84 #include "pvmi_kvp_util.h"
     85 #endif
     86 
     87 #ifndef PVMI_DRM_KVP_H_INCLUDED
     88 #include "pvmi_drm_kvp.h"
     89 #endif
     90 
     91 
     92 #ifndef PVRTSP_CLIENT_ENGINE_NODE_H
     93 #include "pvrtsp_client_engine_node.h"
     94 #endif
     95 
     96 #ifndef PVMF_SM_RTSP_UNICAST_CAPANDCONFIG_H
     97 #include "pvmf_sm_rtsp_unicast_capandconfig.h"
     98 #endif
     99 
    100 #ifndef SDP_MEDIA_PARSER_REGISTRY_POPULATOR
    101 #include "sdp_mediaparser_registry_populator.h"
    102 #endif
    103 
    104 #include "pvmf_rtp_jitter_buffer_factory.h"
    105 
    106 /**
    107 ///////////////////////////////////////////////////////////////////////////////
    108 // Node Constructor & Destructor
    109 ///////////////////////////////////////////////////////////////////////////////
    110 */
    111 PVMFSMRTSPUnicastNode * PVMFSMRTSPUnicastNode::New(int32 aPriority)
    112 {
    113     PVMFSMRTSPUnicastNode * rtspUnicastNode = OSCL_NEW(PVMFSMRTSPUnicastNode, (aPriority));
    114     if (rtspUnicastNode)
    115     {
    116         rtspUnicastNode->Construct();
    117     }
    118     return rtspUnicastNode;
    119 }
    120 
    121 PVMFSMRTSPUnicastNode::PVMFSMRTSPUnicastNode(int32 aPriority): PVMFSMFSPBaseNode(aPriority)
    122 {
    123     iJitterBufferDurationInMilliSeconds = DEFAULT_JITTER_BUFFER_DURATION_IN_MS;
    124     oAutoReposition = false;
    125     iPauseDenied    = false;
    126     ResetNodeParams(false);
    127 }
    128 
    129 PVMFSMRTSPUnicastNode::~PVMFSMRTSPUnicastNode()
    130 {
    131     CleanUp();
    132 }
    133 
    134 void PVMFSMRTSPUnicastNode::Construct()
    135 {
    136     PVMFSMFSPBaseNode::Construct();
    137     int32 err;
    138     OSCL_TRY(err,
    139              iLogger = PVLogger::GetLoggerObject("PVMFSMRTSPUnicastNode");
    140              iAvailableMetadataKeys.reserve(PVMFSTREAMINGMGRNODE_NUM_METADATAKEYS);
    141              iAvailableMetadataKeys.clear();
    142              // create the payload parser registry
    143              PopulatePayloadParserRegistry();
    144              CreateChildNodes();
    145              QueryChildNodesExtentionInterface();
    146              // pass the payload parser registry on to the media layer node
    147              PVMFSMFSPChildNodeContainer* iMediaLayerNodeContainer =
    148                  getChildNodeContainer(PVMF_SM_FSP_MEDIA_LAYER_NODE);
    149              OSCL_ASSERT(iMediaLayerNodeContainer);
    150              PVMFMediaLayerNodeExtensionInterface* mlExtIntf = NULL;
    151              if (iMediaLayerNodeContainer)
    152              mlExtIntf = (PVMFMediaLayerNodeExtensionInterface*)(iMediaLayerNodeContainer->iExtensions[0]);
    153              if (mlExtIntf)
    154                  mlExtIntf->setPayloadParserRegistry(PayloadParserRegistry::GetPayloadParserRegistry());
    155                 );
    156     if (err != OsclErrNone)
    157     {
    158         CleanUp();
    159         OSCL_LEAVE(err);
    160     }
    161 
    162 }
    163 
    164 void PVMFSMRTSPUnicastNode::CreateChildNodes()
    165 {
    166     /*
    167      * Create Socket Node
    168      */
    169     OsclExclusivePtr<PVMFNodeInterface> socketNodeAutoPtr;
    170     PVMFNodeInterface* iSocketNode;
    171     iSocketNode = OSCL_NEW(PVMFSocketNode, (OsclActiveObject::EPriorityNominal));
    172     socketNodeAutoPtr.set(iSocketNode);
    173 
    174     PVMFSMFSPChildNodeContainer sSocketNodeContainer;
    175 
    176     PVMFNodeSessionInfo socketNodeSession(this,
    177                                           this,
    178                                           OSCL_REINTERPRET_CAST(OsclAny*,
    179                                                                 iSocketNode),
    180                                           this,
    181                                           OSCL_REINTERPRET_CAST(OsclAny*,
    182                                                                 iSocketNode));
    183 
    184     sSocketNodeContainer.iNode = iSocketNode;
    185     sSocketNodeContainer.iSessionId =
    186         iSocketNode->Connect(socketNodeSession);
    187     sSocketNodeContainer.iNodeTag =
    188         PVMF_SM_FSP_SOCKET_NODE;
    189     sSocketNodeContainer.commandStartOffset =
    190         PVMF_SM_FSP_SOCKET_NODE_COMMAND_START;
    191     /* Push back the known UUID in case there are no queries */
    192     PVUuid uuid(PVMF_SOCKET_NODE_EXTENSION_INTERFACE_UUID);
    193     sSocketNodeContainer.iExtensionUuids.push_back(uuid);
    194     iFSPChildNodeContainerVec.push_back(sSocketNodeContainer);
    195 
    196     /*
    197      * Create Session Controller Node
    198      */
    199     OsclExclusivePtr<PVMFNodeInterface> sessionControllerAutoPtr;
    200     //PVMFNodeInterface* iSessionControllerNode = OSCL_NEW(PVRTSPEngineNode, (OsclActiveObject::EPriorityNominal));
    201     PVMFNodeInterface* iSessionControllerNode = PVMFRrtspEngineNodeFactory::CreatePVMFRtspEngineNode(OsclActiveObject::EPriorityNominal);
    202     sessionControllerAutoPtr.set(iSessionControllerNode);
    203 
    204     PVMFSMFSPChildNodeContainer sSessionControllerNodeContainer;
    205 
    206     PVMFNodeSessionInfo sessionControllerSession(this,
    207             this,
    208             OSCL_REINTERPRET_CAST(OsclAny*,
    209                                   iSessionControllerNode),
    210             this,
    211             OSCL_REINTERPRET_CAST(OsclAny*,
    212                                   iSessionControllerNode));
    213 
    214     sSessionControllerNodeContainer.iNode = iSessionControllerNode;
    215     sSessionControllerNodeContainer.iSessionId =
    216         iSessionControllerNode->Connect(sessionControllerSession);
    217     sSessionControllerNodeContainer.iNodeTag =
    218         PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE;
    219     sSessionControllerNodeContainer.commandStartOffset =
    220         PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_COMMAND_START;
    221     /* Push back the known UUID in case there are no queries */
    222     sSessionControllerNodeContainer.iExtensionUuids.push_back(KPVRTSPEngineNodeExtensionUuid);
    223     iFSPChildNodeContainerVec.push_back(sSessionControllerNodeContainer);
    224 
    225 
    226     /*
    227      * Create jitter buffer node
    228      */
    229     OsclExclusivePtr<PVMFNodeInterface> jitterBufferNodeAutoPtr;
    230     PVMFNodeInterface* iJitterBufferNode;
    231     iJBFactory = OSCL_NEW(RTPJitterBufferFactory, ());
    232     iJitterBufferNode = OSCL_NEW(PVMFJitterBufferNode, (OsclActiveObject::EPriorityNominal, iJBFactory));
    233 
    234     jitterBufferNodeAutoPtr.set(iJitterBufferNode);
    235 
    236     PVMFSMFSPChildNodeContainer sJitterBufferNodeContainer;
    237 
    238     PVMFNodeSessionInfo jitterBufferSession(this,
    239                                             this,
    240                                             OSCL_REINTERPRET_CAST(OsclAny*,
    241                                                                   iJitterBufferNode),
    242                                             this,
    243                                             OSCL_REINTERPRET_CAST(OsclAny*,
    244                                                                   iJitterBufferNode));
    245 
    246     sJitterBufferNodeContainer.iNode = iJitterBufferNode;
    247     sJitterBufferNodeContainer.iSessionId =
    248         iJitterBufferNode->Connect(jitterBufferSession);
    249     sJitterBufferNodeContainer.iNodeTag =
    250         PVMF_SM_FSP_JITTER_BUFFER_NODE;
    251     sJitterBufferNodeContainer.commandStartOffset =
    252         PVMF_SM_FSP_JITTER_BUFFER_CONTROLLER_COMMAND_START;
    253     /* Push back the known UUID in case there are no queries */
    254     sJitterBufferNodeContainer.iExtensionUuids.push_back(PVMF_JITTERBUFFERNODE_EXTENSIONINTERFACE_UUID);
    255     iFSPChildNodeContainerVec.push_back(sJitterBufferNodeContainer);
    256 
    257 
    258     /*
    259      * Create media layer node
    260      */
    261     OsclExclusivePtr<PVMFNodeInterface> mediaLayerNodeAutoPtr;
    262     PVMFNodeInterface* iMediaLayerNode;
    263     iMediaLayerNode = OSCL_NEW(PVMFMediaLayerNode, (OsclActiveObject::EPriorityNominal));
    264 
    265     mediaLayerNodeAutoPtr.set(iMediaLayerNode);
    266 
    267     PVMFSMFSPChildNodeContainer sMediaLayerNodeContainer;
    268 
    269     PVMFNodeSessionInfo mediaLayerSession(this,
    270                                           this,
    271                                           OSCL_REINTERPRET_CAST(OsclAny*,
    272                                                                 iMediaLayerNode),
    273                                           this,
    274                                           OSCL_REINTERPRET_CAST(OsclAny*,
    275                                                                 iMediaLayerNode));
    276 
    277     sMediaLayerNodeContainer.iNode = iMediaLayerNode;
    278     sMediaLayerNodeContainer.iSessionId =
    279         iMediaLayerNode->Connect(mediaLayerSession);
    280     sMediaLayerNodeContainer.iNodeTag =
    281         PVMF_SM_FSP_MEDIA_LAYER_NODE;
    282     sMediaLayerNodeContainer.commandStartOffset =
    283         PVMF_SM_FSP_MEDIA_LAYER_COMMAND_START;
    284     /* Push back the known UUID in case there are no queries */
    285     sMediaLayerNodeContainer.iExtensionUuids.push_back(PVMF_MEDIALAYERNODE_EXTENSIONINTERFACE_UUID);
    286     iFSPChildNodeContainerVec.push_back(sMediaLayerNodeContainer);
    287 
    288     sessionControllerAutoPtr.release();
    289     socketNodeAutoPtr.release();
    290     jitterBufferNodeAutoPtr.release();
    291     mediaLayerNodeAutoPtr.release();
    292 }
    293 
    294 void PVMFSMRTSPUnicastNode::DestroyChildNodes()
    295 {
    296     uint32 i, j;
    297     for (i = 0; i < iFSPChildNodeContainerVec.size(); i++)
    298     {
    299         for (j = 0; j < iFSPChildNodeContainerVec[i].iExtensions.size(); j++)
    300         {
    301             PVInterface* extIntf = iFSPChildNodeContainerVec[i].iExtensions[j];
    302             extIntf->removeRef();
    303         }
    304 
    305         if (iFSPChildNodeContainerVec[i].iNodeTag == PVMF_SM_FSP_SOCKET_NODE)
    306         {
    307             OSCL_DELETE(OSCL_STATIC_CAST(PVMFSocketNode*, iFSPChildNodeContainerVec[i].iNode));
    308         }
    309         else if (iFSPChildNodeContainerVec[i].iNodeTag == PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE)
    310         {
    311             PVMFRrtspEngineNodeFactory::DeletePVMFRtspEngineNode(iFSPChildNodeContainerVec[i].iNode);
    312         }
    313         else if (iFSPChildNodeContainerVec[i].iNodeTag == PVMF_SM_FSP_JITTER_BUFFER_NODE)
    314         {
    315             OSCL_DELETE(OSCL_STATIC_CAST(PVMFJitterBufferNode*, iFSPChildNodeContainerVec[i].iNode));
    316         }
    317         else if (iFSPChildNodeContainerVec[i].iNodeTag == PVMF_SM_FSP_MEDIA_LAYER_NODE)
    318         {
    319             OSCL_DELETE(OSCL_STATIC_CAST(PVMFMediaLayerNode*, iFSPChildNodeContainerVec[i].iNode));
    320         }
    321         iFSPChildNodeContainerVec[i].iNode = NULL;
    322     }
    323 
    324     iFSPChildNodeContainerVec.clear();
    325 }
    326 
    327 void PVMFSMRTSPUnicastNode::PopulatePayloadParserRegistry()
    328 {
    329     PayloadParserRegistry* registry =
    330         PayloadParserRegistry::GetPayloadParserRegistry();
    331     OSCL_ASSERT(registry == NULL);
    332     PayloadParserRegistry::Init();
    333     registry = PayloadParserRegistry::GetPayloadParserRegistry();
    334 
    335     StrPtrLen aac_latm("audio/MP4A-LATM");
    336     StrPtrLen amr("audio/AMR");
    337     StrPtrLen amrwb("audio/AMR-WB");
    338     StrPtrLen h263_old("video/H263-1998");
    339     StrPtrLen h263("video/H263-2000");
    340     StrPtrLen m4v("video/MP4V-ES");
    341     StrPtrLen h264("video/H264");
    342     StrPtrLen mp4a(PVMF_MIME_MPEG4_AUDIO);
    343     StrPtrLen rfc3640("audio/mpeg4-generic");
    344 
    345     IPayloadParserFactory* m4vP = OSCL_NEW(M4VPayloadParserFactory, ());
    346     IPayloadParserFactory* aacP = OSCL_NEW(M4VAudioPayloadParserFactory, ());
    347     IPayloadParserFactory* amrP = OSCL_NEW(AmrPayloadParserFactory, ());
    348     IPayloadParserFactory* h263P = OSCL_NEW(H263PayloadParserFactory, ());
    349     IPayloadParserFactory* h264P = OSCL_NEW(H264PayloadParserFactory, ());
    350     IPayloadParserFactory* amrwbP = OSCL_NEW(AmrPayloadParserFactory, ());
    351     IPayloadParserFactory* rfc3640P = OSCL_NEW(RFC3640PayloadParserFactory, ());
    352 
    353     registry->addPayloadParserFactoryToRegistry(m4v, m4vP);
    354     registry->addPayloadParserFactoryToRegistry(h264, h264P);
    355     registry->addPayloadParserFactoryToRegistry(aac_latm, aacP);
    356     registry->addPayloadParserFactoryToRegistry(mp4a, aacP);
    357     registry->addPayloadParserFactoryToRegistry(amr, amrP);
    358     registry->addPayloadParserFactoryToRegistry(amrwb, amrwbP);
    359     registry->addPayloadParserFactoryToRegistry(h263_old, h263P);
    360     registry->addPayloadParserFactoryToRegistry(h263, h263P);
    361     registry->addPayloadParserFactoryToRegistry(rfc3640,  rfc3640P);
    362 }
    363 
    364 void PVMFSMRTSPUnicastNode::DestroyPayloadParserRegistry()
    365 {
    366     StrPtrLen aac_latm("audio/MP4A-LATM");
    367     StrPtrLen amr("audio/AMR");
    368     StrPtrLen amrwb("audio/AMR-WB");
    369     StrPtrLen h263("video/H263-2000");
    370     StrPtrLen m4v("video/MP4V-ES");
    371     StrPtrLen h264("video/H264");
    372     StrPtrLen rfc3640("audio/mpeg4-generic");
    373 
    374     PayloadParserRegistry* registry =
    375         PayloadParserRegistry::GetPayloadParserRegistry();
    376     if (registry == NULL) return;
    377 
    378     OsclMemoryFragment memFrag;
    379 
    380     memFrag.ptr = (OsclAny*)(m4v.c_str());
    381     memFrag.len = (uint32)m4v.size();
    382     OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
    383 
    384     memFrag.ptr = (OsclAny*)(h264.c_str());
    385     memFrag.len = (uint32)h264.size();
    386     OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
    387 
    388     memFrag.ptr = (OsclAny*)(aac_latm.c_str());
    389     memFrag.len = (uint32)aac_latm.size();
    390     OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
    391 
    392     memFrag.ptr = (OsclAny*)(amr.c_str());
    393     memFrag.len = (uint32)amr.size();
    394     OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
    395 
    396     memFrag.ptr = (OsclAny*)(amrwb.c_str());
    397     memFrag.len = (uint32)amrwb.size();
    398     OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
    399 
    400     memFrag.ptr = (OsclAny*)(h263.c_str());
    401     memFrag.len = (uint32)h263.size();
    402     OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
    403 
    404     memFrag.ptr = (OsclAny*)(rfc3640.c_str());
    405     memFrag.len = (uint32)rfc3640.size();
    406     OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
    407 
    408     PayloadParserRegistry::Cleanup();
    409 }
    410 
    411 void PVMFSMRTSPUnicastNode::QueryChildNodesExtentionInterface()
    412 {
    413     PVMFSMFSPChildNodeContainerVector::iterator it;
    414     for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
    415     {
    416         //we dont use dynamic cast for cross cast.. because some compilers may not support it, and to avoid
    417         //run time overheads.... So, we need to explicitly downcast the pvmfnodeinterface ptr to its
    418         //concrete implementation and then, upcast it into required PVInterface class
    419 
    420         PVInterface * interfacePtr = NULL;
    421         switch (it->iNodeTag)
    422         {
    423             case PVMF_SM_FSP_SOCKET_NODE:
    424             {
    425                 PVMFSocketNode * tmpPtr = OSCL_STATIC_CAST(PVMFSocketNode *, it->iNode);
    426                 interfacePtr = OSCL_STATIC_CAST(PVInterface*, tmpPtr);
    427             }
    428             break;
    429             case PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE:
    430             {
    431                 PVRTSPEngineNode * tmpPtr = OSCL_STATIC_CAST(PVRTSPEngineNode *, it->iNode);
    432                 interfacePtr = OSCL_STATIC_CAST(PVInterface*, tmpPtr);
    433             }
    434             break;
    435             case PVMF_SM_FSP_JITTER_BUFFER_NODE:
    436             {
    437                 PVMFJitterBufferNode * tmpPtr = OSCL_STATIC_CAST(PVMFJitterBufferNode *, it->iNode);
    438                 interfacePtr = OSCL_STATIC_CAST(PVInterface*, tmpPtr);
    439             }
    440             break;
    441             case PVMF_SM_FSP_MEDIA_LAYER_NODE:
    442             {
    443                 PVMFMediaLayerNode * tmpPtr = OSCL_STATIC_CAST(PVMFMediaLayerNode *, it->iNode);
    444                 interfacePtr = OSCL_STATIC_CAST(PVInterface*, tmpPtr);
    445             }
    446             break;
    447         }
    448 
    449         PVInterface* extensionIntfPtr = NULL;
    450         bool retval = interfacePtr->queryInterface(it->iExtensionUuids.front(), extensionIntfPtr);
    451         if (retval && extensionIntfPtr)
    452         {
    453             it->iExtensions.push_back(extensionIntfPtr);
    454         }
    455     }
    456 }
    457 
    458 /**
    459  * Called by the command handler AO to process a command from
    460  * the input queue.
    461  * Return true if a command was processed, false if the command
    462  * processor is busy and can't process another command now.
    463  */
    464 bool PVMFSMRTSPUnicastNode::ProcessCommand(PVMFSMFSPBaseNodeCommand& aCmd)
    465 {
    466     if (EPVMFNodeError == iInterfaceState)
    467     {
    468         if (iCurrErrHandlingCommand.size() > 0)
    469         {
    470             return false;
    471         }
    472         switch (aCmd.iCmd)
    473         {
    474             case PVMF_SMFSP_NODE_CANCEL_DUE_TO_ERROR:
    475                 DoCancelAllPendingCommands(aCmd);
    476                 break;
    477             case PVMF_SMFSP_NODE_RESET_DUE_TO_ERROR:
    478                 DoResetDueToErr(aCmd);
    479                 break;
    480         }
    481 
    482         return true;
    483     }
    484     /*
    485      * normally this node will not start processing one command
    486      * until the prior one is finished.  However, a hi priority
    487      * command such as Cancel must be able to interrupt a command
    488      * in progress.
    489      */
    490     if ((iCurrentCommand.size() > 0 && !aCmd.hipri()
    491             && aCmd.iCmd != PVMF_SMFSP_NODE_CANCEL_GET_LICENSE)
    492             || iCancelCommand.size() > 0)
    493         return false;
    494 
    495     OSCL_ASSERT(PVMF_SMFSP_NODE_QUERYUUID != aCmd.iCmd);
    496     OSCL_ASSERT(PVMF_SMFSP_NODE_SET_DATASOURCE_RATE != aCmd.iCmd);
    497     switch (aCmd.iCmd)
    498     {
    499             /* node interface commands */
    500         case PVMF_SMFSP_NODE_QUERYINTERFACE:
    501             DoQueryInterface(aCmd);
    502             break;
    503         case PVMF_SMFSP_NODE_INIT:
    504             DoInit(aCmd);
    505             break;
    506         case PVMF_SMFSP_NODE_PREPARE:
    507             DoPrepare(aCmd);
    508             break;
    509         case PVMF_SMFSP_NODE_REQUESTPORT:
    510             DoRequestPort(aCmd);
    511             break;
    512         case PVMF_SMFSP_NODE_RELEASEPORT:
    513             DoReleasePort(aCmd);
    514             break;
    515         case PVMF_SMFSP_NODE_START:
    516             DoStart(aCmd);
    517             break;
    518         case PVMF_SMFSP_NODE_STOP:
    519             DoStop(aCmd);
    520             break;
    521         case PVMF_SMFSP_NODE_FLUSH:
    522             DoFlush(aCmd);
    523             break;
    524         case PVMF_SMFSP_NODE_PAUSE:
    525             if (iPauseDenied)
    526             {
    527                 //Check with the jitter buffer node if the session is already expired?
    528                 bool isSessionDurationExpired = false;
    529                 PVMFSMFSPChildNodeContainer* jitterBufferNodeContainer =
    530                     getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
    531                 if (jitterBufferNodeContainer)
    532                 {
    533                     PVMFJitterBufferExtensionInterface* jbExtIntf =
    534                         OSCL_STATIC_CAST(PVMFJitterBufferExtensionInterface*, jitterBufferNodeContainer->iExtensions.front());
    535                     if (jbExtIntf)
    536                         jbExtIntf->HasSessionDurationExpired(isSessionDurationExpired);
    537                 }
    538 
    539                 if (isSessionDurationExpired)
    540                 {
    541                     DoPause(aCmd);
    542                 }
    543                 else
    544                 {
    545                     CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
    546                 }
    547             }
    548             else
    549             {
    550                 DoPause(aCmd);
    551             }
    552             break;
    553         case PVMF_SMFSP_NODE_RESET:
    554             DoReset(aCmd);
    555             break;
    556         case PVMF_SMFSP_NODE_CANCELALLCOMMANDS:
    557             DoCancelAllCommands(aCmd);
    558             break;
    559         case PVMF_SMFSP_NODE_CANCELCOMMAND:
    560             DoCancelCommand(aCmd);
    561             break;
    562 
    563             /* add extention interface commands */
    564         case PVMF_SMFSP_NODE_SET_DATASOURCE_POSITION:
    565             OSCL_ASSERT(iPlayListRepositioning != true);
    566             if (!oAutoReposition)
    567             {
    568                 DoSetDataSourcePosition(aCmd);
    569             }
    570             else
    571             {
    572                 DoSetDataSourcePositionOverflow(aCmd);
    573             }
    574             break;
    575 
    576         case PVMF_SMFSP_NODE_QUERY_DATASOURCE_POSITION:
    577             DoQueryDataSourcePosition(aCmd);
    578             break;
    579         case PVMF_SMFSP_NODE_SET_DATASOURCE_RATE:
    580 
    581             break;
    582         case PVMF_SMFSP_NODE_GETNODEMETADATAKEYS:
    583         {
    584             PVMFStatus status = DoGetMetadataKeys(aCmd);
    585             if (status != PVMFPending)
    586             {
    587                 CommandComplete(iInputCommands, aCmd, status);
    588             }
    589             else
    590             {
    591                 MoveCmdToCurrentQueue(aCmd);
    592             }
    593         }
    594         break;
    595         case PVMF_SMFSP_NODE_GETNODEMETADATAVALUES:
    596         {
    597             PVMFStatus status = DoGetMetadataValues(aCmd);
    598             if (status != PVMFPending)
    599             {
    600                 CommandComplete(iInputCommands, aCmd, status);
    601             }
    602             else
    603             {
    604                 MoveCmdToCurrentQueue(aCmd);
    605             }
    606         }
    607         break;
    608         case PVMF_SMFSP_NODE_GET_LICENSE_W:
    609         {
    610             PVMFStatus status = DoGetLicense(aCmd, true);
    611             if (status == PVMFPending)
    612             {
    613                 MoveCmdToCurrentQueue(aCmd);
    614             }
    615             else
    616             {
    617                 CommandComplete(iInputCommands, aCmd, status);
    618             }
    619         }
    620         break;
    621         case PVMF_SMFSP_NODE_GET_LICENSE:
    622         {
    623             PVMFStatus status = DoGetLicense(aCmd);
    624             if (status == PVMFPending)
    625             {
    626                 MoveCmdToCurrentQueue(aCmd);
    627             }
    628             else
    629             {
    630                 CommandComplete(iInputCommands, aCmd, status);
    631             }
    632         }
    633         break;
    634         case PVMF_SMFSP_NODE_CANCEL_GET_LICENSE:
    635             DoCancelGetLicense(aCmd);
    636             break;
    637         case PVMF_SMFSP_NODE_CAPCONFIG_SETPARAMS:
    638         {
    639             PvmiMIOSession session;
    640             PvmiKvp* aParameters;
    641             int num_elements;
    642             PvmiKvp** ppRet_kvp;
    643             aCmd.Parse(session, aParameters, num_elements, ppRet_kvp);
    644             setParametersSync(NULL, aParameters, num_elements, *ppRet_kvp);
    645             ciObserver->SignalEvent(aCmd.iId);
    646         }
    647         break;
    648 
    649         /* internal commands common to all types of streaming*/
    650         case PVMF_SMFSP_NODE_CONSTRUCT_SESSION: //to construct the graph
    651         {
    652             PVMFStatus status = DoGraphConstruct();
    653             if (status != PVMFPending)
    654             {
    655                 InternalCommandComplete(iInputCommands, aCmd, status);
    656             }
    657             else
    658             {
    659                 MoveCmdToCurrentQueue(aCmd);
    660             }
    661         }
    662         break;
    663 
    664         /* internal commands specific to rtsp unicast streaming*/
    665 
    666         /* unknown commands */
    667         default:
    668             /* unknown command type */
    669             CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
    670             break;
    671     }
    672     return true;
    673 }
    674 
    675 ///////////////////////////////////////////////////////////////////////////////
    676 //Node command servicing functions queued in input command Q by base class
    677 ///////////////////////////////////////////////////////////////////////////////
    678 void PVMFSMRTSPUnicastNode::DoQueryInterface(PVMFSMFSPBaseNodeCommand& aCmd)
    679 {
    680     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoQueryInterface - In"));
    681 
    682     PVUuid* uuid;
    683     PVInterface** ptr;
    684     aCmd.PVMFSMFSPBaseNodeCommandBase::Parse(uuid, ptr);
    685 
    686     *ptr = NULL;
    687 
    688     if (*uuid == PVMF_TRACK_SELECTION_INTERFACE_UUID)
    689     {
    690         PVMFTrackSelectionExtensionInterface* interimPtr =
    691             OSCL_STATIC_CAST(PVMFTrackSelectionExtensionInterface*, this);
    692         *ptr = OSCL_STATIC_CAST(PVInterface*, interimPtr);
    693     }
    694     else if (*uuid == PVMF_DATA_SOURCE_INIT_INTERFACE_UUID)
    695     {
    696         PVMFDataSourceInitializationExtensionInterface* interimPtr =
    697             OSCL_STATIC_CAST(PVMFDataSourceInitializationExtensionInterface*, this);
    698         *ptr = OSCL_STATIC_CAST(PVInterface*, interimPtr);
    699     }
    700     else if (*uuid == PvmfDataSourcePlaybackControlUuid)
    701     {
    702         PvmfDataSourcePlaybackControlInterface* interimPtr =
    703             OSCL_STATIC_CAST(PvmfDataSourcePlaybackControlInterface*, this);
    704         *ptr = OSCL_STATIC_CAST(PVInterface*, interimPtr);
    705     }
    706     else if (*uuid == KPVMFMetadataExtensionUuid)
    707     {
    708         PVMFMetadataExtensionInterface* interimPtr =
    709             OSCL_STATIC_CAST(PVMFMetadataExtensionInterface*, this);
    710         *ptr = OSCL_STATIC_CAST(PVInterface*, interimPtr);
    711     }
    712     else if (*uuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
    713     {
    714         PvmiCapabilityAndConfig* interimPtr =
    715             OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, this);
    716         *ptr = OSCL_STATIC_CAST(PVInterface*, interimPtr);
    717     }
    718     else if (*uuid == PVMFCPMPluginLicenseInterfaceUuid)
    719     {
    720         PVMFCPMPluginLicenseInterface* interimPtr =
    721             OSCL_STATIC_CAST(PVMFCPMPluginLicenseInterface*, this);
    722         *ptr = OSCL_STATIC_CAST(PVInterface*, interimPtr);
    723     }
    724     else
    725     {
    726         *ptr = NULL;
    727     }
    728 
    729     if (*ptr)
    730     {
    731         PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::QueryInterface() - CmdComplete - PVMFSuccess"));
    732         CommandComplete(iInputCommands, aCmd, PVMFSuccess);
    733     }
    734     else
    735     {
    736         PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::QueryInterface() - CmdFailed - PVMFErrNotSupported"));
    737         CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
    738     }
    739 
    740 
    741     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoQueryInterface - Out"));
    742     return;
    743 }
    744 
    745 void PVMFSMRTSPUnicastNode::DoInit(PVMFSMFSPBaseNodeCommand& aCmd)
    746 {
    747     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoInit - In"));
    748     switch (iInterfaceState)
    749     {
    750         case EPVMFNodeIdle:
    751         {
    752             /*
    753              * At first Init, PVMFErrLicesneRequest is replied from Janus.
    754              * Then iCPMInitPending is set into true.
    755              * If second Init is called, just to check license authentication is required.
    756              */
    757             if (iCPMInitPending)
    758             {
    759                 MoveCmdToCurrentQueue(aCmd);
    760                 if (iSessionSourceInfo->iDRMProtected == true && iCPM)
    761                 {
    762                     RequestUsage();
    763                     return;
    764                 }
    765                 else
    766                 {
    767                     CommandComplete(iCurrentCommand,
    768                                     iCurrentCommand.front(),
    769                                     PVMFFailure,
    770                                     NULL, NULL, NULL);
    771                     return;
    772                 }
    773             }
    774             else
    775             {
    776                 /* An asynchronous method that prepare's the node for init */
    777                 PVMFStatus status = DoPreInit(aCmd);
    778                 if (status == PVMFSuccess)
    779                 {
    780                     /*
    781                      * Init for streaming manager cannot be completed unless Init
    782                      * for all the children nodes are complete
    783                      */
    784                     PVMFSMFSPChildNodeContainerVector::iterator it;
    785                     for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
    786                     {
    787                         PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
    788                         if (internalCmd != NULL)
    789                         {
    790                             internalCmd->cmd =
    791                                 it->commandStartOffset +
    792                                 PVMF_SM_FSP_NODE_INTERNAL_INIT_CMD_OFFSET;
    793                             internalCmd->parentCmd = aCmd.iCmd;
    794 
    795                             OsclAny *cmdContextData =
    796                                 OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
    797 
    798                             PVMFNodeInterface* iNode = it->iNode;
    799 
    800                             iNode->Init(it->iSessionId, cmdContextData);
    801                             it->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
    802                         }
    803                         else
    804                         {
    805                             PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoInit:RequestNewInternalCmd - Failed"));
    806                             CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
    807                             return;
    808                         }
    809                     }
    810                     MoveCmdToCurrentQueue(aCmd);
    811                 }
    812                 else if (status == PVMFPending)
    813                 {
    814                     MoveCmdToCurrentQueue(aCmd);
    815                 }
    816                 else
    817                 {
    818                     PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoInit: DoPreInit() - Failed"));
    819                     PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
    820                     int32 errcode = PVMFStreamingManagerNodeErrorParseSDPFailed;
    821                     CommandComplete(iInputCommands, aCmd, PVMFFailure, NULL, &eventuuid, &errcode);
    822                     return;
    823                 }
    824             }
    825         }
    826         break;
    827 
    828         default:
    829         {
    830             PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::DoInit Failed - Invalid State"));
    831             CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
    832         }
    833         break;
    834     }
    835     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoInit - Out"));
    836 }
    837 
    838 /**
    839  * Call by DoInit as a prep step
    840  */
    841 PVMFStatus PVMFSMRTSPUnicastNode::DoPreInit(PVMFSMFSPBaseNodeCommand& aCmd)
    842 {
    843     OSCL_UNUSED_ARG(aCmd);
    844     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoPreInit - In"));
    845     PVMFStatus status = PVMFSuccess;
    846 
    847     if (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE)
    848     {
    849         status = ProcessSDP();
    850         if (status != PVMFSuccess)
    851         {
    852             PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoPreInit - Out, status=%d", status));
    853             return status;
    854         }
    855 
    856         // ClipEndURL found - let UI know about this
    857         if (iSdpInfo->getSessionInfo()->getEndOfClipAction() == LAUNCH_URL)
    858         {
    859             PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
    860             int32 infocode = PVMFStreamingManagerNodeInfoLaunchURL;
    861             ReportInfoEvent(PVMFInfoRemoteSourceNotification, (OsclAny*)(iSdpInfo->getSessionInfo()->getLaunchURL()), &eventuuid, &infocode);
    862         }
    863 
    864         PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
    865             getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
    866 
    867         if (iSessionControllerNodeContainer == NULL)
    868         {
    869             OSCL_LEAVE(OsclErrBadHandle);
    870             return PVMFFailure;
    871         }
    872 
    873         PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
    874             (PVRTSPEngineNodeExtensionInterface*)
    875             (iSessionControllerNodeContainer->iExtensions[0]);
    876 
    877         /*
    878          * This vector is intentionally left uninitialized.
    879          * Streaming manager does not have any track selection info
    880          * at this stage. "SetSDPInfo" would be called again before
    881          * prepare complete to set up all the selected tracks. This
    882          * call is needed here to indicate to Session Controller node
    883          * that it is NOT a RTSP URL based session
    884          */
    885         Oscl_Vector<StreamInfo, OsclMemAllocator> aSelectedStream;
    886 
    887         status = rtspExtIntf->SetSDPInfo(iSdpInfo,
    888                                          aSelectedStream);
    889         if (status != PVMFSuccess)
    890         {
    891             PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:DoPreInit - SetSDPInfo Failed"));
    892         }
    893 
    894     }
    895     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoPreInit - Out"));
    896     return status;
    897 }
    898 
    899 PVMFStatus PVMFSMRTSPUnicastNode::ProcessSDP()
    900 {
    901     PVMFStatus status;
    902     OsclRefCounterMemFrag iSDPText;
    903 
    904     if (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
    905     {
    906         PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
    907             getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
    908 
    909         if (iSessionControllerNodeContainer == NULL)
    910         {
    911             OSCL_LEAVE(OsclErrBadHandle);
    912             return PVMFFailure;
    913         }
    914 
    915         PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
    916             (PVRTSPEngineNodeExtensionInterface*)
    917             (iSessionControllerNodeContainer->iExtensions[0]);
    918 
    919         status = rtspExtIntf->GetSDP(iSDPText);
    920 
    921         if (status != PVMFSuccess)
    922         {
    923             return status;
    924         }
    925     }
    926     else if (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE)
    927     {
    928         /* Parse SDP file contents into a buffer */
    929         Oscl_FileServer fileServ;
    930         Oscl_File osclFile;
    931         fileServ.Connect();
    932         PVMFSourceContextData* atempData = (PVMFSourceContextData*)iSessionSourceInfo->_sourceData;
    933         if (atempData && atempData->CommonData() && atempData->CommonData()->iFileHandle)
    934         {
    935             OsclFileHandle* tempHandle = atempData ->CommonData()->iFileHandle;
    936             osclFile.SetFileHandle(tempHandle);
    937         }
    938 
    939         if (osclFile.Open(iSessionSourceInfo->_sessionURL.get_cstr(),
    940                           Oscl_File::MODE_READ,
    941                           fileServ) != 0)
    942         {
    943             PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ProcessSDP - Unable to open SDP file"));
    944             return PVMFFailure;
    945         }
    946 
    947         /* Get File Size */
    948         osclFile.Seek(0, Oscl_File::SEEKEND);
    949         int32 fileSize = (TOsclFileOffsetInt32)osclFile.Tell();
    950         osclFile.Seek(0, Oscl_File::SEEKSET);
    951 
    952         if (fileSize <= 0)
    953         {
    954             PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ProcessSDP - Corrupt SDP file"));
    955             return PVMFFailure;
    956         }
    957 
    958         OsclMemAllocDestructDealloc<uint8> my_alloc;
    959         OsclRefCounter* my_refcnt;
    960         uint aligned_refcnt_size =
    961             oscl_mem_aligned_size(sizeof(OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >));
    962         /*
    963          * To acct for null char, as SDP buffer is treated akin to a string by the
    964          * SDP parser lib.
    965          */
    966         uint allocsize = oscl_mem_aligned_size(aligned_refcnt_size + fileSize + 2);
    967         uint8* my_ptr = GetMemoryChunk(my_alloc, allocsize);
    968         if (!my_ptr)
    969         {
    970             PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ProcessSDP - Unable to process SDP file"));
    971             return PVMFFailure;
    972         }
    973 
    974         my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >(my_ptr));
    975         my_ptr += aligned_refcnt_size;
    976 
    977         OsclMemoryFragment memfrag;
    978         memfrag.len = fileSize;
    979         memfrag.ptr = my_ptr;
    980 
    981         OsclRefCounterMemFrag tmpRefcntMemFrag(memfrag, my_refcnt, memfrag.len);
    982         iSDPText = tmpRefcntMemFrag;
    983 
    984         osclFile.Read(memfrag.ptr, 1, fileSize);
    985 
    986         osclFile.Close();
    987         fileServ.Close();
    988     }
    989 
    990     PVMFSMSharedPtrAlloc<SDPInfo> sdpAlloc;
    991     SDPInfo* sdpInfo = sdpAlloc.allocate();
    992 
    993     SDP_Parser *sdpParser;
    994 
    995     SDPMediaParserRegistry* sdpParserReg = SDPMediaParserRegistryPopulater::PopulateRegistry();
    996     sdpParser = OSCL_NEW(SDP_Parser, (sdpParserReg));
    997 
    998     int32 sdpRetVal =
    999         sdpParser->parseSDP((const char*)(iSDPText.getMemFragPtr()),
   1000                             iSDPText.getMemFragSize(),
   1001                             sdpInfo);
   1002 
   1003     // save the SDP file name - the packet source node will need this
   1004     sdpInfo->setSDPFilename(iSessionSourceInfo->_sessionURL);
   1005 
   1006     OSCL_DELETE(sdpParser);
   1007     SDPMediaParserRegistryPopulater::CleanupRegistry(sdpParserReg);
   1008 
   1009     OsclRefCounterSA< PVMFSMSharedPtrAlloc<SDPInfo> > *refcnt =
   1010         new OsclRefCounterSA< PVMFSMSharedPtrAlloc<SDPInfo> >(sdpInfo);
   1011 
   1012     OsclSharedPtr<SDPInfo> sharedSDPInfo(sdpInfo, refcnt);
   1013 
   1014     if (sdpRetVal != SDP_SUCCESS)
   1015     {
   1016         return PVMFFailure;
   1017     }
   1018 
   1019     iSdpInfo = sharedSDPInfo;
   1020 
   1021     return PVMFSuccess;
   1022 }
   1023 
   1024 //Compute Jitter buffer mem pool size
   1025 uint32 PVMFSMRTSPUnicastNode::GetJitterBufferMemPoolSize(PVMFJitterBufferNodePortTag aJBNodePortTag, PVMFRTSPTrackInfo& aRTSPTrackInfo)
   1026 {
   1027     uint32 sizeInBytes = 0;
   1028     uint32 byteRate = (aRTSPTrackInfo.bitRate) / 8;
   1029     uint32 overhead = (byteRate * PVMF_JITTER_BUFFER_NODE_MEM_POOL_OVERHEAD) / 100;
   1030     uint32 jitterBufferDuration;
   1031 
   1032     PVMFSMFSPChildNodeContainer* jitterBufferNodeContainer = getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   1033     if (jitterBufferNodeContainer == NULL)
   1034     {
   1035         OSCL_ASSERT(false);
   1036         return false;
   1037     }
   1038 
   1039     PVMFJitterBufferExtensionInterface* jbExtIntf = OSCL_STATIC_CAST(PVMFJitterBufferExtensionInterface*, jitterBufferNodeContainer->iExtensions[0]);
   1040     if (jbExtIntf == NULL)
   1041     {
   1042         OSCL_ASSERT(false);
   1043         return sizeInBytes;
   1044     }
   1045 
   1046     jbExtIntf->getJitterBufferDurationInMilliSeconds(jitterBufferDuration);
   1047     uint32 durationInSec = jitterBufferDuration / 1000;
   1048     switch (aJBNodePortTag)
   1049     {
   1050         case PVMF_JITTER_BUFFER_PORT_TYPE_INPUT:
   1051         {
   1052             if (durationInSec > 0)
   1053             {
   1054                 sizeInBytes = ((byteRate + overhead) * durationInSec);
   1055                 if (sizeInBytes < MIN_RTP_SOCKET_MEM_POOL_SIZE_IN_BYTES)
   1056                 {
   1057                     sizeInBytes = MIN_RTP_SOCKET_MEM_POOL_SIZE_IN_BYTES;
   1058                 }
   1059                 sizeInBytes += (2 * MAX_SOCKET_BUFFER_SIZE);        //eq. to SNODE_UDP_MULTI_MAX_BYTES_PER_RECV + MAX_UDP_PACKET_SIZE used in socket node
   1060             }
   1061 
   1062         }
   1063         break;
   1064         case PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK:
   1065         {
   1066             if (durationInSec > 0)
   1067             {
   1068                 sizeInBytes = MIN_RTP_SOCKET_MEM_POOL_SIZE_IN_BYTES;
   1069                 sizeInBytes += (2 * MAX_SOCKET_BUFFER_SIZE);        //eq. to SNODE_UDP_MULTI_MAX_BYTES_PER_RECV + MAX_UDP_PACKET_SIZE used in socket node
   1070             }
   1071         }
   1072         break;
   1073         default:
   1074             sizeInBytes = 0;
   1075     }
   1076     return sizeInBytes;
   1077 }
   1078 
   1079 /**
   1080  * Called as a pre step for prepare
   1081  */
   1082 PVMFStatus PVMFSMRTSPUnicastNode::DoGraphConstruct()
   1083 {
   1084     /*
   1085      * Session source info must have been set
   1086      */
   1087     if (iSessionSourceInfo->_sessionType == PVMF_MIME_FORMAT_UNKNOWN)
   1088     {
   1089         PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::GraphConstruct - Invalid Session Type %s", iSessionSourceInfo->_sessionType.getMIMEStrPtr()));
   1090         return PVMFFailure;
   1091     }
   1092     if (!PopulateTrackInfoVec())
   1093     {
   1094         return PVMFFailure;
   1095     }
   1096 
   1097     if (ConstructGraphFor3GPPUDPStreaming())
   1098     {
   1099         if (iTotalNumRequestPortsComplete == iNumRequestPortsPending)
   1100             return PVMFSuccess;
   1101         else
   1102             return PVMFPending;
   1103 
   1104     }
   1105     else
   1106         return PVMFFailure;
   1107 }
   1108 
   1109 bool PVMFSMRTSPUnicastNode::PopulateTrackInfoVec()
   1110 {
   1111     if (iSelectedMediaPresetationInfo.getNumTracks() == 0)
   1112     {
   1113         PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:PopulateTrackInfoVec - Selected Track List Empty"));
   1114         return false;
   1115     }
   1116 
   1117     /*
   1118      * Get selected tracks
   1119      */
   1120 
   1121     int32 numTracks = iSdpInfo->getNumMediaObjects();
   1122 
   1123     if (numTracks > 0)
   1124     {
   1125         for (int32 i = 0; i < numTracks; i++)
   1126         {
   1127             /*
   1128              * Get the vector of mediaInfo as there can
   1129              * alternates for each track
   1130              */
   1131             Oscl_Vector<mediaInfo*, SDPParserAlloc> mediaInfoVec =
   1132                 iSdpInfo->getMediaInfo(i);
   1133 
   1134             uint32 minfoVecLen = mediaInfoVec.size();
   1135             for (uint32 j = 0; j < minfoVecLen; j++)
   1136             {
   1137                 mediaInfo* mInfo = mediaInfoVec[j];
   1138 
   1139                 if (mInfo == NULL)
   1140                 {
   1141                     return false;
   1142                 }
   1143 
   1144                 if (mInfo->getSelect())
   1145                 {
   1146                     PVMFRTSPTrackInfo trackInfo;
   1147                     trackInfo.iTransportType += _STRLIT_CHAR("RTP");
   1148                     trackInfo.trackID = mInfo->getMediaInfoID();
   1149 
   1150                     Oscl_Vector<PayloadSpecificInfoTypeBase*, SDPParserAlloc> payloadVector;
   1151                     payloadVector = mInfo->getPayloadSpecificInfoVector();
   1152 
   1153                     if (payloadVector.size() == 0)
   1154                     {
   1155                         return false;
   1156                     }
   1157                     /*
   1158                      * There can be multiple payloads per media segment.
   1159                      * We only support one for now, so
   1160                      * use just the first payload
   1161                      */
   1162                     PayloadSpecificInfoTypeBase* payloadInfo = payloadVector[0];
   1163                     trackInfo.trackTimeScale = payloadInfo->sampleRate;
   1164 
   1165                     // set config for later
   1166                     int32 configSize = payloadInfo->configSize;
   1167                     OsclAny* config = payloadInfo->configHeader.GetRep();
   1168 
   1169                     const char* mimeType = mInfo->getMIMEType();
   1170                     trackInfo.iMimeType += mimeType;
   1171 
   1172                     trackInfo.portTag = mInfo->getMediaInfoID();
   1173                     trackInfo.bitRate = mInfo->getBitrate();
   1174                     if (mInfo->getReportFrequency() > 0)
   1175                     {
   1176                         trackInfo.iRateAdaptation = true;
   1177                         trackInfo.iRateAdaptationFeedBackFrequency =
   1178                             mInfo->getReportFrequency();
   1179                     }
   1180 
   1181                     if ((mInfo->getRTCPReceiverBitRate() >= 0) &&
   1182                             (mInfo->getRTCPSenderBitRate() >= 0))
   1183                     {
   1184                         trackInfo.iRR = mInfo->getRTCPReceiverBitRate();
   1185                         trackInfo.iRS = mInfo->getRTCPSenderBitRate();
   1186                         trackInfo.iRTCPBwSpecified = true;
   1187                     }
   1188 
   1189                     if ((configSize > 0) && (config != NULL))
   1190                     {
   1191                         OsclMemAllocDestructDealloc<uint8> my_alloc;
   1192                         OsclRefCounter* my_refcnt;
   1193                         uint aligned_refcnt_size =
   1194                             oscl_mem_aligned_size(sizeof(OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >));
   1195 
   1196                         uint8* my_ptr = GetMemoryChunk(my_alloc, aligned_refcnt_size + configSize);
   1197                         if (!my_ptr)
   1198                             return false;
   1199 
   1200                         my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >(my_ptr));
   1201                         my_ptr += aligned_refcnt_size;
   1202 
   1203                         OsclMemoryFragment memfrag;
   1204                         memfrag.len = (uint32)configSize;
   1205                         memfrag.ptr = my_ptr;
   1206 
   1207                         oscl_memcpy((void*)(memfrag.ptr), (const void*)config, memfrag.len);
   1208 
   1209                         OsclRefCounterMemFrag tmpRefcntMemFrag(memfrag, my_refcnt, memfrag.len);
   1210                         trackInfo.iTrackConfig = tmpRefcntMemFrag;
   1211                     }
   1212                     iTrackInfoVec.push_back(trackInfo);
   1213                 }
   1214             }
   1215         }
   1216     }
   1217     else
   1218     {
   1219         PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:PopulateTrackInfoVec - Selected Track List Empty"));
   1220         return false;
   1221     }
   1222 
   1223     return true;
   1224 }
   1225 
   1226 bool PVMFSMRTSPUnicastNode::ConstructGraphFor3GPPUDPStreaming()
   1227 {
   1228     uint32 numPortsRequested = 0;
   1229 
   1230     /*
   1231      * Reserve UDP socket pairs
   1232      */
   1233     if (!ReserveSockets())
   1234     {
   1235         PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - ReserveSockets() Failed"));
   1236         return false;
   1237     }
   1238 
   1239     /*
   1240      * Request data UDP ports
   1241      */
   1242     if (!RequestNetworkNodePorts(PVMF_SOCKET_NODE_PORT_TYPE_SOURCE,
   1243                                  numPortsRequested))
   1244     {
   1245         PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - RequestNetworkNodePorts(PVMF_SOCKET_NODE_PORT_TYPE_SOURCE) Failed"));
   1246         return false;
   1247     }
   1248     iNumRequestPortsPending += numPortsRequested;
   1249 
   1250     /*
   1251      * Request feedback (RTCP) UDP ports
   1252      */
   1253     if (!RequestNetworkNodePorts(PVMF_SOCKET_NODE_PORT_TYPE_SINK,
   1254                                  numPortsRequested))
   1255     {
   1256         PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - RequestNetworkNodePorts(PVMF_SOCKET_NODE_PORT_TYPE_SINK) Failed"));
   1257         return false;
   1258     }
   1259     iNumRequestPortsPending += numPortsRequested;
   1260 
   1261     if (!RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_INPUT,
   1262                                   numPortsRequested))
   1263     {
   1264         PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_INPUT) Failed"));
   1265         return false;
   1266     }
   1267     iNumRequestPortsPending += numPortsRequested;
   1268 
   1269     if (!RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_OUTPUT,
   1270                                   numPortsRequested))
   1271     {
   1272         PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_OUTPUT) Failed"));
   1273         return false;
   1274     }
   1275     iNumRequestPortsPending += numPortsRequested;
   1276 
   1277     if (!RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK,
   1278                                   numPortsRequested))
   1279     {
   1280         PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK) Failed"));
   1281         return false;
   1282     }
   1283     iNumRequestPortsPending += numPortsRequested;
   1284 
   1285     if (!RequestMediaLayerPorts(PVMF_MEDIALAYER_PORT_TYPE_INPUT,
   1286                                 numPortsRequested))
   1287     {
   1288         PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - RequestMediaLayerPorts(PVMF_MEDIALAYER_PORT_TYPE_INPUT) Failed"));
   1289         return false;
   1290     }
   1291     iNumRequestPortsPending += numPortsRequested;
   1292 
   1293     if (!RequestMediaLayerPorts(PVMF_MEDIALAYER_PORT_TYPE_OUTPUT,
   1294                                 numPortsRequested))
   1295     {
   1296         PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - RequestMediaLayerPorts(PVMF_MEDIALAYER_PORT_TYPE_OUTPUT) Failed"));
   1297         return false;
   1298     }
   1299     iNumRequestPortsPending += numPortsRequested;
   1300 
   1301     return true;
   1302 }
   1303 
   1304 bool PVMFSMRTSPUnicastNode::ReserveSockets()
   1305 {
   1306     uint32 sockid = 0;
   1307     char portConfigBuf[64];
   1308     oscl_memset((OsclAny*)portConfigBuf, 0, 64);
   1309     oscl_snprintf(portConfigBuf, 64, "%d", sockid);
   1310     OSCL_StackString<128> portConfig("UDP");
   1311     portConfig += _STRLIT_CHAR("/remote_address=0.0.0.0");
   1312     portConfig += _STRLIT_CHAR(";client_port=");
   1313     portConfig += portConfigBuf;
   1314 
   1315     PVMFSMFSPChildNodeContainer* iSocketNodeContainer =
   1316         getChildNodeContainer(PVMF_SM_FSP_SOCKET_NODE);
   1317     if (iSocketNodeContainer == NULL)
   1318     {
   1319         OSCL_LEAVE(OsclErrBadHandle);
   1320         return false;
   1321     }
   1322     PVMFSocketNodeExtensionInterface* snExtIntf =
   1323         (PVMFSocketNodeExtensionInterface*)
   1324         (iSocketNodeContainer->iExtensions[0]);
   1325 
   1326     PVMFRTSPTrackInfoVector::iterator it;
   1327     uint32 startPortNum = 0;
   1328     {
   1329         TimeValue current_time;
   1330         current_time.set_to_current_time();
   1331         uint32 my_seed = current_time.get_sec();
   1332 
   1333         OsclRand random_num;
   1334         random_num.Seed(my_seed);
   1335         int32 first = random_num.Rand();
   1336         uint32 myport = (first & 0x1FFF) + 0x2000;  //start from 8192
   1337         startPortNum = (myport >> 1) << 1;  //start from even
   1338     }
   1339 
   1340     for (it = iTrackInfoVec.begin();
   1341             it != iTrackInfoVec.end();
   1342             it++)
   1343     {
   1344         OSCL_StackString<128> portConfigWithMime;
   1345         portConfigWithMime += portConfig;
   1346         portConfigWithMime += _STRLIT_CHAR(";mime=");
   1347         portConfigWithMime += it->iMimeType;
   1348 
   1349         PVMFStatus status = snExtIntf->AllocateConsecutivePorts(&portConfigWithMime,
   1350                             it->iRTPSocketID,
   1351                             it->iRTCPSocketID, startPortNum);
   1352         if (status != PVMFSuccess)
   1353         {
   1354             return false;
   1355         }
   1356     }
   1357     return true;
   1358 }
   1359 
   1360 bool PVMFSMRTSPUnicastNode::RequestNetworkNodePorts(int32 portTag,
   1361         uint32& numPortsRequested)
   1362 {
   1363     numPortsRequested = 0;
   1364 
   1365     PVMFSMFSPChildNodeContainer* nodeContainer =
   1366         getChildNodeContainer(PVMF_SM_FSP_SOCKET_NODE);
   1367 
   1368     if (nodeContainer == NULL)
   1369     {
   1370         PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:RequestNetworkNodePorts - getChildNodeContainer Failed"));
   1371         return false;
   1372     }
   1373 
   1374     for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
   1375     {
   1376         PVMFRTSPTrackInfo trackInfo = iTrackInfoVec[i];
   1377 
   1378         PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
   1379         if (internalCmd != NULL)
   1380         {
   1381             internalCmd->cmd =
   1382                 nodeContainer->commandStartOffset +
   1383                 PVMF_SM_FSP_NODE_INTERNAL_REQUEST_PORT_OFFSET;
   1384             internalCmd->parentCmd = PVMF_SMFSP_NODE_CONSTRUCT_SESSION;
   1385             internalCmd->portContext.trackID = trackInfo.trackID;
   1386             internalCmd->portContext.portTag = portTag;
   1387 
   1388             OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
   1389 
   1390             PVMFNodeInterface* iNode = nodeContainer->iNode;
   1391 
   1392             uint32 sockid = 0;
   1393             bool oRTCP = false;
   1394 
   1395             if (portTag == PVMF_SOCKET_NODE_PORT_TYPE_SOURCE)
   1396             {
   1397                 sockid = trackInfo.iRTPSocketID;
   1398             }
   1399             else if (portTag == PVMF_SOCKET_NODE_PORT_TYPE_SINK)
   1400             {
   1401                 sockid = trackInfo.iRTCPSocketID;
   1402                 oRTCP = true;
   1403             }
   1404 
   1405             char portConfigBuf[64];
   1406             oscl_memset((OsclAny*)portConfigBuf, 0, 64);
   1407             oscl_snprintf(portConfigBuf, 64, "%d", sockid);
   1408             OSCL_StackString<128> portConfig("UDP");
   1409             portConfig += _STRLIT_CHAR("/remote_address=0.0.0.0");
   1410             portConfig += _STRLIT_CHAR(";client_port=");
   1411             portConfig += portConfigBuf;
   1412             portConfig += _STRLIT_CHAR(";mime=");
   1413             portConfig += trackInfo.iMimeType.get_cstr();
   1414             if (oRTCP == true)
   1415             {
   1416                 portConfig += _STRLIT_CHAR("/rtcp");
   1417             }
   1418             else
   1419             {
   1420                 portConfig += _STRLIT_CHAR("/rtp");
   1421             }
   1422 
   1423             iNode->RequestPort(nodeContainer->iSessionId,
   1424                                internalCmd->portContext.portTag,
   1425                                &portConfig,
   1426                                cmdContextData);
   1427             numPortsRequested++;
   1428             nodeContainer->iNumRequestPortsPending++;
   1429             nodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
   1430         }
   1431         else
   1432         {
   1433             PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:RequestNetworkNodePorts - RequestNewInternalCmd Failed"));
   1434             return false;
   1435         }
   1436     }
   1437     return true;
   1438 }
   1439 
   1440 bool PVMFSMRTSPUnicastNode::RequestJitterBufferPorts(int32 portType,
   1441         uint32 &numPortsRequested)
   1442 {
   1443     PVMFSMFSPChildNodeContainer* nodeContainer =
   1444         getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   1445 
   1446     if (nodeContainer == NULL)
   1447     {
   1448         PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:RequestJitterBufferPorts - getChildNodeContainer Failed"));
   1449         return false;
   1450     }
   1451 
   1452     numPortsRequested = 0;
   1453     /*
   1454      * Request port - all jitter buffer input ports
   1455      * are even numbered and output and rtcp ports are odd numbered
   1456      */
   1457     int32 portTagStart = portType;
   1458 
   1459     if ((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
   1460             || (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE)
   1461        )
   1462     {
   1463         for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
   1464         {
   1465             PVMFRTSPTrackInfo trackInfo = iTrackInfoVec[i];
   1466 
   1467             PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
   1468             if (internalCmd != NULL)
   1469             {
   1470                 internalCmd->cmd =
   1471                     nodeContainer->commandStartOffset +
   1472                     PVMF_SM_FSP_NODE_INTERNAL_REQUEST_PORT_OFFSET;
   1473                 internalCmd->parentCmd = PVMF_SMFSP_NODE_CONSTRUCT_SESSION;
   1474                 internalCmd->portContext.trackID = trackInfo.trackID;
   1475                 internalCmd->portContext.portTag = portType;
   1476 
   1477                 OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
   1478 
   1479                 PVMFNodeInterface* iNode = nodeContainer->iNode;
   1480 
   1481                 OSCL_StackString<32> portConfig = trackInfo.iTransportType;
   1482                 portConfig += _STRLIT_CHAR("/");
   1483                 portConfig += trackInfo.iMimeType;
   1484                 iNode->RequestPort(nodeContainer->iSessionId,
   1485                                    portTagStart,
   1486                                    &(portConfig),
   1487                                    cmdContextData);
   1488                 numPortsRequested++;
   1489                 nodeContainer->iNumRequestPortsPending++;
   1490                 nodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
   1491             }
   1492             else
   1493             {
   1494                 PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:RequestJitterBufferPorts - RequestNewInternalCmd Failed"));
   1495                 return false;
   1496             }
   1497             portTagStart += 3;
   1498         }
   1499         return true;
   1500     }
   1501     return false;
   1502 }
   1503 
   1504 bool PVMFSMRTSPUnicastNode::RequestMediaLayerPorts(int32 portType,
   1505         uint32& numPortsRequested)
   1506 {
   1507     PVMFSMFSPChildNodeContainer* nodeContainer =
   1508         getChildNodeContainer(PVMF_SM_FSP_MEDIA_LAYER_NODE);
   1509 
   1510     if (nodeContainer == NULL)
   1511     {
   1512         PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:RequestMediaLayerPorts - getChildNodeContainer Failed"));
   1513         return false;
   1514     }
   1515 
   1516     numPortsRequested = 0;
   1517     /*
   1518      * Request port - all media layer input ports
   1519      * are even numbered and output are odd numbered
   1520      */
   1521     int32 portTagStart = portType;
   1522 
   1523     if ((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
   1524             || (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE)
   1525        )
   1526     {
   1527         for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
   1528         {
   1529             PVMFRTSPTrackInfo trackInfo = iTrackInfoVec[i];
   1530 
   1531             PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
   1532             if (internalCmd != NULL)
   1533             {
   1534                 internalCmd->cmd =
   1535                     nodeContainer->commandStartOffset +
   1536                     PVMF_SM_FSP_NODE_INTERNAL_REQUEST_PORT_OFFSET;
   1537                 internalCmd->parentCmd = PVMF_SMFSP_NODE_CONSTRUCT_SESSION;
   1538                 internalCmd->portContext.trackID = trackInfo.trackID;
   1539                 internalCmd->portContext.portTag = portType;
   1540 
   1541                 OsclAny *cmdContextData =
   1542                     OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
   1543 
   1544                 PVMFNodeInterface* iNode = nodeContainer->iNode;
   1545 
   1546                 iNode->RequestPort(nodeContainer->iSessionId,
   1547                                    portTagStart,
   1548                                    &(trackInfo.iMimeType),
   1549                                    cmdContextData);
   1550                 numPortsRequested++;
   1551                 nodeContainer->iNumRequestPortsPending++;
   1552                 nodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
   1553             }
   1554             else
   1555             {
   1556                 PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:RequestMediaLayerPorts - RequestNewInternalCmd Failed"));
   1557                 return false;
   1558             }
   1559             portTagStart += 2;
   1560         }
   1561 
   1562         return true;
   1563     }
   1564 
   1565     //error
   1566     return false;
   1567 }
   1568 
   1569 void PVMFSMRTSPUnicastNode::DoPrepare(PVMFSMFSPBaseNodeCommand& aCmd)
   1570 {
   1571     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoPrepare - In"));
   1572     switch (iInterfaceState)
   1573     {
   1574         case EPVMFNodeInitialized:
   1575         {
   1576             if (iGraphConstructComplete)
   1577             {
   1578                 /*
   1579                  * Connect the graph here. This is needed since we would send firewall packets
   1580                  * as part of Prepare.
   1581                  */
   1582                 if (GraphConnect() == false)
   1583                 {
   1584                     PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoPrepare - GraphConnect Failed"));
   1585                     SetState(EPVMFNodeError);
   1586                     PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
   1587                     int32 errcode = PVMFStreamingManagerNodeGraphConnectFailed;
   1588                     CommandComplete(iInputCommands, aCmd, PVMFFailure, NULL, &eventuuid, &errcode);
   1589                     return;
   1590                 }
   1591 
   1592                 /*
   1593                  * Prepare for streaming manager cannot be completed unless Prepare
   1594                  * for all the children nodes are complete
   1595                  */
   1596                 PVMFSMFSPChildNodeContainerVector::iterator it;
   1597                 for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
   1598                 {
   1599                     PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
   1600                     if (internalCmd != NULL)
   1601                     {
   1602                         internalCmd->cmd =
   1603                             it->commandStartOffset +
   1604                             PVMF_SM_FSP_NODE_INTERNAL_PREPARE_CMD_OFFSET;
   1605                         internalCmd->parentCmd = aCmd.iCmd;
   1606 
   1607                         OsclAny *cmdContextData =
   1608                             OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
   1609 
   1610                         PVMFNodeInterface* iNode = it->iNode;
   1611 
   1612                         iNode->Prepare(it->iSessionId, cmdContextData);
   1613                         it->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
   1614                     }
   1615                     else
   1616                     {
   1617                         PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoPrepare:RequestNewInternalCmd - Failed"));
   1618                         CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
   1619                         return;
   1620                     }
   1621                 }
   1622 
   1623                 MoveCmdToCurrentQueue(aCmd);
   1624             }
   1625             else
   1626             {
   1627                 /* Graph construction not complete, so cant prep */
   1628                 PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoPrepare Failed - Incomplete Graph"));
   1629                 CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
   1630             }
   1631         }
   1632         break;
   1633 
   1634         default:
   1635             PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoPrepare Failed - Invalid State"));
   1636             CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
   1637             break;
   1638     }
   1639     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoPrepare - Out"));
   1640 }
   1641 
   1642 bool PVMFSMRTSPUnicastNode::GraphConnect()
   1643 {
   1644     if (iGraphConnectComplete == false)
   1645     {
   1646         /*
   1647          * Go over the track list and connect:
   1648          * network_node_port -> jitter_buffer_node_input_port;
   1649          * jitter_buffer_node_output_port -> media_layer_input_port
   1650          */
   1651         PVMFStatus status;
   1652         for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
   1653         {
   1654             PVMFRTSPTrackInfo trackInfo = iTrackInfoVec[i];
   1655 
   1656             if ((trackInfo.iNetworkNodePort == NULL) ||
   1657                     (trackInfo.iNetworkNodeRTCPPort == NULL) ||
   1658                     (trackInfo.iJitterBufferInputPort == NULL) ||
   1659                     (trackInfo.iJitterBufferOutputPort == NULL) ||
   1660                     (trackInfo.iJitterBufferRTCPPort == NULL) ||
   1661                     (trackInfo.iMediaLayerInputPort == NULL) ||
   1662                     (trackInfo.iMediaLayerOutputPort == NULL))
   1663             {
   1664                 PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:GraphConnectFor3GPPUDPStreaming - Invalid Ports"));
   1665                 return false;
   1666             }
   1667 
   1668             PVMF_SM_RTSP_LOGINFO((0, "PVMFSM:GraphConnect - Track MimeType %s", trackInfo.iMimeType.get_cstr()));
   1669 
   1670             /* connect network_node_port <-> jitter_buffer_node_input_port */
   1671             status = ConnectPortPairs(trackInfo.iJitterBufferInputPort,
   1672                                       trackInfo.iNetworkNodePort);
   1673 
   1674             PVMF_SM_RTSP_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPUDPStreaming - Connected Network - JB Input"));
   1675             PVMF_SM_RTSP_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPUDPStreaming - NetworkPort=0x%x - JBInputPort=0x%x", trackInfo.iNetworkNodePort, trackInfo.iJitterBufferInputPort));
   1676 
   1677             if (status != PVMFSuccess)
   1678             {
   1679                 return false;
   1680             }
   1681 
   1682             /*
   1683              * connect jitter_buffer_node_output_port <->
   1684              * media_layer_input_port
   1685              */
   1686             status = ConnectPortPairs(trackInfo.iJitterBufferOutputPort,
   1687                                       trackInfo.iMediaLayerInputPort);
   1688 
   1689             PVMF_SM_RTSP_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPUDPStreaming - JB Output - ML Input"));
   1690             PVMF_SM_RTSP_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPUDPStreaming - JB Output=0x%x - ML Input=0x%x", trackInfo.iJitterBufferOutputPort, trackInfo.iMediaLayerInputPort));
   1691 
   1692             if (status != PVMFSuccess)
   1693             {
   1694                 return false;
   1695             }
   1696 
   1697             /*
   1698              * connect network_rtcp_port <-> jitter_buffer_rtcp_port
   1699              */
   1700             status = ConnectPortPairs(trackInfo.iJitterBufferRTCPPort,
   1701                                       trackInfo.iNetworkNodeRTCPPort);
   1702 
   1703             PVMF_SM_RTSP_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPUDPStreaming - NetworkRTCPPort - JBRTCPPort"));
   1704             PVMF_SM_RTSP_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPUDPStreaming - NetworkRTCPPort=0x%x - JBRTCPPort=0x%x", trackInfo.iNetworkNodeRTCPPort, trackInfo.iJitterBufferRTCPPort));
   1705 
   1706             if (status != PVMFSuccess)
   1707             {
   1708                 return false;
   1709             }
   1710         }
   1711         iGraphConnectComplete = true;
   1712     }
   1713     return true;
   1714 }
   1715 
   1716 PVMFStatus PVMFSMRTSPUnicastNode::ConnectPortPairs(PVMFPortInterface* aPort1,
   1717         PVMFPortInterface* aPort2)
   1718 {
   1719     PVMFStatus status;
   1720 
   1721     status = aPort1->Connect(aPort2);
   1722 
   1723     if (status != PVMFSuccess)
   1724     {
   1725         PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ConnectPortPairs - Connect Failed"));
   1726         return status;
   1727     }
   1728 
   1729     return status;
   1730 }
   1731 
   1732 void PVMFSMRTSPUnicastNode::DoRequestPort(PVMFSMFSPBaseNodeCommand& aCmd)
   1733 {
   1734     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoRequestPort - In"));
   1735     /*
   1736      * This node supports port request only after the graph
   1737      * has been fully constructed
   1738      */
   1739     if (iGraphConstructComplete)
   1740     {
   1741         /*
   1742          * retrieve port tag
   1743          */
   1744         OSCL_String* mimetype;
   1745         int32 tag;
   1746         aCmd.PVMFSMFSPBaseNodeCommandBase::Parse(tag, mimetype);
   1747         /*
   1748          * Do not Allocate a new port. RTSP unicast node treats the output
   1749          * port from the media layer as its own output port. Find the media
   1750          * layer output port corresponding to the input mimetype and hand the
   1751          * same out
   1752          */
   1753         PVMFRTSPTrackInfo* trackInfo = FindTrackInfo(tag);
   1754 
   1755         PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
   1756         int32 errcode = PVMFStreamingManagerNodeErrorInvalidRequestPortTag;
   1757 
   1758         if (trackInfo == NULL)
   1759         {
   1760             PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::DoRequestPort: FindTrackInfo failed"));
   1761             CommandComplete(iInputCommands, aCmd, PVMFErrArgument, NULL, &eventuuid, &errcode);
   1762             return;
   1763         }
   1764         if (trackInfo->iMediaLayerOutputPort == NULL)
   1765         {
   1766             PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::DoRequestPort: iMediaLayerOutputPort NULL"));
   1767             CommandComplete(iInputCommands, aCmd, PVMFFailure, NULL, &eventuuid, &errcode);
   1768             return;
   1769         }
   1770         PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::DoRequestPort() - CmdComplete - PVMFSuccess"));
   1771         /*
   1772          * Return the port pointer to the caller.
   1773          */
   1774         CommandComplete(iInputCommands,
   1775                         aCmd,
   1776                         PVMFSuccess,
   1777                         (OsclAny*)(trackInfo->iMediaLayerOutputPort));
   1778 
   1779         PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::DoRequestPort Success"));
   1780     }
   1781     else
   1782     {
   1783         PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::RequestPort() - CmdFailed - PVMFErrInvalidState"));
   1784         PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::DoRequestPort Failed - InvalidState"));
   1785         CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
   1786     }
   1787     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoRequestPort - Out"));
   1788 }
   1789 
   1790 void PVMFSMRTSPUnicastNode::DoReleasePort(PVMFSMFSPBaseNodeCommand& aCmd)
   1791 {
   1792     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoReleasePort - In"));
   1793     /*
   1794      * Since the streaming manager does not have ports of its own,
   1795      * a release port command typically translates to disconnecting
   1796      * the underlying media layer port.
   1797      */
   1798     PVMFPortInterface* port;
   1799     aCmd.PVMFSMFSPBaseNodeCommandBase::Parse((PVMFPortInterface*&)port);
   1800 
   1801     /*
   1802      * Find TrackInfo that corresponds to the Media Layer Output port
   1803      * on which the current relase is being called.
   1804      */
   1805     PVMFRTSPTrackInfoVector::iterator it;
   1806     PVMFRTSPTrackInfo* trackInfo = NULL;
   1807 
   1808     for (it = iTrackInfoVec.begin();
   1809             it != iTrackInfoVec.end();
   1810             it++)
   1811     {
   1812         if (it->iMediaLayerOutputPort == port)
   1813         {
   1814             trackInfo = it;
   1815             break;
   1816         }
   1817     }
   1818 
   1819     PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
   1820     if (trackInfo == NULL)
   1821     {
   1822         PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::ReleasePort() - CmdFailed - PVMFErrArgument"));
   1823         /* invalid port */
   1824         PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::DoReleasePort Failed - Invalid Port"));
   1825         int32 errcode = PVMFStreamingManagerNodeErrorInvalidPort;
   1826         CommandComplete(iInputCommands, aCmd, PVMFErrArgument, NULL, &eventuuid, &errcode);
   1827         return;
   1828     }
   1829     PVMFStatus status = it->iMediaLayerOutputPort->Disconnect();
   1830 
   1831     if (status != PVMFSuccess)
   1832     {
   1833         PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::DoReleasePort Success"));
   1834         CommandComplete(iInputCommands, aCmd, PVMFSuccess);
   1835     }
   1836     else
   1837     {
   1838         PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::DoReleasePort Failed"));
   1839         CommandComplete(iInputCommands, aCmd, PVMFErrPortProcessing);
   1840     }
   1841     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoReleasePort - Out"));
   1842 }
   1843 
   1844 void PVMFSMRTSPUnicastNode::DoStart(PVMFSMFSPBaseNodeCommand& aCmd)
   1845 {
   1846     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoStart - In"));
   1847     switch (iInterfaceState)
   1848     {
   1849         case EPVMFNodePrepared:
   1850         {
   1851             /*
   1852              * Connect the graph if not already connected. Usually the graph is
   1853              * disconnected as part of Stop. In case we are doing a start after
   1854              * stop, we would need to connect the graph again.
   1855              */
   1856             if (GraphConnect() == false)
   1857             {
   1858                 PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:CompleteStart - GraphConnect Failed"));
   1859                 SetState(EPVMFNodeError);
   1860                 PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
   1861                 int32 errcode = PVMFStreamingManagerNodeGraphConnectFailed;
   1862                 CommandComplete(iInputCommands, aCmd, PVMFFailure, NULL, &eventuuid, &errcode);
   1863                 return;
   1864             }
   1865 
   1866             bool isSessionDurationExpired = false;
   1867 
   1868             PVMFSMFSPChildNodeContainer* jitterBufferNodeContainer =
   1869                 getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   1870             if (jitterBufferNodeContainer)
   1871             {
   1872                 PVMFJitterBufferExtensionInterface* jbExtIntf =
   1873                     OSCL_STATIC_CAST(PVMFJitterBufferExtensionInterface*, jitterBufferNodeContainer->iExtensions.front());
   1874                 if (jbExtIntf)
   1875                     jbExtIntf->HasSessionDurationExpired(isSessionDurationExpired);
   1876             }
   1877 
   1878             PVMFSMFSPChildNodeContainer *sessionControllerNodeContainer =
   1879                 getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
   1880             if (sessionControllerNodeContainer)
   1881             {
   1882                 PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
   1883                     OSCL_STATIC_CAST(PVRTSPEngineNodeExtensionInterface*, sessionControllerNodeContainer->iExtensions.front());
   1884                 if (rtspExtIntf)
   1885                     rtspExtIntf->UpdateSessionCompletionStatus(isSessionDurationExpired);
   1886             }
   1887 
   1888             /*
   1889              * Start for streaming manager cannot be completed unless
   1890              * Start for all the children nodes are complete
   1891              */
   1892             PVMFSMFSPChildNodeContainerVector::iterator it;
   1893             for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
   1894             {
   1895                 PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
   1896                 if (internalCmd != NULL)
   1897                 {
   1898                     internalCmd->cmd =
   1899                         it->commandStartOffset +
   1900                         PVMF_SM_FSP_NODE_INTERNAL_START_CMD_OFFSET;
   1901                     internalCmd->parentCmd = aCmd.iCmd;
   1902 
   1903                     OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
   1904 
   1905                     PVMFNodeInterface* iNode = it->iNode;
   1906 
   1907                     iNode->Start(it->iSessionId, cmdContextData);
   1908                     it->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
   1909                 }
   1910                 else
   1911                 {
   1912                     PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoStart:RequestNewInternalCmd - Failed"));
   1913                     CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
   1914                     return;
   1915                 }
   1916             }
   1917 
   1918             MoveCmdToCurrentQueue(aCmd);
   1919         }
   1920         break;
   1921 
   1922         /*
   1923          * GraphConnect() not needed if starting from a paused state
   1924          */
   1925         case EPVMFNodePaused:
   1926         {
   1927             bool isSessionDurationExpired = false;
   1928 
   1929             PVMFSMFSPChildNodeContainer* jitterBufferNodeContainer =
   1930                 getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   1931             if (jitterBufferNodeContainer)
   1932             {
   1933                 PVMFJitterBufferExtensionInterface* jbExtIntf =
   1934                     OSCL_STATIC_CAST(PVMFJitterBufferExtensionInterface*, jitterBufferNodeContainer->iExtensions.front());
   1935                 if (jbExtIntf)
   1936                     jbExtIntf->HasSessionDurationExpired(isSessionDurationExpired);
   1937             }
   1938 
   1939             PVMFSMFSPChildNodeContainer *sessionControllerNodeContainer =
   1940                 getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
   1941             if (sessionControllerNodeContainer)
   1942             {
   1943                 PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
   1944                     OSCL_STATIC_CAST(PVRTSPEngineNodeExtensionInterface*, sessionControllerNodeContainer->iExtensions.front());
   1945                 if (rtspExtIntf)
   1946                     rtspExtIntf->UpdateSessionCompletionStatus(isSessionDurationExpired);
   1947             }
   1948             /*
   1949              * Start for streaming manager cannot be completed unless
   1950              * Start for all the children nodes are complete
   1951              */
   1952             PVMFSMFSPChildNodeContainerVector::iterator it;
   1953             for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
   1954             {
   1955                 if (it->iAutoPaused == false)
   1956                 {
   1957                     PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
   1958                     if (internalCmd != NULL)
   1959                     {
   1960                         internalCmd->cmd =
   1961                             it->commandStartOffset +
   1962                             PVMF_SM_FSP_NODE_INTERNAL_START_CMD_OFFSET;
   1963                         internalCmd->parentCmd = aCmd.iCmd;
   1964 
   1965                         OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
   1966 
   1967                         PVMFNodeInterface* iNode = it->iNode;
   1968 
   1969                         iNode->Start(it->iSessionId, cmdContextData);
   1970                         it->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
   1971                     }
   1972                     else
   1973                     {
   1974                         PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoStart:RequestNewInternalCmd - Failed"));
   1975                         CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
   1976                         return;
   1977                     }
   1978                 }
   1979             }
   1980             MoveCmdToCurrentQueue(aCmd);
   1981         }
   1982         break;
   1983 
   1984         case EPVMFNodeStarted:
   1985             //Ignore start if already started
   1986             CommandComplete(iInputCommands, aCmd, PVMFSuccess);
   1987             break;
   1988 
   1989         default:
   1990             CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
   1991             break;
   1992     }
   1993     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoStart - Out"));
   1994 }
   1995 
   1996 void PVMFSMRTSPUnicastNode::DoStop(PVMFSMFSPBaseNodeCommand& aCmd)
   1997 {
   1998     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoStop - In"));
   1999     iStreamID = 0;
   2000     switch (iInterfaceState)
   2001     {
   2002         case EPVMFNodeStarted:
   2003         case EPVMFNodePaused:
   2004         {
   2005             /*
   2006              * Stop for streaming manager cannot be completed unless
   2007              * Stop for all the children nodes are complete
   2008              */
   2009             PVMFSMFSPChildNodeContainerVector::iterator it;
   2010             for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
   2011             {
   2012                 PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
   2013                 if (internalCmd != NULL)
   2014                 {
   2015                     internalCmd->cmd =
   2016                         it->commandStartOffset +
   2017                         PVMF_SM_FSP_NODE_INTERNAL_STOP_CMD_OFFSET;
   2018                     internalCmd->parentCmd = aCmd.iCmd;
   2019 
   2020                     OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
   2021 
   2022                     PVMFNodeInterface* iNode = it->iNode;
   2023 
   2024                     iNode->Stop(it->iSessionId, cmdContextData);
   2025                     it->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
   2026                 }
   2027                 else
   2028                 {
   2029                     PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoStop:RequestNewInternalCmd - Failed"));
   2030                     CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
   2031                     return;
   2032                 }
   2033             }
   2034             MoveCmdToCurrentQueue(aCmd);
   2035         }
   2036         break;
   2037 
   2038         default:
   2039             PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::DoStop Failure - Invalid State"));
   2040             CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
   2041             break;
   2042     }
   2043     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoStop - Out"));
   2044 }
   2045 
   2046 void PVMFSMRTSPUnicastNode::DoPause(PVMFSMFSPBaseNodeCommand& aCmd)
   2047 {
   2048     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoPause - In"));
   2049     switch (iInterfaceState)
   2050     {
   2051         case EPVMFNodeStarted:
   2052         {
   2053             bool isSessionDurationExpired = false;
   2054 
   2055             PVMFSMFSPChildNodeContainer* jitterBufferNodeContainer =
   2056                 getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   2057             if (jitterBufferNodeContainer)
   2058             {
   2059                 PVMFJitterBufferExtensionInterface* jbExtIntf =
   2060                     OSCL_STATIC_CAST(PVMFJitterBufferExtensionInterface*, jitterBufferNodeContainer->iExtensions.front());
   2061                 if (jbExtIntf)
   2062                     jbExtIntf->HasSessionDurationExpired(isSessionDurationExpired);
   2063             }
   2064 
   2065             PVMFSMFSPChildNodeContainer *sessionControllerNodeContainer =
   2066                 getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
   2067             if (sessionControllerNodeContainer)
   2068             {
   2069                 PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
   2070                     OSCL_STATIC_CAST(PVRTSPEngineNodeExtensionInterface*, sessionControllerNodeContainer->iExtensions.front());
   2071                 if (rtspExtIntf)
   2072                     rtspExtIntf->UpdateSessionCompletionStatus(isSessionDurationExpired);
   2073             }
   2074 
   2075             PVMFSMFSPChildNodeContainerVector::iterator it;
   2076             for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
   2077             {
   2078                 /*
   2079                  * Pause only if not already paused - could happen that
   2080                  * some of the nodes could be paused due to flow control
   2081                  */
   2082                 if ((it->iNode->GetState()) != EPVMFNodePaused)
   2083                 {
   2084                     PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
   2085                     if (internalCmd != NULL)
   2086                     {
   2087                         internalCmd->cmd =
   2088                             it->commandStartOffset +
   2089                             PVMF_SM_FSP_NODE_INTERNAL_PAUSE_CMD_OFFSET;
   2090                         internalCmd->parentCmd = aCmd.iCmd;
   2091 
   2092                         OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
   2093 
   2094                         PVMFNodeInterface* iNode = it->iNode;
   2095 
   2096                         iNode->Pause(it->iSessionId, cmdContextData);
   2097                         it->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
   2098                     }
   2099                     else
   2100                     {
   2101                         PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoPause:RequestNewInternalCmd - Failed"));
   2102                         CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
   2103                         return;
   2104                     }
   2105                 }
   2106             }
   2107             MoveCmdToCurrentQueue(aCmd);
   2108         }
   2109         break;
   2110         default:
   2111             CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
   2112             break;
   2113     }
   2114     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoPause - Out"));
   2115     return;
   2116 }
   2117 
   2118 PVMFRTSPTrackInfo* PVMFSMRTSPUnicastNode::FindTrackInfo(uint32 atrackID)
   2119 {
   2120     PVMFRTSPTrackInfoVector::iterator it;
   2121 
   2122     for (it = iTrackInfoVec.begin();
   2123             it != iTrackInfoVec.end();
   2124             it++)
   2125     {
   2126         if (it->trackID == atrackID)
   2127         {
   2128             return (it);
   2129         }
   2130     }
   2131     return NULL;
   2132 }
   2133 
   2134 ///////////////////////////////////////////////////////////////////////////////
   2135 //Implemenation of pure virtuals from PvmiCapabilityAndConfig interface
   2136 ///////////////////////////////////////////////////////////////////////////////
   2137 void PVMFSMRTSPUnicastNode::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
   2138 {
   2139     ciObserver = aObserver;
   2140 }
   2141 
   2142 PVMFStatus PVMFSMRTSPUnicastNode::getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
   2143         PvmiKvp*& aParameters, int& aNumParamElements,
   2144         PvmiCapabilityContext aContext)
   2145 {
   2146     OSCL_UNUSED_ARG(aSession);
   2147     OSCL_UNUSED_ARG(aContext);
   2148 
   2149     // Initialize the output parameters
   2150     aNumParamElements = 0;
   2151     aParameters = NULL;
   2152 
   2153     // Count the number of components and parameters in the key
   2154     int compcount = pv_mime_string_compcnt(aIdentifier);
   2155     // Retrieve the first component from the key string
   2156     char* compstr = NULL;
   2157     pv_mime_string_extract_type(0, aIdentifier, compstr);
   2158 
   2159     if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf")) < 0) || compcount < 2)
   2160     {
   2161         // First component should be "x-pvmf" and there must
   2162         // be at least two components to go past x-pvmf
   2163         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSMRTSPUnicastNode::getParametersSync() Invalid key string"));
   2164         return PVMFErrArgument;
   2165     }
   2166 
   2167     // Retrieve the second component from the key string
   2168     pv_mime_string_extract_type(1, aIdentifier, compstr);
   2169 
   2170     // Check if it is key string for streaming manager
   2171     if (pv_mime_strcmp(compstr, _STRLIT_CHAR("net")) < 0)
   2172     {
   2173         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSMRTSPUnicastNode::getParametersSync() Unsupported key"));
   2174         return PVMFFailure;
   2175     }
   2176 
   2177 
   2178     if (compcount == 2)
   2179     {
   2180         // Since key is "x-pvmf/net" return all
   2181         // nodes available at this level. Ignore attribute
   2182         // since capability is only allowed
   2183 
   2184         // Allocate memory for the KVP list
   2185         aParameters = (PvmiKvp*)oscl_malloc(StreamingManagerConfig_NumBaseKeys * sizeof(PvmiKvp));
   2186         if (aParameters == NULL)
   2187         {
   2188             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSMRTSPUnicastNode::getParametersSync() Memory allocation for KVP failed"));
   2189             return PVMFErrNoMemory;
   2190         }
   2191         oscl_memset(aParameters, 0, StreamingManagerConfig_NumBaseKeys*sizeof(PvmiKvp));
   2192         // Allocate memory for the key strings in each KVP
   2193         PvmiKeyType memblock = (PvmiKeyType)oscl_malloc(StreamingManagerConfig_NumBaseKeys * SMCONFIG_KEYSTRING_SIZE * sizeof(char));
   2194         if (memblock == NULL)
   2195         {
   2196             oscl_free(aParameters);
   2197             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSMRTSPUnicastNode::getParametersSync() Memory allocation for key string failed"));
   2198             return PVMFErrNoMemory;
   2199         }
   2200         oscl_strset(memblock, 0, StreamingManagerConfig_NumBaseKeys*SMCONFIG_KEYSTRING_SIZE*sizeof(char));
   2201         // Assign the key string buffer to each KVP
   2202         uint32 j;
   2203         for (j = 0; j < StreamingManagerConfig_NumBaseKeys; ++j)
   2204         {
   2205             aParameters[j].key = memblock + (j * SMCONFIG_KEYSTRING_SIZE);
   2206         }
   2207         // Copy the requested info
   2208         for (j = 0; j < StreamingManagerConfig_NumBaseKeys; ++j)
   2209         {
   2210             oscl_strncat(aParameters[j].key, _STRLIT_CHAR("x-pvmf/net/"), 17);
   2211             oscl_strncat(aParameters[j].key, StreamingManagerConfig_BaseKeys[j].iString, oscl_strlen(StreamingManagerConfig_BaseKeys[j].iString));
   2212             oscl_strncat(aParameters[j].key, _STRLIT_CHAR(";type="), 6);
   2213             switch (StreamingManagerConfig_BaseKeys[j].iType)
   2214             {
   2215                 case PVMI_KVPTYPE_AGGREGATE:
   2216                     oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPTYPE_AGGREGATE_STRING), oscl_strlen(PVMI_KVPTYPE_AGGREGATE_STRING));
   2217                     break;
   2218 
   2219                 case PVMI_KVPTYPE_POINTER:
   2220                     oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPTYPE_POINTER_STRING), oscl_strlen(PVMI_KVPTYPE_POINTER_STRING));
   2221                     break;
   2222 
   2223                 case PVMI_KVPTYPE_VALUE:
   2224                 default:
   2225                     oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPTYPE_VALUE_STRING), oscl_strlen(PVMI_KVPTYPE_VALUE_STRING));
   2226                     break;
   2227             }
   2228             oscl_strncat(aParameters[j].key, _STRLIT_CHAR(";valtype="), 9);
   2229             switch (StreamingManagerConfig_BaseKeys[j].iValueType)
   2230             {
   2231                 case PVMI_KVPVALTYPE_RANGE_INT32:
   2232                     oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_INT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_INT32_STRING));
   2233                     break;
   2234 
   2235                 case PVMI_KVPVALTYPE_KSV:
   2236                     oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_KSV_STRING), oscl_strlen(PVMI_KVPVALTYPE_KSV_STRING));
   2237                     break;
   2238 
   2239                 case PVMI_KVPVALTYPE_CHARPTR:
   2240                     oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_CHARPTR_STRING), oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING));
   2241                     break;
   2242 
   2243                 case PVMI_KVPVALTYPE_BOOL:
   2244                     oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BOOL_STRING), oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING));
   2245                     break;
   2246 
   2247                 case PVMI_KVPVALTYPE_UINT32:
   2248                 default:
   2249                     oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_UINT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING));
   2250                     break;
   2251             }
   2252             aParameters[j].key[SMCONFIG_KEYSTRING_SIZE-1] = 0;
   2253         }
   2254 
   2255         aNumParamElements = StreamingManagerConfig_NumBaseKeys;
   2256     }
   2257     else if (compcount == 3)
   2258     {
   2259         pv_mime_string_extract_type(2, aIdentifier, compstr);
   2260 
   2261         // Determine what is requested
   2262         PvmiKvpAttr reqattr = GetAttrTypeFromKeyString(aIdentifier);
   2263         if (reqattr == PVMI_KVPATTR_UNKNOWN)
   2264         {
   2265             reqattr = PVMI_KVPATTR_CUR;
   2266         }
   2267         uint i;
   2268         for (i = 0; i < StreamingManagerConfig_NumBaseKeys; i++)
   2269         {
   2270             if (pv_mime_strcmp(compstr, (char*)(StreamingManagerConfig_BaseKeys[i].iString)) >= 0)
   2271             {
   2272                 break;
   2273             }
   2274         }
   2275 
   2276         if (i == StreamingManagerConfig_NumBaseKeys)
   2277         {
   2278             // no match found
   2279             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
   2280                             (0, "PVMFSMRTSPUnicastNode::getParametersSync() Unsupported key"));
   2281             return PVMFErrNoMemory;
   2282         }
   2283 
   2284         PVMFStatus retval = GetConfigParameter(aParameters, aNumParamElements, i, reqattr);
   2285         if (retval != PVMFSuccess)
   2286         {
   2287             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
   2288                             (0, "PVMFSMRTSPUnicastNode::getParametersSync() "
   2289                              "Retrieving streaming manager parameter failed"));
   2290             return retval;
   2291         }
   2292     }
   2293     else
   2294     {
   2295         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSMRTSPUnicastNode::getParametersSync() Unsupported key"));
   2296         return PVMFErrArgument;
   2297     }
   2298 
   2299     return PVMFSuccess;
   2300 }
   2301 
   2302 PVMFStatus PVMFSMRTSPUnicastNode::GetConfigParameter(PvmiKvp*& aParameters,
   2303         int& aNumParamElements,
   2304         int32 aIndex, PvmiKvpAttr reqattr)
   2305 {
   2306     PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::GetConfigParameter() In"));
   2307 
   2308     aNumParamElements = 0;
   2309 
   2310     // Allocate memory for the KVP
   2311     aParameters = (PvmiKvp*)oscl_malloc(sizeof(PvmiKvp));
   2312     if (aParameters == NULL)
   2313     {
   2314         PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::GetConfigParameter() Memory allocation for KVP failed"));
   2315         return PVMFErrNoMemory;
   2316     }
   2317     oscl_memset(aParameters, 0, sizeof(PvmiKvp));
   2318 
   2319     // Allocate memory for the key string in KVP
   2320     PvmiKeyType memblock = (PvmiKeyType)oscl_malloc(SMCONFIG_KEYSTRING_SIZE * sizeof(char));
   2321     if (memblock == NULL)
   2322     {
   2323         oscl_free(aParameters);
   2324         PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::GetConfigParameter() Memory allocation for key string failed"));
   2325         return PVMFErrNoMemory;
   2326     }
   2327     oscl_strset(memblock, 0, SMCONFIG_KEYSTRING_SIZE*sizeof(char));
   2328 
   2329     // Assign the key string buffer to KVP
   2330     aParameters[0].key = memblock;
   2331 
   2332     // Copy the key string
   2333     oscl_strncat(aParameters[0].key, _STRLIT_CHAR("x-pvmf/net/"), 17);
   2334     oscl_strncat(aParameters[0].key, StreamingManagerConfig_BaseKeys[aIndex].iString,
   2335                  oscl_strlen(StreamingManagerConfig_BaseKeys[aIndex].iString));
   2336     oscl_strncat(aParameters[0].key, _STRLIT_CHAR(";type=value;valtype="), 20);
   2337     switch (StreamingManagerConfig_BaseKeys[aIndex].iValueType)
   2338     {
   2339         case PVMI_KVPVALTYPE_RANGE_INT32:
   2340             oscl_strncat(aParameters[0].key,
   2341                          _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_INT32_STRING),
   2342                          oscl_strlen(PVMI_KVPVALTYPE_RANGE_INT32_STRING));
   2343             break;
   2344 
   2345         case PVMI_KVPVALTYPE_KSV:
   2346             oscl_strncat(aParameters[0].key,
   2347                          _STRLIT_CHAR(PVMI_KVPVALTYPE_KSV_STRING),
   2348                          oscl_strlen(PVMI_KVPVALTYPE_KSV_STRING));
   2349             break;
   2350 
   2351         case PVMI_KVPVALTYPE_CHARPTR:
   2352             oscl_strncat(aParameters[0].key,
   2353                          _STRLIT_CHAR(PVMI_KVPVALTYPE_CHARPTR_STRING),
   2354                          oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING));
   2355             break;
   2356 
   2357         case PVMI_KVPVALTYPE_WCHARPTR:
   2358             oscl_strncat(aParameters[0].key,
   2359                          _STRLIT_CHAR(PVMI_KVPVALTYPE_WCHARPTR_STRING),
   2360                          oscl_strlen(PVMI_KVPVALTYPE_WCHARPTR_STRING));
   2361             break;
   2362 
   2363         case PVMI_KVPVALTYPE_BOOL:
   2364             oscl_strncat(aParameters[0].key,
   2365                          _STRLIT_CHAR(PVMI_KVPVALTYPE_BOOL_STRING),
   2366                          oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING));
   2367             break;
   2368 
   2369         case PVMI_KVPVALTYPE_UINT32:
   2370         default:
   2371             if (reqattr == PVMI_KVPATTR_CAP)
   2372             {
   2373                 oscl_strncat(aParameters[0].key,
   2374                              _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_UINT32_STRING),
   2375                              oscl_strlen(PVMI_KVPVALTYPE_RANGE_UINT32_STRING));
   2376             }
   2377             else
   2378             {
   2379                 oscl_strncat(aParameters[0].key,
   2380                              _STRLIT_CHAR(PVMI_KVPVALTYPE_UINT32_STRING),
   2381                              oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING));
   2382             }
   2383             break;
   2384     }
   2385     aParameters[0].key[SMCONFIG_KEYSTRING_SIZE-1] = 0;
   2386 
   2387     // Copy the requested info
   2388     switch (aIndex)
   2389     {
   2390         case BASEKEY_DELAY:
   2391             if (reqattr == PVMI_KVPATTR_CUR)
   2392             {
   2393                 // Return current value
   2394                 PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   2395                     getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   2396                 OSCL_ASSERT(iJitterBufferNodeContainer);
   2397                 if (!iJitterBufferNodeContainer)
   2398                     return PVMFFailure;
   2399                 PVMFJitterBufferExtensionInterface* jbExtIntf =
   2400                     (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
   2401                 if (!jbExtIntf)
   2402                     return PVMFFailure;
   2403                 jbExtIntf->getJitterBufferDurationInMilliSeconds(aParameters[0].value.uint32_value);
   2404             }
   2405             else if (reqattr == PVMI_KVPATTR_DEF)
   2406             {
   2407                 // Return default
   2408                 aParameters[0].value.uint32_value = DEFAULT_JITTER_BUFFER_DURATION_IN_MS;
   2409             }
   2410             else
   2411             {
   2412                 // Return capability
   2413                 range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
   2414                 if (rui32 == NULL)
   2415                 {
   2416                     oscl_free(aParameters[0].key);
   2417                     oscl_free(aParameters);
   2418                     PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::GetConfigParameter() "
   2419                                            "Memory allocation for range uint32 failed"));
   2420                     return PVMFErrNoMemory;
   2421                 }
   2422                 rui32->min = MIN_JITTER_BUFFER_DURATION_IN_MS;
   2423                 rui32->max = MAX_JITTER_BUFFER_DURATION_IN_MS;
   2424                 aParameters[0].value.key_specific_value = (void*)rui32;
   2425             }
   2426             break;
   2427         case BASEKEY_REBUFFERING_THRESHOLD:
   2428         {
   2429             if (reqattr == PVMI_KVPATTR_CUR)
   2430             {
   2431                 // Return current value
   2432                 PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   2433                     getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   2434                 OSCL_ASSERT(iJitterBufferNodeContainer);
   2435                 if (!iJitterBufferNodeContainer)
   2436                     return PVMFFailure;
   2437                 PVMFJitterBufferExtensionInterface* jbExtIntf =
   2438                     (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
   2439                 OSCL_ASSERT(jbExtIntf);
   2440                 if (!jbExtIntf)
   2441                     return PVMFFailure;
   2442                 jbExtIntf->getJitterBufferRebufferingThresholdInMilliSeconds(aParameters[0].value.uint32_value);
   2443             }
   2444             else if (reqattr == PVMI_KVPATTR_DEF)
   2445             {
   2446                 // Return default
   2447                 aParameters[0].value.uint32_value = DEFAULT_JITTER_BUFFER_UNDERFLOW_THRESHOLD_IN_MS;
   2448             }
   2449             else
   2450             {
   2451                 // Return capability
   2452                 range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
   2453                 if (rui32 == NULL)
   2454                 {
   2455                     oscl_free(aParameters[0].key);
   2456                     oscl_free(aParameters);
   2457                     PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::GetConfigParameter() "
   2458                                            "Memory allocation for range uint32 failed"));
   2459                     return PVMFErrNoMemory;
   2460                 }
   2461                 rui32->min = DEFAULT_JITTER_BUFFER_UNDERFLOW_THRESHOLD_IN_MS;
   2462                 rui32->max = DEFAULT_JITTER_BUFFER_UNDERFLOW_THRESHOLD_IN_MS;
   2463                 aParameters[0].value.key_specific_value = (void*)rui32;
   2464             }
   2465         }
   2466         break;
   2467         case BASEKEY_JITTERBUFFER_NUMRESIZE:
   2468             if (reqattr == PVMI_KVPATTR_CUR)
   2469             {
   2470                 // Return current value
   2471                 uint32 numResize, resizeSize;
   2472                 PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   2473                     getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   2474                 OSCL_ASSERT(iJitterBufferNodeContainer);
   2475                 if (!iJitterBufferNodeContainer)
   2476                     return PVMFFailure;
   2477                 PVMFJitterBufferExtensionInterface* jbExtIntf =
   2478                     (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
   2479                 jbExtIntf->GetSharedBufferResizeParams(numResize, resizeSize);
   2480                 aParameters[0].value.uint32_value = numResize;
   2481             }
   2482             else if (reqattr == PVMI_KVPATTR_DEF)
   2483             {
   2484                 // Return default
   2485                 aParameters[0].value.uint32_value = DEFAULT_MAX_NUM_SOCKETMEMPOOL_RESIZES;
   2486             }
   2487             else
   2488             {
   2489                 // Return capability
   2490                 range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
   2491                 if (rui32 == NULL)
   2492                 {
   2493                     oscl_free(aParameters[0].key);
   2494                     oscl_free(aParameters);
   2495                     PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::GetConfigParameter() "
   2496                                            "Memory allocation for range uint32 failed"));
   2497                     return PVMFErrNoMemory;
   2498                 }
   2499                 rui32->min = MIN_NUM_SOCKETMEMPOOL_RESIZES;
   2500                 rui32->max = MAX_NUM_SOCKETMEMPOOL_RESIZES;
   2501                 aParameters[0].value.key_specific_value = (void*)rui32;
   2502             }
   2503             break;
   2504         case BASEKEY_JITTERBUFFER_RESIZESIZE:
   2505             if (reqattr == PVMI_KVPATTR_CUR)
   2506             {
   2507                 // Return current value
   2508                 uint32 numResize, resizeSize;
   2509                 PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   2510                     getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   2511                 OSCL_ASSERT(iJitterBufferNodeContainer);
   2512                 if (!iJitterBufferNodeContainer)
   2513                     return PVMFFailure;
   2514                 PVMFJitterBufferExtensionInterface* jbExtIntf =
   2515                     (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
   2516                 jbExtIntf->GetSharedBufferResizeParams(numResize, resizeSize);
   2517                 aParameters[0].value.uint32_value = resizeSize;
   2518             }
   2519             else if (reqattr == PVMI_KVPATTR_DEF)
   2520             {
   2521                 // Return default
   2522                 aParameters[0].value.uint32_value = DEFAULT_MAX_SOCKETMEMPOOL_RESIZELEN_INPUT_PORT;
   2523             }
   2524             else
   2525             {
   2526                 // Return capability
   2527                 range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
   2528                 if (rui32 == NULL)
   2529                 {
   2530                     oscl_free(aParameters[0].key);
   2531                     oscl_free(aParameters);
   2532                     PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::GetConfigParameter() "
   2533                                            "Memory allocation for range uint32 failed"));
   2534                     return PVMFErrNoMemory;
   2535                 }
   2536                 rui32->min = MIN_SOCKETMEMPOOL_RESIZELEN_INPUT_PORT;
   2537                 rui32->max = MAX_SOCKETMEMPOOL_RESIZELEN_INPUT_PORT;
   2538                 aParameters[0].value.key_specific_value = (void*)rui32;
   2539             }
   2540             break;
   2541         case BASEKEY_JITTERBUFFER_MAX_INACTIVITY_DURATION:
   2542             if (reqattr == PVMI_KVPATTR_CUR)
   2543             {
   2544                 // Return current value
   2545                 PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   2546                     getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   2547                 OSCL_ASSERT(iJitterBufferNodeContainer);
   2548                 if (!iJitterBufferNodeContainer)
   2549                     return PVMFFailure;
   2550                 PVMFJitterBufferExtensionInterface* jbExtIntf =
   2551                     (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
   2552                 OSCL_ASSERT(jbExtIntf);
   2553                 uint32 inactivityDuration = 0;
   2554                 if (jbExtIntf)
   2555                 {
   2556                     jbExtIntf->getMaxInactivityDurationForMediaInMs(inactivityDuration);
   2557                 }
   2558                 aParameters[0].value.uint32_value = inactivityDuration;
   2559             }
   2560             else if (reqattr == PVMI_KVPATTR_DEF)
   2561             {
   2562                 // Return default
   2563                 aParameters[0].value.uint32_value = DEFAULT_MAX_INACTIVITY_DURATION_IN_MS;
   2564             }
   2565             else
   2566             {
   2567                 // Return capability
   2568                 range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
   2569                 if (rui32 == NULL)
   2570                 {
   2571                     oscl_free(aParameters[0].key);
   2572                     oscl_free(aParameters);
   2573                     PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::GetConfigParameter() "
   2574                                            "Memory allocation for range uint32 failed"));
   2575                     return PVMFErrNoMemory;
   2576                 }
   2577                 rui32->min = 0;
   2578                 rui32->max = DEFAULT_MAX_INACTIVITY_DURATION_IN_MS;
   2579                 aParameters[0].value.key_specific_value = (void*)rui32;
   2580             }
   2581             break;
   2582         case BASEKEY_SESSION_CONTROLLER_USER_AGENT:
   2583             if ((reqattr == PVMI_KVPATTR_CUR) || (reqattr == PVMI_KVPATTR_DEF))
   2584             {
   2585                 aParameters[0].value.pWChar_value = NULL;
   2586                 /* As of now just RTSP node supports an external config of user agent */
   2587                 PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
   2588                     getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
   2589                 if (iSessionControllerNodeContainer != NULL)
   2590                 {
   2591                     PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
   2592                         (PVRTSPEngineNodeExtensionInterface*)
   2593                         (iSessionControllerNodeContainer->iExtensions[0]);
   2594 
   2595                     OSCL_wHeapString<OsclMemAllocator> userAgent;
   2596                     if (rtspExtIntf->GetUserAgent(userAgent) == PVMFSuccess)
   2597                     {
   2598                         // Return current value
   2599                         oscl_wchar* ptr = (oscl_wchar*)oscl_malloc(sizeof(oscl_wchar) * (userAgent.get_size()));
   2600                         if (ptr)
   2601                         {
   2602                             oscl_memcpy(ptr, userAgent.get_cstr(), userAgent.get_size());
   2603                             aParameters[0].value.pWChar_value = ptr;
   2604                         }
   2605                         else
   2606                         {
   2607                             oscl_free(aParameters[0].key);
   2608                             oscl_free(aParameters);
   2609                             PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::GetConfigParameter() "
   2610                                                    "Memory allocation for user agent failed"));
   2611                             return PVMFErrNoMemory;
   2612                         }
   2613                     }
   2614                 }
   2615             }
   2616             else
   2617             {
   2618                 // Return capability - no concept of capability for user agent
   2619                 // do nothing
   2620             }
   2621             break;
   2622         case BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_INTERVAL:
   2623         case BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_DURING_PLAY:
   2624             if ((reqattr == PVMI_KVPATTR_CUR) || (reqattr == PVMI_KVPATTR_DEF))
   2625             {
   2626                 if (aIndex == BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_INTERVAL)
   2627                 {
   2628                     aParameters[0].value.uint32_value = PVRTSPENGINENODE_DEFAULT_KEEP_ALIVE_INTERVAL;
   2629                 }
   2630                 else
   2631                 {
   2632                     aParameters[0].value.bool_value = false;
   2633                 }
   2634                 /* As of now just RTSP node supports an external config of user agent */
   2635                 PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
   2636                     getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
   2637                 if (iSessionControllerNodeContainer != NULL)
   2638                 {
   2639                     PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
   2640                         (PVRTSPEngineNodeExtensionInterface*)
   2641                         (iSessionControllerNodeContainer->iExtensions[0]);
   2642                     uint32 timeout;
   2643                     bool okeepalivemethod;
   2644                     bool okeepaliveinplay;
   2645                     rtspExtIntf->GetKeepAliveMethod((int32&)timeout, okeepalivemethod, okeepaliveinplay);
   2646                     if (aIndex == BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_INTERVAL)
   2647                     {
   2648                         aParameters[0].value.uint32_value = timeout;
   2649                     }
   2650                     else
   2651                     {
   2652                         aParameters[0].value.bool_value = okeepaliveinplay;
   2653                     }
   2654                 }
   2655             }
   2656             else
   2657             {
   2658                 // Return capability - no concept of capability for keep alive interval
   2659                 // do nothing
   2660             }
   2661             break;
   2662 
   2663         case BASEKEY_SESSION_CONTROLLER_RTSP_TIMEOUT:
   2664         {
   2665             if ((reqattr == PVMI_KVPATTR_CUR) || (reqattr == PVMI_KVPATTR_DEF))
   2666             {
   2667                 /* As of now just RTSP node supports an external config of RTSP time out */
   2668                 PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
   2669                     getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
   2670                 if (iSessionControllerNodeContainer != NULL)
   2671                 {
   2672                     PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
   2673                         (PVRTSPEngineNodeExtensionInterface*)
   2674                         (iSessionControllerNodeContainer->iExtensions[0]);
   2675                     int32 timeout;
   2676                     rtspExtIntf->GetRTSPTimeOut(timeout);
   2677                     aParameters[0].value.uint32_value = OSCL_STATIC_CAST(uint32, timeout);
   2678                 }
   2679             }
   2680             else
   2681             {
   2682                 // Return capability
   2683                 range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
   2684                 if (rui32 == NULL)
   2685                 {
   2686                     oscl_free(aParameters[0].key);
   2687                     oscl_free(aParameters);
   2688                     PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastPlusPVRNode::GetConfigParameter() "
   2689                                            "Memory allocation for range uint32 failed"));
   2690                     return PVMFErrNoMemory;
   2691                 }
   2692                 rui32->min = MIN_RTSP_SERVER_INACTIVITY_TIMEOUT_IN_SEC;
   2693                 rui32->max = MAX_RTSP_SERVER_INACTIVITY_TIMEOUT_IN_SEC;
   2694                 aParameters[0].value.key_specific_value = (void*)rui32;
   2695             }
   2696         }
   2697         break;
   2698         case BASEKEY_DISABLE_FIREWALL_PACKETS:
   2699         {
   2700             if ((reqattr == PVMI_KVPATTR_CUR) || (reqattr == PVMI_KVPATTR_DEF))
   2701             {
   2702                 aParameters[0].value.bool_value = false;
   2703             }
   2704         }
   2705         break;
   2706 
   2707 
   2708         default:
   2709             // Invalid index
   2710             oscl_free(aParameters[0].key);
   2711             oscl_free(aParameters);
   2712             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoGetPlayerParameter() Invalid index to player parameter"));
   2713             return PVMFErrArgument;
   2714     }
   2715 
   2716     aNumParamElements = 1;
   2717 
   2718     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoGetPlayerParameter() Out"));
   2719     return PVMFSuccess;
   2720 }
   2721 
   2722 PVMFStatus PVMFSMRTSPUnicastNode::releaseParameters(PvmiMIOSession aSession,
   2723         PvmiKvp* aParameters,
   2724         int num_elements)
   2725 {
   2726     OSCL_UNUSED_ARG(aSession);
   2727 
   2728     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
   2729                     (0, "PVMFSMRTSPUnicastNode::releaseParameters() In"));
   2730 
   2731     if (aParameters == NULL || num_elements < 1)
   2732     {
   2733         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
   2734                         (0, "PVMFSMRTSPUnicastNode::releaseParameters() KVP list is NULL or number of elements is 0"));
   2735         return PVMFErrArgument;
   2736     }
   2737 
   2738     // Count the number of components and parameters in the key
   2739     int compcount = pv_mime_string_compcnt(aParameters[0].key);
   2740     // Retrieve the first component from the key string
   2741     char* compstr = NULL;
   2742     pv_mime_string_extract_type(0, aParameters[0].key, compstr);
   2743 
   2744     if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf")) < 0) || compcount < 2)
   2745     {
   2746         // First component should be "x-pvmf" and there must
   2747         // be at least two components to go past x-pvmf
   2748         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
   2749                         (0, "PVMFSMRTSPUnicastNode::releaseParameters() Unsupported key"));
   2750         return PVMFErrArgument;
   2751     }
   2752 
   2753     // Retrieve the second component from the key string
   2754     pv_mime_string_extract_type(1, aParameters[0].key, compstr);
   2755 
   2756     // Assume all the parameters come from the same component so the base components are the same
   2757     if (pv_mime_strcmp(compstr, _STRLIT_CHAR("net")) >= 0)
   2758     {
   2759         // Go through each KVP and release memory for value if allocated from heap
   2760         for (int32 i = 0; i < num_elements; ++i)
   2761         {
   2762             // Next check if it is a value type that allocated memory
   2763             PvmiKvpType kvptype = GetTypeFromKeyString(aParameters[i].key);
   2764             if (kvptype == PVMI_KVPTYPE_VALUE || kvptype == PVMI_KVPTYPE_UNKNOWN)
   2765             {
   2766                 PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameters[i].key);
   2767                 if (keyvaltype == PVMI_KVPVALTYPE_UNKNOWN)
   2768                 {
   2769                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
   2770                                     (0, "PVMFSMRTSPUnicastNode::releaseParameters() Valtype not specified in key string"));
   2771                     return PVMFErrArgument;
   2772                 }
   2773 
   2774                 if (keyvaltype == PVMI_KVPVALTYPE_CHARPTR && aParameters[i].value.pChar_value != NULL)
   2775                 {
   2776                     oscl_free(aParameters[i].value.pChar_value);
   2777                     aParameters[i].value.pChar_value = NULL;
   2778                 }
   2779                 else if (keyvaltype == PVMI_KVPVALTYPE_WCHARPTR && aParameters[i].value.pWChar_value != NULL)
   2780                 {
   2781                     oscl_free(aParameters[i].value.pWChar_value);
   2782                     aParameters[i].value.pWChar_value = NULL;
   2783                 }
   2784                 else if (keyvaltype == PVMI_KVPVALTYPE_CHARPTR && aParameters[i].value.pChar_value != NULL)
   2785                 {
   2786                     oscl_free(aParameters[i].value.pChar_value);
   2787                     aParameters[i].value.pChar_value = NULL;
   2788                 }
   2789                 else if (keyvaltype == PVMI_KVPVALTYPE_KSV && aParameters[i].value.key_specific_value != NULL)
   2790                 {
   2791                     oscl_free(aParameters[i].value.key_specific_value);
   2792                     aParameters[i].value.key_specific_value = NULL;
   2793                 }
   2794                 else if (keyvaltype == PVMI_KVPVALTYPE_RANGE_INT32 && aParameters[i].value.key_specific_value != NULL)
   2795                 {
   2796                     range_int32* ri32 = (range_int32*)aParameters[i].value.key_specific_value;
   2797                     aParameters[i].value.key_specific_value = NULL;
   2798                     oscl_free(ri32);
   2799                 }
   2800                 else if (keyvaltype == PVMI_KVPVALTYPE_RANGE_UINT32 && aParameters[i].value.key_specific_value != NULL)
   2801                 {
   2802                     range_uint32* rui32 = (range_uint32*)aParameters[i].value.key_specific_value;
   2803                     aParameters[i].value.key_specific_value = NULL;
   2804                     oscl_free(rui32);
   2805                 }
   2806             }
   2807         }
   2808 
   2809         oscl_free(aParameters[0].key);
   2810 
   2811         // Free memory for the parameter list
   2812         oscl_free(aParameters);
   2813         aParameters = NULL;
   2814     }
   2815     else
   2816     {
   2817         // Unknown key string
   2818         return PVMFErrArgument;
   2819     }
   2820 
   2821     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
   2822                     (0, "PVMFSMRTSPUnicastNode::releaseParameters() Out"));
   2823     return PVMFSuccess;
   2824 }
   2825 
   2826 void PVMFSMRTSPUnicastNode::createContext(PvmiMIOSession aSession,
   2827         PvmiCapabilityContext& aContext)
   2828 {
   2829     OSCL_UNUSED_ARG(aSession);
   2830     OSCL_UNUSED_ARG(aContext);
   2831     // not supported
   2832     OSCL_LEAVE(PVMFErrNotSupported);
   2833 }
   2834 
   2835 void PVMFSMRTSPUnicastNode::setContextParameters(PvmiMIOSession aSession,
   2836         PvmiCapabilityContext& aContext,
   2837         PvmiKvp* aParameters,
   2838         int num_parameter_elements)
   2839 {
   2840     OSCL_UNUSED_ARG(aSession);
   2841     OSCL_UNUSED_ARG(aContext);
   2842     OSCL_UNUSED_ARG(aParameters);
   2843     OSCL_UNUSED_ARG(num_parameter_elements);
   2844     // not supported
   2845     OSCL_LEAVE(PVMFErrNotSupported);
   2846 }
   2847 
   2848 void PVMFSMRTSPUnicastNode::DeleteContext(PvmiMIOSession aSession,
   2849         PvmiCapabilityContext& aContext)
   2850 {
   2851     OSCL_UNUSED_ARG(aSession);
   2852     OSCL_UNUSED_ARG(aContext);
   2853     // not supported
   2854     OSCL_LEAVE(PVMFErrNotSupported);
   2855 }
   2856 
   2857 void PVMFSMRTSPUnicastNode::setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
   2858         int num_elements, PvmiKvp* &aRet_kvp)
   2859 {
   2860     OSCL_UNUSED_ARG(aSession);
   2861 
   2862     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
   2863                     (0, "PVMFSMRTSPUnicastNode::setParametersSync() In"));
   2864 
   2865 
   2866     // Go through each parameter
   2867     for (int paramind = 0; paramind < num_elements; ++paramind)
   2868     {
   2869         // Count the number of components and parameters in the key
   2870         int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
   2871 
   2872         // Retrieve the first component from the key string
   2873         char* compstr = NULL;
   2874         pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
   2875 
   2876         if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf")) < 0) || compcount < 2)
   2877         {
   2878             // First component should be "x-pvmf" and there must
   2879             // be at least two components to go past x-pvmf
   2880             aRet_kvp = &aParameters[paramind];
   2881             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
   2882                             (0, "PVMFSMRTSPUnicastNode::setParametersSync() Unsupported key"));
   2883             return;
   2884         }
   2885 
   2886         // Retrieve the second component from the key string
   2887         pv_mime_string_extract_type(1, aParameters[paramind].key, compstr);
   2888 
   2889         // First check if it is key string for the streaming manager
   2890         if (pv_mime_strcmp(compstr, _STRLIT_CHAR("net")) >= 0)
   2891         {
   2892             if (compcount == 3)
   2893             {
   2894                 pv_mime_string_extract_type(2, aParameters[paramind].key, compstr);
   2895                 uint i;
   2896                 for (i = 0; i < StreamingManagerConfig_NumBaseKeys; i++)
   2897                 {
   2898                     if (pv_mime_strcmp(compstr, (char*)(StreamingManagerConfig_BaseKeys[i].iString)) >= 0)
   2899                     {
   2900                         break;
   2901                     }
   2902                 }
   2903 
   2904                 if (StreamingManagerConfig_NumBaseKeys == i)
   2905                 {
   2906                     // invalid third component
   2907                     aRet_kvp = &aParameters[paramind];
   2908                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
   2909                                     (0, "PVMFSMRTSPUnicastNode::setParametersSync() Unsupported key"));
   2910                     return;
   2911                 }
   2912                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
   2913                                 (0, "PVMFSMRTSPUnicastNode::setParametersSync() key str %s", compstr));
   2914                 // Verify and set the passed-in setting
   2915                 PVMFStatus retval = VerifyAndSetConfigParameter(i, aParameters[paramind], true);
   2916                 if (retval != PVMFSuccess)
   2917                 {
   2918                     aRet_kvp = &aParameters[paramind];
   2919                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
   2920                                     (0, "PVMFSMRTSPUnicastNode::setParametersSync() Setting "
   2921                                      "parameter %d failed", paramind));
   2922                     return;
   2923                 }
   2924             }
   2925             else
   2926             {
   2927                 // Do not support more than 3 components right now
   2928                 aRet_kvp = &aParameters[paramind];
   2929                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
   2930                                 (0, "PVMFSMRTSPUnicastNode::setParametersSync() Unsupported key"));
   2931                 return;
   2932             }
   2933         }
   2934         else
   2935         {
   2936             // Unknown key string
   2937             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
   2938                             (0, "PVMFSMRTSPUnicastNode::setParametersSync() Unsupported key"));
   2939             return;
   2940         }
   2941     }
   2942 
   2943     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
   2944                     (0, "PVMFSMRTSPUnicastNode::setParametersSync() Out"));
   2945 }
   2946 
   2947 
   2948 
   2949 uint32 PVMFSMRTSPUnicastNode::getCapabilityMetric(PvmiMIOSession aSession)
   2950 {
   2951     OSCL_UNUSED_ARG(aSession);
   2952     return 0;
   2953 }
   2954 
   2955 PVMFStatus PVMFSMRTSPUnicastNode::verifyParametersSync(PvmiMIOSession aSession,
   2956         PvmiKvp* aParameters,
   2957         int num_elements)
   2958 {
   2959     OSCL_UNUSED_ARG(aSession);
   2960 
   2961     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
   2962                     (0, "PVMFSMRTSPUnicastNode::verifyParametersSync() In"));
   2963 
   2964     if (aParameters == NULL || num_elements < 1)
   2965     {
   2966         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
   2967                         (0, "PVMFSMRTSPUnicastNode::verifyParametersSync() Passed in parameter invalid"));
   2968         return PVMFErrArgument;
   2969     }
   2970 
   2971     // Go through each parameter and verify
   2972     for (int32 paramind = 0; paramind < num_elements; ++paramind)
   2973     {
   2974         // Count the number of components and parameters in the key
   2975         int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
   2976         // Retrieve the first component from the key string
   2977         char* compstr = NULL;
   2978         pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
   2979 
   2980         if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf")) < 0) || compcount < 2)
   2981         {
   2982             // First component should be "x-pvmf" and there must
   2983             // be at least two components to go past x-pvmf
   2984             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::verifyParametersSync() Unsupported key"));
   2985             return PVMFErrArgument;
   2986         }
   2987 
   2988         // Retrieve the second component from the key string
   2989         pv_mime_string_extract_type(1, aParameters[paramind].key, compstr);
   2990 
   2991         // First check if it is key string for this node
   2992         if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("net")) >= 0) && (compcount == 3))
   2993         {
   2994             pv_mime_string_extract_type(2, aParameters[paramind].key, compstr);
   2995             uint i;
   2996             for (i = 0; i < StreamingManagerConfig_NumBaseKeys; i++)
   2997             {
   2998                 if (pv_mime_strcmp(compstr, (char*)(StreamingManagerConfig_BaseKeys[i].iString)) >= 0)
   2999                 {
   3000                     break;
   3001                 }
   3002             }
   3003 
   3004             if (StreamingManagerConfig_NumBaseKeys == i)
   3005             {
   3006                 return PVMFErrArgument;
   3007             }
   3008 
   3009             // Verify the passed-in player setting
   3010             PVMFStatus retval = VerifyAndSetConfigParameter(i, aParameters[paramind], false);
   3011             if (retval != PVMFSuccess)
   3012             {
   3013                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoCapConfigVerifyParameters() Verifying parameter %d failed", paramind));
   3014                 return retval;
   3015             }
   3016         }
   3017         else
   3018         {
   3019             // Unknown key string
   3020             return PVMFErrArgument;
   3021         }
   3022     }
   3023 
   3024     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCapConfigVerifyParameters() Out"));
   3025     return PVMFSuccess;
   3026 }
   3027 
   3028 
   3029 
   3030 PVMFStatus PVMFSMRTSPUnicastNode::VerifyAndSetConfigParameter(int index, PvmiKvp& aParameter, bool set)
   3031 {
   3032     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::VerifyAndSetConfigParameter() In index[%d]", index));
   3033 
   3034     // Determine the valtype
   3035     PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameter.key);
   3036     if (keyvaltype == PVMI_KVPVALTYPE_UNKNOWN)
   3037     {
   3038         PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::VerifyAndSetConfigParameter() "
   3039                                "Valtype in key string unknown"));
   3040         return PVMFErrArgument;
   3041     }
   3042 
   3043     // Verify the valtype
   3044     if (keyvaltype != StreamingManagerConfig_BaseKeys[index].iValueType)
   3045     {
   3046         PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::VerifyAndSetConfigParameter() "
   3047                                "Valtype does not match for key"));
   3048         return PVMFErrArgument;
   3049     }
   3050 
   3051     switch (index)
   3052     {
   3053         case BASEKEY_DELAY:
   3054         {
   3055             uint32  rebuffThreshold = 0;
   3056             PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   3057                 getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   3058             OSCL_ASSERT(iJitterBufferNodeContainer);
   3059             if (!iJitterBufferNodeContainer)
   3060                 return PVMFFailure;
   3061             PVMFJitterBufferExtensionInterface* jbExtIntf = NULL;
   3062             if (iJitterBufferNodeContainer)
   3063                 jbExtIntf = (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
   3064             if (jbExtIntf)
   3065                 jbExtIntf->getJitterBufferRebufferingThresholdInMilliSeconds(rebuffThreshold);
   3066             if (!jbExtIntf)
   3067                 return PVMFFailure;
   3068             // Validate
   3069             if ((aParameter.value.uint32_value < MIN_JITTER_BUFFER_DURATION_IN_MS) ||
   3070                     (aParameter.value.uint32_value > MAX_JITTER_BUFFER_DURATION_IN_MS) ||
   3071                     (aParameter.value.uint32_value < rebuffThreshold))
   3072             {
   3073                 PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::VerifyAndSetConfigParameter() "
   3074                                        "Trying to set delay to 0"));
   3075                 return PVMFErrArgument;
   3076             }
   3077             if (set)
   3078             {
   3079                 // save value locally
   3080                 setJitterBufferDurationInMilliSeconds(aParameter.value.uint32_value);
   3081                 // pass the value on to the jitter buffer node
   3082                 jbExtIntf->setJitterBufferDurationInMilliSeconds(aParameter.value.uint32_value);
   3083             }
   3084         }
   3085         break;
   3086         case BASEKEY_REBUFFERING_THRESHOLD:
   3087         {
   3088             uint32 jbDuration = 0;
   3089             PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   3090                 getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   3091             OSCL_ASSERT(iJitterBufferNodeContainer);
   3092             if (!iJitterBufferNodeContainer)
   3093                 return PVMFFailure;
   3094             PVMFJitterBufferExtensionInterface* jbExtIntf =
   3095                 (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
   3096             jbExtIntf->getJitterBufferDurationInMilliSeconds(jbDuration);
   3097             // Validate
   3098             if (aParameter.value.uint32_value >= jbDuration)
   3099             {
   3100                 PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::VerifyAndSetConfigParameter() "
   3101                                        "Trying to set rebuffering threshold greater than equal to jitter buffer duration"));
   3102                 return PVMFErrArgument;
   3103             }
   3104             if (set)
   3105             {
   3106                 // pass the value on to the jitter buffer node
   3107                 jbExtIntf->setJitterBufferRebufferingThresholdInMilliSeconds(aParameter.value.uint32_value);
   3108             }
   3109         }
   3110         break;
   3111         case BASEKEY_JITTERBUFFER_NUMRESIZE:
   3112         {
   3113             if (set)
   3114             {
   3115                 // retrieve and update
   3116                 uint32 numResize, resizeSize;
   3117                 PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   3118                     getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   3119                 OSCL_ASSERT(iJitterBufferNodeContainer);
   3120                 if (!iJitterBufferNodeContainer)
   3121                     return PVMFFailure;
   3122                 PVMFJitterBufferExtensionInterface* jbExtIntf =
   3123                     (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
   3124                 OSCL_ASSERT(jbExtIntf);
   3125                 if (!jbExtIntf)
   3126                     return PVMFFailure;
   3127                 jbExtIntf->GetSharedBufferResizeParams(numResize, resizeSize);
   3128                 jbExtIntf->SetSharedBufferResizeParams(aParameter.value.uint32_value, resizeSize);
   3129             }
   3130         }
   3131         break;
   3132         case BASEKEY_JITTERBUFFER_RESIZESIZE:
   3133         {
   3134             if (set)
   3135             {
   3136                 // retrieve and update
   3137                 uint32 numResize, resizeSize;
   3138                 PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   3139                     getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   3140                 OSCL_ASSERT(iJitterBufferNodeContainer);
   3141                 if (!iJitterBufferNodeContainer)
   3142                     return PVMFFailure;
   3143                 PVMFJitterBufferExtensionInterface* jbExtIntf =
   3144                     (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
   3145                 OSCL_ASSERT(jbExtIntf);
   3146                 if (!jbExtIntf)
   3147                     return PVMFFailure;
   3148                 jbExtIntf->GetSharedBufferResizeParams(numResize, resizeSize);
   3149                 jbExtIntf->SetSharedBufferResizeParams(numResize, aParameter.value.uint32_value);
   3150             }
   3151         }
   3152         break;
   3153         case BASEKEY_JITTERBUFFER_MAX_INACTIVITY_DURATION:
   3154         {
   3155             PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   3156                 getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   3157             OSCL_ASSERT(iJitterBufferNodeContainer);
   3158             if (!iJitterBufferNodeContainer)
   3159                 return PVMFFailure;
   3160             PVMFJitterBufferExtensionInterface* jbExtIntf =
   3161                 (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
   3162             OSCL_ASSERT(jbExtIntf);
   3163             if (!jbExtIntf)
   3164                 return PVMFFailure;
   3165             //validate input value...
   3166             if (aParameter.value.uint32_value > DEFAULT_MAX_INACTIVITY_DURATION_IN_MS)
   3167             {
   3168                 PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::VerifyAndSetConfigParameter() "
   3169                                        "Trying to set max inactivity duration greater than allowed inactivity duration"));
   3170                 return PVMFErrArgument;
   3171             }
   3172             if (set)
   3173             {
   3174                 //update the maximum alloyed delay for the incoming msg at input port of JB node
   3175                 jbExtIntf->setMaxInactivityDurationForMediaInMs(aParameter.value.uint32_value);
   3176             }
   3177         }
   3178         break;
   3179         case BASEKEY_SESSION_CONTROLLER_USER_AGENT:
   3180         {
   3181             if (set)
   3182             {
   3183                 // user agent update
   3184                 PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer = NULL;
   3185                 iSessionControllerNodeContainer =
   3186                     getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
   3187                 OSCL_wHeapString<OsclMemAllocator> userAgent;
   3188                 OSCL_wHeapString<OsclMemAllocator> dummy;
   3189                 if (iSessionControllerNodeContainer != NULL)
   3190                 {
   3191                     PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
   3192                         (PVRTSPEngineNodeExtensionInterface*)
   3193                         (iSessionControllerNodeContainer->iExtensions[0]);
   3194 
   3195                     userAgent = aParameter.value.pWChar_value;
   3196                     rtspExtIntf->SetClientParameters(userAgent, dummy, dummy);
   3197                 }
   3198                 // save user-agent kvp for cpm
   3199                 if (iCPM)
   3200                 {
   3201                     PVMFStatus status = iCPMKvpStore.addKVPString(aParameter.key, userAgent);
   3202                     if (status != PVMFSuccess) return status;
   3203                 }
   3204 
   3205             }
   3206         }
   3207         break;
   3208 
   3209         case BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_DURING_PLAY:
   3210         {
   3211             if (set)
   3212             {
   3213                 // keep-alive during play update
   3214                 /* As of now just RTSP node supports an external config of keep-alive during play */
   3215                 PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
   3216                     getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
   3217                 if (iSessionControllerNodeContainer != NULL)
   3218                 {
   3219                     PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
   3220                         (PVRTSPEngineNodeExtensionInterface*)
   3221                         (iSessionControllerNodeContainer->iExtensions[0]);
   3222                     rtspExtIntf->SetKeepAliveMethod_keep_alive_in_play(aParameter.value.bool_value);
   3223                 }
   3224             }
   3225         }
   3226         break;
   3227 
   3228         case BASEKEY_SESSION_CONTROLLER_RTSP_TIMEOUT:
   3229         {
   3230             if (set)
   3231             {
   3232                 PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::VerifyAndSetConfigParameter() BASEKEY_SESSION_CONTROLLER_RTSP_TIMEOUT "));
   3233                 // RTSP response waiting time out
   3234                 PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
   3235                     getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
   3236                 if (iSessionControllerNodeContainer != NULL)
   3237                 {
   3238                     PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
   3239                         (PVRTSPEngineNodeExtensionInterface*)
   3240                         (iSessionControllerNodeContainer->iExtensions[0]);
   3241                     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::VerifyAndSetConfigParameter() BASEKEY_SESSION_CONTROLLER_RTSP_TIMEOUT rtspExtIntf%x", rtspExtIntf));
   3242                     rtspExtIntf->SetRTSPTimeOut(aParameter.value.uint32_value);
   3243                 }
   3244                 PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::VerifyAndSetConfigParameter() BASEKEY_SESSION_CONTROLLER_RTSP_TIMEOUT Done"));
   3245             }
   3246         }
   3247         break;
   3248 
   3249         case BASEKEY_DISABLE_FIREWALL_PACKETS:
   3250         {
   3251             if (set)
   3252             {
   3253                 PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   3254                     getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   3255                 OSCL_ASSERT(iJitterBufferNodeContainer);
   3256                 if (!iJitterBufferNodeContainer)
   3257                     return PVMFFailure;
   3258                 PVMFJitterBufferExtensionInterface* jbExtIntf =
   3259                     (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
   3260                 OSCL_ASSERT(jbExtIntf);
   3261                 if (!jbExtIntf)
   3262                     return PVMFFailure;
   3263                 jbExtIntf->DisableFireWallPackets();
   3264             }
   3265         }
   3266         break;
   3267 
   3268         default:
   3269             return PVMFErrNotSupported;
   3270     }
   3271 
   3272     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
   3273                     (0, "PVMFSMRTSPUnicastNode::VerifyAndSetPlayerParameter() Out"));
   3274 
   3275     return PVMFSuccess;
   3276 }
   3277 
   3278 ///////////////////////////////////////////////////////////////////////////////
   3279 // Implemenation of PVMFDataSourceInitializationExtensionInterface interface
   3280 ///////////////////////////////////////////////////////////////////////////////
   3281 
   3282 PVMFStatus PVMFSMRTSPUnicastNode::SetSourceInitializationData(OSCL_wString& aSourceURL, PVMFFormatType& aSourceFormat, OsclAny* aSourceData)
   3283 {
   3284     //To set proxy server info with the session controller node
   3285     if (aSourceData != NULL)
   3286     {
   3287         PVInterface* pvInterface = OSCL_STATIC_CAST(PVInterface*, aSourceData);
   3288         PVInterface* sourceDataContext = NULL;
   3289         PVUuid sourceContextUuid(PVMF_SOURCE_CONTEXT_DATA_UUID);
   3290         if (pvInterface->queryInterface(sourceContextUuid, sourceDataContext))
   3291         {
   3292             if (sourceDataContext)
   3293             {
   3294                 PVInterface* streamingDataContext = NULL;
   3295                 PVUuid streamingContextUuid(PVMF_SOURCE_CONTEXT_DATA_STREAMING_UUID);
   3296 
   3297                 if (sourceDataContext->queryInterface(streamingContextUuid, streamingDataContext))
   3298                 {
   3299                     if (streamingDataContext)
   3300                     {
   3301                         PVMFSourceContextDataStreaming* sContext =
   3302                             OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, streamingDataContext);
   3303                         if (sContext->iProxyName.get_size() > 0)
   3304                         {
   3305                             PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer = NULL;
   3306                             iSessionControllerNodeContainer = getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
   3307                             if (iSessionControllerNodeContainer)
   3308                             {
   3309                                 PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
   3310                                     (PVRTSPEngineNodeExtensionInterface*)(iSessionControllerNodeContainer->iExtensions[0]);
   3311                                 if (rtspExtIntf)
   3312                                 {   //the proxyname doesn't need to be unicode
   3313                                     OsclMemAllocator alloc;
   3314                                     char *buf = (char*)alloc.allocate(sContext->iProxyName.get_size() + 1);
   3315                                     if (!buf)
   3316                                         return PVMFErrNoMemory;
   3317                                     uint32 size = oscl_UnicodeToUTF8(sContext->iProxyName.get_cstr(), sContext->iProxyName.get_size(), buf, sContext->iProxyName.get_size() + 1);
   3318                                     if (size == 0)
   3319                                     {
   3320                                         alloc.deallocate(buf);
   3321                                         return PVMFErrNoMemory;
   3322                                     }
   3323 
   3324                                     OSCL_FastString myProxyName(buf, size);
   3325 
   3326                                     rtspExtIntf->SetRtspProxy(myProxyName, sContext->iProxyPort);
   3327                                     alloc.deallocate(buf);
   3328                                 }
   3329                             }
   3330                         }
   3331                     }
   3332                 }
   3333 
   3334             }
   3335         }
   3336     }
   3337     //to check if we should use CPM plugin?
   3338     if (aSourceData)
   3339     {
   3340         PVInterface* pvInterface =
   3341             OSCL_STATIC_CAST(PVInterface*, aSourceData);
   3342         PVInterface* streamingDataSrc = NULL;
   3343         PVUuid streamingDataSrcUuid(PVMF_STREAMING_DATASOURCE_UUID);
   3344         if (pvInterface->queryInterface(streamingDataSrcUuid, streamingDataSrc))
   3345         {
   3346             PVMFStreamingDataSource* opaqueData =
   3347                 OSCL_STATIC_CAST(PVMFStreamingDataSource*, streamingDataSrc);
   3348             iPreviewMode = opaqueData->iPreviewMode;
   3349             iUseCPMPluginRegistry = true;
   3350             iCPMSourceData.iPreviewMode = iPreviewMode;
   3351             iCPMSourceData.iIntent = opaqueData->iIntent;
   3352         }
   3353         else
   3354         {
   3355             PVInterface* sourceDataContext = NULL;
   3356             PVInterface* commonDataContext = NULL;
   3357             PVUuid sourceContextUuid(PVMF_SOURCE_CONTEXT_DATA_UUID);
   3358             PVUuid commonContextUuid(PVMF_SOURCE_CONTEXT_DATA_COMMON_UUID);
   3359             if (pvInterface->queryInterface(sourceContextUuid, sourceDataContext))
   3360             {
   3361                 if (sourceDataContext->queryInterface(commonContextUuid, commonDataContext))
   3362                 {
   3363                     PVMFSourceContextDataCommon* cContext =
   3364                         OSCL_STATIC_CAST(PVMFSourceContextDataCommon*, commonDataContext);
   3365                     iPreviewMode = cContext->iPreviewMode;
   3366                     iUseCPMPluginRegistry = true;
   3367                     PVMFSourceContextData* sContext =
   3368                         OSCL_STATIC_CAST(PVMFSourceContextData*, sourceDataContext);
   3369                     iSourceContextData = *sContext;
   3370                     iSourceContextDataValid = true;
   3371                 }
   3372             }
   3373         }
   3374     }
   3375     /*
   3376      * If a CPM flag is provided in the source data, then
   3377      * create a CPM object here...
   3378      */
   3379     if (iUseCPMPluginRegistry)
   3380     {
   3381         //cleanup any prior instance
   3382         if (iCPM)
   3383         {
   3384             iCPM->ThreadLogoff();
   3385             PVMFCPMFactory::DestroyContentPolicyManager(iCPM);
   3386             iCPM = NULL;
   3387         }
   3388         iCPM = PVMFCPMFactory::CreateContentPolicyManager(*this);
   3389         //thread logon may leave if there are no plugins
   3390         int32 err;
   3391         OSCL_TRY(err, iCPM->ThreadLogon(););
   3392         OSCL_FIRST_CATCH_ANY(err,
   3393                              iCPM->ThreadLogoff();
   3394                              PVMFCPMFactory::DestroyContentPolicyManager(iCPM);
   3395                              iCPM = NULL;
   3396                              iUseCPMPluginRegistry = false;
   3397                             );
   3398     }
   3399 
   3400     //to set the sessionsource info and configure session controller node [RTSP client], with the session type
   3401     if ((aSourceFormat == PVMF_MIME_DATA_SOURCE_RTSP_URL))
   3402     {
   3403         PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
   3404             getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
   3405         if (iSessionControllerNodeContainer == NULL)
   3406         {
   3407             OSCL_LEAVE(OsclErrBadHandle);
   3408             return PVMFFailure;
   3409         }
   3410         PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
   3411             (PVRTSPEngineNodeExtensionInterface*)
   3412             (iSessionControllerNodeContainer->iExtensions[0]);
   3413 
   3414         iSessionSourceInfo->_sessionType = aSourceFormat;
   3415         iSessionSourceInfo->_sessionURL  = aSourceURL;
   3416         rtspExtIntf->SetStreamingType(PVRTSP_3GPP_UDP);
   3417         return (rtspExtIntf->SetSessionURL(iSessionSourceInfo->_sessionURL));
   3418     }
   3419     else if (aSourceFormat == PVMF_MIME_DATA_SOURCE_SDP_FILE)
   3420     {
   3421         PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
   3422             getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
   3423         if (iSessionControllerNodeContainer == NULL)
   3424         {
   3425             OSCL_LEAVE(OsclErrBadHandle);
   3426             return PVMFFailure;
   3427         }
   3428         PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
   3429             (PVRTSPEngineNodeExtensionInterface*)
   3430             (iSessionControllerNodeContainer->iExtensions[0]);
   3431         // right now, PVMF_MIME_DATA_SOURCE_SDP_FILE => non-interleaved RTSP
   3432         rtspExtIntf->SetStreamingType(PVRTSP_3GPP_UDP);
   3433         iSessionSourceInfo->_sessionType = aSourceFormat;
   3434         iSessionSourceInfo->_sessionURL  = aSourceURL;
   3435         iSessionSourceInfo->_sourceData = aSourceData;
   3436 
   3437         return PVMFSuccess;
   3438     }
   3439     else
   3440         return PVMFErrNotSupported;
   3441 
   3442 }
   3443 
   3444 PVMFStatus PVMFSMRTSPUnicastNode::SetClientPlayBackClock(PVMFMediaClock* aClientClock)
   3445 {
   3446     PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   3447         getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   3448 
   3449     if (iJitterBufferNodeContainer == NULL)
   3450     {
   3451         OSCL_LEAVE(OsclErrBadHandle);
   3452         return PVMFFailure;
   3453     }
   3454 
   3455     PVMFJitterBufferExtensionInterface* jbExtIntf =
   3456         (PVMFJitterBufferExtensionInterface*)
   3457         (iJitterBufferNodeContainer->iExtensions[0]);
   3458 
   3459     jbExtIntf->setClientPlayBackClock(aClientClock);
   3460 
   3461     PVMFSMFSPChildNodeContainer* iMediaLayerNodeContainer =
   3462         getChildNodeContainer(PVMF_SM_FSP_MEDIA_LAYER_NODE);
   3463 
   3464     if (iMediaLayerNodeContainer == NULL)
   3465     {
   3466         OSCL_LEAVE(OsclErrBadHandle);
   3467         return PVMFFailure;
   3468     }
   3469 
   3470     PVMFMediaLayerNodeExtensionInterface* mlExtIntf =
   3471         (PVMFMediaLayerNodeExtensionInterface*)
   3472         (iMediaLayerNodeContainer->iExtensions[0]);
   3473 
   3474     mlExtIntf->setClientPlayBackClock(aClientClock);
   3475 
   3476     return PVMFSuccess;
   3477 }
   3478 
   3479 PVMFStatus PVMFSMRTSPUnicastNode::SetEstimatedServerClock(PVMFMediaClock* aClientClock)
   3480 {
   3481     OSCL_UNUSED_ARG(aClientClock);
   3482     return PVMFErrNotSupported;
   3483 }
   3484 
   3485 ///////////////////////////////////////////////////////////////////////////////
   3486 //Implementation of PVMFTrackSelectionExtensionInterface
   3487 ///////////////////////////////////////////////////////////////////////////////
   3488 PVMFStatus PVMFSMRTSPUnicastNode::GetMediaPresentationInfo(PVMFMediaPresentationInfo& aInfo)
   3489 {
   3490     SDPInfo* sdpInfo = iSdpInfo.GetRep();
   3491 
   3492     /* Get SDP Session Info */
   3493     sessionDescription* sessionInfo  = NULL;
   3494     if (sdpInfo)
   3495     {
   3496         sessionInfo = sdpInfo->getSessionInfo();
   3497         if (!sessionInfo)
   3498         {
   3499             return PVMFFailure;
   3500         }
   3501     }
   3502     else
   3503     {
   3504         return PVMFFailure;
   3505     }
   3506 
   3507 
   3508 
   3509     RtspRangeType *sessionRange = OSCL_CONST_CAST(RtspRangeType*, (sessionInfo->getRange()));
   3510 
   3511     int32 sessionStartTime = 0, sessionStopTime = 0;
   3512 
   3513     sessionRange->convertToMilliSec(sessionStartTime, sessionStopTime);
   3514 
   3515     int32 duration_msec = (sessionStopTime - sessionStartTime);
   3516 
   3517     uint64 duration64;
   3518     Oscl_Int64_Utils::set_uint64(duration64, 0, (uint32)duration_msec);
   3519 
   3520     if (sessionRange->end_is_set == true)
   3521     {
   3522         aInfo.setDurationValue(duration64);
   3523         aInfo.setDurationTimeScale(1000);
   3524     }
   3525     else
   3526     {
   3527         aInfo.SetDurationAvailable(false);
   3528     }
   3529 
   3530     aInfo.setSeekableFlag((!(sessionInfo->getRandomAccessDenied())));
   3531 
   3532     int32 numTracks = sdpInfo->getNumMediaObjects();
   3533 
   3534     SDPAltGroupType sdpAltGroupType = sessionInfo->getSDPAltGroupType();
   3535 
   3536     PVMF_TRACK_INFO_TRACK_ALTERNATE_TYPE iAltType = PVMF_TRACK_ALTERNATE_TYPE_UNDEFINED;
   3537 
   3538     if (sdpAltGroupType == SDP_ALT_GROUP_LANGUAGE)
   3539     {
   3540         iAltType = PVMF_TRACK_ALTERNATE_TYPE_LANGUAGE;
   3541     }
   3542     else if (sdpAltGroupType == SDP_ALT_GROUP_BANDWIDTH)
   3543     {
   3544         iAltType = PVMF_TRACK_ALTERNATE_TYPE_BANDWIDTH;
   3545     }
   3546 
   3547     for (int32 i = 0; i < numTracks; i++)
   3548     {
   3549         /*
   3550          * Get the vector of mediaInfo as there can
   3551          * alternates for each track
   3552          */
   3553         Oscl_Vector<mediaInfo*, SDPParserAlloc> mediaInfoVec =
   3554             sdpInfo->getMediaInfo(i);
   3555 
   3556         uint32 minfoVecLen = mediaInfoVec.size();
   3557 
   3558         for (uint32 j = 0; j < minfoVecLen; j++)
   3559         {
   3560             mediaInfo* mInfo = mediaInfoVec[j];
   3561 
   3562             if (mInfo == NULL)
   3563             {
   3564                 return PVMFFailure;
   3565             }
   3566 
   3567             RtspRangeType *mediaRange = mInfo->getRtspRange();
   3568 
   3569             int32 mediaStartTime = 0, mediaStopTime = 0;
   3570 
   3571             mediaRange->convertToMilliSec(mediaStartTime, mediaStopTime);
   3572             int32 mediaDuration_ms = mediaStopTime - mediaStartTime;
   3573             uint64 mediaDuration64;
   3574             Oscl_Int64_Utils::set_uint64(mediaDuration64, 0, (uint32)mediaDuration_ms);
   3575 
   3576             PVMFTrackInfo trackInfo;
   3577 
   3578             Oscl_Vector<PayloadSpecificInfoTypeBase*, SDPParserAlloc> payloadVector;
   3579             payloadVector = mInfo->getPayloadSpecificInfoVector();
   3580 
   3581             if (payloadVector.size() == 0)
   3582             {
   3583                 return false;
   3584             }
   3585             /*
   3586              * There can be multiple payloads per media segment.
   3587              * We only support one for now, so
   3588              * use just the first payload
   3589              */
   3590             PayloadSpecificInfoTypeBase* payloadInfo = payloadVector[0];
   3591 
   3592             // set config for later
   3593             int32 configSize = payloadInfo->configSize;
   3594             OsclAny* config = payloadInfo->configHeader.GetRep();
   3595 
   3596             OSCL_StackString<256> mimeString;
   3597             const char* mimeType = mInfo->getMIMEType();
   3598             mimeString += mimeType;
   3599             trackInfo.setTrackMimeType(mimeString);
   3600 
   3601             uint32 trackID = mInfo->getMediaInfoID();
   3602 
   3603             trackInfo.setTrackID(trackID);
   3604             trackInfo.setPortTag(trackID);
   3605 
   3606             trackInfo.setTrackBitRate(mInfo->getBitrate());
   3607 
   3608             if (mediaRange->end_is_set == true)
   3609             {
   3610                 trackInfo.setTrackDurationValue(mediaDuration64);
   3611             }
   3612             else
   3613             {
   3614                 trackInfo.SetDurationAvailable(false);
   3615             }
   3616 
   3617             if ((configSize > 0) && (config != NULL))
   3618             {
   3619                 OsclMemAllocDestructDealloc<uint8> my_alloc;
   3620                 OsclRefCounter* my_refcnt;
   3621                 uint aligned_refcnt_size =
   3622                     oscl_mem_aligned_size(sizeof(OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >));
   3623 
   3624                 uint8* my_ptr = GetMemoryChunk(my_alloc, aligned_refcnt_size + configSize);
   3625                 if (!my_ptr)
   3626                     return PVMFFailure;
   3627 
   3628                 my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >(my_ptr));
   3629                 my_ptr += aligned_refcnt_size;
   3630 
   3631                 OsclMemoryFragment memfrag;
   3632                 memfrag.len = (uint32)configSize;
   3633                 memfrag.ptr = my_ptr;
   3634 
   3635                 oscl_memcpy((void*)(memfrag.ptr), (const void*)config, memfrag.len);
   3636 
   3637                 OsclRefCounterMemFrag tmpRefcntMemFrag(memfrag, my_refcnt, memfrag.len);
   3638                 trackInfo.setTrackConfigInfo(tmpRefcntMemFrag);
   3639             }
   3640 
   3641             int32 dependsOnTrackID = mInfo->getDependsOnTrackID();
   3642 
   3643             if (dependsOnTrackID != -1)
   3644             {
   3645                 trackInfo.setDependsOn();
   3646                 mediaInfo* baseMediaInfo = sdpInfo->getMediaInfoBasedOnDependsOnID(dependsOnTrackID);
   3647                 if (baseMediaInfo == NULL)
   3648                 {
   3649                     return PVMFFailure;
   3650                 }
   3651                 trackInfo.addDependsOnTrackID(baseMediaInfo->getMediaInfoID());
   3652             }
   3653 
   3654             if (iAltType != PVMF_TRACK_ALTERNATE_TYPE_UNDEFINED)
   3655             {
   3656                 /* Expose alternate track ids */
   3657                 trackInfo.setTrackAlternates(iAltType);
   3658                 for (uint32 k = 0; k < minfoVecLen; k++)
   3659                 {
   3660                     mediaInfo* mInfo = mediaInfoVec[k];
   3661                     if (mInfo == NULL)
   3662                     {
   3663                         return PVMFFailure;
   3664                     }
   3665                     uint32 altID = mInfo->getMediaInfoID();
   3666                     if (altID != trackID)
   3667                     {
   3668                         trackInfo.addAlternateTrackID((int32)altID);
   3669                     }
   3670                 }
   3671             }
   3672             aInfo.addTrackInfo(trackInfo);
   3673         }
   3674     }
   3675     iCompleteMediaPresetationInfo = aInfo;
   3676     return PVMFSuccess;
   3677 }
   3678 
   3679 PVMFStatus PVMFSMRTSPUnicastNode::SelectTracks(PVMFMediaPresentationInfo& aInfo)
   3680 {
   3681     SDPInfo* sdpInfo = iSdpInfo.GetRep();
   3682     if (sdpInfo == NULL)
   3683     {
   3684         PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:SelectTracks - SDP Not Available"));
   3685         return PVMFErrArgument;
   3686     }
   3687 
   3688     int32 numTracks = aInfo.getNumTracks();
   3689 
   3690     for (int32 i = 0; i < numTracks; i++)
   3691     {
   3692         PVMFTrackInfo* trackInfo = aInfo.getTrackInfo(i);
   3693 
   3694         uint32 trackID = trackInfo->getTrackID();
   3695 
   3696         mediaInfo* mInfo =
   3697             sdpInfo->getMediaInfoBasedOnID(trackID);
   3698 
   3699         if (mInfo == NULL)
   3700         {
   3701             PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:SelectTracks - Invalid SDP TrackID"));
   3702             return PVMFErrArgument;
   3703         }
   3704 
   3705         mInfo->setSelect();
   3706 
   3707         /* Set selected field in meta info */
   3708         Oscl_Vector<PVMFSMTrackMetaDataInfo, OsclMemAllocator>::iterator it;
   3709         for (it = iMetaDataInfo->iTrackMetaDataInfoVec.begin(); it != iMetaDataInfo->iTrackMetaDataInfoVec.end(); it++)
   3710         {
   3711             if (it->iTrackID == trackID)
   3712             {
   3713                 it->iTrackSelected = true;
   3714             }
   3715         }
   3716     }
   3717     iSelectedMediaPresetationInfo = aInfo;
   3718     return PVMFSuccess;
   3719 }
   3720 
   3721 ///////////////////////////////////////////////////////////////////////////////
   3722 //Implementation of PVMFMetadataExtensionInterface
   3723 ///////////////////////////////////////////////////////////////////////////////
   3724 uint32 PVMFSMRTSPUnicastNode::GetNumMetadataKeys(char* aQueryKeyString)
   3725 {
   3726     //Metadata is avaialable in three forms
   3727     //1. Metadata common to streaming of all type of payloads and FF specific metadata
   3728     //2. Streaming specific metadata
   3729     //3. CPM metadata
   3730     //First two types are avaiable in iAvailableMetaDatakeys vector
   3731     //Third type can be had from metadataextension interface
   3732     //base class considers count of all of these
   3733     return PVMFSMFSPBaseNode::GetNumMetadataKeysBase(aQueryKeyString);
   3734 }
   3735 
   3736 uint32 PVMFSMRTSPUnicastNode::GetNumMetadataValues(PVMFMetadataList& aKeyList)
   3737 {
   3738     //Metadata is avaialable in three forms
   3739     //1. Metadata common to streaming of all type of payloads and FF specific metadata
   3740     //2. Streaming specific metadata
   3741     //3. CPM metadata
   3742     //First two types are avaiable in iAvailableMetaDatakeys vector
   3743     //Third type can be had from metadataextension interface
   3744     //Base class considers count of all of these
   3745     return PVMFSMFSPBaseNode::GetNumMetadataValuesBase(aKeyList);
   3746 }
   3747 
   3748 PVMFStatus PVMFSMRTSPUnicastNode::DoGetMetadataKeys(PVMFSMFSPBaseNodeCommand& aCmd)
   3749 {
   3750     return DoGetMetadataKeysBase(aCmd);
   3751 }
   3752 
   3753 PVMFStatus PVMFSMRTSPUnicastNode::GetRTSPPluginSpecificValues(PVMFSMFSPBaseNodeCommand& aCmd)
   3754 {
   3755     PVMFMetadataList* keylistptr = NULL;
   3756     Oscl_Vector<PvmiKvp, OsclMemAllocator>* valuelistptr = NULL;
   3757     uint32 starting_index;
   3758     int32 max_entries;
   3759 
   3760     aCmd.PVMFSMFSPBaseNodeCommand::Parse(keylistptr, valuelistptr, starting_index, max_entries);
   3761 
   3762     // Check the parameters
   3763     if (keylistptr == NULL || valuelistptr == NULL)
   3764     {
   3765         return PVMFErrArgument;
   3766     }
   3767 
   3768     uint32 numkeys = keylistptr->size();
   3769 
   3770     if (numkeys <= 0 || max_entries == 0)
   3771     {
   3772         // Don't do anything
   3773         return PVMFErrArgument;
   3774     }
   3775 
   3776     uint32 numvalentries = 0;
   3777     int32 numentriesadded = 0;
   3778 
   3779     for (uint32 lcv = 0; lcv < numkeys; lcv++)
   3780     {
   3781         PvmiKvp KeyVal;
   3782         KeyVal.key = NULL;
   3783         KeyVal.value.pWChar_value = NULL;
   3784         KeyVal.value.pChar_value = NULL;
   3785 
   3786         if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_PAUSE_DENIED_KEY) != NULL)
   3787         {
   3788             // Increment the counter for the number of values found so far
   3789             ++numvalentries;
   3790             // Create a value entry if past the starting index
   3791             if (numvalentries > starting_index)
   3792             {
   3793                 PVMFStatus retval = PVMFCreateKVPUtils::CreateKVPForBoolValue(KeyVal,
   3794                                     PVMFSTREAMINGMGRNODE_PAUSE_DENIED_KEY,
   3795                                     iPauseDenied);
   3796                 if (retval != PVMFSuccess && retval != PVMFErrArgument)
   3797                 {
   3798                     break;
   3799                 }
   3800             }
   3801         }
   3802 
   3803         /* Check if the max number of value entries were added */
   3804         if (max_entries > 0 && numentriesadded >= max_entries)
   3805         {
   3806             iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
   3807             return PVMFSuccess;
   3808         }
   3809 
   3810         // Add the KVP to the list if the key string was created
   3811         if (KeyVal.key != NULL)
   3812         {
   3813             if (PVMFSuccess != PushKVPToMetadataValueList(valuelistptr, KeyVal))
   3814             {
   3815                 switch (GetValTypeFromKeyString(KeyVal.key))
   3816                 {
   3817                     case PVMI_KVPVALTYPE_CHARPTR:
   3818                         if (KeyVal.value.pChar_value != NULL)
   3819                         {
   3820                             OSCL_ARRAY_DELETE(KeyVal.value.pChar_value);
   3821                             KeyVal.value.pChar_value = NULL;
   3822                         }
   3823                         break;
   3824 
   3825                     default:
   3826                         // Add more case statements if other value types are returned
   3827                         break;
   3828                 }
   3829 
   3830                 OSCL_ARRAY_DELETE(KeyVal.key);
   3831                 KeyVal.key = NULL;
   3832             }
   3833             else
   3834             {
   3835                 // Increment the counter for number of value entries added to the list
   3836                 ++numentriesadded;
   3837             }
   3838 
   3839             // Check if the max number of value entries were added
   3840             if (max_entries > 0 && numentriesadded >= max_entries)
   3841             {
   3842                 // Maximum number of values added so break out of the loop
   3843                 break;
   3844             }
   3845         }
   3846     }
   3847 
   3848     iNoOfValuesIteratedForValueVect = numvalentries;
   3849     iNoOfValuesPushedInValueVect = numentriesadded;
   3850 
   3851     iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
   3852     return PVMFSuccess;
   3853 }
   3854 
   3855 PVMFStatus PVMFSMRTSPUnicastNode::DoGetMetadataValues(PVMFSMFSPBaseNodeCommand& aCmd)
   3856 {
   3857     iNoOfValuesIteratedForValueVect = 0;
   3858     iNoOfValuesPushedInValueVect = 0;
   3859     PVMFStatus retval = GetRTSPPluginSpecificValues(aCmd);
   3860     if (PVMFSuccess != retval)
   3861         return retval;
   3862     return DoGetMetadataValuesBase(aCmd);
   3863 }
   3864 
   3865 PVMFStatus PVMFSMRTSPUnicastNode::ReleaseNodeMetadataKeys(PVMFMetadataList& aKeyList,
   3866         uint32 aStartingKeyIndex,
   3867         uint32 aEndKeyIndex)
   3868 {
   3869     //no allocation for any keys took in derived class so just calling base class release functions
   3870     return ReleaseNodeMetadataKeysBase(aKeyList, aStartingKeyIndex, aEndKeyIndex);
   3871 }
   3872 
   3873 PVMFStatus PVMFSMRTSPUnicastNode::ReleaseNodeMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList,
   3874         uint32 aStartingValueIndex,
   3875         uint32 aEndValueIndex)
   3876 {
   3877     //no allocation for any value in kvp took in derived class so just calling base class release functions
   3878     return ReleaseNodeMetadataValuesBase(aValueList, aStartingValueIndex, aEndValueIndex);
   3879 }
   3880 
   3881 void PVMFSMRTSPUnicastNode::DoSetDataSourcePosition(PVMFSMFSPBaseNodeCommand& aCmd)
   3882 {
   3883     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMFSPBaseNodeCommand::DoSetDataSourcePosition - In"));
   3884 
   3885     iActualRepositionStartNPTInMSPtr = NULL;
   3886     iActualMediaDataTSPtr = NULL;
   3887     iPVMFDataSourcePositionParamsPtr = NULL;
   3888     iJumpToIFrame = false;
   3889     uint32 streamID = 0;
   3890 
   3891     aCmd.PVMFSMFSPBaseNodeCommand::Parse(iRepositionRequestedStartNPTInMS,
   3892                                          iActualRepositionStartNPTInMSPtr,
   3893                                          iActualMediaDataTSPtr,
   3894                                          iJumpToIFrame,
   3895                                          streamID);
   3896 
   3897     PVMF_SM_RTSP_LOG_COMMAND_REPOS((0, "PVMFSMFSPBaseNodeCommand::DoSetDataSourcePosition - TargetNPT = %d", iRepositionRequestedStartNPTInMS));
   3898 
   3899     PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   3900         getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   3901     if (iJitterBufferNodeContainer == NULL)
   3902     {
   3903         OSCL_LEAVE(OsclErrBadHandle);
   3904         return;
   3905     }
   3906     PVMFJitterBufferExtensionInterface* jbExtIntf =
   3907         (PVMFJitterBufferExtensionInterface*)
   3908         (iJitterBufferNodeContainer->iExtensions[0]);
   3909 
   3910     *iActualRepositionStartNPTInMSPtr = 0;
   3911     *iActualMediaDataTSPtr = 0;
   3912 
   3913 
   3914     if ((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL) ||
   3915             (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
   3916     {
   3917         if (iInterfaceState == EPVMFNodePrepared)
   3918         {
   3919             iStreamID = streamID;
   3920             jbExtIntf->SendBOSMessage(iStreamID);
   3921 
   3922             bool oRandAccessDenied = true;
   3923 
   3924             sessionDescription* sessionInfo =
   3925                 iSdpInfo->getSessionInfo();
   3926             oRandAccessDenied = sessionInfo->getRandomAccessDenied();
   3927 
   3928             if ((oRandAccessDenied == true) ||
   3929                     (iSessionStopTimeAvailable == false) ||
   3930                     (((int32)iRepositionRequestedStartNPTInMS < (int32)iSessionStartTime) ||
   3931                      ((int32)iRepositionRequestedStartNPTInMS >= (int32)iSessionStopTime)))
   3932             {
   3933                 if (iRepositionRequestedStartNPTInMS == 0)
   3934                 {
   3935                     /* Implies that we are repositioning to zero, which is not a invalid request
   3936                      * so dont send PVMFErrNotSupported
   3937                      */
   3938                 }
   3939                 else
   3940                 {
   3941                     /*
   3942                      * Implies an open ended session or invalid request time
   3943                      * - no pause or reposition
   3944                      */
   3945                     CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
   3946                     return;
   3947                 }
   3948             }
   3949 
   3950             /*
   3951              * SetDataSource from a prepared state could mean two things:
   3952              *  - In Play-Stop-Play usecase engine does a SetDataSourcePosition
   3953              *    to get the start media TS to set its playback clock
   3954              *  - Engine is trying to do a play with a non-zero start offset
   3955              */
   3956             if (iRepositionRequestedStartNPTInMS < iSessionStopTime && iRepositionRequestedStartNPTInMS != iSessionStartTime)
   3957             {
   3958                 // we need to use part of the logic of repositioning to start
   3959                 // streaming from a non-zero offset. Enabled only for 3gpp streaming
   3960                 iRepositioning = true;
   3961                 /* Start the nodes */
   3962                 PVMFStatus status = DoRepositioningStart3GPPStreaming();
   3963                 if (PVMFSuccess != status)
   3964                 {
   3965                     CommandComplete(iInputCommands, aCmd, status);
   3966                     return;
   3967                 }
   3968 
   3969                 MoveCmdToCurrentQueue(aCmd);
   3970                 return;
   3971             }
   3972 
   3973             GetActualMediaTSAfterSeek();
   3974             PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::SetDataSourcePosition() - CmdComplete"));
   3975             CommandComplete(iInputCommands, aCmd, PVMFSuccess);
   3976         }
   3977         else if ((iInterfaceState == EPVMFNodeStarted) || (iInterfaceState == EPVMFNodePaused))
   3978         {
   3979             bool oRandAccessDenied = true;
   3980 
   3981             sessionDescription* sessionInfo =
   3982                 iSdpInfo->getSessionInfo();
   3983             oRandAccessDenied = sessionInfo->getRandomAccessDenied();
   3984 
   3985 
   3986             if (!CanPerformRepositioning(oRandAccessDenied))
   3987             {
   3988                 CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
   3989                 return;
   3990             }
   3991 
   3992             iStreamID = streamID;
   3993             jbExtIntf->SendBOSMessage(iStreamID);
   3994 
   3995             iRepositioning = true;
   3996 
   3997             /* Put the jitter buffer into a state of transition */
   3998             PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   3999                 getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   4000             if (iJitterBufferNodeContainer == NULL)
   4001             {
   4002                 OSCL_LEAVE(OsclErrBadHandle);
   4003                 return;
   4004             }
   4005             PVMFJitterBufferExtensionInterface* jbExtIntf =
   4006                 (PVMFJitterBufferExtensionInterface*)
   4007                 (iJitterBufferNodeContainer->iExtensions[0]);
   4008             jbExtIntf->PrepareForRepositioning();
   4009 
   4010             /* If node is running, pause first */
   4011             if (iInterfaceState == EPVMFNodeStarted)
   4012             {
   4013                 if (!DoRepositioningPause3GPPStreaming())
   4014                 {
   4015                     CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
   4016                 }
   4017             }
   4018             /* If already paused do not pause */
   4019             else if (iInterfaceState == EPVMFNodePaused)
   4020             {
   4021                 PVMFStatus status = DoRepositioningStart3GPPStreaming();
   4022                 if (PVMFSuccess != status)
   4023                 {
   4024                     CommandComplete(iInputCommands, aCmd, status);
   4025                 }
   4026             }
   4027             MoveCmdToCurrentQueue(aCmd);
   4028         }
   4029         else
   4030         {
   4031             CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
   4032             return;
   4033         }
   4034     }
   4035     else
   4036     {
   4037         PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::SetDataSourcePosition() - Cmd Failed - PVMFErrArgument"));
   4038         CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
   4039         return;
   4040     }
   4041     return;
   4042 }
   4043 
   4044 
   4045 
   4046 void PVMFSMRTSPUnicastNode::DoQueryDataSourcePosition(PVMFSMFSPBaseNodeCommand& aCmd)
   4047 {
   4048     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoQueryDataSourcePosition - In"));
   4049 
   4050     PVMFTimestamp repositionrequestedstartnptinms = 0;
   4051     PVMFTimestamp* actualrepositionstartnptinmsptr = NULL;
   4052     bool seektosyncpoint = false;
   4053 
   4054     aCmd.PVMFSMFSPBaseNodeCommand::Parse(repositionrequestedstartnptinms,
   4055                                          actualrepositionstartnptinmsptr,
   4056                                          seektosyncpoint);
   4057 
   4058     if (actualrepositionstartnptinmsptr == NULL)
   4059     {
   4060         CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
   4061         return;
   4062     }
   4063     *actualrepositionstartnptinmsptr = 0;
   4064 
   4065     // This query is not supported for streaming sessions
   4066     CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
   4067     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoQueryDataSourcePosition - Out"));
   4068     return;
   4069 }
   4070 
   4071 PVMFStatus PVMFSMRTSPUnicastNode::ComputeSkipTimeStamp(PVMFTimestamp aTargetNPT,
   4072         PVMFTimestamp aActualNPT,
   4073         PVMFTimestamp aActualMediaDataTS,
   4074         PVMFTimestamp& aSkipTimeStamp,
   4075         PVMFTimestamp& aStartNPT)
   4076 {
   4077     //for RTSP streaming we always start playback from aActualNPT
   4078     //by defintion aActualMediaDataTS is the timestamp that corresponds
   4079     //to aActualNPT
   4080     OSCL_UNUSED_ARG(aTargetNPT);
   4081     OSCL_UNUSED_ARG(aSkipTimeStamp);
   4082     OSCL_UNUSED_ARG(aStartNPT);
   4083     aSkipTimeStamp = aActualMediaDataTS;
   4084     aStartNPT = aActualNPT;
   4085     return PVMFSuccess;
   4086 }
   4087 
   4088 ///////////////////////////////////////////////////////////////////////////////
   4089 //Implementation of the virtual function declared in PVMFNodeCmdStatusObserver
   4090 ///////////////////////////////////////////////////////////////////////////////
   4091 void PVMFSMRTSPUnicastNode::NodeCommandCompleted(const PVMFCmdResp& aResponse)
   4092 {
   4093     PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::NodeCommandCompleted"));
   4094     bool performErrHandling = false;
   4095     HandleChildNodeCommandCompletion(aResponse, performErrHandling);
   4096     PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::NodeCommandCompleted - performErrHandling[%d]", performErrHandling));
   4097 
   4098     if (performErrHandling == true)
   4099     {
   4100         HandleError(aResponse);
   4101     }
   4102 
   4103     return;
   4104 }
   4105 
   4106 /**
   4107 retval: true - perform error handling based on response (if needed)
   4108 retval: false - do not perform error handling.Concrete implemenbtation of the FSP will take care of error handling
   4109 */
   4110 void PVMFSMRTSPUnicastNode::HandleChildNodeCommandCompletion(const PVMFCmdResp& aResponse, bool& aPerformErrHandling)
   4111 {
   4112     aPerformErrHandling = true;
   4113 
   4114     PVMFSMFSPCommandContext *cmdContextData =
   4115         OSCL_REINTERPRET_CAST(PVMFSMFSPCommandContext*, aResponse.GetContext());
   4116 
   4117     PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode:HandleChildNodeCommandCompletion: %d", cmdContextData->cmd));
   4118 
   4119     if ((cmdContextData->cmd >=
   4120             PVMF_SM_FSP_SOCKET_NODE_COMMAND_START) &&
   4121             (cmdContextData->cmd <
   4122              PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_COMMAND_START))
   4123 
   4124     {
   4125         HandleSocketNodeCommandCompleted(aResponse, aPerformErrHandling);
   4126     }
   4127     else if ((cmdContextData->cmd >=
   4128               PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_COMMAND_START) &&
   4129              (cmdContextData->cmd <
   4130               PVMF_SM_FSP_JITTER_BUFFER_CONTROLLER_COMMAND_START))
   4131 
   4132     {
   4133         HandleRTSPSessionControllerCommandCompleted(aResponse, aPerformErrHandling);
   4134     }
   4135     else if ((cmdContextData->cmd >=
   4136               PVMF_SM_FSP_JITTER_BUFFER_CONTROLLER_COMMAND_START) &&
   4137              (cmdContextData->cmd <
   4138               PVMF_SM_FSP_MEDIA_LAYER_COMMAND_START))
   4139 
   4140     {
   4141         HandleJitterBufferCommandCompleted(aResponse, aPerformErrHandling);
   4142     }
   4143     else if ((cmdContextData->cmd >=
   4144               PVMF_SM_FSP_MEDIA_LAYER_COMMAND_START) &&
   4145              (cmdContextData->cmd <
   4146               PVMF_SM_FSP_HTTP_SESSION_CONTROLLER_COMMAND_START))
   4147 
   4148     {
   4149         HandleMediaLayerCommandCompleted(aResponse, aPerformErrHandling);
   4150     }
   4151     else
   4152     {
   4153         OSCL_ASSERT(false);
   4154     }
   4155 
   4156 }
   4157 
   4158 void PVMFSMRTSPUnicastNode::HandleSocketNodeCommandCompleted(const PVMFCmdResp& aResponse, bool& aPerformErrHandling)
   4159 {
   4160     aPerformErrHandling = false;
   4161 
   4162     PVMFSMFSPChildNodeContainer* iSocketNodeContainer =
   4163         getChildNodeContainer(PVMF_SM_FSP_SOCKET_NODE);
   4164     if (iSocketNodeContainer == NULL)
   4165     {
   4166         OSCL_LEAVE(OsclErrBadHandle);
   4167         return;
   4168     }
   4169 
   4170     PVMFSMFSPCommandContext *cmdContextData =
   4171         OSCL_REINTERPRET_CAST(PVMFSMFSPCommandContext*, aResponse.GetContext());
   4172     cmdContextData->oFree = true;
   4173 
   4174     PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleSocketNodeCommandCompleted In - cmd [%d] iSocketNodeContainer->iNodeCmdState [%d] iInterfaceState[%d]", cmdContextData->cmd, iSocketNodeContainer->iNodeCmdState, iInterfaceState));
   4175 
   4176     //RTSPUNICAST plugin uses sync version of QueryInterface to get xtension interface of its various child nodes
   4177     //Also RTSPUNICAST plugin doesn t call QueryUUID on child node.
   4178     //So, command completion of async version of QueryUUID and QueryInterface from child node not expected.
   4179     OSCL_ASSERT(cmdContextData->cmd != PVMF_SM_FSP_SOCKET_NODE_QUERY_UUID);
   4180     OSCL_ASSERT(cmdContextData->cmd != PVMF_SM_FSP_SOCKET_NODE_QUERY_INTERFACE);
   4181 
   4182 
   4183 
   4184     if (iSocketNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_PENDING)
   4185     {
   4186         if (cmdContextData->cmd == PVMF_SM_FSP_SOCKET_NODE_REQUEST_PORT)
   4187         {
   4188             //This is last of the request ports
   4189             OSCL_ASSERT(iSocketNodeContainer->iNumRequestPortsPending > 0);
   4190             if (--iSocketNodeContainer->iNumRequestPortsPending == 0)
   4191             {
   4192                 iSocketNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
   4193             }
   4194         }
   4195         else
   4196         {
   4197             iSocketNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
   4198         }
   4199     }
   4200     else if (iSocketNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_CANCEL_PENDING)
   4201     {
   4202         if ((cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCELALLCOMMANDS) || (cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCELCOMMAND) || (cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCEL_DUE_TO_ERROR))
   4203         {
   4204             iSocketNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
   4205         }
   4206         else
   4207         {
   4208             PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleSocketNodeCommandCompleted cmd completion for cmd other than cancel during cancellation"));
   4209 
   4210             //if cancel is pending and if the parent cmd is not cancel then this is
   4211             //is most likely the cmd that is being cancelled.
   4212             //we ignore cmd completes from child nodes if cancel is pending
   4213             //we simply wait on cancel complete and cancel the pending cmd
   4214             return;
   4215         }
   4216     }
   4217     else if (iSocketNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_IDLE)
   4218     {
   4219         PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleSocketNodeCommandCompleted Nodecontainer state IDLE already!!!!!"));
   4220         /*
   4221          * This is to handle a usecase where a node reports cmd complete for cancelall first
   4222          * and then reports cmd complete on the cmd that was meant to be cancelled.
   4223          * There are two possible scenarios that could arise based on this:
   4224          * i) SM node has reported cmd complete on both canceall and the cmd meant to be cancelled
   4225          * to engine by the time cmd complete on the cmd that was meant to be cancelled arrives
   4226          * from the child node. In this case iNodeCmdState would be PVMFSMFSP_NODE_CMD_NO_PENDING.
   4227          * ii) SM node is still waiting on some other child nodes to complete cancelall.
   4228          * In this case iNodeCmdState would be PVMFSMFSP_NODE_CMD_IDLE.
   4229          * In either case iNodeCmdState cannot be PVMFSMFSP_NODE_CMD_PENDING or PVMFSMFSP_NODE_CMD_IDLE
   4230          * (recall that we call ResetNodeContainerCmdState  prior to issuing cancelall)
   4231          * Or this is the case of node reporting cmd complete multiple times for a cmd, which
   4232          * also can be ignored
   4233          */
   4234         return;
   4235     }
   4236 
   4237     if (EPVMFNodeError == iInterfaceState)//If interface is in err state, let the err handler do processing
   4238     {
   4239         aPerformErrHandling = true;
   4240         return;
   4241     }
   4242 
   4243     if (aResponse.GetCmdStatus() != PVMFSuccess)
   4244     {
   4245         if (aResponse.GetCmdStatus() != PVMFErrCancelled)
   4246         {
   4247             aPerformErrHandling = true;
   4248         }
   4249 
   4250         PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::HandleSocketNodeCommandCompleted - Command failed - context=0x%x, status=0x%x", aResponse.GetContext(), aResponse.GetCmdStatus()));
   4251         if (IsBusy())
   4252         {
   4253             Cancel();
   4254             RunIfNotReady();
   4255         }
   4256         return;
   4257     }
   4258 
   4259     switch (cmdContextData->cmd)
   4260     {
   4261         case PVMF_SM_FSP_SOCKET_NODE_INIT:
   4262         {
   4263             CompleteInit();
   4264         }
   4265         break;
   4266 
   4267         case PVMF_SM_FSP_SOCKET_NODE_PREPARE:
   4268         {
   4269             CompletePrepare();
   4270         }
   4271         break;
   4272 
   4273         case PVMF_SM_FSP_SOCKET_NODE_START:
   4274         {
   4275             CompleteStart();
   4276         }
   4277         break;
   4278 
   4279         case PVMF_SM_FSP_SOCKET_NODE_STOP:
   4280         {
   4281             CompleteStop();
   4282         }
   4283         break;
   4284 
   4285         case PVMF_SM_FSP_SOCKET_NODE_FLUSH:
   4286         {
   4287             CompleteFlush();
   4288         }
   4289         break;
   4290 
   4291         case PVMF_SM_FSP_SOCKET_NODE_PAUSE:
   4292         {
   4293             CompletePause();
   4294         }
   4295         break;
   4296 
   4297         case PVMF_SM_FSP_SOCKET_NODE_RESET:
   4298         {
   4299             CompleteReset();
   4300         }
   4301         break;
   4302 
   4303         case PVMF_SM_FSP_SOCKET_NODE_REQUEST_PORT:
   4304         {
   4305             PVMFPortInterface* port =
   4306                 (PVMFPortInterface*)aResponse.GetEventData();
   4307 
   4308             /*
   4309              * Save the port in TrackInfo
   4310              */
   4311             PVMFRTSPTrackInfo* trackInfo =
   4312                 FindTrackInfo(cmdContextData->portContext.trackID);
   4313             OSCL_ASSERT(trackInfo);
   4314             if (!trackInfo)
   4315                 return;
   4316             if (cmdContextData->portContext.portTag ==
   4317                     PVMF_SOCKET_NODE_PORT_TYPE_SOURCE)
   4318             {
   4319                 if (trackInfo)
   4320                     trackInfo->iNetworkNodePort = port;
   4321                 iSocketNodeContainer->iOutputPorts.push_back(port);
   4322             }
   4323             else if (cmdContextData->portContext.portTag ==
   4324                      PVMF_SOCKET_NODE_PORT_TYPE_SINK)
   4325             {
   4326                 if (trackInfo)
   4327                     trackInfo->iNetworkNodeRTCPPort = port;
   4328                 iSocketNodeContainer->iInputPorts.push_back(port);
   4329             }
   4330             CompleteGraphConstruct();
   4331         }
   4332         break;
   4333         case PVMF_SM_FSP_SOCKET_NODE_CANCEL_ALL_COMMANDS:
   4334         {
   4335             CompleteChildNodesCmdCancellation();
   4336         }
   4337         break;
   4338 
   4339         default:
   4340             break;
   4341     }
   4342     return;
   4343 }
   4344 
   4345 void PVMFSMRTSPUnicastNode::HandleRTSPSessionControllerCommandCompleted(const PVMFCmdResp& aResponse,
   4346         bool& aPerformErrHandling)
   4347 {
   4348     aPerformErrHandling = false;
   4349 
   4350     PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
   4351         getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
   4352     if (iSessionControllerNodeContainer == NULL)
   4353     {
   4354         OSCL_LEAVE(OsclErrBadHandle);
   4355         return;
   4356     }
   4357 
   4358     PVMFSMFSPCommandContext *cmdContextData =
   4359         OSCL_REINTERPRET_CAST(PVMFSMFSPCommandContext*, aResponse.GetContext());
   4360     cmdContextData->oFree = true;
   4361 
   4362 
   4363     PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleRTSPSessionControllerCommandCompleted In - cmd [%d] iSessionControllerNodeContainer->iNodeCmdState [%d] iInterfaceState[%d]", cmdContextData->cmd, iSessionControllerNodeContainer->iNodeCmdState, iInterfaceState));
   4364 
   4365     //RTSPPLUSUNICAST plugin uses sync version of QueryInterface to get xtension interface of its various child nodes
   4366     //Also RTSPPLUSUNICAST plugin doesn t call QueryUUID on child node.
   4367     //So, command completion of async version of QueryUUID and QueryInterface from child node not expected.
   4368     OSCL_ASSERT(cmdContextData->cmd != PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_QUERY_UUID);
   4369     OSCL_ASSERT(cmdContextData->cmd != PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_QUERY_INTERFACE);
   4370 
   4371     if (iSessionControllerNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_PENDING)
   4372     {
   4373         if (cmdContextData->cmd == PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_REQUEST_PORT)
   4374         {
   4375             //This is last of the request ports
   4376             OSCL_ASSERT(iSessionControllerNodeContainer->iNumRequestPortsPending > 0);
   4377             if (--iSessionControllerNodeContainer->iNumRequestPortsPending == 0)
   4378             {
   4379                 iSessionControllerNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
   4380             }
   4381         }
   4382         else
   4383         {
   4384             iSessionControllerNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
   4385         }
   4386     }
   4387     else if (iSessionControllerNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_CANCEL_PENDING)
   4388     {
   4389         if ((cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCELALLCOMMANDS) || (cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCELCOMMAND) || (cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCEL_DUE_TO_ERROR))
   4390         {
   4391             iSessionControllerNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
   4392         }
   4393         else
   4394         {
   4395             PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleRTSPSessionControllerCommandCompleted cmd completion for cmd other than cancel during cancellation"));
   4396 
   4397             //if cancel is pending and if the parent cmd is not cancel then this is
   4398             //is most likely the cmd that is being cancelled.
   4399             //we ignore cmd completes from child nodes if cancel is pending
   4400             //we simply wait on cancel complete and cancel the pending cmd
   4401             return;
   4402         }
   4403     }
   4404     else if (iSessionControllerNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_IDLE)
   4405     {
   4406         PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleRTSPSessionControllerCommandCompleted Container in IDLE state already"));
   4407         /*
   4408          * This is to handle a usecase where a node reports cmd complete for cancelall first
   4409          * and then reports cmd complete on the cmd that was meant to be cancelled.
   4410          * There are two possible scenarios that could arise based on this:
   4411          * i) SM node has reported cmd complete on both canceall and the cmd meant to be cancelled
   4412          * to engine by the time cmd complete on the cmd that was meant to be cancelled arrives
   4413          * from the child node. In this case iNodeCmdState would be PVMFSMFSP_NODE_CMD_NO_PENDING.
   4414          * ii) SM node is still waiting on some other child nodes to complete cancelall.
   4415          * In this case iNodeCmdState would be PVMFSMFSP_NODE_CMD_IDLE.
   4416          * In either case iNodeCmdState cannot be PVMFSMFSP_NODE_CMD_PENDING or PVMFSMFSP_NODE_CMD_IDLE
   4417          * (recall that we call ResetNodeContainerCmdState  prior to issuing cancelall)
   4418          * Or this is the case of node reporting cmd complete multiple times for a cmd, which
   4419          * also can be ignored
   4420          */
   4421         return;
   4422     }
   4423 
   4424     if (EPVMFNodeError == iInterfaceState)//If interface is in err state, let the err handler do processing
   4425     {
   4426         aPerformErrHandling = true;
   4427         return;
   4428     }
   4429     if (aResponse.GetCmdStatus() != PVMFSuccess)
   4430     {
   4431         if (aResponse.GetCmdStatus() != PVMFErrCancelled)
   4432         {
   4433             aPerformErrHandling = true;
   4434         }
   4435         if ((cmdContextData->cmd == PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_PAUSE) ||
   4436                 (cmdContextData->cmd == PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_STOP))
   4437         {
   4438             /*
   4439              * Check if it is a pause/stop  failure - suppress pause/stop failures if they
   4440              * happen after a session is complete
   4441              */
   4442             PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   4443                 getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   4444             if (iJitterBufferNodeContainer == NULL)
   4445             {
   4446                 OSCL_LEAVE(OsclErrBadHandle);
   4447                 return;
   4448             }
   4449             PVMFJitterBufferExtensionInterface* jbExtIntf =
   4450                 (PVMFJitterBufferExtensionInterface*)
   4451                 (iJitterBufferNodeContainer->iExtensions[0]);
   4452             bool oSessionExpired = false;
   4453             jbExtIntf->HasSessionDurationExpired(oSessionExpired);
   4454             if (oSessionExpired == true)
   4455             {
   4456                 aPerformErrHandling = false;
   4457             }
   4458         }
   4459         /* if a failure has been overridden just fall thru */
   4460         if (aPerformErrHandling == true)
   4461         {
   4462             PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::HandleRTSPSessionControllerCommandCompleted - Command failed - context=0x%x, status=0x%x", aResponse.GetContext(), aResponse.GetCmdStatus()));
   4463             if (IsBusy())
   4464             {
   4465                 Cancel();
   4466                 RunIfNotReady();
   4467             }
   4468             return;
   4469         }
   4470     }
   4471 
   4472     switch (cmdContextData->cmd)
   4473     {
   4474         case PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_INIT:
   4475             CompleteInit();
   4476             break;
   4477 
   4478         case PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_PREPARE:
   4479         {
   4480             /* Complete set up of feedback channels */
   4481             CompleteFeedBackPortsSetup();
   4482             /*
   4483              * Send start complete params to child nodes
   4484              * viz. SSRC etc
   4485              */
   4486             SendSessionControlPrepareCompleteParams();
   4487             CompletePrepare();
   4488         }
   4489         break;
   4490 
   4491         case PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_START:
   4492         {
   4493             /*
   4494              * Send start complete params to child nodes
   4495              * viz. actual play range, rtp info params etc
   4496              */
   4497             SendSessionControlStartCompleteParams();
   4498             /* We should resume output of JB has it been paused */
   4499             for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
   4500             {
   4501                 if (iFSPChildNodeContainerVec[i].iNodeTag == PVMF_SM_FSP_JITTER_BUFFER_NODE &&
   4502                         iFSPChildNodeContainerVec[i].iNodeCmdState == PVMFSMFSP_NODE_CMD_IDLE)
   4503                 {
   4504                     PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer = getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   4505                     if (iJitterBufferNodeContainer == NULL)
   4506                     {
   4507                         OSCL_LEAVE(OsclErrBadHandle);
   4508                         return;
   4509                     }
   4510                     PVMFJitterBufferExtensionInterface* jbExtIntf =
   4511                         (PVMFJitterBufferExtensionInterface*)(iJitterBufferNodeContainer->iExtensions[0]);
   4512                     jbExtIntf->StartOutputPorts();
   4513                 }
   4514             }
   4515             CompleteStart();
   4516         }
   4517         break;
   4518 
   4519         case PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_STOP:
   4520         {
   4521             CompleteStop();
   4522         }
   4523         break;
   4524 
   4525         case PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_FLUSH:
   4526             CompleteFlush();
   4527             break;
   4528 
   4529         case PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_PAUSE:
   4530         {
   4531             CompletePause();
   4532         }
   4533         break;
   4534 
   4535         case PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_RESET:
   4536             CompleteReset();
   4537             break;
   4538 
   4539         case PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_REQUEST_PORT:
   4540         {
   4541             /*
   4542              * Save the port in TrackInfo
   4543              */
   4544             PVMFRTSPTrackInfo* trackInfo =
   4545                 FindTrackInfo(cmdContextData->portContext.trackID);
   4546             OSCL_ASSERT(trackInfo);
   4547 
   4548             PVMFPortInterface* port =
   4549                 (PVMFPortInterface*)aResponse.GetEventData();
   4550 
   4551             if (cmdContextData->portContext.portTag ==
   4552                     PVMF_RTSP_NODE_PORT_TYPE_OUTPUT)
   4553             {
   4554                 if (trackInfo)
   4555                     trackInfo->iSessionControllerOutputPort = port;
   4556                 iSessionControllerNodeContainer->iOutputPorts.push_back(port);
   4557             }
   4558             else if (cmdContextData->portContext.portTag ==
   4559                      PVMF_RTSP_NODE_PORT_TYPE_INPUT)
   4560             {
   4561                 iSessionControllerNodeContainer->iInputPorts.push_back(port);
   4562             }
   4563             else if (cmdContextData->portContext.portTag ==
   4564                      PVMF_RTSP_NODE_PORT_TYPE_INPUT_OUTPUT)
   4565             {
   4566                 if (trackInfo)
   4567                     trackInfo->iSessionControllerFeedbackPort = port;
   4568                 iSessionControllerNodeContainer->iFeedBackPorts.push_back(port);
   4569             }
   4570             CompleteGraphConstruct();
   4571         }
   4572         break;
   4573 
   4574         case PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_CANCEL_ALL_COMMANDS:
   4575         {
   4576             CompleteChildNodesCmdCancellation();
   4577         }
   4578         break;
   4579 
   4580         default:
   4581             break;
   4582     }
   4583     return;
   4584 }
   4585 
   4586 void PVMFSMRTSPUnicastNode::HandleJitterBufferCommandCompleted(const PVMFCmdResp& aResponse, bool& aPerformErrHandling)
   4587 {
   4588     aPerformErrHandling = false;
   4589     PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   4590         getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   4591     if (iJitterBufferNodeContainer == NULL)
   4592     {
   4593         OSCL_LEAVE(OsclErrBadHandle);
   4594         return;
   4595     }
   4596 
   4597     PVMFSMFSPCommandContext *cmdContextData =
   4598         OSCL_REINTERPRET_CAST(PVMFSMFSPCommandContext*, aResponse.GetContext());
   4599     cmdContextData->oFree = true;
   4600 
   4601     PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleJitterBufferCommandCompleted In - cmd [%d] iJitterBufferNodeContainer->iNodeCmdState [%d] iInterfaceState[%d]", cmdContextData->cmd, iJitterBufferNodeContainer->iNodeCmdState, iInterfaceState));
   4602 
   4603     OSCL_ASSERT(cmdContextData->cmd != PVMF_SM_FSP_JITTER_BUFFER_QUERY_UUID);
   4604     OSCL_ASSERT(cmdContextData->cmd != PVMF_SM_FSP_JITTER_BUFFER_QUERY_INTERFACE);
   4605 
   4606 
   4607     if (iJitterBufferNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_PENDING)
   4608     {
   4609         if (cmdContextData->cmd == PVMF_SM_FSP_JITTER_BUFFER_REQUEST_PORT)
   4610         {
   4611             //This is last of the request ports
   4612             OSCL_ASSERT(iJitterBufferNodeContainer->iNumRequestPortsPending > 0);
   4613             if (--iJitterBufferNodeContainer->iNumRequestPortsPending == 0)
   4614             {
   4615                 iJitterBufferNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
   4616             }
   4617         }
   4618         else
   4619         {
   4620             iJitterBufferNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
   4621         }
   4622     }
   4623     else if (iJitterBufferNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_CANCEL_PENDING)
   4624     {
   4625         if ((cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCELALLCOMMANDS) || (cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCELCOMMAND) || (cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCEL_DUE_TO_ERROR))
   4626         {
   4627             iJitterBufferNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
   4628         }
   4629         else
   4630         {
   4631             PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleJitterBufferCommandCompleted cmd completion for cmd other than cancel during cancellation"));
   4632             //if cancel is pending and if the parent cmd is not cancel then this is
   4633             //is most likely the cmd that is being cancelled.
   4634             //we ignore cmd completes from child nodes if cancel is pending
   4635             //we simply wait on cancel complete and cancel the pending cmd
   4636             return;
   4637         }
   4638     }
   4639     else if (iJitterBufferNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_IDLE)
   4640     {
   4641         PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleJitterBufferCommandCompleted cmd container in IDLE state already"));
   4642         /*
   4643          * This is to handle a usecase where a node reports cmd complete for cancelall first
   4644          * and then reports cmd complete on the cmd that was meant to be cancelled.
   4645          * There are two possible scenarios that could arise based on this:
   4646          * i) SM node has reported cmd complete on both canceall and the cmd meant to be cancelled
   4647          * to engine by the time cmd complete on the cmd that was meant to be cancelled arrives
   4648          * from the child node. In this case iNodeCmdState would be PVMFSMFSP_NODE_CMD_NO_PENDING.
   4649          * ii) SM node is still waiting on some other child nodes to complete cancelall.
   4650          * In this case iNodeCmdState would be PVMFSMFSP_NODE_CMD_IDLE.
   4651          * In either case iNodeCmdState cannot be PVMFSMFSP_NODE_CMD_PENDING or PVMFSMFSP_NODE_CMD_IDLE
   4652          * (recall that we call ResetNodeContainerCmdState  prior to issuing cancelall)
   4653          * Or this is the case of node reporting cmd complete multiple times for a cmd, which
   4654          * also can be ignored
   4655          */
   4656         return;
   4657     }
   4658 
   4659     if (EPVMFNodeError == iInterfaceState)//If interface is in err state, let the err handler do processing
   4660     {
   4661         aPerformErrHandling = true;
   4662         return;
   4663     }
   4664 
   4665     if (aResponse.GetCmdStatus() != PVMFSuccess)
   4666     {
   4667         if (aResponse.GetCmdStatus() != PVMFErrCancelled)
   4668         {
   4669             aPerformErrHandling = true;
   4670         }
   4671 
   4672         PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::HandleJitterBufferCommandCompleted - Command failed - context=0x%x, status=0x%x", aResponse.GetContext(), aResponse.GetCmdStatus()));
   4673         if (IsBusy())
   4674         {
   4675             Cancel();
   4676             RunIfNotReady();
   4677         }
   4678         return;
   4679     }
   4680 
   4681     switch (cmdContextData->cmd)
   4682     {
   4683         case PVMF_SM_FSP_JITTER_BUFFER_INIT:
   4684         {
   4685             PVMFJitterBufferExtensionInterface* jbExtIntf =
   4686                 (PVMFJitterBufferExtensionInterface*)
   4687                 (iJitterBufferNodeContainer->iExtensions[0]);
   4688             if (jbExtIntf == NULL)
   4689             {
   4690                 OSCL_LEAVE(OsclErrBadHandle);
   4691                 return;
   4692             }
   4693             bool disableFireWallPackets = true;
   4694             if ((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL) ||
   4695                     (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
   4696             {
   4697 
   4698 
   4699                 //do not disable fw pkts run time
   4700                 //apps can still disable it compile time or using KVP
   4701                 //for UDP sessions ofcourse
   4702                 disableFireWallPackets = false;
   4703 
   4704             }
   4705             CompleteInit();
   4706         }
   4707         break;
   4708 
   4709         case PVMF_SM_FSP_JITTER_BUFFER_PREPARE:
   4710             CompletePrepare();
   4711             break;
   4712 
   4713         case PVMF_SM_FSP_JITTER_BUFFER_START:
   4714         {
   4715             /* If start has been cancelled wait for cancel success */
   4716             if (aResponse.GetCmdStatus() != PVMFErrCancelled)
   4717             {
   4718                 /* We need to pause output of JB before RTSP response is received */
   4719                 for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
   4720                 {
   4721                     if (iFSPChildNodeContainerVec[i].iNodeTag == PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE &&
   4722                             iFSPChildNodeContainerVec[i].iNodeCmdState == PVMFSMFSP_NODE_CMD_PENDING)
   4723                     {
   4724                         PVMFJitterBufferExtensionInterface* jbExtIntf =
   4725                             (PVMFJitterBufferExtensionInterface*)(iJitterBufferNodeContainer->iExtensions[0]);
   4726                         jbExtIntf->StopOutputPorts();
   4727                         PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::HandleJitterBufferCommandCompleted - StopOutputPorts()"));
   4728                     }
   4729                 }
   4730                 CompleteStart();
   4731             }
   4732         }
   4733         break;
   4734 
   4735         case PVMF_SM_FSP_JITTER_BUFFER_STOP:
   4736         {
   4737             CompleteStop();
   4738         }
   4739         break;
   4740 
   4741         case PVMF_SM_FSP_JITTER_BUFFER_FLUSH:
   4742             CompleteFlush();
   4743             break;
   4744 
   4745         case PVMF_SM_FSP_JITTER_BUFFER_PAUSE:
   4746             CompletePause();
   4747             break;
   4748 
   4749         case PVMF_SM_FSP_JITTER_BUFFER_RESET:
   4750             CompleteReset();
   4751             break;
   4752 
   4753         case PVMF_SM_FSP_JITTER_BUFFER_REQUEST_PORT:
   4754         {
   4755             PVMFJitterBufferExtensionInterface* jbExtIntf =
   4756                 (PVMFJitterBufferExtensionInterface*)
   4757                 (iJitterBufferNodeContainer->iExtensions[0]);
   4758 
   4759             if (jbExtIntf == NULL)
   4760             {
   4761                 OSCL_LEAVE(OsclErrBadHandle);
   4762                 return;
   4763             }
   4764 
   4765             /*
   4766              * Save the port in TrackInfo
   4767              */
   4768             PVMFRTSPTrackInfo* trackInfo =
   4769                 FindTrackInfo(cmdContextData->portContext.trackID);
   4770 
   4771             OSCL_ASSERT(trackInfo);
   4772 
   4773             PVMFPortInterface* port =
   4774                 (PVMFPortInterface*)aResponse.GetEventData();
   4775 
   4776             uint32 bitrate = 0;
   4777 
   4778             if (cmdContextData->portContext.portTag ==
   4779                     PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
   4780             {
   4781                 if (trackInfo)
   4782                 {
   4783                     bitrate = trackInfo->bitRate;
   4784                     trackInfo->iJitterBufferInputPort = port;
   4785                 }
   4786                 iJitterBufferNodeContainer->iInputPorts.push_back(port);
   4787             }
   4788             else if (cmdContextData->portContext.portTag ==
   4789                      PVMF_JITTER_BUFFER_PORT_TYPE_OUTPUT)
   4790             {
   4791                 if (trackInfo)
   4792                     trackInfo->iJitterBufferOutputPort = port;
   4793                 iJitterBufferNodeContainer->iOutputPorts.push_back(port);
   4794             }
   4795             else if (cmdContextData->portContext.portTag ==
   4796                      PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK)
   4797             {
   4798                 iJitterBufferNodeContainer->iFeedBackPorts.push_back(port);
   4799                 if (trackInfo)
   4800                 {
   4801                     trackInfo->iJitterBufferRTCPPort = port;
   4802                     if (trackInfo->iRTCPBwSpecified)
   4803                     {
   4804                         jbExtIntf->setPortRTCPParams(port, iTrackInfoVec.size(), trackInfo->iRR, trackInfo->iRS);
   4805                     }
   4806                 }
   4807 
   4808             }
   4809             jbExtIntf->setPortParams(port,
   4810                                      trackInfo->trackTimeScale,
   4811                                      bitrate,
   4812                                      trackInfo->iTrackConfig,
   4813                                      trackInfo->iRateAdaptation,
   4814                                      trackInfo->iRateAdaptationFeedBackFrequency);
   4815             CompleteGraphConstruct();
   4816         }
   4817         break;
   4818 
   4819         case PVMF_SM_FSP_JITTER_BUFFER_CANCEL_ALL_COMMANDS:
   4820         {
   4821             CompleteChildNodesCmdCancellation();
   4822         }
   4823         break;
   4824 
   4825         default:
   4826             break;
   4827     }
   4828     return;
   4829 }
   4830 
   4831 void PVMFSMRTSPUnicastNode::HandleMediaLayerCommandCompleted(const PVMFCmdResp& aResponse, bool& aPerformErrHandling)
   4832 {
   4833     aPerformErrHandling = false;
   4834     PVMFSMFSPChildNodeContainer* iMediaLayerNodeContainer =
   4835         getChildNodeContainer(PVMF_SM_FSP_MEDIA_LAYER_NODE);
   4836     if (iMediaLayerNodeContainer == NULL)
   4837     {
   4838         OSCL_LEAVE(OsclErrBadHandle);
   4839         return;
   4840     }
   4841 
   4842     PVMFSMFSPCommandContext *cmdContextData =
   4843         OSCL_REINTERPRET_CAST(PVMFSMFSPCommandContext*, aResponse.GetContext());
   4844     cmdContextData->oFree = true;
   4845 
   4846     PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleMediaLayerCommandCompleted In - cmd [%d] iMediaLayerNodeContainer->iNodeCmdState [%d] iInterfaceState[%d]", cmdContextData->cmd, iMediaLayerNodeContainer->iNodeCmdState, iInterfaceState));
   4847     OSCL_ASSERT(cmdContextData->cmd != PVMF_SM_FSP_MEDIA_LAYER_QUERY_UUID);
   4848     OSCL_ASSERT(cmdContextData->cmd != PVMF_SM_FSP_MEDIA_LAYER_QUERY_INTERFACE);
   4849 
   4850     if (iMediaLayerNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_PENDING)
   4851     {
   4852         if (cmdContextData->cmd == PVMF_SM_FSP_MEDIA_LAYER_REQUEST_PORT)
   4853         {
   4854             //This is last of the request ports
   4855             OSCL_ASSERT(iMediaLayerNodeContainer->iNumRequestPortsPending > 0);
   4856             if (--iMediaLayerNodeContainer->iNumRequestPortsPending == 0)
   4857             {
   4858                 iMediaLayerNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
   4859             }
   4860         }
   4861         else
   4862         {
   4863             iMediaLayerNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
   4864         }
   4865     }
   4866     else if (iMediaLayerNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_CANCEL_PENDING)
   4867     {
   4868         if ((cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCELALLCOMMANDS) || (cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCELCOMMAND) || (cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCEL_DUE_TO_ERROR))
   4869         {
   4870             iMediaLayerNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
   4871         }
   4872         else
   4873         {
   4874             PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleMediaLayerCommandCompleted cmd completion for cmd other than cancel during cancellation"));
   4875             //if cancel is pending and if the parent cmd is not cancel then this is
   4876             //is most likely the cmd that is being cancelled.
   4877             //we ignore cmd completes from child nodes if cancel is pending
   4878             //we simply wait on cancel complete and cancel the pending cmd
   4879             return;
   4880         }
   4881     }
   4882     else if (iMediaLayerNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_IDLE)
   4883     {
   4884         PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleMediaLayerCommandCompleted container in IDLE state already"));
   4885         /*
   4886          * This is to handle a usecase where a node reports cmd complete for cancelall first
   4887          * and then reports cmd complete on the cmd that was meant to be cancelled.
   4888          * There are two possible scenarios that could arise based on this:
   4889          * i) SM node has reported cmd complete on both canceall and the cmd meant to be cancelled
   4890          * to engine by the time cmd complete on the cmd that was meant to be cancelled arrives
   4891          * from the child node. In this case iNodeCmdState would be PVMFSMFSP_NODE_CMD_NO_PENDING.
   4892          * ii) SM node is still waiting on some other child nodes to complete cancelall.
   4893          * In this case iNodeCmdState would be PVMFSMFSP_NODE_CMD_IDLE.
   4894          * In either case iNodeCmdState cannot be PVMFSMFSP_NODE_CMD_PENDING or PVMFSMFSP_NODE_CMD_IDLE
   4895          * (recall that we call ResetNodeContainerCmdState  prior to issuing cancelall)
   4896          * Or this is the case of node reporting cmd complete multiple times for a cmd, which
   4897          * also can be ignored
   4898          */
   4899         return;
   4900     }
   4901     if (EPVMFNodeError == iInterfaceState)//If interface is in err state, let the err handler do processing
   4902     {
   4903         aPerformErrHandling = true;
   4904         return;
   4905     }
   4906 
   4907     if (aResponse.GetCmdStatus() != PVMFSuccess)
   4908     {
   4909         if (aResponse.GetCmdStatus() != PVMFErrCancelled)
   4910         {
   4911             aPerformErrHandling = true;
   4912         }
   4913 
   4914         PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::HandleMediaLayerCommandCompleted - Command failed - context=0x%x, status=0x%x", aResponse.GetContext(), aResponse.GetCmdStatus()));
   4915         if (IsBusy())
   4916         {
   4917             Cancel();
   4918             RunIfNotReady();
   4919         }
   4920         return;
   4921     }
   4922 
   4923     switch (cmdContextData->cmd)
   4924     {
   4925         case PVMF_SM_FSP_MEDIA_LAYER_INIT:
   4926             CompleteInit();
   4927             break;
   4928 
   4929         case PVMF_SM_FSP_MEDIA_LAYER_PREPARE:
   4930             CompletePrepare();
   4931             break;
   4932 
   4933         case PVMF_SM_FSP_MEDIA_LAYER_START:
   4934         {
   4935             CompleteStart();
   4936         }
   4937         break;
   4938 
   4939         case PVMF_SM_FSP_MEDIA_LAYER_STOP:
   4940         {
   4941             CompleteStop();
   4942         }
   4943         break;
   4944 
   4945         case PVMF_SM_FSP_MEDIA_LAYER_FLUSH:
   4946             CompleteFlush();
   4947             break;
   4948 
   4949         case PVMF_SM_FSP_MEDIA_LAYER_PAUSE:
   4950             CompletePause();
   4951             break;
   4952 
   4953         case PVMF_SM_FSP_MEDIA_LAYER_RESET:
   4954             CompleteReset();
   4955             break;
   4956 
   4957         case PVMF_SM_FSP_MEDIA_LAYER_REQUEST_PORT:
   4958         {
   4959             PVMFMediaLayerNodeExtensionInterface* mlExtIntf =
   4960                 (PVMFMediaLayerNodeExtensionInterface*)
   4961                 (iMediaLayerNodeContainer->iExtensions[0]);
   4962 
   4963             if (mlExtIntf == NULL)
   4964             {
   4965                 OSCL_LEAVE(OsclErrBadHandle);
   4966                 return;
   4967             }
   4968 
   4969             /*
   4970              * Save the port in TrackInfo
   4971              */
   4972             PVMFRTSPTrackInfo* trackInfo =
   4973                 FindTrackInfo(cmdContextData->portContext.trackID);
   4974 
   4975             PVMFPortInterface* port =
   4976                 (PVMFPortInterface*)aResponse.GetEventData();
   4977             OSCL_ASSERT(trackInfo && port);
   4978 
   4979             if (cmdContextData->portContext.portTag ==
   4980                     PVMF_MEDIALAYER_PORT_TYPE_INPUT)
   4981             {
   4982                 if (trackInfo)
   4983                     trackInfo->iMediaLayerInputPort = port;
   4984                 iMediaLayerNodeContainer->iInputPorts.push_back(port);
   4985             }
   4986             else if (cmdContextData->portContext.portTag ==
   4987                      PVMF_MEDIALAYER_PORT_TYPE_OUTPUT)
   4988             {
   4989                 if (trackInfo)
   4990                     trackInfo->iMediaLayerOutputPort = port;
   4991                 iMediaLayerNodeContainer->iOutputPorts.push_back(port);
   4992                 uint32 preroll32 = 0;
   4993                 const bool live = false;
   4994                 mlExtIntf->setOutPortStreamParams(port,
   4995                                                   cmdContextData->portContext.trackID,
   4996                                                   preroll32,
   4997                                                   live);
   4998             }
   4999             mediaInfo* mInfo = NULL;
   5000 
   5001             SDPInfo* sdpInfo = iSdpInfo.GetRep();
   5002             if (sdpInfo == NULL)
   5003             {
   5004                 OSCL_LEAVE(OsclErrBadHandle);
   5005                 return;
   5006             }
   5007             if (trackInfo)
   5008                 mInfo = sdpInfo->getMediaInfoBasedOnID(trackInfo->trackID);
   5009             mlExtIntf->setPortMediaParams(port, trackInfo->iTrackConfig, mInfo);
   5010             CompleteGraphConstruct();
   5011         }
   5012         break;
   5013 
   5014         case PVMF_SM_FSP_MEDIA_LAYER_CANCEL_ALL_COMMANDS:
   5015         {
   5016             CompleteChildNodesCmdCancellation();
   5017         }
   5018         break;
   5019 
   5020         default:
   5021             break;
   5022     }
   5023     return;
   5024 }
   5025 
   5026 void PVMFSMRTSPUnicastNode::CompleteInit()
   5027 {
   5028     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::CompleteInit - In"));
   5029     if (CheckChildrenNodesInit())
   5030     {
   5031         if (!iCurrentCommand.empty() && iCancelCommand.empty())
   5032         {
   5033             PVMFSMFSPBaseNodeCommand& aCmd = iCurrentCommand.front();
   5034             if (aCmd.iCmd == PVMF_SMFSP_NODE_INIT)
   5035             {
   5036                 PVMFStatus status = PVMFSuccess;
   5037 
   5038                 if ((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL))
   5039                 {
   5040                     status = ProcessSDP();
   5041                 }
   5042 
   5043                 if (status == PVMFSuccess)
   5044                 {
   5045                     status = InitMetaData();
   5046                     if (status == PVMFSuccess)
   5047                     {
   5048                         if (iSessionSourceInfo->iDRMProtected == true)
   5049                         {
   5050                             PopulateDRMInfo();
   5051                             //This clip is protected clip
   5052                             if (iCPM)
   5053                             {
   5054                                 /*
   5055                                  * Go thru CPM commands before parsing the file in case
   5056                                  * of a new source file.
   5057                                  * - Init CPM
   5058                                  * - Open Session
   5059                                  * - Register Content
   5060                                  * - Get Content Type
   5061                                  * - Approve Usage
   5062                                  * In case the source file has already been parsed skip to
   5063                                  * - Approve Usage
   5064                                  */
   5065                                 InitCPM();
   5066                                 return;
   5067                             }
   5068                             else
   5069                             {
   5070                                 PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::Init() - CmdComplete - PVMFErrArgument"));
   5071                                 CommandComplete(iCurrentCommand,
   5072                                                 iCurrentCommand.front(),
   5073                                                 PVMFErrArgument,
   5074                                                 NULL, NULL, NULL);
   5075                                 return;
   5076                             }
   5077                         }
   5078                     }
   5079                     else
   5080                     {
   5081                         PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::CompleteInit - InitMetaData fail"));
   5082                     }
   5083 
   5084                     PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::Init() - CmdComplete - PVMFSuccess"));
   5085                     //Init is completed at unprotected clip
   5086                     SetState(EPVMFNodeInitialized);
   5087                     PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::CompleteInit Success"));
   5088                     CommandComplete(iCurrentCommand, aCmd, PVMFSuccess);
   5089                 }
   5090                 else
   5091                 {
   5092                     PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::Init() - Cmd Failed - PVMFStreamingManagerNodeErrorParseSDPFailed"));
   5093                     PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::CompleteInit Failure"));
   5094                     PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
   5095                     int32 errcode = PVMFStreamingManagerNodeErrorParseSDPFailed;
   5096                     CommandComplete(iCurrentCommand, aCmd, status, NULL, &eventuuid, &errcode);
   5097                 }
   5098             }
   5099         }
   5100     }
   5101     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFPVMFSMRTSPUnicastNode::CompleteInit - Out"));
   5102     return;
   5103 }
   5104 
   5105 bool PVMFSMRTSPUnicastNode::CheckChildrenNodesInit()
   5106 {
   5107     for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
   5108     {
   5109         if (iFSPChildNodeContainerVec[i].iNodeCmdState != PVMFSMFSP_NODE_CMD_IDLE)
   5110         {
   5111             return false;
   5112         }
   5113     }
   5114     return true;
   5115 }
   5116 
   5117 PVMFStatus PVMFSMRTSPUnicastNode::InitMetaData()
   5118 {
   5119     // Clear out the existing key list
   5120     iAvailableMetadataKeys.clear();
   5121     iCPMMetadataKeys.clear();
   5122 
   5123     // Get the SDP info
   5124     SDPInfo* sdpInfo = iSdpInfo.GetRep();
   5125     if (sdpInfo == NULL)
   5126     {
   5127         return PVMFErrInvalidState;
   5128     }
   5129     // Get Asset Info
   5130     sessionDescription* sessionInfo = sdpInfo->getSessionInfo();
   5131     if (sessionInfo != NULL)
   5132     {
   5133         iMetaDataInfo->iRandomAccessDenied = sessionInfo->getRandomAccessDenied();
   5134 
   5135         AssetInfoType assetInfo = sessionInfo->getAssetInfo();
   5136 
   5137         iMetaDataInfo->iTitlePresent = assetInfo.oTitlePresent;
   5138         iMetaDataInfo->iDescriptionPresent = assetInfo.oDescriptionPresent;
   5139         iMetaDataInfo->iCopyRightPresent = assetInfo.oCopyRightPresent;
   5140         iMetaDataInfo->iPerformerPresent = assetInfo.oPerformerPresent;
   5141         iMetaDataInfo->iAuthorPresent = assetInfo.oAuthorPresent;
   5142         iMetaDataInfo->iGenrePresent = assetInfo.oGenrePresent;
   5143         iMetaDataInfo->iRatingPresent = assetInfo.oRatingPresent;
   5144         iMetaDataInfo->iClassificationPresent = assetInfo.oClassificationPresent;
   5145         iMetaDataInfo->iKeyWordsPresent = assetInfo.oKeyWordsPresent;
   5146         iMetaDataInfo->iLocationPresent = assetInfo.oLocationPresent;
   5147         iMetaDataInfo->iAlbumPresent = assetInfo.oAlbumPresent;
   5148 
   5149         if (iMetaDataInfo->iTitlePresent)
   5150         {
   5151             iMetaDataInfo->iTitle = assetInfo.Box[AssetInfoType::TITLE];
   5152         }
   5153         if (iMetaDataInfo->iDescriptionPresent)
   5154         {
   5155             iMetaDataInfo->iDescription = assetInfo.Box[AssetInfoType::DESCRIPTION];
   5156         }
   5157         if (iMetaDataInfo->iCopyRightPresent)
   5158         {
   5159             iMetaDataInfo->iCopyright = assetInfo.Box[AssetInfoType::COPYRIGHT];
   5160         }
   5161         if (iMetaDataInfo->iPerformerPresent)
   5162         {
   5163             iMetaDataInfo->iPerformer = assetInfo.Box[AssetInfoType::PERFORMER];
   5164         }
   5165         if (iMetaDataInfo->iAuthorPresent)
   5166         {
   5167             iMetaDataInfo->iAuthor = assetInfo.Box[AssetInfoType::AUTHOR];
   5168         }
   5169         if (iMetaDataInfo->iRatingPresent)
   5170         {
   5171             iMetaDataInfo->iRating = assetInfo.Box[AssetInfoType::RATING];
   5172         }
   5173         if (iMetaDataInfo->iClassificationPresent)
   5174         {
   5175             iMetaDataInfo->iClassification = assetInfo.Box[AssetInfoType::CLASSIFICATION];
   5176         }
   5177         if (iMetaDataInfo->iKeyWordsPresent)
   5178         {
   5179             iMetaDataInfo->iNumKeyWords = assetInfo.iNumKeyWords;
   5180             for (uint32 i = 0; i < iMetaDataInfo->iNumKeyWords; i++)
   5181             {
   5182                 iMetaDataInfo->iKeyWords[i] = assetInfo.KeyWords[i];
   5183             }
   5184         }
   5185         if (iMetaDataInfo->iLocationPresent)
   5186         {
   5187             iMetaDataInfo->iLocationStruct = assetInfo.iLocationStruct;
   5188         }
   5189         if (iMetaDataInfo->iAlbumPresent)
   5190         {
   5191             iMetaDataInfo->iAlbum = assetInfo.Box[AssetInfoType::ALBUM];
   5192         }
   5193         if (assetInfo.iRecordingYear)
   5194         {
   5195             iMetaDataInfo->iYear = assetInfo.iRecordingYear;
   5196         }
   5197 
   5198         RtspRangeType *sessionRange = OSCL_CONST_CAST(RtspRangeType*, (sessionInfo->getRange()));
   5199         if (sessionRange->end_is_set == true)
   5200         {
   5201             iMetaDataInfo->iSessionDurationAvailable = true;
   5202 
   5203             int32 sessionStartTime = 0, sessionStopTime = 0;
   5204             sessionRange->convertToMilliSec(sessionStartTime, sessionStopTime);
   5205             uint32 duration = 0;
   5206             if (sessionStopTime > sessionStartTime && sessionStartTime >= 0)
   5207             {
   5208                 duration = (uint32)(sessionStopTime - sessionStartTime);
   5209             }
   5210             Oscl_Int64_Utils::set_uint64(iMetaDataInfo->iSessionDuration, 0, duration);
   5211             iMetaDataInfo->iSessionDurationTimeScale = 1000;
   5212         }
   5213 
   5214         iPauseDenied = iMetaDataInfo->iSessionDurationAvailable ? false : true;
   5215 
   5216     }
   5217 
   5218     iMetaDataInfo->iNumTracks = sdpInfo->getNumMediaObjects();
   5219 
   5220     for (uint32 i = 0; i < iMetaDataInfo->iNumTracks; i++)
   5221     {
   5222         Oscl_Vector<mediaInfo*, SDPParserAlloc> mediaInfoVec = sdpInfo->getMediaInfo(i);
   5223         for (uint32 j = 0; j < mediaInfoVec.size(); ++j)
   5224         {
   5225             mediaInfo* mInfo = mediaInfoVec[j];
   5226             if (mInfo != NULL)
   5227             {
   5228                 PVMFSMTrackMetaDataInfo trackMetaDataInfo;
   5229 
   5230                 trackMetaDataInfo.iTrackID = mInfo->getMediaInfoID();
   5231                 const char* mimeType = mInfo->getMIMEType();
   5232                 OSCL_StackString<32> realAudio(_STRLIT_CHAR("realaudio"));
   5233                 OSCL_StackString<32> realVideo(_STRLIT_CHAR("realvideo"));
   5234                 OSCL_StackString<32> h263(_STRLIT_CHAR("H263"));
   5235                 if (oscl_strstr(mimeType, realAudio.get_cstr()) != NULL)
   5236                 {
   5237                     trackMetaDataInfo.iMimeType = PVMF_MIME_REAL_AUDIO;
   5238                 }
   5239                 else if (oscl_strstr(mimeType, realVideo.get_cstr()) != NULL)
   5240                 {
   5241                     trackMetaDataInfo.iMimeType = PVMF_MIME_REAL_VIDEO;
   5242                 }
   5243                 else
   5244                 {
   5245                     trackMetaDataInfo.iMimeType += mimeType;
   5246                 }
   5247 
   5248                 Oscl_Vector<PayloadSpecificInfoTypeBase*, SDPParserAlloc> payloadVector;
   5249                 payloadVector = mInfo->getPayloadSpecificInfoVector();
   5250                 if (payloadVector.size() != 0)
   5251                 {
   5252                     /*
   5253                      * There can be multiple payloads per media segment.
   5254                      * We only support one for now, so
   5255                      * use just the first payload
   5256                      */
   5257                     PayloadSpecificInfoTypeBase* payloadInfo = payloadVector[0];
   5258                     if (oscl_strstr(mimeType, h263.get_cstr()) != NULL)
   5259                     {
   5260                         H263PayloadSpecificInfoType* h263PayloadInfo =
   5261                             OSCL_STATIC_CAST(H263PayloadSpecificInfoType*, payloadInfo);
   5262                         trackMetaDataInfo.iTrackWidth = h263PayloadInfo->getFrameWidth();
   5263                         trackMetaDataInfo.iTrackHeight = h263PayloadInfo->getFrameHeight();
   5264                     }
   5265 
   5266                     int32 configSize = payloadInfo->configSize;
   5267                     OsclAny* config = payloadInfo->configHeader.GetRep();
   5268 
   5269                     if ((configSize > 0) && (config != NULL))
   5270                     {
   5271                         OsclMemAllocDestructDealloc<uint8> my_alloc;
   5272                         OsclRefCounter* my_refcnt;
   5273                         uint aligned_refcnt_size =
   5274                             oscl_mem_aligned_size(sizeof(OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >));
   5275 
   5276                         uint8* my_ptr = GetMemoryChunk(my_alloc, aligned_refcnt_size + configSize);
   5277                         if (!my_ptr)
   5278                             return PVMFErrResource;
   5279 
   5280                         my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >(my_ptr));
   5281                         my_ptr += aligned_refcnt_size;
   5282 
   5283                         OsclMemoryFragment memfrag;
   5284                         memfrag.len = (uint32)configSize;
   5285                         memfrag.ptr = my_ptr;
   5286 
   5287                         oscl_memcpy((void*)(memfrag.ptr), (const void*)config, memfrag.len);
   5288 
   5289                         OsclRefCounterMemFrag tmpRefcntMemFrag(memfrag, my_refcnt, memfrag.len);
   5290                         trackMetaDataInfo.iCodecSpecificInfo = tmpRefcntMemFrag;
   5291                     }
   5292                 }
   5293 
   5294                 trackMetaDataInfo.iTrackBitRate = (uint32)(mInfo->getBitrate());
   5295 
   5296                 RtspRangeType *mediaRange = mInfo->getRtspRange();
   5297                 if (mediaRange->end_is_set == true)
   5298                 {
   5299                     int32 mediaStartTime = 0, mediaStopTime = 0;
   5300                     mediaRange->convertToMilliSec(mediaStartTime, mediaStopTime);
   5301                     uint32 trackduration = 0;
   5302                     if (mediaStopTime > mediaStartTime && mediaStartTime >= 0)
   5303                     {
   5304                         trackduration = (uint32)(mediaStopTime - mediaStartTime);
   5305                     }
   5306                     uint64 trackduration64 = 0;
   5307                     Oscl_Int64_Utils::set_uint64(trackduration64, 0, trackduration);
   5308                     trackMetaDataInfo.iTrackDuration = trackduration64;
   5309                     trackMetaDataInfo.iTrackDurationTimeScale = 1000;
   5310                     trackMetaDataInfo.iTrackDurationAvailable = true;
   5311                 }
   5312                 else
   5313                 {
   5314                     trackMetaDataInfo.iTrackDurationAvailable = false;
   5315                 }
   5316                 iMetaDataInfo->iTrackMetaDataInfoVec.push_back(trackMetaDataInfo);
   5317             }
   5318         }
   5319     }
   5320 
   5321     PVMFStatus status = PopulateAvailableMetadataKeys();
   5322     if (PVMFSuccess != status)
   5323     {
   5324         return status;
   5325     }
   5326     iMetaDataInfo->iMetadataAvailable = true;
   5327     return PVMFSuccess;
   5328 }
   5329 
   5330 PVMFStatus PVMFSMRTSPUnicastNode::PopulateAvailableMetadataKeys()
   5331 {
   5332     int32 leavecode = OsclErrNone;
   5333     OSCL_TRY(leavecode,
   5334              PVMFSMFSPBaseNode::PopulateAvailableMetadataKeys();
   5335 
   5336              //Add feature specific streaming metadata keys
   5337              // Create the parameter string for the index range
   5338              if (iMetaDataInfo->iNumTracks > 0)
   5339 {
   5340     char indexparam[18];
   5341         oscl_snprintf(indexparam, 18, ";index=0...%d", (iMetaDataInfo->iNumTracks - 1));
   5342         indexparam[17] = NULL_TERM_CHAR;
   5343 
   5344         iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_BITRATE_KEY);
   5345         iAvailableMetadataKeys[0] += indexparam;
   5346     }
   5347     iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_PAUSE_DENIED_KEY);
   5348             );
   5349     if (leavecode != OsclErrNone)
   5350         return leavecode;
   5351     else
   5352         return PVMFSuccess;
   5353 }
   5354 
   5355 void PVMFSMRTSPUnicastNode::CompletePrepare()
   5356 {
   5357     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::CompletePrepare - In"));
   5358     if ((CheckChildrenNodesPrepare()) && (iGraphConstructComplete))
   5359     {
   5360         if (!iCurrentCommand.empty() && iCancelCommand.empty())
   5361         {
   5362             PVMFSMFSPBaseNodeCommand& aCmd = iCurrentCommand.front();
   5363             if (aCmd.iCmd == PVMF_SMFSP_NODE_PREPARE)
   5364             {
   5365                 SetState(EPVMFNodePrepared);
   5366                 PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::Prepare() - CmdComplete - PVMFSuccess"));
   5367                 CommandComplete(iCurrentCommand, aCmd, PVMFSuccess);
   5368             }
   5369         }
   5370     }
   5371     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFPVMFSMRTSPUnicastNode::CompletePrepare - Out"));
   5372     return;
   5373 }
   5374 
   5375 bool PVMFSMRTSPUnicastNode::CheckChildrenNodesPrepare()
   5376 {
   5377     for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
   5378     {
   5379         if (iFSPChildNodeContainerVec[i].iNodeCmdState != PVMFSMFSP_NODE_CMD_IDLE)
   5380         {
   5381             return false;
   5382         }
   5383     }
   5384     return true;
   5385 }
   5386 
   5387 void PVMFSMRTSPUnicastNode::CompleteStart()
   5388 {
   5389     int32 localMode = 0;
   5390 
   5391     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::CompleteStart - In"));
   5392     if (CheckChildrenNodesStart())
   5393     {
   5394         if (!iCurrentCommand.empty() && iCancelCommand.empty())
   5395         {
   5396             PVMFSMFSPBaseNodeCommand& aCmd = iCurrentCommand.front();
   5397             if ((aCmd.iCmd == PVMF_SMFSP_NODE_START) ||
   5398                     (aCmd.iCmd == PVMF_SMFSP_NODE_SET_DATASOURCE_POSITION))
   5399             {
   5400                 if (iRepositioning)
   5401                 {
   5402                     PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::SetDataSourcePosition() - CmdComplete - PMVFSuccess"));
   5403                     iRepositioning = false;
   5404                     iPlayListRepositioning = false;
   5405 
   5406                     if ((localMode == 0) || (localMode == -1))
   5407                     {
   5408                         GetActualMediaTSAfterSeek();
   5409                     }
   5410                     iPVMFDataSourcePositionParamsPtr = NULL;
   5411                 }
   5412                 if ((localMode == 0) || (localMode == -1))
   5413                 {
   5414                     SetState(EPVMFNodeStarted);
   5415                     if (IsAdded())
   5416                     {
   5417                         /* wakeup the AO */
   5418                         RunIfNotReady();
   5419                     }
   5420                     PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::Start() - CmdComplete - PMVFSuccess"));
   5421                 }
   5422                 CommandComplete(iCurrentCommand, aCmd, PVMFSuccess);
   5423             }
   5424         }
   5425     }
   5426     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::CompleteStart - Out"));
   5427     return;
   5428 }
   5429 
   5430 bool PVMFSMRTSPUnicastNode::CheckChildrenNodesStart()
   5431 {
   5432     for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
   5433     {
   5434         if (iFSPChildNodeContainerVec[i].iNodeCmdState == PVMFSMFSP_NODE_CMD_PENDING)
   5435         {
   5436             return false;
   5437         }
   5438     }
   5439     return true;
   5440 }
   5441 
   5442 void PVMFSMRTSPUnicastNode::GetActualMediaTSAfterSeek()
   5443 {
   5444     PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   5445         getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   5446     if (iJitterBufferNodeContainer == NULL)
   5447     {
   5448         OSCL_LEAVE(OsclErrBadHandle);
   5449         return;
   5450     }
   5451     PVMFJitterBufferExtensionInterface* jbExtIntf =
   5452         (PVMFJitterBufferExtensionInterface*)
   5453         (iJitterBufferNodeContainer->iExtensions[0]);
   5454 
   5455     PVMFSMFSPChildNodeContainer* iMediaLayerNodeContainer =
   5456         getChildNodeContainer(PVMF_SM_FSP_MEDIA_LAYER_NODE);
   5457     if (iMediaLayerNodeContainer == NULL)
   5458     {
   5459         OSCL_LEAVE(OsclErrBadHandle);
   5460         return;
   5461     }
   5462     PVMFMediaLayerNodeExtensionInterface* mlExtIntf =
   5463         (PVMFMediaLayerNodeExtensionInterface*)
   5464         (iMediaLayerNodeContainer->iExtensions[0]);
   5465     if (mlExtIntf == NULL)
   5466     {
   5467         OSCL_LEAVE(OsclErrBadHandle);
   5468         return;
   5469     }
   5470     iActualMediaDataTS = jbExtIntf->getActualMediaDataTSAfterSeek();
   5471     if (iActualMediaDataTSPtr != NULL)
   5472     {
   5473         *iActualMediaDataTSPtr = iActualMediaDataTS;
   5474         PVMF_SM_RTSP_LOG_COMMAND_REPOS((0, "PVMFPVMFSMRTSPUnicastNode::GetActualMediaTSAfterSeek - TargetNPT = %d, ActualNPT=%d, ActualMediaDataTS=%d",
   5475                                         iRepositionRequestedStartNPTInMS, *iActualRepositionStartNPTInMSPtr, *iActualMediaDataTSPtr));
   5476     }
   5477 }
   5478 
   5479 void PVMFSMRTSPUnicastNode::CompleteStop()
   5480 {
   5481     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::CompleteStop - In"));
   5482     if (CheckChildrenNodesStop())
   5483     {
   5484         if (!iCurrentCommand.empty() && iCancelCommand.empty())
   5485         {
   5486             PVMFSMFSPBaseNodeCommand& aCmd = iCurrentCommand.front();
   5487             if (aCmd.iCmd == PVMF_SMFSP_NODE_STOP)
   5488             {
   5489                 /* transition to Prepared state */
   5490                 ResetStopCompleteParams();
   5491                 SetState(EPVMFNodePrepared);
   5492                 PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::Stop() - CmdComplete - PVMFSuccess"));
   5493                 CommandComplete(iCurrentCommand, aCmd, PVMFSuccess);
   5494             }
   5495         }
   5496     }
   5497     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::CompleteStop - Out"));
   5498     return;
   5499 }
   5500 
   5501 void PVMFSMRTSPUnicastNode::ResetStopCompleteParams()
   5502 {
   5503     iPlaylistPlayInProgress = false;
   5504     iRepositionRequestedStartNPTInMS = 0;
   5505 }
   5506 
   5507 void PVMFSMRTSPUnicastNode::CompletePause()
   5508 {
   5509     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFPVMFSMRTSPUnicastNode::CompletePause - In"));
   5510     if (CheckChildrenNodesPause())
   5511     {
   5512         SetState(EPVMFNodePaused);
   5513         if (iRepositioning)
   5514         {
   5515             OSCL_ASSERT((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL) ||
   5516                         (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE));
   5517             /*
   5518              * Pause request generated by a reposition command
   5519              * complete. Issue a start.
   5520              */
   5521             if (iPVMFDataSourcePositionParamsPtr == NULL)
   5522             {
   5523                 DoRepositioningStart3GPPStreaming();
   5524             }
   5525         }
   5526         else
   5527         {
   5528             if (!iCurrentCommand.empty() && iCancelCommand.empty())
   5529             {
   5530                 PVMFSMFSPBaseNodeCommand& aCmd = iCurrentCommand.front();
   5531                 PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFPVMFSMRTSPUnicastNode::Pause() - CmdComplete - PVMFSuccess"));
   5532                 CommandComplete(iCurrentCommand, aCmd, PVMFSuccess);
   5533             }
   5534         }
   5535 
   5536     }
   5537     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFPVMFSMRTSPUnicastNode::CompletePause - Out"));
   5538     return;
   5539 }
   5540 
   5541 bool PVMFSMRTSPUnicastNode::CheckChildrenNodesPause()
   5542 {
   5543     for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
   5544     {
   5545         if (iFSPChildNodeContainerVec[i].iNodeCmdState != PVMFSMFSP_NODE_CMD_IDLE
   5546                 && iFSPChildNodeContainerVec[i].iNodeCmdState != PVMFSMFSP_NODE_CMD_CANCEL_PENDING)
   5547         {
   5548             return false;
   5549         }
   5550     }
   5551     return true;
   5552 }
   5553 
   5554 /*
   5555  * Called by the call back routine whenever a "RequestPort" call
   5556  * completes successfully.
   5557  */
   5558 void PVMFSMRTSPUnicastNode::CompleteGraphConstruct()
   5559 {
   5560     iTotalNumRequestPortsComplete++;
   5561     /*
   5562      * Once all port requests are complete, connect the graph
   5563      */
   5564     if (iTotalNumRequestPortsComplete == iNumRequestPortsPending)
   5565     {
   5566         PVMFSMFSPBaseNodeCommand& aCmd = iCurrentCommand.front();
   5567         if (!SendSessionSourceInfoToSessionController())
   5568         {
   5569             PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:CompleteGraphConstruct - SendSessionSourceInfoToSessionController Failed"));
   5570             InternalCommandComplete(iCurrentCommand, aCmd, PVMFFailure);
   5571         }
   5572         else
   5573         {
   5574             iGraphConstructComplete = true;
   5575             PVMFSMFSPChildNodeContainer* socketNodeContainer = getChildNodeContainer(PVMF_SM_FSP_SOCKET_NODE);
   5576             PVMFSMFSPChildNodeContainer* jitterBufferNodeContainer = getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   5577             if ((socketNodeContainer == NULL) || (jitterBufferNodeContainer == NULL))
   5578             {
   5579                 OSCL_ASSERT(false);
   5580                 return;
   5581             }
   5582 
   5583             PVMFJitterBufferExtensionInterface* jbExtIntf = OSCL_STATIC_CAST(PVMFJitterBufferExtensionInterface*, jitterBufferNodeContainer->iExtensions[0]);
   5584             PVMFSocketNodeExtensionInterface* socketExtnIntf =  OSCL_STATIC_CAST(PVMFSocketNodeExtensionInterface*, socketNodeContainer->iExtensions[0]);
   5585 
   5586             OSCL_ASSERT(jbExtIntf && socketExtnIntf);
   5587             if (!jbExtIntf || !socketExtnIntf)
   5588                 return;
   5589 
   5590             //For RTSP based streamings, we want the mempools to get resized
   5591             //For input port, get the value from Jitter Buffer Node
   5592             uint32 resizeSizeInputPort = 0;
   5593             uint32 numResizeInputPort = 0;
   5594             jbExtIntf->GetSharedBufferResizeParams(numResizeInputPort, resizeSizeInputPort);
   5595             //For feedback port we use the const initialized to a configurable macro
   5596             const uint32 resizeSizeFeedbackPort = DEFAULT_MAX_SOCKETMEMPOOL_RESIZELEN_FEEDBACK_PORT;
   5597             const uint32 numResizeFeedbackPort = 1;
   5598 
   5599             //For every track
   5600             //Decide the size of the shared buffer to be allocated at socket node for receiving
   5601             //RTP packets [Input port]
   5602             //Receiving the response of RTCP reports send by JB [Feedback Port]
   5603 
   5604             for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
   5605             {
   5606                 PVMFRTSPTrackInfo trackInfo = iTrackInfoVec[i];
   5607                 uint32 bufferSzForRTPPackets = GetJitterBufferMemPoolSize(PVMF_JITTER_BUFFER_PORT_TYPE_INPUT, iTrackInfoVec[i]);
   5608                 uint32 bufferSzForRTCPResponse = GetJitterBufferMemPoolSize(PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK, iTrackInfoVec[i]);
   5609 
   5610                 //Set with the socket node
   5611                 OsclMemPoolResizableAllocator* socketAlloc = socketExtnIntf->CreateSharedBuffer(trackInfo.iNetworkNodePort, bufferSzForRTPPackets, DEFAULT_NUM_MEDIA_MSGS_IN_JITTER_BUFFER, resizeSizeInputPort, numResizeInputPort);
   5612                 jbExtIntf->SetJitterBufferChunkAllocator(socketAlloc, trackInfo.iJitterBufferInputPort);
   5613                 const uint32 numMemChunksForRTCPMemPool = bufferSzForRTCPResponse / MAX_SOCKET_BUFFER_SIZE;
   5614                 socketExtnIntf->CreateSharedBuffer(trackInfo.iNetworkNodeRTCPPort, bufferSzForRTCPResponse, numMemChunksForRTCPMemPool, resizeSizeFeedbackPort, numResizeFeedbackPort);
   5615             }
   5616             InternalCommandComplete(iCurrentCommand, aCmd, PVMFSuccess);
   5617         }
   5618     }
   5619 }
   5620 
   5621 /*
   5622  * Called when all port requests are complete, in order to send the
   5623  * UDP port information to RTSP
   5624  */
   5625 bool PVMFSMRTSPUnicastNode::SendSessionSourceInfoToSessionController()
   5626 {
   5627     if (((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL) ||
   5628             (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE)))
   5629     {
   5630         PVMFSMFSPChildNodeContainer* iSocketNodeContainer =
   5631             getChildNodeContainer(PVMF_SM_FSP_SOCKET_NODE);
   5632         if (iSocketNodeContainer == NULL)
   5633         {
   5634             OSCL_LEAVE(OsclErrBadHandle);
   5635             return false;
   5636         }
   5637 
   5638         PVMFSocketNode* socketNode =
   5639             (PVMFSocketNode*)(iSocketNodeContainer->iNode);
   5640 
   5641         PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
   5642             getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
   5643 
   5644         if (iSessionControllerNodeContainer == NULL)
   5645         {
   5646             OSCL_LEAVE(OsclErrBadHandle);
   5647             return false;
   5648         }
   5649 
   5650         PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
   5651             (PVRTSPEngineNodeExtensionInterface*)
   5652             (iSessionControllerNodeContainer->iExtensions[0]);
   5653 
   5654         Oscl_Vector<StreamInfo, OsclMemAllocator> aSelectedStream;
   5655 
   5656         for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
   5657         {
   5658             PVMFRTSPTrackInfo trackInfo = iTrackInfoVec[i];
   5659 
   5660             OsclNetworkAddress localAdd;
   5661             OsclNetworkAddress remoteAdd;
   5662             StreamInfo sInfo;
   5663 
   5664             sInfo.iSDPStreamId = trackInfo.trackID;
   5665 
   5666 
   5667             if (trackInfo.iNetworkNodePort == NULL)
   5668             {
   5669                 PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:SendSessionSourceInfoToSessionController - Invalid Port"));
   5670                 return false;
   5671             }
   5672 
   5673             socketNode->GetPortConfig(*trackInfo.iNetworkNodePort,
   5674                                       localAdd,
   5675                                       remoteAdd);
   5676 
   5677             sInfo.iCliRTPPort = localAdd.port;
   5678 
   5679             socketNode->GetPortConfig(*trackInfo.iNetworkNodeRTCPPort,
   5680                                       localAdd,
   5681                                       remoteAdd);
   5682 
   5683             sInfo.iCliRTCPPort = localAdd.port;
   5684 
   5685 
   5686             /* Set Rate Adaptation parameters */
   5687             sInfo.b3gppAdaptationIsSet = false;
   5688             if (trackInfo.iRateAdaptation)
   5689             {
   5690                 sInfo.b3gppAdaptationIsSet = true;
   5691                 /* Compute buffer size based on bitrate and jitter duration*/
   5692                 uint32 sizeInBytes = MIN_RTP_SOCKET_MEM_POOL_SIZE_IN_BYTES;
   5693                 if (((int32)iJitterBufferDurationInMilliSeconds > 0) &&
   5694                         ((int32)trackInfo.bitRate > 0))
   5695                 {
   5696                     uint32 byteRate = trackInfo.bitRate / 8;
   5697                     uint32 overhead = (byteRate * PVMF_JITTER_BUFFER_NODE_MEM_POOL_OVERHEAD) / 100;
   5698                     uint32 durationInSec = iJitterBufferDurationInMilliSeconds / 1000;
   5699                     sizeInBytes = ((byteRate + overhead) * durationInSec);
   5700                     if (sizeInBytes < MIN_RTP_SOCKET_MEM_POOL_SIZE_IN_BYTES)
   5701                     {
   5702                         sizeInBytes = MIN_RTP_SOCKET_MEM_POOL_SIZE_IN_BYTES;
   5703                     }
   5704                     sizeInBytes += 2 * MAX_SOCKET_BUFFER_SIZE;
   5705                 }
   5706                 sInfo.iBufSize = sizeInBytes;
   5707                 sInfo.iTargetTime = iJitterBufferDurationInMilliSeconds;
   5708             }
   5709             aSelectedStream.push_back(sInfo);
   5710         }
   5711 
   5712         if (rtspExtIntf->SetSDPInfo(iSdpInfo,
   5713                                     aSelectedStream) != PVMFSuccess)
   5714         {
   5715             PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:SendSessionSourceInfoToSessionController - SetSDPInfo Failed"));
   5716             return false;
   5717         }
   5718 
   5719         /* Set play range from SDP */
   5720         sessionDescription* sessionInfo = iSdpInfo->getSessionInfo();
   5721         RtspRangeType *rtspRange = OSCL_CONST_CAST(RtspRangeType*, (sessionInfo->getRange()));
   5722         rtspRange->convertToMilliSec((int32&)iSessionStartTime, (int32&)iSessionStopTime);
   5723 
   5724         if (rtspRange->end_is_set == false)
   5725         {
   5726             iSessionStopTime = 0xFFFFFFFF;
   5727             iSessionStopTimeAvailable = false;
   5728         }
   5729 
   5730         if ((rtspRange->format != RtspRangeType::INVALID_RANGE) &&
   5731                 (rtspRange->start_is_set != false))
   5732         {
   5733             if (rtspExtIntf->SetRequestPlayRange(*rtspRange) != PVMFSuccess)
   5734             {
   5735                 PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:SendRequestPlayRangeToSessionController - SetRequestPlayRange Failed"));
   5736                 return false;
   5737             }
   5738         }
   5739     }
   5740     return true;
   5741 }
   5742 
   5743 ///////////////////////////////////////////////////////////////////////////////
   5744 //Implemenation of pure virtuals from PVMFSMFSPBaseNode
   5745 ///////////////////////////////////////////////////////////////////////////////
   5746 bool PVMFSMRTSPUnicastNode::IsFSPInternalCmd(PVMFCommandId aId)
   5747 {
   5748     OSCL_UNUSED_ARG(aId);
   5749     return false;
   5750 }
   5751 
   5752 void PVMFSMRTSPUnicastNode::addRef()
   5753 {
   5754 }
   5755 
   5756 void PVMFSMRTSPUnicastNode::removeRef()
   5757 {
   5758 }
   5759 
   5760 void PVMFSMRTSPUnicastNode::setJitterBufferDurationInMilliSeconds(uint32 duration)
   5761 {
   5762     iJitterBufferDurationInMilliSeconds = duration;
   5763 }
   5764 
   5765 PVMFStatus PVMFSMRTSPUnicastNode::DoRepositioningStart3GPPStreaming()
   5766 {
   5767     PVMFStatus status = SetRTSPPlaybackRange();
   5768     if (PVMFSuccess != status)
   5769     {
   5770         return status;
   5771     }
   5772 
   5773     bool isSessionDurationExpired = false;
   5774 
   5775     PVMFSMFSPChildNodeContainer* jitterBufferNodeContainer =
   5776         getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   5777     if (jitterBufferNodeContainer)
   5778     {
   5779         PVMFJitterBufferExtensionInterface* jbExtIntf =
   5780             OSCL_STATIC_CAST(PVMFJitterBufferExtensionInterface*, jitterBufferNodeContainer->iExtensions.front());
   5781         if (jbExtIntf)
   5782             jbExtIntf->HasSessionDurationExpired(isSessionDurationExpired);
   5783     }
   5784 
   5785     PVMFSMFSPChildNodeContainer *sessionControllerNodeContainer =
   5786         getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
   5787     if (sessionControllerNodeContainer)
   5788     {
   5789         PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
   5790             OSCL_STATIC_CAST(PVRTSPEngineNodeExtensionInterface*, sessionControllerNodeContainer->iExtensions.front());
   5791         if (rtspExtIntf)
   5792             rtspExtIntf->UpdateSessionCompletionStatus(isSessionDurationExpired);
   5793     }
   5794 
   5795     PVMFSMFSPChildNodeContainerVector::iterator it;
   5796     for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
   5797     {
   5798         PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
   5799         if (internalCmd != NULL)
   5800         {
   5801             internalCmd->cmd =
   5802                 it->commandStartOffset +
   5803                 PVMF_SM_FSP_NODE_INTERNAL_START_CMD_OFFSET;
   5804             internalCmd->parentCmd = PVMF_SMFSP_NODE_SET_DATASOURCE_POSITION;
   5805 
   5806             OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
   5807 
   5808             PVMFNodeInterface* iNode = it->iNode;
   5809 
   5810             iNode->Start(it->iSessionId, cmdContextData);
   5811             it->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
   5812         }
   5813         else
   5814         {
   5815             PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoRepositioningStart:RequestNewInternalCmd - Failed"));
   5816             status = PVMFErrNoMemory;
   5817         }
   5818     }
   5819     return status;
   5820 }
   5821 
   5822 PVMFStatus PVMFSMRTSPUnicastNode::SetRTSPPlaybackRange()
   5823 {
   5824     PVMFStatus status = PVMFSuccess;
   5825 
   5826     /* Set Requested Play Range */
   5827     PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
   5828         getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
   5829 
   5830     if (iSessionControllerNodeContainer == NULL)
   5831     {
   5832         OSCL_LEAVE(OsclErrBadHandle);
   5833         return false;
   5834     }
   5835 
   5836     PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
   5837         (PVRTSPEngineNodeExtensionInterface*)
   5838         (iSessionControllerNodeContainer->iExtensions[0]);
   5839 
   5840     RtspRangeType rtspRange;
   5841     rtspRange.format = RtspRangeType::NPT_RANGE;
   5842     rtspRange.start_is_set = true;
   5843     rtspRange.npt_start.npt_format = NptTimeFormat::NPT_SEC;
   5844     rtspRange.npt_start.npt_sec.sec = iRepositionRequestedStartNPTInMS / 1000;
   5845     rtspRange.npt_start.npt_sec.milli_sec =
   5846         (iRepositionRequestedStartNPTInMS - ((iRepositionRequestedStartNPTInMS / 1000) * 1000));
   5847     rtspRange.end_is_set = true;
   5848     rtspRange.npt_end.npt_format = NptTimeFormat::NPT_SEC;
   5849     rtspRange.npt_end.npt_sec.sec = iSessionStopTime / 1000;
   5850     rtspRange.npt_end.npt_sec.milli_sec =
   5851         (iSessionStopTime - ((iSessionStopTime / 1000) * 1000));
   5852 
   5853     status = rtspExtIntf->SetRequestPlayRange(rtspRange);
   5854     if (PVMFSuccess != status)
   5855     {
   5856         PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:SetRTSPPlaybackRange() - SetRequestPlayRange Failed"));
   5857     }
   5858 
   5859     return status;
   5860 }
   5861 
   5862 bool PVMFSMRTSPUnicastNode::DoRepositioningPause3GPPStreaming()
   5863 {
   5864     PVMFSMFSPChildNodeContainerVector::iterator it;
   5865 
   5866     bool isSessionDurationExpired = false;
   5867 
   5868     PVMFSMFSPChildNodeContainer* jitterBufferNodeContainer =
   5869         getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   5870     if (jitterBufferNodeContainer)
   5871     {
   5872         PVMFJitterBufferExtensionInterface* jbExtIntf =
   5873             OSCL_STATIC_CAST(PVMFJitterBufferExtensionInterface*, jitterBufferNodeContainer->iExtensions.front());
   5874         if (jbExtIntf)
   5875             jbExtIntf->HasSessionDurationExpired(isSessionDurationExpired);
   5876     }
   5877 
   5878     PVMFSMFSPChildNodeContainer *sessionControllerNodeContainer =
   5879         getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
   5880     if (sessionControllerNodeContainer)
   5881     {
   5882         PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
   5883             OSCL_STATIC_CAST(PVRTSPEngineNodeExtensionInterface*, sessionControllerNodeContainer->iExtensions.front());
   5884         if (rtspExtIntf)
   5885             rtspExtIntf->UpdateSessionCompletionStatus(isSessionDurationExpired);
   5886     }
   5887 
   5888     for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
   5889     {
   5890         int32 nodeTag = it->iNodeTag;
   5891         //if pv playlist rp, don't pause
   5892         if ((nodeTag == PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE) ||
   5893                 (nodeTag == PVMF_SM_FSP_MEDIA_LAYER_NODE) ||
   5894                 (nodeTag == PVMF_SM_FSP_JITTER_BUFFER_NODE) ||
   5895                 (nodeTag == PVMF_SM_FSP_SOCKET_NODE))
   5896         {
   5897             PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
   5898             if (internalCmd != NULL)
   5899             {
   5900                 internalCmd->cmd =
   5901                     it->commandStartOffset +
   5902                     PVMF_SM_FSP_NODE_INTERNAL_PAUSE_CMD_OFFSET;
   5903                 internalCmd->parentCmd = PVMF_SMFSP_NODE_SET_DATASOURCE_POSITION;
   5904 
   5905                 OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
   5906 
   5907                 PVMFNodeInterface* iNode = it->iNode;
   5908 
   5909                 iNode->Pause(it->iSessionId, cmdContextData);
   5910                 it->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
   5911             }
   5912             else
   5913             {
   5914                 PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoRepositioningPause:RequestNewInternalCmd - Failed"));
   5915                 return false;
   5916             }
   5917         }
   5918     }
   5919     return true;
   5920 }
   5921 
   5922 bool PVMFSMRTSPUnicastNode::CompleteFeedBackPortsSetup()
   5923 {
   5924     PVMFSMFSPChildNodeContainer* iSocketNodeContainer =
   5925         getChildNodeContainer(PVMF_SM_FSP_SOCKET_NODE);
   5926     if (iSocketNodeContainer == NULL)
   5927     {
   5928         OSCL_LEAVE(OsclErrBadHandle);
   5929         return false;
   5930     }
   5931 
   5932     PVMFSocketNode* socketNode =
   5933         (PVMFSocketNode*)(iSocketNodeContainer->iNode);
   5934 
   5935     PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
   5936         getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
   5937 
   5938     if (iSessionControllerNodeContainer == NULL)
   5939     {
   5940         OSCL_LEAVE(OsclErrBadHandle);
   5941         return false;
   5942     }
   5943 
   5944     PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
   5945         (PVRTSPEngineNodeExtensionInterface*)
   5946         (iSessionControllerNodeContainer->iExtensions[0]);
   5947 
   5948     Oscl_Vector<StreamInfo, OsclMemAllocator> aSelectedStream;
   5949 
   5950     if (rtspExtIntf->GetStreamInfo(aSelectedStream) != PVMFSuccess)
   5951     {
   5952         OSCL_LEAVE(OsclErrGeneral);
   5953     }
   5954 
   5955     for (uint32 i = 0; i < aSelectedStream.size(); i++)
   5956     {
   5957         StreamInfo streamInfo = aSelectedStream[i];
   5958 
   5959         PVMFRTSPTrackInfo* trackInfo = FindTrackInfo(streamInfo.iSDPStreamId);
   5960 
   5961         if (trackInfo == NULL)
   5962         {
   5963             PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:CompleteFeedBackPortsSetup - FindTrackInfo Failed"));
   5964             return false;
   5965         }
   5966 
   5967         if (trackInfo->iNetworkNodeRTCPPort == NULL)
   5968         {
   5969             PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:CompleteFeedBackPortsSetup - Invalid RTCP Port"));
   5970             return false;
   5971         }
   5972 
   5973         OsclNetworkAddress localAddRTCP;
   5974         OsclNetworkAddress remoteAddRTCP;
   5975 
   5976         localAddRTCP.port = streamInfo.iCliRTCPPort;
   5977         remoteAddRTCP.port = streamInfo.iSerRTCPPort;
   5978         remoteAddRTCP.ipAddr = streamInfo.iSerIpAddr;
   5979 
   5980         socketNode->SetPortConfig(*(trackInfo->iNetworkNodeRTCPPort),
   5981                                   localAddRTCP,
   5982                                   remoteAddRTCP);
   5983 
   5984         if (trackInfo->iNetworkNodePort == NULL)
   5985         {
   5986             PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:CompleteFeedBackPortsSetup - Invalid RTP Port"));
   5987             return false;
   5988         }
   5989 
   5990         OsclNetworkAddress localAddRTP;
   5991         OsclNetworkAddress remoteAddRTP;
   5992 
   5993         localAddRTP.port = streamInfo.iCliRTPPort;
   5994         remoteAddRTP.port = streamInfo.iSerRTPPort;
   5995         remoteAddRTP.ipAddr = streamInfo.iSerIpAddr;
   5996 
   5997         socketNode->SetPortConfig(*(trackInfo->iNetworkNodePort),
   5998                                   localAddRTP,
   5999                                   remoteAddRTP);
   6000 
   6001     }
   6002 
   6003     return true;
   6004 }
   6005 
   6006 bool
   6007 PVMFSMRTSPUnicastNode::SendSessionControlPrepareCompleteParams()
   6008 {
   6009     if ((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL) ||
   6010             (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
   6011     {
   6012         PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
   6013             getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
   6014         if (iSessionControllerNodeContainer == NULL)
   6015         {
   6016             OSCL_LEAVE(OsclErrBadHandle);
   6017             return false;
   6018         }
   6019         PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
   6020             (PVRTSPEngineNodeExtensionInterface*)
   6021             (iSessionControllerNodeContainer->iExtensions[0]);
   6022 
   6023         PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   6024             getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   6025         if (iJitterBufferNodeContainer == NULL)
   6026         {
   6027             OSCL_LEAVE(OsclErrBadHandle);
   6028             return false;
   6029         }
   6030         PVMFJitterBufferExtensionInterface* jbExtIntf =
   6031             (PVMFJitterBufferExtensionInterface*)
   6032             (iJitterBufferNodeContainer->iExtensions[0]);
   6033 
   6034         Oscl_Vector<StreamInfo, OsclMemAllocator> aSelectedStream;
   6035 
   6036         if (rtspExtIntf->GetStreamInfo(aSelectedStream) != PVMFSuccess)
   6037         {
   6038             OSCL_LEAVE(OsclErrGeneral);
   6039         }
   6040 
   6041         for (uint32 i = 0; i < aSelectedStream.size(); i++)
   6042         {
   6043             StreamInfo streamInfo = aSelectedStream[i];
   6044 
   6045             PVMFRTSPTrackInfo* trackInfo = FindTrackInfo(streamInfo.iSDPStreamId);
   6046 
   6047             if (trackInfo == NULL)
   6048             {
   6049                 PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:SendSessionControlPrepareCompleteParams - FindTrackInfo Failed"));
   6050                 return false;
   6051             }
   6052 
   6053             if (trackInfo->iJitterBufferInputPort == NULL)
   6054             {
   6055                 PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:SendSessionControlPrepareCompleteParams - Invalid Port"));
   6056                 return false;
   6057             }
   6058 
   6059             if (streamInfo.ssrcIsSet)
   6060             {
   6061                 jbExtIntf->setPortSSRC(trackInfo->iJitterBufferInputPort,
   6062                                        streamInfo.iSSRC);
   6063             }
   6064         }
   6065 
   6066         /* Set server info */
   6067         PVRTSPEngineNodeServerInfo rtspServerInfo;
   6068         PVMFJitterBufferFireWallPacketInfo fireWallPktInfo;
   6069 
   6070         rtspExtIntf->GetServerInfo(rtspServerInfo);
   6071 
   6072         if (rtspServerInfo.iIsPVServer)
   6073         {
   6074             fireWallPktInfo.iFormat = PVMF_JB_FW_PKT_FORMAT_PV;
   6075         }
   6076         fireWallPktInfo.iServerRoundTripDelayInMS = rtspServerInfo.iRoundTripDelayInMS;
   6077 
   6078         if (0 == fireWallPktInfo.iServerRoundTripDelayInMS)
   6079         {
   6080             fireWallPktInfo.iServerRoundTripDelayInMS = PVMF_JITTER_BUFFER_NODE_FIREWALL_PKT_DEFAULT_SERVER_RESPONSE_TIMEOUT_IN_MS;
   6081         }
   6082 
   6083         fireWallPktInfo.iNumAttempts = PVMF_JITTER_BUFFER_NODE_DEFAULT_FIREWALL_PKT_ATTEMPTS;
   6084 
   6085         jbExtIntf->setServerInfo(fireWallPktInfo);
   6086     }
   6087     return true;
   6088 }
   6089 
   6090 bool PVMFSMRTSPUnicastNode::SendSessionControlStartCompleteParams()
   6091 {
   6092     PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   6093         getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   6094     if (iJitterBufferNodeContainer == NULL)
   6095     {
   6096         OSCL_LEAVE(OsclErrBadHandle);
   6097         return false;
   6098     }
   6099     PVMFJitterBufferExtensionInterface* jbExtIntf =
   6100         (PVMFJitterBufferExtensionInterface*)
   6101         (iJitterBufferNodeContainer->iExtensions[0]);
   6102 
   6103     PVMFSMFSPChildNodeContainer* iMediaLayerNodeContainer =
   6104         getChildNodeContainer(PVMF_SM_FSP_MEDIA_LAYER_NODE);
   6105     if (iMediaLayerNodeContainer == NULL)
   6106     {
   6107         OSCL_LEAVE(OsclErrBadHandle);
   6108         return false;
   6109     }
   6110     PVMFMediaLayerNodeExtensionInterface* mlExtIntf =
   6111         (PVMFMediaLayerNodeExtensionInterface*)
   6112         (iMediaLayerNodeContainer->iExtensions[0]);
   6113 
   6114     bool end_is_set = true;
   6115     int32 startTime = 0;
   6116     int32 stopTime  = 0;
   6117 
   6118     if ((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL) ||
   6119             (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
   6120     {
   6121         PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
   6122             getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
   6123         if (iSessionControllerNodeContainer == NULL)
   6124         {
   6125             OSCL_LEAVE(OsclErrBadHandle);
   6126             return false;
   6127         }
   6128         PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
   6129             (PVRTSPEngineNodeExtensionInterface*)
   6130             (iSessionControllerNodeContainer->iExtensions[0]);
   6131 
   6132         /* Get Actual Play Range */
   6133         RtspRangeType rangeType;
   6134         if (rtspExtIntf->GetActualPlayRange(rangeType) != PVMFSuccess)
   6135         {
   6136             return false;
   6137         }
   6138 
   6139         rangeType.convertToMilliSec(startTime, stopTime);
   6140 
   6141         /* Use from SDP if not set */
   6142         end_is_set = rangeType.end_is_set;
   6143         if (end_is_set == false)
   6144         {
   6145             stopTime = iSessionStopTime;
   6146         }
   6147 
   6148         if (iRepositioning)
   6149         {
   6150             iActualRepositionStartNPTInMS = startTime;
   6151             if (iActualRepositionStartNPTInMSPtr != NULL)
   6152             {
   6153                 *iActualRepositionStartNPTInMSPtr = startTime;
   6154             }
   6155         }
   6156 
   6157         Oscl_Vector<StreamInfo, OsclMemAllocator> aSelectedStream;
   6158 
   6159         if (rtspExtIntf->GetStreamInfo(aSelectedStream) != PVMFSuccess)
   6160         {
   6161             OSCL_LEAVE(OsclErrGeneral);
   6162         }
   6163 
   6164         for (uint32 i = 0; i < aSelectedStream.size(); i++)
   6165         {
   6166             StreamInfo streamInfo = aSelectedStream[i];
   6167 
   6168             PVMFRTSPTrackInfo* trackInfo = FindTrackInfo(streamInfo.iSDPStreamId);
   6169 
   6170             if (trackInfo == NULL)
   6171             {
   6172                 PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:SendStartCompleteSessionControlParams - FindTrackInfo Failed"));
   6173                 return false;
   6174             }
   6175 
   6176             if (trackInfo->iJitterBufferInputPort == NULL)
   6177             {
   6178                 PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:SendStartCompleteSessionControlParams - Invalid Port"));
   6179                 return false;
   6180             }
   6181 
   6182             if (streamInfo.seqIsSet != true)
   6183             {
   6184                 streamInfo.seqIsSet = false;
   6185                 streamInfo.seq = 0;
   6186             }
   6187             if (streamInfo.rtptimeIsSet != true)
   6188             {
   6189                 streamInfo.rtptimeIsSet = false;
   6190                 streamInfo.rtptime = 0;
   6191             }
   6192             jbExtIntf->setPortRTPParams(trackInfo->iJitterBufferInputPort,
   6193                                         streamInfo.seqIsSet,
   6194                                         streamInfo.seq,
   6195                                         streamInfo.rtptimeIsSet,
   6196                                         streamInfo.rtptime,
   6197                                         rangeType.start_is_set,
   6198                                         startTime,
   6199                                         iRepositioning);
   6200 
   6201         }
   6202     }
   6203 
   6204 
   6205     /* Send actual stop time to Jitter Buffer */
   6206     if (jbExtIntf->setPlayRange(startTime,
   6207                                 stopTime,
   6208                                 iRepositioning,
   6209                                 end_is_set) != true)
   6210     {
   6211         return false;
   6212     }
   6213 
   6214     if (mlExtIntf->setPlayRange(startTime, stopTime, iRepositioning) != true)
   6215     {
   6216         return false;
   6217     }
   6218     return true;
   6219 }
   6220 
   6221 void PVMFSMRTSPUnicastNode::HandleNodeInformationalEvent(const PVMFAsyncEvent& aEvent)
   6222 {
   6223     if (SupressInfoEvent())
   6224     {
   6225         PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode:HandleNodeInformationalEvent Supress info event %u", aEvent.GetEventType()));
   6226         return;
   6227     }
   6228 
   6229     PVMFAsyncEvent event = OSCL_CONST_CAST(PVMFAsyncEvent, aEvent);
   6230     PVMFEventType infoEvent = aEvent.GetEventType();
   6231     if (infoEvent == PVMFInfoEndOfData)
   6232     {
   6233         /* Notify jitter buffer */
   6234         PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   6235             getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   6236         if (iJitterBufferNodeContainer == NULL)
   6237         {
   6238             OSCL_LEAVE(OsclErrBadHandle);
   6239             return;
   6240         }
   6241         PVMFJitterBufferExtensionInterface* jbExtIntf =
   6242             (PVMFJitterBufferExtensionInterface*)
   6243             (iJitterBufferNodeContainer->iExtensions[0]);
   6244         jbExtIntf->NotifyOutOfBandEOS();
   6245     }
   6246     else if (infoEvent == PVMFInfoPlayListClipTransition)
   6247     {
   6248         if (iPlaylistPlayInProgress)
   6249         {
   6250             iPlaylistPlayInProgress = false;
   6251             PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
   6252                 getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
   6253             if (iSessionControllerNodeContainer == NULL)
   6254             {
   6255                 OSCL_LEAVE(OsclErrBadHandle);
   6256                 return;
   6257             }
   6258 
   6259             PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   6260                 getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   6261             if (iJitterBufferNodeContainer == NULL)
   6262             {
   6263                 OSCL_LEAVE(OsclErrBadHandle);
   6264                 return;
   6265             }
   6266             PVMFJitterBufferExtensionInterface* jbExtIntf =
   6267                 (PVMFJitterBufferExtensionInterface*)
   6268                 (iJitterBufferNodeContainer->iExtensions[0]);
   6269 
   6270             PVMFRTSPClientEngineNodePlaylistInfoType *myType = (PVMFRTSPClientEngineNodePlaylistInfoType*)(aEvent.GetEventData());
   6271             if (myType == NULL)
   6272             {//hang?
   6273                 PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::HandleNodeInformationalEvent - PVMFInfoPlayListClipTransition No event data - context=0x%x, event data=0x%x", aEvent.GetContext(), aEvent.GetEventData()));
   6274                 if (IsBusy())
   6275                 {
   6276                     Cancel();
   6277                     RunIfNotReady();
   6278                 }
   6279                 return;
   6280             }
   6281 
   6282             NptTimeFormat npt_start;
   6283             npt_start.npt_format = NptTimeFormat::NPT_SEC;
   6284             npt_start.npt_sec.sec = myType->iPlaylistNPTSec;
   6285             npt_start.npt_sec.milli_sec = myType->iPlaylistNPTMillsec;
   6286 
   6287             jbExtIntf->PurgeElementsWithNPTLessThan(npt_start);
   6288             iSessionControllerNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
   6289             CompleteStart();
   6290 
   6291         }
   6292 
   6293         PVMFNodeInterface::ReportInfoEvent(event);
   6294     }
   6295     else if (infoEvent == PVMFInfoSourceOverflow)
   6296     {
   6297         /* Make note of the overflow */
   6298         oAutoReposition = true;
   6299         PVMFNodeInterface::ReportInfoEvent(event);
   6300     }
   6301     else
   6302     {
   6303         /* Just pass the info event up */
   6304         PVMFNodeInterface::ReportInfoEvent(event);
   6305     }
   6306 }
   6307 bool PVMFSMRTSPUnicastNode::CanPerformRepositioning(bool aRandAccessDenied)
   6308 {
   6309 
   6310     if ((aRandAccessDenied == true) ||
   6311             (iSessionStopTimeAvailable == false) ||
   6312             (((int32)iRepositionRequestedStartNPTInMS < (int32)iSessionStartTime) ||
   6313              ((int32)iRepositionRequestedStartNPTInMS > (int32)iSessionStopTime)))
   6314     {
   6315         /*
   6316          * Implies an open ended session or invalid request time
   6317          * - no pause or reposition
   6318          */
   6319         return false;
   6320 
   6321     }
   6322     return true;
   6323 
   6324 }
   6325 
   6326 bool
   6327 PVMFSMRTSPUnicastNode::CheckChildrenNodesStop()
   6328 {
   6329 
   6330     {
   6331         for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
   6332         {
   6333             if (iFSPChildNodeContainerVec[i].iNodeCmdState != PVMFSMFSP_NODE_CMD_IDLE)
   6334             {
   6335                 return false;
   6336             }
   6337         }
   6338     }
   6339     return true;
   6340 }
   6341 
   6342 void PVMFSMRTSPUnicastNode::CleanUp()
   6343 {
   6344     DestroyChildNodes();
   6345     DestroyPayloadParserRegistry();
   6346     ResetNodeParams();
   6347     iLogger = NULL;
   6348 }
   6349 
   6350 void PVMFSMRTSPUnicastNode::PopulateDRMInfo()
   6351 {
   6352     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::PopulateDRMInfo() In"));
   6353     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::PopulateDRMInfo() - CPM not supported yet"));
   6354 }
   6355 
   6356 void PVMFSMRTSPUnicastNode::ResetNodeParams(bool aReleaseMemmory)
   6357 {
   6358     iTrackInfoVec.clear();
   6359     iSdpInfo.Unbind();
   6360     PVMFSMFSPBaseNode::ResetNodeParams(aReleaseMemmory);
   6361 }
   6362 
   6363 void PVMFSMRTSPUnicastNode::GetMaxMediaTS()
   6364 {
   6365     PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   6366         getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   6367 
   6368     if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
   6369     PVMFJitterBufferExtensionInterface* jbExtIntf =
   6370         (PVMFJitterBufferExtensionInterface*)
   6371         (iJitterBufferNodeContainer->iExtensions[0]);
   6372 
   6373     PVMFSMFSPChildNodeContainer* iMediaLayerNodeContainer =
   6374         getChildNodeContainer(PVMF_SM_FSP_MEDIA_LAYER_NODE);
   6375     if (iMediaLayerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
   6376     PVMFMediaLayerNodeExtensionInterface* mlExtIntf =
   6377         (PVMFMediaLayerNodeExtensionInterface*)
   6378         (iMediaLayerNodeContainer->iExtensions[0]);
   6379     if (mlExtIntf == NULL) OSCL_LEAVE(OsclErrBadHandle);
   6380     PVMFPortInterface* mlInPort = iMediaLayerNodeContainer->iInputPorts[0];
   6381 
   6382     if ((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL) ||
   6383             (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
   6384     {
   6385         iActualMediaDataTS = jbExtIntf->getMaxMediaDataTS();
   6386         if (iActualMediaDataTSPtr != NULL)
   6387         {
   6388             *iActualMediaDataTSPtr = iActualMediaDataTS;
   6389             PVMF_SM_RTSP_LOG_COMMAND_REPOS((0, "PVMFStreamingManagerNode::GetActualMediaTSAfterSeek - TargetNPT = %d, ActualNPT=%d, ActualMediaDataTS=%d",
   6390                                             iRepositionRequestedStartNPTInMS, *iActualRepositionStartNPTInMSPtr, *iActualMediaDataTSPtr));
   6391         }
   6392         if (iPVMFDataSourcePositionParamsPtr != NULL)
   6393         {
   6394             iPVMFDataSourcePositionParamsPtr->iActualMediaDataTS = iActualMediaDataTS;
   6395             PVMF_SM_RTSP_LOG_COMMAND_REPOS((0, "PVMFStreamingManagerNode::GetActualMediaTSAfterSeek - ActualMediaDataTS=%d",
   6396                                             iPVMFDataSourcePositionParamsPtr->iActualMediaDataTS));
   6397         }
   6398     }
   6399     else if (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL)
   6400     {
   6401         iActualRepositionStartNPTInMS = jbExtIntf->getActualMediaDataTSAfterSeek();
   6402         *iActualRepositionStartNPTInMSPtr = iActualRepositionStartNPTInMS;
   6403         iActualMediaDataTS = mlExtIntf->getMaxOutPortTimestamp(mlInPort);
   6404         *iActualMediaDataTSPtr = iActualMediaDataTS;
   6405         PVMF_SM_RTSP_LOG_COMMAND_REPOS((0, "PVMFStreamingManagerNode::GetActualMediaTSAfterSeek - TargetNPT = %d, ActualNPT=%d, ActualMediaDataTS=%d",
   6406                                         iRepositionRequestedStartNPTInMS, *iActualRepositionStartNPTInMSPtr, *iActualMediaDataTSPtr));
   6407     }
   6408 }
   6409 
   6410 
   6411 void PVMFSMRTSPUnicastNode::DoSetDataSourcePositionOverflow(PVMFSMFSPBaseNodeCommand& aCmd)
   6412 {
   6413     PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoSetDataSourcePositionOverflow - In"));
   6414 
   6415     iActualRepositionStartNPTInMSPtr = NULL;
   6416     iActualMediaDataTSPtr = NULL;
   6417     iPVMFDataSourcePositionParamsPtr = NULL;
   6418     iJumpToIFrame = false;
   6419     PVMFTimestamp aTargetNPT;
   6420     bool aSeekToSyncPoint;
   6421     aCmd.PVMFSMFSPBaseNodeCommand::Parse(aTargetNPT,
   6422                                          iActualRepositionStartNPTInMSPtr,
   6423                                          iActualMediaDataTSPtr,
   6424                                          aSeekToSyncPoint,
   6425                                          iStreamID);
   6426 
   6427     PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   6428         getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   6429     if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
   6430     PVMFJitterBufferExtensionInterface* jbExtIntf =
   6431         (PVMFJitterBufferExtensionInterface*)
   6432         (iJitterBufferNodeContainer->iExtensions[0]);
   6433 
   6434     jbExtIntf->SendBOSMessage(iStreamID);
   6435     oAutoReposition = false;
   6436 
   6437     if (iInterfaceState == EPVMFNodeStarted)
   6438     {
   6439         bool oRandAccessDenied = false;
   6440 
   6441         if ((iSessionSourceInfo->_sessionType != PVMF_MIME_DATA_SOURCE_RTSP_URL) &&
   6442                 (iSessionSourceInfo->_sessionType != PVMF_MIME_DATA_SOURCE_SDP_FILE))
   6443         {
   6444             PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:DoSetDataSourcePositionOverflow - Invalid Session Type"));
   6445             oRandAccessDenied = true;
   6446         }
   6447 
   6448         if (oRandAccessDenied == true)
   6449         {
   6450             /*
   6451             * Implies an open ended session or invalid request time
   6452             * - no pause or reposition
   6453                 */
   6454             PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:DoSetDataSourcePositionOverflow - Invalid Args"));
   6455             CommandComplete(iInputCommands, aCmd, PVMFFailure);
   6456             return;
   6457         }
   6458 
   6459         /* Put the jitter buffer into a state of transition - only if the playlist switch mode is 0*/
   6460 
   6461         PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   6462             getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   6463         if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
   6464         PVMFJitterBufferExtensionInterface* jbExtIntf =
   6465             (PVMFJitterBufferExtensionInterface*)
   6466             (iJitterBufferNodeContainer->iExtensions[0]);
   6467         jbExtIntf->PrepareForRepositioning();
   6468         if ((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL) ||
   6469                 (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
   6470         {
   6471             // Purge JB at this point
   6472             GetMaxMediaTS();
   6473             *iActualMediaDataTSPtr = iActualMediaDataTS;
   6474             PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
   6475                 getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
   6476             if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
   6477             PVMFJitterBufferExtensionInterface* jbExtIntf =
   6478                 (PVMFJitterBufferExtensionInterface*)
   6479                 (iJitterBufferNodeContainer->iExtensions[0]);
   6480 
   6481             // Convert iActualMediaDataTS to NPT time format
   6482             NptTimeFormat npt_start;
   6483             npt_start.npt_format = NptTimeFormat::NPT_SEC;
   6484             npt_start.npt_sec.sec = iActualMediaDataTS / 1000;
   6485             npt_start.npt_sec.milli_sec = iActualMediaDataTS - 1000 * (iActualMediaDataTS / 1000);
   6486 
   6487             jbExtIntf->PurgeElementsWithNPTLessThan(npt_start);
   6488             CommandComplete(iInputCommands, aCmd, PVMFSuccess);
   6489         }
   6490         else
   6491         {
   6492             PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:DoSetDataSourcePositionOverflow - Invalid Session Type"));
   6493             CommandComplete(iInputCommands, aCmd, PVMFFailure);
   6494         }
   6495     }
   6496     else
   6497     {
   6498         PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:DoSetDataSourcePositionOverflow - Invalid State"));
   6499         CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
   6500     }
   6501     return;
   6502 }
   6503