void rm_parser_set_stream(rm_parser** ppParser, UINT32 ulStreamNum)
{
    if (ppParser)
    {
        /* Get the internal parser struct */
        rm_parser_internal* pInt = (rm_parser_internal*) *ppParser;
        pInt->ulCurrentStream = ulStreamNum;
        rm_parseri_file_seek(pInt, pInt->pMediaPropsHdr[pInt->ulCurrentStream].start_offset, HX_SEEK_ORIGIN_SET);
    }
}
void rm_parser_file_skip(rm_parser* pParser, UINT32 ulOffset)
{
    HX_RESULT retVal = HXR_FAIL;

    if (pParser)
    {
        /* Get the internal parser struct */
        rm_parser_internal* pInt = (rm_parser_internal*) pParser;
        /* Read the next packet */
        rm_parseri_file_seek(pInt, ulOffset, HX_SEEK_ORIGIN_CUR);
    }
}
Exemple #3
0
/*
seek to next key frame and get real time stamp.
add sheen
*/
UINT32 rm_getNextKeyTimeStamp(UINT32 ulTime)
{
	HX_RESULT           retVal         = HXR_OK;
	rm_parser_internal* pInt = (rm_parser_internal*) pParser;
	/*
	retVal=rm_parser_seek(pParser, ulTime);
	if(retVal==HXR_OK)
	{
		if(pInt->pStreamInfo)
			retVal=pInt->pStreamInfo[usRvStreamNum].keyFramePacket.ulTimestamp;
	}
	else
		retVal=0;
	*/
//rm_printf("1 ulTime=%d",ulTime);

	if (pInt && pInt->pStreamInfo)
    {
        HX_RESULT status       = HXR_FAIL;
        UINT32    ulFoundTime  = 0;
        UINT32    ulDataOffset = 0;
		struct rm_stream_info* pInfo = &pInt->pStreamInfo[usRvStreamNum];

		if (pInfo)
		{
			status = rm_parseri_search_seek_table(&pInfo->seekTable,
				ulTime,&ulFoundTime, &ulDataOffset);
		}

        if (status == HXR_OK)
        {
            retVal =ulFoundTime;
        }
        else if (pInt->propHdr.index_offset )
        {
            /*
             * Try to find the offset via the index chunks
             * at the end of the file
             */
			struct rm_index_hdr hdr;
			struct rm_index_rec rec;
			UINT32 ulChunkID     = 0;
			UINT32 ulStreamNum   = 0;
			UINT32 i             = 0;
			UINT32 ulIndexOffset = pInt->propHdr.index_offset;

			/* Clear the return value */
			retVal = HXR_OK;
			/* Loop through all the index chunks */
			while (HX_SUCCEEDED(retVal) && ulIndexOffset)
			{
				/* Seek the file to the next index chunk */
				rm_parseri_file_seek(pInt, ulIndexOffset, HX_SEEK_ORIGIN_SET);
				/* Read the index header */
				retVal = rm_parseri_read_next_header(pInt, &ulChunkID);
				if (retVal == HXR_OK)
				{
					/* Assume the worst */
					retVal = HXR_FAIL;
					/* Make sure this is an INDX header */
					if (ulChunkID == RM_INDEX_OBJECT)
					{
						/* Parse the index header */
						retVal = rm_parseri_unpack_index_hdr(pInt, &hdr);
						if (retVal == HXR_OK)
						{
							/*
							 * Translate the stream number. If the
							 * stream number doesn't translate, then
							 * we will not consider it an error - we'll
							 * just go on to the next index chunk.
							 */
							ulStreamNum = rm_parseri_translate_stream_number(pInt, hdr.stream_num);
							//if (ulStreamNum != RM_NO_STREAM_SET)
							if (ulStreamNum == usRvStreamNum)
							{
								/* Read all the index records in this chunk */
								for (i = 0; i < hdr.num_recs && retVal == HXR_OK; i++)
								{
									retVal = rm_parseri_read_next_index_rec(pInt, &rec);
									if (retVal == HXR_OK)
									{
										/*
										 * Set this record into the on-the-fly
										 * seek table.
										 */
										rm_parseri_update_seek_table(pInt,
																	 ulStreamNum,
																	 rec.timestamp,
																	 rec.offset,
																	 HX_KEYFRAME_FLAG);

										rm_printf(" rec.timestamp=%d",rec.timestamp);

										/*
										 * Is the timestamp of the record
										 * greater than or equal to the seek time?
										 */
										if (rec.timestamp >= ulTime)
										{
											retVal=rec.timestamp;
											ulIndexOffset=0;
											/*
											 * Now we can stop looking at index records
											 * for this stream
											 */
											break;
										}
										
									}
								}
							}
							/* 
							 * Set the next index header. If there are
							 * no more index chunks, next_index_hdr will
							 * be zero.
							 */
							if(!ulIndexOffset)break;//get the stamp.
							ulIndexOffset = hdr.next_index_hdr;
						}
					}
				}
			}
        }
    }
	
	return retVal;
}