bool
PVMFOMXEncPort::pvmiSetPortFormatSpecificInfoSync(OsclRefCounterMemFrag& aMemFrag)
{
    if ((iConnectedPort) &&
            (iTag == PVMF_OMX_ENC_NODE_PORT_TYPE_OUTPUT))
    {
        OsclAny* temp = NULL;
        iConnectedPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
        PvmiCapabilityAndConfig *config = (PvmiCapabilityAndConfig*) temp;

        /*
         * Create PvmiKvp for capability settings
         */
        if ((config) && (aMemFrag.getMemFragSize() > 0))
        {
            OsclMemAllocator alloc;
            PvmiKvp kvp;
            kvp.key = NULL;
            kvp.length = oscl_strlen(PVMF_FORMAT_SPECIFIC_INFO_KEY) + 1; // +1 for \0
            kvp.key = (PvmiKeyType)alloc.ALLOCATE(kvp.length);
            if (kvp.key == NULL)
            {
                return false;
            }
            oscl_strncpy(kvp.key, PVMF_FORMAT_SPECIFIC_INFO_KEY, kvp.length);

            kvp.value.key_specific_value = (OsclAny*)(aMemFrag.getMemFragPtr());
            kvp.capacity = aMemFrag.getMemFragSize();
            kvp.length = aMemFrag.getMemFragSize();
            PvmiKvp* retKvp = NULL; // for return value
            int32 err;
            OSCL_TRY(err, config->setParametersSync(NULL, &kvp, 1, retKvp););
bool
PVMFSocketPort::pvmiGetPortInPlaceDataProcessingInfoSync(const char* aFormatValType,
        PvmiKvp*& aKvp)
{
    /*
     * Create PvmiKvp for capability settings
     */
    aKvp = NULL;
    OsclMemAllocator alloc;
    uint32 strLen = oscl_strlen(aFormatValType) + 1;
    uint8* ptr = (uint8*)alloc.allocate(sizeof(PvmiKvp) + strLen);
    if (!ptr)
    {
        PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSocketPort::pvmiGetPortInPlaceDataProcessingInfoSync: Error - No memory. Cannot allocate PvmiKvp"));
        return false;
    }
    aKvp = new(ptr) PvmiKvp;
    ptr += sizeof(PvmiKvp);
    aKvp->key = (PvmiKeyType)ptr;
    oscl_strncpy(aKvp->key, aFormatValType, strLen);
    aKvp->length = aKvp->capacity = strLen;

#if SNODE_ENABLE_UDP_MULTI_PACKET
    if (iTag == PVMF_SOCKET_NODE_PORT_TYPE_SOURCE)
        aKvp->value.bool_value = false;//for the multiple UDP recv feature
    else
#endif
        aKvp->value.bool_value = true;

    return true;
}
        PVLoggerConfigFile(): iLogFileRead(false)
        {
            iFileServer.Connect();
            // Full path of pvlogger.ini is: SOURCENAME_PREPEND_STRING + pvlogger.ini
            oscl_strncpy(iLogFileName, SOURCENAME_PREPEND_STRING,
                         oscl_strlen(SOURCENAME_PREPEND_STRING) + 1);
            oscl_strcat(iLogFileName, "pvlogger.ini");
            oscl_memset(ibuffer, 0, sizeof(ibuffer));
            iAppenderType = 0;

        }
void pv_metadata_engine_test::ReadClipsFile()
{

    char* iClip;
    char ClipsFileName[255];
    int32 err = 0;

    Oscl_FileServer fileServer;
    err = fileServer.Connect();

    if (0 == err)
    {
        Oscl_File *ClipsFile = new Oscl_File;
        // Full path of ClipsFile is: SOURCENAME_PREPEND_STRING + pvlogger.ini
        oscl_strncpy(ClipsFileName, SOURCENAME_PREPEND_STRING,
                     oscl_strlen(SOURCENAME_PREPEND_STRING) + 1);
        oscl_strcat(ClipsFileName, "Clips.txt");

        printf("\nPath for Clips File is %s\n", ClipsFileName);

        err = ClipsFile->Open(ClipsFileName, Oscl_File::MODE_READ, fileServer);

        if (0 == err)
        {
            int len = 0;
            if (0 == ClipsFile->Seek(0, Oscl_File::SEEKSET))
            {
                while (!ClipsFile->EndOfFile())
                {
                    iClip = (char*)oscl_malloc(200);
                    iClip[0] = '\0';
                    fgetline(ClipsFile, iClip, 127);
                    len = oscl_strlen(iClip);
                    if (len == 0 || iClip[0] == '\n' || (iClip[0] == '\r' && iClip[1] == '\n'))
                    {
                        numOfClips--;
                        oscl_free(iClip);
                    }
                    else if (iClip[len-1] == '\n' && iClip[len-2] == '\r')
                    {
                        iClip[len-2] = '\0';
                        iClips.push_back(iClip);
                    }
                    else if (iClip[len-1] == '\n' && iClip[len-2] != '\r')
                    {
                        iClip[len-1] = '\0';
                        iClips.push_back(iClip);
                    }
                    else
                    {
                        iClip[len] = '\0';
                        iClips.push_back(iClip);
                    }

                    numOfClips++;

                }

                ClipsFile->Close();

                printf("\nClips are\n");
                for (it = iClips.begin(); it < iClips.end(); it++)
                {
                    printf("\n%s\n", *it);
                }

                it = iClips.begin();
                iClipFilePresent = true;

            }
        }
        delete(ClipsFile);
    }
    fileServer.Close();

}
void pv_metadata_engine_test::ReadMetadataFile()
{
    Oscl_File *MetadataFile = new Oscl_File;
    const int numKeys = 40;
    char arr[numKeys][MAX_LEN];
    char *keys[numKeys];
    int count = 0;
    char KeysFileName[255];
    int32 err = 0;

    Oscl_FileServer fileServer;
    err = fileServer.Connect();

    // Full path of MetadataFile is: SOURCENAME_PREPEND_STRING + pvlogger.ini
    oscl_strncpy(KeysFileName, SOURCENAME_PREPEND_STRING,
                 oscl_strlen(SOURCENAME_PREPEND_STRING) + 1);
    oscl_strcat(KeysFileName, "MetadataKeys.txt");

    printf("\nPath for Keys File is %s\n", KeysFileName);

    err = MetadataFile->Open(KeysFileName, Oscl_File::MODE_READ, fileServer);

    if (0 == err)
    {
        int ii = 0;
        int len = 0;
        if (0 == MetadataFile->Seek(0, Oscl_File::SEEKSET))
        {
            while (!MetadataFile->EndOfFile())
            {
                arr[ii][0] = '\0';
                fgetline(MetadataFile, arr[ii], MAX_LEN);
                len = oscl_strlen(arr[ii]);

                if (len == 0 || arr[ii][0] == '\n' || (arr[ii][0] == '\r' && arr[ii][1] == '\n'))
                {
                    ii--;
                }
                else if (arr[ii][len-1] == '\n' && arr[ii][len-2] == '\r')
                {
                    arr[ii][len-2] = '\0';
                    keys[ii] = arr[ii];
                }
                else if (arr[ii][len-1] == '\n' && arr[ii][len-2] != '\r')
                {
                    arr[ii][len-1] = '\0';
                    keys[ii] = arr[ii];
                }
                else
                {
                    arr[ii][len] = '\0';
                    keys[ii] = arr[ii];
                }

                ii++;
            }
        }

        MetadataFile->Close();

        count = ii - 1;

        printf("\nKeys are\n");
        for (int j = 0; j <= ii - 1; j++)
        {
            printf("\n%s", keys[j]);
        }

        for (int i = 0; i <= count; i++)
        {
            iMetadataKeyList.push_front(keys[i]);
        }

    }
    fileServer.Close();
    delete(MetadataFile);
}
OSCL_EXPORT_REF bool parseRtspRange(const char *rangeString, int length, RtspRangeType& range)
{
    const char *end = rangeString + length;

    const char* sptr, *eptr;

    // initialize range to invalid format
    range.format = RtspRangeType::INVALID_RANGE;

    // find the first word before the "="
    sptr = skip_whitespace_and_line_term(rangeString, end);
    if (sptr >= end)
    {
        return false;
    }

    for (eptr = sptr; eptr < end &&
            (*eptr != '=' && *eptr != ':' && *eptr != ' ' && *eptr != '\t');
            ++eptr);


    StrPtrLen smpte_type("smpte");
    StrPtrLen smpte25_type("smpte-25");
    StrPtrLen smpte30_type("smpte-30-drop");
    StrPtrLen npt_type("npt");
    StrPtrLen abs_type("clock");
//#ifdef RTSP_PLAYLIST_SUPPORT
    StrPtrLen playlist_play_time_type("playlist_play_time");
//#endif //#ifdef RTSP_PLAYLIST_SUPPORT

    if (!oscl_strncmp(sptr, smpte_type.c_str(), eptr - sptr) ||
            !oscl_strncmp(sptr, smpte25_type.c_str(), eptr - sptr) ||
            !oscl_strncmp(sptr, smpte30_type.c_str(), eptr - sptr))
    {
        // Parsing one of the SMPTE time formats

        // save the exact format temporarily
        RtspRangeType::RtspRangeFormat tmp_format;
        if (!oscl_strncmp(sptr, smpte30_type.c_str(), smpte30_type.length()))
        {
            tmp_format = RtspRangeType::SMPTE_30_RANGE;
        }
        else if (!oscl_strncmp(sptr, smpte25_type.c_str(), smpte25_type.length()))
        {
            tmp_format = RtspRangeType::SMPTE_25_RANGE;
        }
        else
        {
            tmp_format = RtspRangeType::SMPTE_RANGE;
        }

        // skip ahead to beyond the "="
        if (*eptr != '=')
        {
            for (; eptr < end && *eptr != '='; ++eptr);
        }

        sptr = skip_whitespace(eptr + 1, end);
        if (sptr >= end)
        {
            return false;
        }

        // find the start/end separator
        for (eptr = sptr; eptr < end &&
                (*eptr != '-'); ++eptr);

        if (*eptr != '-')
        {
            return false;
        }

        range.start_is_set = false;
        if (eptr > sptr)
        {
            // there is a start time

            if (parse_smpte_format(sptr, eptr, tmp_format, range.smpte_start) == false)
            {
                return false;
            }

            // now set the appropriate flags
            range.start_is_set = true;
        }

        // see if there is a stop time
        sptr = skip_whitespace_and_line_term(eptr + 1, end);
        range.end_is_set = false;
        if (sptr < end)
        {
            // there is a stop time specification
            eptr = skip_to_whitespace(sptr, end);

            if (parse_smpte_format(sptr, eptr, tmp_format, range.smpte_end)
                    == false)
            {
                return false;
            }

            // now set the appropriate flags
            range.end_is_set = true;
        }

        // now set the appropriate range format
        range.format = tmp_format;

    } // end if this is an SMPTE time format

    else if (!oscl_strncmp(sptr, npt_type.c_str(), eptr - sptr))
    {

        // skip ahead to beyond the "=" or ":"
        if (*eptr != '=')
        {
            for (; eptr < end && *eptr != '=' && *eptr != ':'; ++eptr);
        }

        sptr = skip_whitespace(eptr + 1, end);
        if (sptr >= end)
        {
            return false;
        }

        // find the start/end separator
        for (eptr = sptr; eptr < end &&
                (*eptr != '-'); ++eptr);

        if (*eptr != '-')
        {
            return false;
        }

        range.start_is_set = false;
        if (eptr > sptr)
        {
            // there is a start time
            if (parse_npt_format(sptr, eptr, range.npt_start) == false)
            {
                return false;
            }

            // now set the appropriate flags
            range.start_is_set = true;

        }

        // see if there is a stop time
        range.end_is_set = false;
        sptr = skip_whitespace_and_line_term(eptr + 1, end);
        if (sptr < end)
        {
            // there is a stop time specification
            eptr = skip_to_whitespace(sptr, end);

            if (parse_npt_format(sptr, eptr, range.npt_end)
                    == false)
            {
                return false;
            }

            // now set the appropriate flags
            range.end_is_set = true;
        }

        // now set the appropriate range format
        range.format = RtspRangeType::NPT_RANGE;

    } // end if this is an NPT time format

    else if (!oscl_strncmp(sptr, abs_type.c_str(), eptr - sptr))
    {


        // skip ahead to beyond the "="
        if (*eptr != '=')
        {
            for (; eptr < end && *eptr != '='; ++eptr);
        }

        sptr = skip_whitespace(eptr + 1, end);
        if (sptr >= end)
        {
            return false;
        }

        // find the start/end separator
        for (eptr = sptr; eptr < end &&
                (*eptr != '-'); ++eptr);

        if (*eptr != '-')
        {
            return false;
        }

        range.start_is_set = false;
        if (eptr > sptr)
        {
            // there is a start time
            if (parse_abs_format(sptr, eptr, range.abs_start) == false)
            {
                return false;
            }

            // now set the appropriate flags
            range.start_is_set = true;

        }

        // see if there is a stop time
        sptr = skip_whitespace_and_line_term(eptr + 1, end);
        range.end_is_set = true;
        if (sptr < end)
        {
            // there is a stop time specification
            eptr = skip_to_whitespace(sptr, end);

            if (parse_abs_format(sptr, eptr, range.abs_end)
                    == false)
            {
                return false;
            }

            // now set the appropriate flags
            range.end_is_set = true;
        }

        // now set the appropriate range format
        range.format = RtspRangeType::ABS_RANGE;

    } // end if this is an ABS time format
//#ifdef RTSP_PLAYLIST_SUPPORT
    // for Range:playlist_play_time=<URN,clipIndex,clipOffset>
    //playlist_play_time=</public/playlist/va_playlists/test.ply,3,0.0>;npt=194.81542
    else if (!oscl_strncmp(sptr, playlist_play_time_type.c_str(), eptr - sptr))
    {
        // store the whole string since we may not need the parsed version of things
        //oscl_memcpy(range.iPlaylistPlayStr,rangeString,length);
        //range.iPlaylistPlayStr[length] = '\0';

        range.format = RtspRangeType::PLAYLIST_TIME_RANGE;
        range.start_is_set = range.end_is_set = false;

        // now set the appropriate flags
        range.start_is_set = true;

        // skip ahead to beyond the "="
        if (*eptr != '=')
        {
            for (; eptr < end && *eptr != '='; ++eptr);
        }

        sptr = skip_whitespace(eptr + 1, end);
        if (sptr >= end)
        {
            return false;
        }

        // next should be the opening "<"
        // skip ahead to beyond the "<"
        if (*eptr != '<')
        {
            for (; eptr < end && *eptr != '<'; ++eptr);
        }

        sptr = skip_whitespace(eptr + 1, end);
        if (sptr >= end)
        {
            return false;
        }

        // find the comma separator
        for (eptr = sptr; eptr < end &&
                (*eptr != ','); ++eptr);

        if (*eptr != ',')
        {
            return false;
        }

        // first the urn
        if (eptr > sptr)
        {
            // there is a urn
            if (oscl_memcpy(range.iPlaylistUrl, sptr, eptr - sptr) == false)
            {
                return false;
            }
            //range.iUrn[(eptr-sptr)+1] = '\0';
            range.iPlaylistUrl[eptr-sptr] = '\0';
        }

        // now the clipIndex
        sptr = skip_whitespace(eptr + 1, end);
        if (sptr >= end)
        {
            return false;
        }

        // find the next comma separator
        for (eptr = sptr; eptr < end &&
                (*eptr != ','); ++eptr);

        if (*eptr != ',')
        {
            return false;
        }

        // now the clipIndex
        if (eptr > sptr)
        {
            // there is a clipIndex
            uint32 tmp;
            if (PV_atoi(sptr, 'd', eptr - sptr, tmp) == false)
            {
                return false;
            }
            range.playlist_start.iClipIndex = (int32)tmp;
        }

        // now the clipOffset
        sptr = skip_whitespace(eptr + 1, end);
        if (sptr >= end)
        {
            return false;
        }

        // find the final '>' separator or the final possible '.' in offset
        //<sec>.<frac>
        for (eptr = sptr; eptr < end &&
                (*eptr != '>') && (*eptr != '.'); ++eptr);

        if (eptr >= end)
        {
            return false;
        }

        // @todo ignore the factional part for now
        // now the clipOffset
        if (eptr > sptr)
        {
            // there is a clipOffset
            uint32 tmp;
            if (PV_atoi(sptr, 'd', eptr - sptr, tmp) == false)
            {
                return false;
            }
            range.playlist_start.sec = (int32)tmp;

            {
                range.playlist_start.milli_sec = 0;
                if (*eptr == '.')
                {
                    // there is an optional fractional seconds field

                    // get the fractional seconds
                    const int MAX_TMP_BUFSIZE = 12;
                    char tmpbuf[MAX_TMP_BUFSIZE];
                    int copy_size;

                    eptr = skip_to_whitespace(sptr, end);

                    copy_size = eptr - sptr;

                    if (copy_size > MAX_TMP_BUFSIZE - 1)
                    {
                        copy_size = MAX_TMP_BUFSIZE - 1;
                    }

                    oscl_strncpy(tmpbuf, sptr, copy_size);


                    tmpbuf[copy_size] = '\0';

                    OsclFloat tmp_fnum;
                    if (!PV_atof(tmpbuf, tmp_fnum))
                        return false;
                    range.playlist_start.milli_sec = (uint32)(1000.0 * tmp_fnum + 0.5);
                }
            }
        }
    }  // end if this is a playlist_play_time format, for response to playlist_play commands
//#endif //#ifdef RTSP_PLAYLIST_SUPPORT
    else
    {
        /*Unsupported time format*/
        range.format = RtspRangeType::UNKNOWN_RANGE;
        range.start_is_set = false;
        range.end_is_set = false;
        return false;
    }

    return true;
}
OSCL_EXPORT_REF bool parse_abs_format(const char* start_ptr, const char *end_ptr,
                                      AbsTimeFormat& abs_range)
{

    // get format YYYYMMDDT
    const char *sptr, *eptr;
    char sep;
    uint32 tmp;

    sptr = start_ptr;

    // check if the ninth character is a "T"
    eptr = sptr + 8;

    sep = 'T';
    if (eptr >= end_ptr || *eptr != sep)
    {
        return false;
    }

    sptr = parse_range_integer(sptr, eptr,
                               4, &sep, tmp);

    if (! sptr || tmp > 9999)
    {
        return false;
    }

    abs_range.year = (uint16)tmp;

    // get the month
    sptr = parse_range_integer(sptr, eptr,
                               2, &sep, tmp);

    if (! sptr || tmp == 0 || tmp > 12)
    {
        return false;
    }

    abs_range.month = (uint8)tmp;

    // get the day
    sptr = parse_range_integer(sptr, eptr,
                               2, &sep, tmp);

    if (! sptr || tmp == 0 || tmp > 31)
    {
        return false;
    }

    abs_range.day = (uint8)tmp;


    sptr = eptr + 1;
    eptr = sptr + 6;

    if (eptr >= end_ptr || (*eptr != 'Z' && *eptr != '.'))
    {
        return false;
    }

    // get the hours
    sptr = parse_range_integer(sptr, eptr,
                               2, NULL, tmp);

    if (! sptr || tmp > 23)
    {
        return false;
    }

    abs_range.hours = (uint8)tmp;

    // get the minutes
    sptr = parse_range_integer(sptr, eptr,
                               2, NULL, tmp);

    if (! sptr || tmp > 59)
    {
        return false;
    }

    abs_range.min = (uint8)tmp;

    // get the number of seconds
    sptr = parse_range_integer(sptr, eptr,
                               2, NULL, tmp);

    if (! sptr || tmp > 59)
    {
        return false;
    }

    abs_range.sec = (uint8)tmp;

    abs_range.frac_sec = 0;

    if (*eptr == '.')
    {
        // get the fractional seconds
        // get the fractional seconds
        const int MAX_TMP_BUFSIZE = 12;
        char tmpbuf[MAX_TMP_BUFSIZE];
        int copy_size;

        sptr = eptr;

        for (eptr = sptr; eptr < end_ptr && *eptr != 'Z';
                ++eptr);

        if (*eptr != 'Z')
        {
            return false;
        }

        copy_size = eptr - sptr;
        if (copy_size > MAX_TMP_BUFSIZE - 1)
        {
            copy_size = MAX_TMP_BUFSIZE - 1;
        }

        oscl_strncpy(tmpbuf, sptr, copy_size);

        tmpbuf[copy_size] = '\0';

        if (!PV_atof(tmpbuf, abs_range.frac_sec))
            return false;

    }

    return true;
}
OSCL_EXPORT_REF bool parse_npt_format(const char* start_ptr, const char *end_ptr,
                                      NptTimeFormat& npt_range)
{

    // get required HH:MM:SS values
    const char *sptr, *eptr;
    uint32 tmp;

    sptr = start_ptr;

    StrPtrLen now_str("now");
    if (!oscl_strncmp(sptr, now_str.c_str(), now_str.length()))
    {
        // this is the "now" keyword
        npt_range.npt_format = NptTimeFormat::NOW;
        return true;
    }

    // see if the format contains a ':' separator character
    for (eptr = sptr; eptr < end_ptr && *eptr != ':'; ++eptr);

    if (*eptr == ':')
    {
        // this is the npt-hhmmss format

        char sep = ':';
        // get the number of hours
        sptr = parse_range_integer(sptr, eptr,
                                   0, &sep, tmp);

        if (!sptr)
        {
            return false;
        }

        npt_range.npt_format = NptTimeFormat::NPT_HHMMSS;
        npt_range.npt_hhmmss.hours = tmp;


        // get the number of minutes
        sptr = parse_range_integer(sptr + 1, end_ptr,
                                   2, &sep, tmp);

        if (!sptr || *sptr != ':')
        {
            return false;
        }

        if (tmp > 59)
        {
            return false;
        }

        npt_range.npt_hhmmss.min = (uint8)tmp;


        sep = '.';
        // get the number of seconds
        sptr = parse_range_integer(sptr + 1, end_ptr,
                                   2, &sep, tmp);

        if (!sptr)
        {
            return false;
        }

        if (tmp > 59)
        {
            return false;
        }

        npt_range.npt_hhmmss.sec = (uint8)tmp;

        npt_range.npt_hhmmss.frac_sec = 0;
        // determine if the fractional seconds exists
        if (*sptr == '.')
        {
            // get the fractional seconds
            const int MAX_TMP_BUFSIZE = 12;
            char tmpbuf[MAX_TMP_BUFSIZE];
            int copy_size;

            eptr = skip_to_whitespace(sptr, end_ptr);

            copy_size = eptr - sptr;
            if (copy_size > MAX_TMP_BUFSIZE - 1)
            {
                copy_size = MAX_TMP_BUFSIZE - 1;
            }

            oscl_strncpy(tmpbuf, sptr, copy_size);

            tmpbuf[copy_size] = '\0';

            if (!PV_atof(tmpbuf, npt_range.npt_hhmmss.frac_sec))
                return false;

        }

    } // end if the format is NPT_HHMMSS

    else
    {

        char sep = '.';
        // this is the NPT_SEC format
        npt_range.npt_format = NptTimeFormat::NPT_SEC;

        // get the number of seconds
        sptr = parse_range_integer(sptr, eptr,
                                   0, &sep, tmp);

        if (!sptr)
        {
            return false;
        }

        npt_range.npt_sec.sec = tmp;

        npt_range.npt_sec.milli_sec = 0;
        if (*sptr == '.')
        {
            // there is an optional fractional seconds field

            // get the fractional seconds
            const int MAX_TMP_BUFSIZE = 12;
            char tmpbuf[MAX_TMP_BUFSIZE];
            int copy_size;

            eptr = skip_to_whitespace(sptr, end_ptr);

            copy_size = eptr - sptr;

            if (copy_size > MAX_TMP_BUFSIZE - 1)
            {
                copy_size = MAX_TMP_BUFSIZE - 1;
            }

            oscl_strncpy(tmpbuf, sptr, copy_size);


            tmpbuf[copy_size] = '\0';

            OsclFloat tmp_fnum;
            if (!PV_atof(tmpbuf, tmp_fnum))
                return false;
            npt_range.npt_sec.milli_sec = (uint32)(1000.0 * tmp_fnum + 0.5);
        }

    } // end if the format is NPT_SEC

    return true;
}
PVAviFileStreamlist::PVAviFileStreamlist(PVFile *aFp, uint32 aStrListSz)
{
    iCodecSpecificHdrDataSize = 0;
    iStreamListSize = aStrListSz;
    ipCodecSpecificHdrData = NULL;
    iError = PV_AVI_FILE_PARSER_SUCCESS;
    uint32 bytesRead = 0;
    uint32 chunkType = 0;

    while (bytesRead < iStreamListSize)
    {
        if ((iError = PVAviFileParserUtils::ReadNextChunkType(aFp, chunkType)) != PV_AVI_FILE_PARSER_SUCCESS)
        {
            PVAVIFILE_LOGINFO((0, "PVAviFileStreamlist::PVAviFileStreamlist: Unsupported chunk"));

            if (PV_AVI_FILE_PARSER_UNSUPPORTED_CHUNK == iError)
            {
                uint32 chksz = 0;
                if (PV_AVI_FILE_PARSER_SUCCESS != PVAviFileParserUtils::read32(aFp, chksz, true))
                {
                    PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Read Error"));
                    iError = PV_AVI_FILE_PARSER_READ_ERROR;
                    break;
                }
                aFp->Seek(chksz, Oscl_File::SEEKCUR);
                bytesRead += chksz + CHUNK_SIZE + CHUNK_SIZE; // data + chunk size + chunk type

                PVAVIFILE_LOGINFO((0, "PVAviFileStreamlist::PVAviFileStreamlist: Unsupported Chunk Skipped"));

                iError = PV_AVI_FILE_PARSER_SUCCESS;
                continue;
            }
            else
            {

                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Read Error"));
                iError = PV_AVI_FILE_PARSER_READ_ERROR;
                break;
            }
        }

        bytesRead += CHUNK_SIZE;

        if (STRH == chunkType)
        {
            PVAVIFILE_LOGINFO((0, "PVAviFileStreamlist::PVAviFileStreamlist: Found Stream Header"));

            uint32 aviStrhSize = 0;
            if (PV_AVI_FILE_PARSER_SUCCESS != PVAviFileParserUtils::read32(aFp, aviStrhSize, true))
            {
                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Read Error"));
                iError =  PV_AVI_FILE_PARSER_READ_ERROR;
                break;
            }

            bytesRead += CHUNK_SIZE;

            if (bytesRead > iStreamListSize)
            {
                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File & Byte Count mismatch"));
                iError =  PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR;
                break;

            }

            if ((aviStrhSize <= 0) || (aviStrhSize > iStreamListSize))
            {
                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: stream header size greater than stream list size"));
                iError =  PV_AVI_FILE_PARSER_WRONG_SIZE;
                break;

            }

            if ((iError = ParseStreamHeader(aFp, aviStrhSize)) != PV_AVI_FILE_PARSER_SUCCESS)
            {
                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: ParseStreamHeader function error"));
                break;
            }

            bytesRead += aviStrhSize;
            if (bytesRead > iStreamListSize)
            {
                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Size & Byte Count Mismatch"));
                iError =  PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR;
                break;

            }
        }
        else if (STRF == chunkType)
        {
            PVAVIFILE_LOGINFO((0, "PVAviFileStreamlist::PVAviFileStreamlist: Found Stream Format Header"));

            uint32 aviStrfSize = 0;
            if (PV_AVI_FILE_PARSER_SUCCESS != PVAviFileParserUtils::read32(aFp, aviStrfSize, true))
            {
                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Read Error"));
                iError =  PV_AVI_FILE_PARSER_READ_ERROR;
                break;
            }

            bytesRead += CHUNK_SIZE;

            if (bytesRead > iStreamListSize)
            {
                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Size & Byte Count Mismatch"));
                iError =  PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR;
                break;

            }

            if ((aviStrfSize <= 0) || (aviStrfSize > iStreamListSize))
            {
                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: Stream Format Header Size Greater Than Stream List Size"));
                iError =  PV_AVI_FILE_PARSER_WRONG_SIZE;
                break;

            }

            if ((iError = ParseStreamFormat(aFp, aviStrfSize)) != PV_AVI_FILE_PARSER_SUCCESS)
            {
                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: ParseStreamFormat returned error"));
                break;
            }

            bytesRead += aviStrfSize;
            if (bytesRead > iStreamListSize)
            {
                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Size & Byte Count Mismatch"));
                iError =  PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR;
                break;

            }
        }
        else if (STRD == chunkType)
        {
            if (PV_AVI_FILE_PARSER_SUCCESS != PVAviFileParserUtils::read32(aFp, iCodecSpecificHdrDataSize, true))
            {
                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Read Error"));
                iError =  PV_AVI_FILE_PARSER_READ_ERROR;
                break;
            }

            bytesRead += CHUNK_SIZE;

            if ((iCodecSpecificHdrDataSize <= 0) || (iCodecSpecificHdrDataSize > iStreamListSize))
            {
                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Size & Byte Count Mismatch"));
                iError =  PV_AVI_FILE_PARSER_WRONG_SIZE;
                break;
            }

            ipCodecSpecificHdrData = NULL;
            ipCodecSpecificHdrData = (uint8*)oscl_malloc(iCodecSpecificHdrDataSize);
            if (!ipCodecSpecificHdrData)
            {
                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: Unable to allocate memory."));
                iError = PV_AVI_FILE_PARSER_INSUFFICIENT_MEMORY;
                break;
            }
            if (0 == PVAviFileParserUtils::read8(aFp, ipCodecSpecificHdrData, iCodecSpecificHdrDataSize))
            {
                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Read Error"));
                iError =  PV_AVI_FILE_PARSER_READ_ERROR;
                break;
            }

            bytesRead += iCodecSpecificHdrDataSize;
            if (bytesRead > iStreamListSize)
            {
                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Size & Byte Count Mismatch"));
                iError =  PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR;
                break;
            }
        }
        else if (STRN == chunkType)
        {
            PVAVIFILE_LOGINFO((0, "PVAviFileStreamlist::PVAviFileStreamlist: Found stream name"));

            uint32 strnSz = 0;
            if (PV_AVI_FILE_PARSER_SUCCESS != PVAviFileParserUtils::read32(aFp, strnSz, true))
            {
                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Read Error"));
                iError =  PV_AVI_FILE_PARSER_READ_ERROR;
                break;
            }
            bytesRead += CHUNK_SIZE;
            if (strnSz >= MAX_STRN_SZ)
            {
                uint8* strn = (uint8*)oscl_malloc(strnSz);
                if (!strn)
                {
                    PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: Unable to allocate memory."));
                    iError = PV_AVI_FILE_PARSER_INSUFFICIENT_MEMORY;
                    break;
                }
                if (PVAviFileParserUtils::read8(aFp, strn, strnSz) == 0)
                {
                    PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Read Error"));
                    iError =  PV_AVI_FILE_PARSER_READ_ERROR;
                    break;
                }

                oscl_strncpy(iStreamName, (char*)strn, (MAX_STRN_SZ - 1));
                iStreamName[MAX_STRN_SZ - 1] = '\0';
                oscl_free(strn);
            }
            else
            {
                if (PVAviFileParserUtils::read8(aFp, (uint8*)iStreamName, strnSz) == 0)
                {
                    PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Read Error"));
                    iError =  PV_AVI_FILE_PARSER_READ_ERROR;
                    break;
                }
            }

            bytesRead += strnSz;
            if (bytesRead > iStreamListSize)
            {
                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Size & Byte Count Mismatch"));
                iError =  PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR;
                break;
            }

        }
        else if (JUNK == chunkType)
        {
            PVAVIFILE_LOGINFO((0, "PVAviFileStreamlist::PVAviFileStreamlist: Skip Junk Data"));

            uint32 junkSize = 0;
            if (PV_AVI_FILE_PARSER_SUCCESS != PVAviFileParserUtils::read32(aFp, junkSize, true))
            {
                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Read Error"));
                iError =  PV_AVI_FILE_PARSER_READ_ERROR;
                break;
            }

            bytesRead += CHUNK_SIZE;
            if (bytesRead > iStreamListSize)
            {
                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Size & Byte Count Mismatch"));
                iError = PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR;
                break;
            }

            if ((junkSize <= 0) || (junkSize > iStreamListSize))
            {
                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: Junk data size more than stream list size"));
                iError = PV_AVI_FILE_PARSER_WRONG_SIZE;
                break;
            }

            aFp->Seek(junkSize, Oscl_File::SEEKCUR);
            bytesRead += junkSize;
            if (bytesRead > iStreamListSize)
            {
                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Size & Byte Count Mismatch"));
                iError =  PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR;
                break;
            }

        }
        else
        {
            PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: Unexpected chunk in stream list"));
            iError = PV_AVI_FILE_PARSER_WRONG_CHUNK;
            break;
        }


    } //while(bytesRead <= iStreamListSize)

}
// Pull out source file name from arguments
//  -source sometestfile.mp4
//
//
void FindSourceFile(cmd_line* command_line, OSCL_HeapString<OsclMemAllocator>& aFileNameInfo, PVMFFormatType& aInputFileFormatType, FILE* aFile)
{
    aFileNameInfo = SOURCENAME_PREPEND_STRING;
    aFileNameInfo += DEFAULTSOURCEFILENAME;
    aInputFileFormatType = DEFAULTSOURCEFORMATTYPE;

    int iFileArgument = 0;
    bool iFileFound = false;
    bool cmdline_iswchar = command_line->is_wchar();

    int count = command_line->get_count();

    // Search for the "-source" argument
    // Go through each argument
    for (int iFileSearch = 0; iFileSearch < count; iFileSearch++)
    {
        char argstr[128];
        // Convert to UTF8 if necessary
        if (cmdline_iswchar)
        {
            oscl_wchar* argwstr = NULL;
            command_line->get_arg(iFileSearch, argwstr);
            oscl_UnicodeToUTF8(argwstr, oscl_strlen(argwstr), argstr, 128);
            argstr[127] = NULL;
        }
        else
        {
            char* tmpstr = NULL;
            command_line->get_arg(iFileSearch, tmpstr);
            int32 tmpstrlen = oscl_strlen(tmpstr) + 1;
            if (tmpstrlen > 128)
            {
                tmpstrlen = 128;
            }
            oscl_strncpy(argstr, tmpstr, tmpstrlen);
            argstr[tmpstrlen-1] = NULL;
        }

        // Do the string compare
        if (oscl_strcmp(argstr, "-help") == NULL)
        {
            fprintf(aFile, "Source specification option. Default is 'test.mp4':\n");
            fprintf(aFile, "  -source sourcename\n");
            fprintf(aFile, "   Specify the source filename or URL to use for test cases which\n");
            fprintf(aFile, "   allow user-specified source name. The unit test determines the\n");
            fprintf(aFile, "   source format type using extension or URL header.\n\n");
        }
        else if (oscl_strcmp(argstr, "-source") == NULL)
        {
            iFileFound = true;
            iFileArgument = ++iFileSearch;
            break;
        }
    }

    if (iFileFound)
    {
        // Convert to UTF8 if necessary
        if (cmdline_iswchar)
        {
            oscl_wchar* cmd;
            command_line->get_arg(iFileArgument, cmd);
            char tmpstr[256];
            oscl_UnicodeToUTF8(cmd, oscl_strlen(cmd), tmpstr, 256);
            tmpstr[255] = NULL;
            aFileNameInfo = tmpstr;
        }
        else
        {
            char* cmdlinefilename = NULL;
            command_line->get_arg(iFileArgument, cmdlinefilename);
            aFileNameInfo = cmdlinefilename;
        }

        // Check the file extension to determine format type
        // AAC file
        if (oscl_strstr(aFileNameInfo.get_cstr(), ".aac") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".AAC") != NULL)
        {
            aInputFileFormatType = PVMF_MIME_AACFF;
        }
        // MP3 file
        else  if (oscl_strstr(aFileNameInfo.get_cstr(), ".mp3") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".MP3") != NULL)
        {
            aInputFileFormatType = PVMF_MIME_MP3FF;
        }
        // AMR file (IETF and IF2)
        else  if (oscl_strstr(aFileNameInfo.get_cstr(), ".amr") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".AMR") != NULL ||
                  oscl_strstr(aFileNameInfo.get_cstr(), ".cod") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".COD") != NULL)
        {
            aInputFileFormatType = PVMF_MIME_AMRFF;
        }
        // RTSP URL
        else  if ((!oscl_strncmp("rtsp", aFileNameInfo.get_cstr(), 4)) ||
                  (!oscl_strncmp("RTSP", aFileNameInfo.get_cstr(), 4)))
        {
            aInputFileFormatType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
        }
        // HTTP URL
        else  if (oscl_strstr(aFileNameInfo.get_cstr(), "http:") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), "HTTP:") != NULL)
        {
            aInputFileFormatType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
        }
        // MP4/3GP file
        else  if (oscl_strstr(aFileNameInfo.get_cstr(), ".mp4") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".MP4") != NULL ||
                  oscl_strstr(aFileNameInfo.get_cstr(), ".3gp") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".3GP") != NULL)
        {
            aInputFileFormatType = PVMF_MIME_MPEG4FF;
        }
        // ASF file
        else  if (oscl_strstr(aFileNameInfo.get_cstr(), ".asf") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".ASF") != NULL ||
                  oscl_strstr(aFileNameInfo.get_cstr(), ".wma") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".WMA") != NULL ||
                  oscl_strstr(aFileNameInfo.get_cstr(), ".wmv") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".WMV") != NULL)
        {
            aInputFileFormatType = PVMF_MIME_ASFFF;
        }
        // SDP file
        else  if (oscl_strstr(aFileNameInfo.get_cstr(), ".sdp") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".SDP") != NULL)
        {
            aInputFileFormatType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
        }
        // PVX file
        else  if (oscl_strstr(aFileNameInfo.get_cstr(), ".pvx") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".PVX") != NULL)
        {
            aInputFileFormatType = PVMF_MIME_DATA_SOURCE_PVX_FILE;
        }
        // WAV file
        else  if (oscl_strstr(aFileNameInfo.get_cstr(), ".wav") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".WAV") != NULL)
        {
            aInputFileFormatType = PVMF_MIME_WAVFF;
        }
        // Unknown so set to unknown and let the player engine determine the format type
        else
        {
            fprintf(file, "Source type unknown so setting to unknown and have the utility recognize it\n");
            aInputFileFormatType = PVMF_MIME_FORMAT_UNKNOWN;
        }
    }
}