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 #include "pvdl_config_file.h"
     19 #include "pvmf_protocolengine_node_tunables.h"
     20 
     21 #define PVDLCONFIGFILE_VECTOR_RESERVE_NUMBER    4
     22 #define PVDLCONFIGFILE_TEMPORARY_BUFFER_SIZE    4096
     23 #define PVDLCONFIGFILE_FIXED_HEADER_SIZE        100 // 96+4
     24 #define PVDLCONFIGFILE_FILE_CACHE_BUFFER_SIZE   1024
     25 
     26 
     27 OSCL_EXPORT_REF PVDlCfgFile::PVDlCfgFile()
     28         : iTmpBuf(NULL)
     29         , iFile(NULL)
     30         , iProxyPort(0)
     31         , iMaxAllowedFileSize(0)
     32         , iOverallFileSize(0)
     33         , iCurrentFileSize(0)
     34         , iHasContentLength(1)
     35         , iConnectTimeout(0)
     36         , iSendTimeout(0)
     37         , iRecvTimeout(0)
     38         , iRangeStartTime(0)
     39         , iMagic32(0x4a6a446c)
     40         , iVersion(1)
     41         , iFlag(0)
     42         , iTotalFixedHeaderSize(PVDLCONFIGFILE_FIXED_HEADER_SIZE)
     43         , PVDL_CFG_FILE_CACHE_BUF(PVDLCONFIGFILE_FILE_CACHE_BUFFER_SIZE)
     44         , iLogger(NULL)
     45         , bIsNewSession(true)
     46         , iHttpVersionNum(PDL_HTTP_VERSION_NUMBER) // assume 0 => Http 1.0 ; 1 => Http 1.1
     47         , iDisableHeadRequest(false)
     48 {
     49     int32 err;
     50     OSCL_TRY(err,
     51              iFileServer.Connect();
     52              iTmpBuf = OSCL_ARRAY_NEW(uint8, iTotalFixedHeaderSize);
     53              iLogger = PVLogger::GetLoggerObject("PVDlCfgFile");
     54              iExtensionHeaderKeys.reserve(PVDLCONFIGFILE_VECTOR_RESERVE_NUMBER);
     55              iExtensionHeaderValues.reserve(PVDLCONFIGFILE_VECTOR_RESERVE_NUMBER);
     56              iMethodMaskForExtensionHeaders.reserve(PVDLCONFIGFILE_VECTOR_RESERVE_NUMBER);
     57              iExtensionHeadersPurgeOnRedirect.reserve(PVDLCONFIGFILE_VECTOR_RESERVE_NUMBER);
     58             );
     59 
     60     if (err != OsclErrNone)
     61     {
     62         OSCL_LEAVE(err);
     63     }
     64 }
     65 
     66 OSCL_EXPORT_REF PVDlCfgFile::~PVDlCfgFile()
     67 {
     68     //SaveConfig();
     69 
     70     if (iTmpBuf)
     71     {
     72         //OSCL_ARRAY_DELETE(iTmpBuf);
     73         OSCL_ARRAY_DELETE(iTmpBuf);
     74         iTmpBuf = NULL;
     75     }
     76 
     77     if (iFile)
     78     {
     79         iFile->Flush();
     80         iFile->Close();
     81         OSCL_DELETE(iFile);
     82         iFile = NULL;
     83     }
     84 
     85     iFileServer.Close();
     86     iExtensionHeaderKeys.clear();
     87     iExtensionHeaderValues.clear();
     88     iExtensionHeadersPurgeOnRedirect.clear();
     89 }
     90 
     91 OSCL_EXPORT_REF void PVDlCfgFile::SetDownloadType(bool aIsFastTrack)
     92 {
     93     if (aIsFastTrack)
     94     {
     95         iFlag   |= 0x1;
     96     }
     97     else
     98     {
     99         iFlag   &= (~0x1);
    100     }
    101 }
    102 
    103 OSCL_EXPORT_REF bool PVDlCfgFile::IsFastTrack(void)
    104 {
    105     return (iFlag & 0x1);
    106 }
    107 
    108 OSCL_EXPORT_REF void PVDlCfgFile::SetDonwloadComplete(void)
    109 {
    110     iFlag   |=  0x2;
    111 }
    112 
    113 OSCL_EXPORT_REF void PVDlCfgFile::SetPlaybackMode(TPVDLPlaybackMode aPlaybackMode)
    114 {
    115     iFlag   &= (~0xC);  //clear
    116     uint32 playbackModeBit = OSCL_STATIC_CAST(uint32, aPlaybackMode);
    117     iFlag   |= (playbackModeBit << 2);
    118 }
    119 
    120 OSCL_EXPORT_REF PVDlCfgFile::TPVDLPlaybackMode PVDlCfgFile::GetPlaybackMode(void)
    121 {
    122     return OSCL_STATIC_CAST(TPVDLPlaybackMode, ((iFlag & 0xC) >> 2));
    123 }
    124 
    125 OSCL_EXPORT_REF bool PVDlCfgFile::SaveConfig(void)
    126 {
    127     if (iConfigFileName.get_size() <= 0)
    128     {
    129         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::SaveConfig() ERROR. line %d ", __LINE__));
    130         return false;
    131     }
    132 
    133     if (iFile)
    134     {
    135         iFile->Close();
    136     }
    137     else
    138     {
    139         int32 err;
    140         OSCL_TRY(err, iFile = OSCL_NEW(Oscl_File, (PVDL_CFG_FILE_CACHE_BUF)););
    141         if ((err != OsclErrNone) || (iFile == NULL))
    142         {
    143             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVDlCfgFile::SaveConfig() OSCL_NEW ERROR. line %d ", __LINE__));
    144             return false;
    145         }
    146     }
    147 
    148     int32 retval = iFile->Open(iConfigFileName.get_cstr(), Oscl_File::MODE_READWRITE | Oscl_File::MODE_BINARY, iFileServer);
    149     if (retval)
    150     {
    151         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::SaveConfig() ERROR. line %d ", __LINE__));
    152         return false;
    153     }
    154 
    155     //fixed len part
    156     composeFixedHeader(iTmpBuf);
    157 
    158     int32 tmpRet = iFile->Write(iTmpBuf, 1, iTotalFixedHeaderSize);
    159     if (tmpRet == 0)
    160     {
    161         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::SaveConfig() ERROR. line %d ", __LINE__));
    162         return false;
    163     }
    164 
    165     //var len part
    166     uint8 *tmpBuf = iTmpBuf;
    167     if (iSelectedTrackIDs.size())
    168     {
    169         for (int32 i = iSelectedTrackIDs.size() - 1; i >= 0; i--)
    170         {//Track ID should only use one byte.
    171             *tmpBuf++ = OSCL_STATIC_CAST(uint8, iSelectedTrackIDs[i]);
    172         }
    173         tmpRet = iFile->Write(iTmpBuf, 1, iSelectedTrackIDs.size());
    174         if (tmpRet == 0)
    175         {
    176             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::SaveConfig() ERROR. line %d ", __LINE__));
    177             return false;
    178         }
    179     }
    180 
    181 
    182     if (iUrl.get_size())
    183     {
    184         tmpRet = iFile->Write(iUrl.get_str(), 1, iUrl.get_size());
    185         if (tmpRet == 0)
    186         {
    187             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::SaveConfig() ERROR. line %d ", __LINE__));
    188             return false;
    189         }
    190     }
    191 
    192     if (iProxyName.get_size())
    193     {
    194         tmpRet = iFile->Write(iProxyName.get_str(), 1, iProxyName.get_size());
    195         if (tmpRet == 0)
    196         {
    197             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::SaveConfig() ERROR. line %d ", __LINE__));
    198             return false;
    199         }
    200     }
    201 
    202     if (iPlayerVersion.get_size())
    203     {
    204         tmpRet = iFile->Write(iPlayerVersion.get_str(), 1, iPlayerVersion.get_size());
    205         if (tmpRet == 0)
    206         {
    207             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::SaveConfig() ERROR. line %d ", __LINE__));
    208             return false;
    209         }
    210     }
    211 
    212     if (iUserAgent.get_size())
    213     {
    214         tmpRet = iFile->Write(iUserAgent.get_str(), 1, iUserAgent.get_size());
    215         if (tmpRet == 0)
    216         {
    217             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::SaveConfig() ERROR. line %d ", __LINE__));
    218             return false;
    219         }
    220     }
    221 
    222     if (iUserNetwork.get_size())
    223     {
    224         tmpRet = iFile->Write(iUserNetwork.get_str(), 1, iUserNetwork.get_size());
    225         if (tmpRet == 0)
    226         {
    227             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::SaveConfig() ERROR. line %d ", __LINE__));
    228             return false;
    229         }
    230     }
    231 
    232     if (iDeviceInfo.get_size())
    233     {
    234         tmpRet = iFile->Write(iDeviceInfo.get_str(), 1, iDeviceInfo.get_size());
    235         if (tmpRet == 0)
    236         {
    237             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::SaveConfig() ERROR. line %d ", __LINE__));
    238             return false;
    239         }
    240     }
    241 
    242     if (iUserId.get_size())
    243     {
    244         tmpRet = iFile->Write(iUserId.get_str(), 1, iUserId.get_size());
    245         if (tmpRet == 0)
    246         {
    247             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::SaveConfig() ERROR. line %d ", __LINE__));
    248             return false;
    249         }
    250     }
    251 
    252     if (iUserAuth.get_size())
    253     {
    254         tmpRet = iFile->Write(iUserAuth.get_str(), 1, iUserAuth.get_size());
    255         if (tmpRet == 0)
    256         {
    257             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::SaveConfig() ERROR. line %d ", __LINE__));
    258             return false;
    259         }
    260     }
    261 
    262     if (iExpiration.get_size())
    263     {
    264         tmpRet = iFile->Write(iExpiration.get_str(), 1, iExpiration.get_size());
    265         if (tmpRet == 0)
    266         {
    267             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::SaveConfig() ERROR. line %d ", __LINE__));
    268             return false;
    269         }
    270     }
    271 
    272     if (iAppString.get_size())
    273     {
    274         tmpRet = iFile->Write(iAppString.get_str(), 1, iAppString.get_size());
    275         if (tmpRet == 0)
    276         {
    277             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::SaveConfig() ERROR. line %d ", __LINE__));
    278             return false;
    279         }
    280     }
    281 
    282     if (iFiller.get_size())
    283     {
    284         tmpRet = iFile->Write(iFiller.get_str(), 1, iFiller.get_size());
    285         if (tmpRet == 0)
    286         {
    287             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::SaveConfig() ERROR. line %d ", __LINE__));
    288             return false;
    289         }
    290     }
    291 
    292     if (iSign.get_size())
    293     {
    294         tmpRet = iFile->Write(iSign.get_str(), 1, iSign.get_size());
    295         if (tmpRet == 0)
    296         {
    297             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::SaveConfig() ERROR. line %d ", __LINE__));
    298             return false;
    299         }
    300     }
    301 
    302     iFile->Flush();
    303     return true;
    304 }
    305 
    306 OSCL_EXPORT_REF int32 PVDlCfgFile::LoadConfig(void)
    307 {
    308     bIsNewSession = false;
    309 
    310     if (iConfigFileName.get_size() <= 0)
    311     {
    312         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::LoadConfig() ERROR. line %d ", __LINE__));
    313         return LoadConfigStatus_CriticalError;
    314     }
    315 
    316     if (iFile)
    317     {
    318         iFile->Close();
    319     }
    320     else
    321     {
    322         int32 err;
    323         OSCL_TRY(err, iFile = OSCL_NEW(Oscl_File, (PVDL_CFG_FILE_CACHE_BUF)););
    324         if ((err != OsclErrNone) || (iFile == NULL))
    325         {
    326             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVDlCfgFile::LoadConfig() OSCL_NEW ERROR. line %d ", __LINE__));
    327             return LoadConfigStatus_CriticalError;
    328         }
    329     }
    330 
    331     int32 retval = iFile->Open(iConfigFileName.get_cstr(), Oscl_File::MODE_READ | Oscl_File::MODE_BINARY, iFileServer);
    332     if (retval)
    333     {
    334         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::LoadConfig() ERROR. line %d ", __LINE__));
    335         return LoadConfigStatus_NonCriticalError; // file might not exist yet
    336     }
    337 
    338     if (iTotalFixedHeaderSize != iFile->Read(iTmpBuf, 1, iTotalFixedHeaderSize))
    339     {
    340         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::LoadConfig() ERROR. line %d ", __LINE__));
    341         return LoadConfigStatus_NonCriticalError;
    342     };
    343 
    344     {
    345         uint32 *tmpPtr = OSCL_STATIC_CAST(uint32*, iTmpBuf);
    346         if (iMagic32 != *tmpPtr++)
    347         {
    348             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::LoadConfig() ERROR. line %d ", __LINE__));
    349             return LoadConfigStatus_NonCriticalError;
    350         }
    351         if (iVersion != *tmpPtr++)
    352         {
    353             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::LoadConfig() ERROR. line %d ", __LINE__));
    354             return LoadConfigStatus_NonCriticalError;
    355         }
    356 
    357         //flag for download type 3gpp/fasttrack, download complete, and playback modes
    358         iFlag = *tmpPtr++;
    359         uint32 aUrlLen = *tmpPtr++;
    360 
    361         uint32 aHostNameLen = *tmpPtr++;    //if proxy is in use, it is the proxy address len
    362         iProxyPort = *tmpPtr++;
    363 
    364         //client only downloads the clip which is smaller than this size
    365         uint32 aMaxAllowedFileSize = *tmpPtr++;
    366         if (/*iMaxAllowedFileSize==0 && */aMaxAllowedFileSize > 0) iMaxAllowedFileSize = aMaxAllowedFileSize;
    367 
    368         //the file size after it is completly downloaded.
    369         iOverallFileSize = *tmpPtr++;
    370         //for FastTrack, this would be the accumulated bytes downloaded
    371         iCurrentFileSize = *tmpPtr++;
    372         if (iOverallFileSize == 0 ||
    373                 iMaxAllowedFileSize < iOverallFileSize ||
    374                 iOverallFileSize < iCurrentFileSize)
    375         {
    376             return LoadConfigStatus_NonCriticalError;
    377         }
    378         // for content-length flag
    379         iHasContentLength = *tmpPtr++;
    380 
    381         iConnectTimeout = *tmpPtr++;
    382         iSendTimeout = *tmpPtr++;
    383         iRecvTimeout = *tmpPtr++;
    384 
    385         //FastTrack only
    386         iRangeStartTime = *tmpPtr++; //in ms
    387         uint32 aSelectedTrackIDsSize = *tmpPtr++;
    388 
    389         uint32 aPlayerVersionLen = *tmpPtr++;
    390         uint32 aUserAgentLen = *tmpPtr++;
    391         uint32 aUserNetworkLen = *tmpPtr++;
    392         uint32 aDeviceInfoLen = *tmpPtr++;
    393         uint32 aUserIdLen = *tmpPtr++;
    394         uint32 aUserAuthLen = *tmpPtr++;
    395         uint32 aExpirationLen = *tmpPtr++;
    396         uint32 aAppStringLen = *tmpPtr++;
    397         uint32 aFillerLen = *tmpPtr++;
    398         uint32 aSignLen = *tmpPtr++;
    399 
    400         iSelectedTrackIDs.clear();
    401         if (aSelectedTrackIDsSize)
    402         {
    403             if (aSelectedTrackIDsSize != iFile->Read(iTmpBuf, 1, aSelectedTrackIDsSize))
    404             {
    405                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::LoadConfig() ERROR. line %d ", __LINE__));
    406                 return LoadConfigStatus_NonCriticalError;
    407             };
    408             uint8 *tmpBuf = iTmpBuf;
    409             for (int32 i = aSelectedTrackIDsSize - 1; i >= 0; i--)
    410             {//Track ID should only use one byte.
    411                 iSelectedTrackIDs.push_back(*tmpBuf++);
    412             }
    413         }
    414 
    415         // allocate memory for reading the following string
    416         PVDlCfgFileAllocator alloc;
    417         uint8 *aTmpBuf = (uint8 *)alloc.allocate(PVDLCONFIGFILE_TEMPORARY_BUFFER_SIZE);
    418         if (!aTmpBuf) return LoadConfigStatus_CriticalError;
    419 
    420         if (aUrlLen)
    421         {
    422             if (aUrlLen != iFile->Read(aTmpBuf, 1, aUrlLen))
    423             {
    424                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::LoadConfig() ERROR. line %d ", __LINE__));
    425                 alloc.deallocate(aTmpBuf);
    426                 return LoadConfigStatus_NonCriticalError;
    427             };
    428             aTmpBuf[aUrlLen] = 0;
    429             if (iUrl.get_size() == 0)
    430                 iUrl.set(OSCL_STATIC_CAST(char*, aTmpBuf), aUrlLen);
    431             else
    432             {
    433                 // new url exists, and need to compare it with the url in config file
    434                 if (iUrl.get_size() != aUrlLen)
    435                 {
    436                     alloc.deallocate(aTmpBuf);
    437                     return LoadConfigStatus_NonCriticalError;
    438                 }
    439                 if (oscl_strcmp(iUrl.get_cstr(), OSCL_STATIC_CAST(char*, aTmpBuf)) != 0)
    440                 {
    441                     alloc.deallocate(aTmpBuf);
    442                     return LoadConfigStatus_NonCriticalError;
    443                 }
    444             }
    445         }
    446         if (aHostNameLen)
    447         {
    448             if (aHostNameLen != iFile->Read(aTmpBuf, 1, aHostNameLen))
    449             {
    450                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::LoadConfig() ERROR. line %d ", __LINE__));
    451                 alloc.deallocate(aTmpBuf);
    452                 return LoadConfigStatus_NonCriticalError;
    453             };
    454             iProxyName.set(OSCL_STATIC_CAST(char*, aTmpBuf), aHostNameLen);
    455         }
    456         if (aPlayerVersionLen)
    457         {
    458             if (aPlayerVersionLen != iFile->Read(aTmpBuf, 1, aPlayerVersionLen))
    459             {
    460                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::LoadConfig() ERROR. line %d ", __LINE__));
    461                 alloc.deallocate(aTmpBuf);
    462                 return LoadConfigStatus_NonCriticalError;
    463             };
    464             iPlayerVersion.set(OSCL_STATIC_CAST(char*, aTmpBuf), aPlayerVersionLen);
    465         }
    466         if (aUserAgentLen)
    467         {
    468             if (aUserAgentLen != iFile->Read(aTmpBuf, 1, aUserAgentLen))
    469             {
    470                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::LoadConfig() ERROR. line %d ", __LINE__));
    471                 alloc.deallocate(aTmpBuf);
    472                 return LoadConfigStatus_NonCriticalError;
    473             };
    474             iUserAgent.set(OSCL_STATIC_CAST(char*, aTmpBuf), aUserAgentLen);
    475         }
    476         if (aUserNetworkLen)
    477         {
    478             if (aUserNetworkLen != iFile->Read(aTmpBuf, 1, aUserNetworkLen))
    479             {
    480                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::LoadConfig() ERROR. line %d ", __LINE__));
    481                 alloc.deallocate(aTmpBuf);
    482                 return LoadConfigStatus_NonCriticalError;
    483             };
    484             iUserNetwork.set(OSCL_STATIC_CAST(char*, aTmpBuf), aUserNetworkLen);
    485         }
    486         if (aDeviceInfoLen)
    487         {
    488             if (aDeviceInfoLen != iFile->Read(aTmpBuf, 1, aDeviceInfoLen))
    489             {
    490                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::LoadConfig() ERROR. line %d ", __LINE__));
    491                 alloc.deallocate(aTmpBuf);
    492                 return LoadConfigStatus_NonCriticalError;
    493             };
    494             iDeviceInfo.set(OSCL_STATIC_CAST(char*, aTmpBuf), aDeviceInfoLen);
    495         }
    496 
    497         if (aUserIdLen)
    498         {
    499             if (aUserIdLen != iFile->Read(aTmpBuf, 1, aUserIdLen))
    500             {
    501                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::LoadConfig() ERROR. line %d ", __LINE__));
    502                 alloc.deallocate(aTmpBuf);
    503                 return LoadConfigStatus_NonCriticalError;
    504             };
    505             iUserId.set(OSCL_STATIC_CAST(char*, aTmpBuf), aUserIdLen);
    506         }
    507         if (aUserAuthLen)
    508         {
    509             if (aUserAuthLen != iFile->Read(aTmpBuf, 1, aUserAuthLen))
    510             {
    511                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::LoadConfig() ERROR. line %d ", __LINE__));
    512                 alloc.deallocate(aTmpBuf);
    513                 return LoadConfigStatus_NonCriticalError;
    514             };
    515             iUserAuth.set(OSCL_STATIC_CAST(char*, aTmpBuf), aUserAuthLen);
    516         }
    517         if (aExpirationLen)
    518         {
    519             if (aExpirationLen != iFile->Read(aTmpBuf, 1, aExpirationLen))
    520             {
    521                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::LoadConfig() ERROR. line %d ", __LINE__));
    522                 alloc.deallocate(aTmpBuf);
    523                 return LoadConfigStatus_NonCriticalError;
    524             };
    525             iExpiration.set(OSCL_STATIC_CAST(char*, aTmpBuf), aExpirationLen);
    526         }
    527         if (aAppStringLen)
    528         {
    529             if (aAppStringLen != iFile->Read(aTmpBuf, 1, aAppStringLen))
    530             {
    531                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::LoadConfig() ERROR. line %d ", __LINE__));
    532                 alloc.deallocate(aTmpBuf);
    533                 return LoadConfigStatus_NonCriticalError;
    534             };
    535             iAppString.set(OSCL_STATIC_CAST(char*, aTmpBuf), aAppStringLen);
    536         }
    537         if (aFillerLen)
    538         {
    539             if (aFillerLen != iFile->Read(aTmpBuf, 1, aFillerLen))
    540             {
    541                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::LoadConfig() ERROR. line %d ", __LINE__));
    542                 alloc.deallocate(aTmpBuf);
    543                 return LoadConfigStatus_NonCriticalError;
    544             };
    545             iFiller.set(OSCL_STATIC_CAST(char*, aTmpBuf), aFillerLen);
    546         }
    547         if (aSignLen)
    548         {
    549             if (aSignLen != iFile->Read(aTmpBuf, 1, aSignLen))
    550             {
    551                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVDlCfgFile::LoadConfig() ERROR. line %d ", __LINE__));
    552                 alloc.deallocate(aTmpBuf);
    553                 return LoadConfigStatus_NonCriticalError;
    554             };
    555             iSign.set(OSCL_STATIC_CAST(char*, aTmpBuf), aSignLen);
    556         }
    557         alloc.deallocate(aTmpBuf);
    558     }
    559 
    560     return LoadConfigStatus_NoError;
    561 }
    562 
    563 void PVDlCfgFile::composeFixedHeader(uint8 *aBuf)
    564 {
    565     uint32 *tmpPtr = OSCL_STATIC_CAST(uint32*, aBuf);
    566     *tmpPtr++ =     iMagic32;
    567     *tmpPtr++ =     iVersion;
    568 
    569     //flag for download type 3gpp/fasttrack, download complete, and playback modes
    570     *tmpPtr++ =     iFlag;
    571     *tmpPtr++ =     iUrl.get_size();
    572     *tmpPtr++ =     iProxyName.get_size();  //if proxy is in use, it is the proxy address len
    573     *tmpPtr++ =     iProxyPort;
    574 
    575     //client only downloads the clip which is smaller than this size
    576     *tmpPtr++ =     iMaxAllowedFileSize;
    577     //the file size after it is completly downloaded.
    578     *tmpPtr++ =     iOverallFileSize;
    579     //for FastTrack, this would be the accumulated bytes downloaded
    580     *tmpPtr++ =     iCurrentFileSize;
    581     // flag of whether to have content length for the previous download
    582     *tmpPtr++ =     iHasContentLength;
    583 
    584     *tmpPtr++ =     iConnectTimeout;
    585     *tmpPtr++ =     iSendTimeout;
    586     *tmpPtr++ =     iRecvTimeout;
    587 
    588     //FastTrack only
    589     *tmpPtr++ =     iRangeStartTime; //in ms
    590     *tmpPtr++ =     iSelectedTrackIDs.size();
    591 
    592     *tmpPtr++ =     iPlayerVersion.get_size();
    593     *tmpPtr++ =     iUserAgent.get_size();
    594     *tmpPtr++ =     iUserNetwork.get_size();
    595     *tmpPtr++ =     iDeviceInfo.get_size();
    596     *tmpPtr++ =     iUserId.get_size();
    597     *tmpPtr++ =     iUserAuth.get_size();
    598     *tmpPtr++ =     iExpiration.get_size();
    599     *tmpPtr++ =     iAppString.get_size();
    600     *tmpPtr++ =     iFiller.get_size();
    601     *tmpPtr++ =     iSign.get_size();
    602 }
    603 
    604 
    605