⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rmasfdemux.cpp

📁 Sigma SMP8634 Mrua v. 2.8.2.0
💻 CPP
📖 第 1 页 / 共 5 页
字号:
}RMstatus RMasfdemux::SeekToPacket(RMnonAscii *fileName, RMuint32 packetNum){	RMfile f;#define SEEK_BUFFER_SIZE (8 * 1024)	RMuint8 buffer[SEEK_BUFFER_SIZE];	RMuint32 readSize;	RMstatus status = RM_ERROR;	RMint8 res;	RMDBGLOG((ASFDEMUXDBG,"Seek to packet %lu ...\n", packetNum));	if(!m_isIndexConstructed){		RMDBGLOG((ENABLE,"Error : index is not constructed\n"));		return RM_ERROR;	}	if(fileName == (RMnonAscii *)NULL){		RMDBGLOG((ENABLE,"Error : no file specified\n"));		return RM_ERROR;	}	//Reset(m_context);	f = RMOpenFile(fileName, RM_FILE_OPEN_READ);		if(f == (RMfile)NULL){		RMDBGLOG((ENABLE,"Error : cannot open file \"%s\"\n", fileName));		status = RM_ERROR;		goto finish;	}	while (RMReadFile (f, buffer, SEEK_BUFFER_SIZE, &readSize) == RM_OK){		res = asf_demux_seek ((struct asf_demux_state_t *)m_asf_demux_state, buffer, (RMuint64)readSize, packetNum);		if(res == 1) {			RMDBGLOG((ASFDEMUXDBG,"Reached packet %lu\n", packetNum));			status = RM_OK;			break;		}		else if(res < 0){			RMDBGLOG((ENABLE,"Error in asf_demux_seek function\n"));			status = RM_ERROR;			break;		}	}	 finish:	if (f)		RMCloseFile(f);	return status;}/* local callbacks */void RMasfdemux::indexLOCALcb(void *context,			 RMuint8 phase_num,			 RMuint16 specifier_number,			 RMuint32 block_number,			 RMuint32 entry_number,			 RMuint32 index_entry_time_interval, // 100-ns units			 RMuint16 index_specifiers_count,			 RMuint32 index_block_count,			 RMuint16 stream_number,			 RMuint16 index_type,			 RMuint32 index_entry_count,			 RMuint64 position,			 RMuint32 offset){	RMasfdemux *pmodule = (RMasfdemux *)context;	RMDBGLOG((CALLBACKDBG, "indexcb %s\n", (pmodule->m_activeCallbacks & INDEX_CB) ? "enabled":"disabled"));	if (!(pmodule->m_activeCallbacks & INDEX_CB))		return;	if (pmodule->m_drmError != 0)		return;	RMDBGLOG((CALLBACKHOOKDBG, "indexcb called, context @0x%08X\n", context));	pmodule->m_isThereAnIndex = TRUE;	// use application's callback if it was registered, else, use local functions	if (pmodule->m_indexentrycb != indexLOCALcb) {		if (pmodule->m_indexentrycb)			pmodule->m_indexentrycb(pmodule->m_context,						phase_num,						specifier_number,						block_number,						entry_number,						index_entry_time_interval,						index_specifiers_count,						index_block_count,						stream_number,						index_type,						index_entry_count,						position,						offset);		return;	}	// we're building a local index	pmodule->m_localIndex = TRUE;	switch (phase_num){	case 1:		RMDBGLOG((ENABLE, "First phase : \n"));				if( pmodule->m_index.specifier_count == 0){			pmodule->m_index.time_interval = index_entry_time_interval;			pmodule->m_index.specifier_count = index_specifiers_count;			RMASSERT( pmodule->m_index.specifier == (typeIndexSpecifier*)NULL);			pmodule->m_index.specifier = (typeIndexSpecifier*)RMMalloc(sizeof(typeIndexSpecifier)*index_specifiers_count);			RMDBGLOG((ENABLE, "Specifiers created, nb = %lu, time interval == %llu\n", 				  pmodule->m_index.specifier_count,				  pmodule->m_index.time_interval));		}				if( pmodule->m_index.block_count == 0){			pmodule->m_index.block_count = index_block_count;			RMASSERT( pmodule->m_index.block == (typedIndexBlock*)NULL);			pmodule->m_index.block = (typedIndexBlock*)RMMalloc(sizeof(typedIndexBlock)* pmodule->m_index.block_count);			RMDBGLOG((ENABLE, "Blocks created, nb = %lu\n",				  pmodule->m_index.block_count));		}				if(specifier_number >  pmodule->m_index.specifier_count) {			RMDBGLOG((ENABLE, "Specifier number (%lu) > max specifier number (%lu)\n", 				  specifier_number,  pmodule->m_index.specifier_count));			return;		}				pmodule->m_index.specifier[specifier_number].stream_number = stream_number;		pmodule->m_index.specifier[specifier_number].index_type = index_type;				RMDBGLOG((ENABLE, "Specifier %lu, stream_numer == %lu, index_type == %lu\n", 			  specifier_number, 			  pmodule->m_index.specifier[specifier_number].stream_number, 			  pmodule->m_index.specifier[specifier_number].index_type));		break;	case 2:		RMDBGLOG((ENABLE, "Second phase : \n"));		if(block_number >  pmodule->m_index.block_count){			RMDBGLOG((ENABLE, "Block number (%lu) > max block number (%lu)\n", 				  block_number,  pmodule->m_index.block_count));			return;		}		if( pmodule->m_index.block[block_number].entry_count == 0){			pmodule->m_index.block[block_number].entry_count = index_entry_count;			RMASSERT( pmodule->m_index.block[block_number].position == (RMuint64*)NULL);			pmodule->m_index.block[block_number].position = (RMuint64*)RMMalloc(sizeof(RMuint64)* pmodule->m_index.specifier_count);			RMASSERT( pmodule->m_index.block[block_number].offset == NULL);			pmodule->m_index.block[block_number].offset = (RMuint32**)RMMalloc(sizeof(RMuint32)* pmodule->m_index.block[block_number].entry_count* pmodule->m_index.specifier_count);			RMDBGLOG((ENABLE, "index entry and bloc positions created for bloc %lu nb entry = %lu\n",				  block_number,  pmodule->m_index.block[block_number].entry_count));		}				if(specifier_number >  pmodule->m_index.specifier_count){						RMDBGLOG((ENABLE, "Specifier number (%lu) > max specifier number (%lu)\n", 				  specifier_number,  pmodule->m_index.specifier_count));			return;		}				pmodule->m_index.block[block_number].position[specifier_number] = position;				RMDBGLOG((ENABLE, "Specifier %lu, block num = %lu, position = %lu\n",			  specifier_number, 			  block_number,			  pmodule->m_index.block[block_number].position[specifier_number]));		break;	case 3:		RMDBGLOG((ENABLE, "Third phase : \n"));		if(block_number >  pmodule->m_index.block_count){			RMDBGLOG((ENABLE, "Block number (%lu) > max block number (%lu)\n", 				  block_number,  pmodule->m_index.block_count));			return;		}				if( pmodule->m_index.block[block_number].entry_count == 0){			RMDBGLOG((ENABLE, "No entry count !!!\n"));			pmodule->m_isThereAnIndex = FALSE;			return;		}		if(specifier_number >  pmodule->m_index.specifier_count){						RMDBGLOG((ENABLE, "Specifier number (%lu) > max specifier number (%lu)\n", 				  specifier_number,  pmodule->m_index.specifier_count));			return;		}				if(entry_number >  pmodule->m_index.block[block_number].entry_count){						RMDBGLOG((ENABLE, "Entry number (%lu) > max entry number (%lu)\n", 				  entry_number,  pmodule->m_index.block[block_number].entry_count));			return;		}				pmodule->m_index.block[block_number].offset[entry_number][specifier_number] = offset;		RMDBGLOG((ENABLE, "Specifier %lu, block num = %lu, entry number = %lu, position = %lu\n",			  specifier_number, 			  block_number,			  entry_number,			  pmodule->m_index.block[block_number].offset[entry_number][specifier_number]));		break;	default:		RMDBGLOG((ENABLE, "Unknown phase in index callback\n"));		return;	}}void RMasfdemux::simpleIndexLOCALcb(void *context,			       RMuint8 simple_index_number,			       RMuint32 index_index,			       RMuint32 Index_Entries_Count,			       RMuint64 Index_Entry_Time_Interval, // 100-ns units			       RMuint32 Packet_Number,			       RMuint16 Packet_Count){	RMasfdemux *pmodule = (RMasfdemux *)context;	RMDBGLOG((CALLBACKDBG, "simpleIndexcb %s\n", (pmodule->m_activeCallbacks & SIMPLE_INDEX_CB) ? "enabled":"disabled"));	if (!(pmodule->m_activeCallbacks & SIMPLE_INDEX_CB))		return;	if (pmodule->m_drmError != 0)		return;	RMDBGLOG((CALLBACKHOOKDBG, "simpleindexcb called, context @0x%08X\n", context));			pmodule->m_isThereAnIndex = TRUE;	// use application's callback if it was registered, else, use local functions	if (pmodule->m_simpleindexentrycb != simpleIndexLOCALcb) {		if (pmodule->m_simpleindexentrycb)			pmodule->m_simpleindexentrycb(pmodule->m_context,						      simple_index_number,						      index_index,						      Index_Entries_Count,						      Index_Entry_Time_Interval,						      Packet_Number,						      Packet_Count);		return;	}	if(Index_Entries_Count == 0){		RMDBGLOG((ENABLE, "ERROR : index entries count == 0 !!\n"));		pmodule->m_isThereAnIndex = FALSE;		return;	}		// we're building a local index	pmodule->m_localIndex = TRUE;	if((RMuint32)(simple_index_number+1) >   pmodule->m_numberOfIndex) {		pmodule->m_numberOfIndex++;		RMDBGLOG((ENABLE, "Number of index == %lu!!\n",   pmodule->m_numberOfIndex));	}		if(  pmodule->m_simpleIndex[simple_index_number].index_Entries_Count == 0){		RMDBGLOG((ASFDEMUXDBG, "Allocating %lu entries \n", Index_Entries_Count));		pmodule->m_simpleIndex[simple_index_number].index_Entries_Count = Index_Entries_Count;		pmodule->m_simpleIndex[simple_index_number].index_Entry_Time_Interval = Index_Entry_Time_Interval;		if(  pmodule->m_simpleIndex[simple_index_number].entry != (typeSimpleIndexEntry*)NULL)			RMFree(  pmodule->m_simpleIndex[simple_index_number].entry);				pmodule->m_simpleIndex[simple_index_number].entry = (typeSimpleIndexEntry *)RMMalloc(sizeof(typeSimpleIndexEntry)*  pmodule->m_simpleIndex[simple_index_number].index_Entries_Count);					}		if(  pmodule->m_simpleIndex[simple_index_number].index_Entries_Count != Index_Entries_Count) {		RMDBGLOG((ENABLE, "ERROR : wrong index entries count !!\n"));		pmodule->m_isThereAnIndex = FALSE;		return;	}		pmodule->m_simpleIndex[simple_index_number].entry[index_index].Packet_Number = Packet_Number;	pmodule->m_simpleIndex[simple_index_number].entry[index_index].Packet_Count = Packet_Count;		RMDBGLOG((DISABLE, "Index entry : \n\tsimple_index_number  : %lu, \n\tindex_index = %lu, \n\tIndex_Entries_Count = %lu, \n\tIndex_Entry_Time_Interval = %llu, \n\tPacket_Number = %lu, \n\tPacket_Count = %lu\n",		  simple_index_number,		  index_index,		  Index_Entries_Count,		  Index_Entry_Time_Interval,		  Packet_Number,		  Packet_Count));}void RMasfdemux::payloadLOCALcb( void *context,		     RMuint8 Stream_Number,		     RMuint8 *buf, 		     RMuint32 size, 		     RMuint32 bytes_left, 		     RMuint8 Is_Key_Frame,		     RMuint32 Media_Object_Number, 		     RMuint8 Media_Object_Number_valid,		     RMuint32 Presentation_Time, 		     RMuint8 Presentation_Time_valid,		     RMuint32 Offset_Into_Media_Object){	RMasfdemux *pmodule = (RMasfdemux *)context;	RMDBGLOG((CALLBACKDBG, "payloadcb %s\n", (pmodule->m_activeCallbacks & PAYLOAD_CB) ? "enabled":"disabled"));	if (!(pmodule->m_activeCallbacks & PAYLOAD_CB))		return;	if (pmodule->m_drmError != 0)		return;	RMDBGLOG((CALLBACKHOOKDBG, "payloadCB called with context 0x%08X, using application's context %08X\n", context, pmodule->m_context));	if (pmodule->m_payloadcb)		pmodule->m_payloadcb(pmodule->m_context, 				     Stream_Number,				     buf,				     size,				     bytes_left,				     Is_Key_Frame,				     Media_Object_Number,				     Media_Object_Number_valid,				     Presentation_Time,				     Presentation_Time_valid,				     Offset_Into_Media_Object);}	void RMasfdemux::audiopropLOCALcb(void *context,		      RMuint8 Stream_Number,                  // 1..127		      RMuint16 Codec_ID,                      // see MSDN Library		      RMuint16 Number_of_Channels,		      RMuint32 Samples_Per_Second,		      RMuint32 Average_Number_of_Bytes_Per_Second,		      RMuint16 Block_Alignment,		      RMuint16 Bits_Per_Sample,		      RMuint8 *Codec_Specific_Data,		      RMuint32 Partial_Codec_Specific_Data_Size,		      RMuint32 Codec_Specific_Data_Size)     // bytes{	RMasfdemux *pmodule = (RMasfdemux *)context;	RMDBGLOG((CALLBACKDBG, "audiopropcb %s\n", (pmodule->m_activeCallbacks & AUDIO_PROP_CB) ? "enabled":"disabled"));	if (!(pmodule->m_activeCallbacks & AUDIO_PROP_CB))		return;	if (pmodule->m_drmError != 0)		return;	pmodule->m_audioBYTERate = Average_Number_of_Bytes_Per_Second;	RMDBGLOG((ENABLE, ">>> audio stream byte rate %lubytes/sec\n", pmodule->m_audioBYTERate));	RMDBGLOG((CALLBACKHOOKDBG, "audiopropCB called with context 0x%08X, using application's context %08X\n", context, pmodule->m_context));	if (pmodule->m_audiostreampropcb) {		pmodule->m_audioStreamFound = TRUE;		pmodule->m_audiostreampropcb(pmodule->m_context, 					     Stream_Number,					     Codec_ID,					     Number_of_Channels,					     Samples_Per_Second,					     Average_Number_of_Bytes_Per_Second,					     Block_Alignment,					     Bits_Per_Sample,					     Codec_Specific_Data,					     Partial_Codec_Specific_Data_Size,					     Codec_Specific_Data_Size);	}	}	void RMasfdemux::filepropLOCALcb(void *context,		     RMuint64 File_Size,                 // bytes (invalid if Broadcast)		     RMuint64 Creation_Date,             // See MSDN Library		     RMuint64 Data_Packets_Count,        // (invalid if Broadcast)		     RMuint64 Play_Duration,             // 100-ns units (invalid if Broadcast)		     RMuint64 Send_Duration,             // 100-ns units (invalid if Broadcast)		     RMuint64 Preroll,                   // milliseconds		     RMuint32 Minimum_Data_Packet_Size,  // bytes		     RMuint32 Maximum_Data_Packet_Size,  // bytes		     RMuint32 Maximum_Bitrate,           // bits/s		     RMuint8 Broadcast,                  // boolean		     RMuint8 Seekable)                    // boolean{	RMasfdemux *pmodule = (RMasfdemux *)context;	RMDBGLOG((CALLBACKDBG, "filepropcb %s\n", (pmodule->m_activeCallbacks & FILE_PROP_CB) ? "enabled":"disabled"));	if (!(pmodule->m_activeCallbacks & FILE_PROP_CB))		return;	if (pmodule->m_drmError != 0)		return;	if (Preroll) {		RMDBGLOG((ENABLE, ">>> Preroll is %llu\n", Preroll));		pmodule->m_preroll = Preroll;	}	if (!Broadcast) {		pmodule->m_duration = (Play_Duration / 10000) - Preroll;		RMDBGLOG((ENABLE, ">>> Duration is %llu ms\n", pmodule->m_duration));				pmodule->m_fileSize = File_Size;		RMDBGLOG((ENABLE, ">>> File Size %llu bytes\n", pmodule->m_fileSize));		pmodule->m_packetCount = Data_Packets_Count;		RMDBGLOG((ENABLE, ">>> Packet Count %llu\n", pmodule->m_packetCount));	}	else {		RMDBGLOG((ENABLE, "+++ Stream has broadcast flag set!, some reported values are invalid!\n"));	}	pmodule->m_Broadcast = Broadcast;	if (Seekable)		pmodule->m_isFileSeekable = TRUE;	else {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -