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

📄 asfdemux_callback.c

📁 1. 8623L平台
💻 C
📖 第 1 页 / 共 5 页
字号:
			if (pSendContext->addSeqHeader)				dumpedFrameSize += pSendContext->seqHeaderSize;			if ((pSendContext->addEntryHeader) && Media_Object_Number_valid && (Media_Object_Number != PrevMON) && Is_Key_Frame && (Offset_Into_Media_Object == 0))				dumpedFrameSize += pSendContext->entryHeaderSize;			if ((pSendContext->addFrameHeader) && Media_Object_Number_valid && (Media_Object_Number != PrevMON))				dumpedFrameSize += 4;#ifndef WITH_MONO			if (pSendContext->play_opt->savems) {				RMstatus err;				RMuint32 dummy;				RMuint8 *buffer = (RMuint8*)&dummy;								RMuint32ToLeBuf(dumpedFrameSize, buffer);				RMDBGLOG((ENABLE, "frameSize %lu, dumpedFrameSize %lu (0x%lx)\n", size, dumpedFrameSize, dumpedFrameSize));				err = dump_data_into_file(pSendContext->play_opt, RMVDEMUX_VIDEO, buffer, sizeof(RMuint32), Presentation_Time, Presentation_Time_valid, 0);				if (RMFAILED(err)) {					RMDBGLOG((ENABLE, "Cannot dump pts data %d\n", err));					goto return_from_callback;				}							}#endif // WITH_MONO						// sequence header			if (pSendContext->addSeqHeader) {				RMuint32 i;				// copy the seqHeader				RMDBGLOG((ENABLE, "adding seqHeader, size %lu, startCodeBufferLeft %lu\n", pSendContext->seqHeaderSize, pSendContext->startCodeBufferLeft));				for (i = 0; i < pSendContext->seqHeaderSize; i++)					*(pSendContext->startCodeBuffer + i) = *(pSendContext->seqHeader + i);								// send the seqHeader				while (RUASendData(pSendContext->pRUA, decoder, pSendContext->pDMA, pSendContext->startCodeBuffer, pSendContext->seqHeaderSize, pInfo, size_info) != RM_OK) {					RMDBGLOG((ENABLE, "waiting for sendSeqHeader to complete\n"));				}								// we only send the PTS with the first chunk				pInfo = NULL;				size_info = 0;				// eventually, dump it to a file				{					RMstatus err;					err = dump_data_into_file(pSendContext->play_opt, RMVDEMUX_VIDEO, pSendContext->startCodeBuffer, pSendContext->seqHeaderSize, Presentation_Time, Presentation_Time_valid, 0);					if (RMFAILED(err)) {						RMDBGLOG((ENABLE, "Cannot dump data %d\n", err));						goto return_from_callback;					}				}				pSendContext->startCodeBuffer += pSendContext->seqHeaderSize;				pSendContext->startCodeBufferLeft -= pSendContext->seqHeaderSize;				pSendContext->addSeqHeader = FALSE;			}			// entry header (for iframes)			if ((pSendContext->addEntryHeader) && Media_Object_Number_valid && (Media_Object_Number != PrevMON) && Is_Key_Frame && (Offset_Into_Media_Object == 0))  {				RMuint32 i;				// copy the entryHeader				RMDBGLOG((VC1_STARTCODE_DBG, "adding entryHeader (size %lu) to iframe MON %lu, startCodeBufferLeft %lu\n", pSendContext->entryHeaderSize, (RMuint32) Media_Object_Number, pSendContext->startCodeBufferLeft ));				for (i = 0; i < pSendContext->entryHeaderSize; i++)					*(pSendContext->startCodeBuffer + i) = *(pSendContext->entryHeader + i);								// send the entryHeader				while (RUASendData(pSendContext->pRUA, decoder, pSendContext->pDMA, pSendContext->startCodeBuffer, pSendContext->entryHeaderSize, pInfo, size_info) != RM_OK) {					RMDBGLOG((ENABLE, "waiting for sendEntryHeader to complete\n"));				}				// we only send the PTS with the first chunk				pInfo = NULL;				size_info = 0;								// eventually, dump it to a file				{					RMstatus err;					err = dump_data_into_file(pSendContext->play_opt, RMVDEMUX_VIDEO, pSendContext->startCodeBuffer, pSendContext->entryHeaderSize, Presentation_Time, Presentation_Time_valid, 0);					if (RMFAILED(err)) {						RMDBGLOG((ENABLE, "Cannot dump data %d\n", err));						goto return_from_callback;					}				}				pSendContext->startCodeBuffer += pSendContext->entryHeaderSize;				pSendContext->startCodeBufferLeft -= pSendContext->entryHeaderSize;			}			// picture header (for all frames)			if ((pSendContext->addFrameHeader) && Media_Object_Number_valid && (Media_Object_Number != PrevMON)) {				// new picture, add picture header startcode "00 00 01 0D"				RMDBGLOG((VC1_STARTCODE_DBG, "add newPic startcode to MON %lu, startCodeBufferLeft %lu\n", (RMuint32) Media_Object_Number, pSendContext->startCodeBufferLeft ));				*(pSendContext->startCodeBuffer) = 0x00;				*(pSendContext->startCodeBuffer + 1) = 0x00;				*(pSendContext->startCodeBuffer + 2) = 0x01;				*(pSendContext->startCodeBuffer + 3) = 0x0D;				// send the startcode				while (1) {					RMstatus err;					err = RUASendData(pSendContext->pRUA, decoder, pSendContext->pDMA, pSendContext->startCodeBuffer, 4, pInfo, size_info);					if (err == RM_OK) 						break;					/* exit prebuf state if fifo is full */					else if (err == RM_PENDING) {						struct RUAEvent e;						asf_check_prebuf_state(pSendContext, 0);																		e.ModuleID = decoder;						e.Mask = RUAEVENT_XFER_FIFO_READY;						RUAWaitForMultipleEvents(pSendContext->pRUA, &e, 1, SENDDATA_TIMEOUT_US, NULL);						RMDBGLOG((ENABLE, "waiting for sendNewPicSC to complete\n"));					}					else						goto return_from_callback;				}				// we only send the PTS with the first chunk				pInfo = NULL;				size_info = 0;								// eventually, dump it to a file				{					RMstatus err;					err = dump_data_into_file(pSendContext->play_opt, RMVDEMUX_VIDEO, pSendContext->startCodeBuffer, 4, Presentation_Time, Presentation_Time_valid, 0);					if (RMFAILED(err)) {						RMDBGLOG((ENABLE, "Cannot dump data %d\n", err));						goto return_from_callback;					}				}				pSendContext->startCodeBuffer += 4;				pSendContext->startCodeBufferLeft -= 4;			}			if (pSendContext->startCodeBufferLeft < (pSendContext->seqHeaderSize + pSendContext->entryHeaderSize + 4))				pSendContext->getStartCodeBuffer = TRUE;					}		// send the data from the asf packet		if (dataType == RM_STREAM_AUDIO) {			RMint32 lastOKinstance = -1;			while (DCCMultipleAudioSendData(pSendContext->dcc_info->pMultipleAudioSource, pSendContext->pDMA, buf, size, pInfo, size_info, &lastOKinstance) != RM_OK) {				struct RUAEvent e;				struct DCCAudioSourceHandle audioHandle;				//RMbool gotKey;				RMstatus status;				if (lastOKinstance == -1) {					fprintf(stderr, "cant wait on unknown instance!!\n");					goto return_from_callback;				}									asf_check_prebuf_state(pSendContext, 0);										#if 0				//impossible, if we are here, it's wma and not wmapro				gotKey = asf_try_decode_wmapro(pSendContext, FALSE);				if (gotKey)					RMDBGLOG((ENABLE, "*************gotkey\n"));#endif				PROCESS_KEY_INCALLBACK(TRUE,FALSE);								status = DCCMultipleAudioSourceGetSingleDecoderHandleForInstance(pSendContext->dcc_info->pMultipleAudioSource, lastOKinstance, &audioHandle);				if (status != RM_OK)					goto return_from_callback;				#ifdef CHECK_BUFFER_4_VIDEO				cWait ++;#endif				e.ModuleID = audioHandle.moduleID;				e.Mask = RUAEVENT_XFER_FIFO_READY;				RUAWaitForMultipleEvents(pSendContext->pRUA, &e, 1, SENDDATA_TIMEOUT_US, NULL);				RUAResetEvent(pSendContext->pRUA, &e);							}		}		else {			while (RUASendData(pSendContext->pRUA, decoder, pSendContext->pDMA, buf, size, pInfo, size_info) != RM_OK) {				struct RUAEvent e;								RMDBGLOG((ENABLE, "waiting for senddata %s\n", dataType == RM_STREAM_VIDEO ? "video":"audio"));								asf_check_prebuf_state(pSendContext, 0);															asf_try_decode_wmapro(pSendContext, FALSE);				PROCESS_KEY_INCALLBACK(TRUE,FALSE);				#ifdef CHECK_BUFFER_4_VIDEO				cWait ++;#endif				e.ModuleID = decoder;				e.Mask = RUAEVENT_XFER_FIFO_READY;				RUAWaitForMultipleEvents(pSendContext->pRUA, &e, 1, SENDDATA_TIMEOUT_US, NULL);			}			/* sendind data may fill-up the xfer fifo, so we reset the event */			{				struct RUAEvent e;								e.ModuleID = decoder;				e.Mask = RUAEVENT_XFER_FIFO_READY;				RUAResetEvent(pSendContext->pRUA, &e);			}		}		#ifdef CHECK_BUFFER_4_VIDEO		if(cWait)			printf("Wait %d cycle to send video data\n", cWait);#endif		goto callback_end; //callback end	}	#if 1	/* wmapro decoding and senddata */		if ((dataType == RM_STREAM_AUDIO) && 	    ((PlaybackStatus == RM_PSM_Playing) || 	     (PlaybackStatus == RM_PSM_Paused) || 	     (PlaybackStatus == RM_PSM_Prebuffering) ||	     (pSendContext->sendAudioTrickmode)) &&	    (pSendContext->isWMAPRO)) {		RMuint32 wr1, wr2; 		RMuint32 size1;		struct asf_wmapro_buffer_info *buf_info;		RMDBGLOG((SENDDBG, "sending (wmapro) MON(%lu) %s, size %lu, pts %llu = 0x%llx (%s), %s, %lu\n",			  Media_Object_Number, 			  dataType == RM_STREAM_VIDEO ? "video":"audio",			  size, 			  pInfo == NULL ? 0:pInfo->TimeStamp, 			  pInfo == NULL ? 0:pInfo->TimeStamp,			  pInfo == NULL ? "no pts":(pInfo->ValidFields & TIME_STAMP_INFO ? "valid":""),			  Is_Key_Frame == 1 ? "key":"", 			  Offset_Into_Media_Object)); 		while (RMfifo_get_writable_size(pSendContext->wmapro_fifo, &wr1, &size1, &wr2) < sizeof(struct asf_wmapro_buffer_info)) {			RMDBGLOG((WMAPRODBG, "WMAPRO fifo too small\n"));			asf_try_decode_wmapro(pSendContext, FALSE);			PROCESS_KEY_INCALLBACK(TRUE,FALSE);  		}  		buf_info = (struct asf_wmapro_buffer_info *) wr1;  #if (EM86XX_MODE == EM86XX_MODEID_STANDALONE)#if (EM86XX_CHIP == EM86XX_CHIPID_TANGO2)		buf_info->ptr = buf;#else 		buf_info->ptr = (RMuint8 *)((RMuint32)buf & 0x7fffffff);#endif#else 		buf_info->ptr = buf;#endif   		buf_info->size = size; 		buf_info->new_buffer = TRUE; 		buf_info->Info = Info; 		buf_info->Stream_Number = Stream_Number; 		buf_info->Media_Object_Number = Media_Object_Number; 		buf_info->fSendPTS = 2; 		RUAAcquireBuffer(pSendContext->pDMA, buf); 		RMDBGLOG((WMAPRODBG, "Insert address %p into WMAPRO fifo size(%lu), valid(%lu) "			"pts(%llu), MON(%lu)\n", buf, size, Info.ValidFields, Info.TimeStamp,			 Media_Object_Number)); 		RMfifo_incr_write_ptr(pSendContext->wmapro_fifo, sizeof(struct asf_wmapro_buffer_info));  	        RMDBGLOG((WMAPRODBG, "buf 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", 		  *(RMuint8*)buf, 		  *(RMuint8*)(buf+1), 		  *(RMuint8*)(buf+2), 		  *(RMuint8*)(buf+3), 		  *(RMuint8*)(buf+4), 		  *(RMuint8*)(buf+5)));		{			asf_try_decode_wmapro(pSendContext, FALSE);			PROCESS_KEY_INCALLBACK(TRUE,FALSE);		}	}#endif   callback_end:	/*************************************************************************************/	/* video debug stuff */	/*************************************************************************************/	if (dataType == RM_STREAM_VIDEO) {		if (Media_Object_Number_valid && (Media_Object_Number != PrevMON)) {#ifdef SAVE_INPUT_FRAMES			char szTemp[50];			if (pSendContext->f_compressed_frames >= 0)				close(pSendContext->f_compressed_frames);			sprintf(szTemp, "frame%d.bin", (int) pSendContext->video_frame_counter + 1);			pSendContext->f_compressed_frames = open(szTemp, 				O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE | S_IRGRP);#endif			pSendContext->video_frame_counter++;#ifdef DISPLAY_VIDEO_STREAM_PAYLOAD_INFO			RMDBGLOG((ENABLE, "VideoFrameCnt=%ld VideoByteCounter=0x%lx (size=0x%lx)",				  pSendContext->video_frame_counter, pSendContext->VideoByteCounter, size))#if 0			if (Presentation_Time_valid)				RMDBGLOG((ENABLE, " - PTS = 0x%lx", Presentation_Time))			if (Media_Object_Number_valid)				RMDBGLOG((ENABLE, " - Media_Object_Number = %lx", Media_Object_Number))			if (Is_Key_Frame)				RMDBGLOG((ENABLE, " (key frame)"));#endif			RMDBGLOG((ENABLE,"\n"));			RMDBGLOG((ENABLE,"%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x...\n",				  (int)(buf[0]), (int)(buf[1]), (int)(buf[2]), (int)(buf[3]), 				  (int)(buf[4]), (int)(buf[5]), (int)(buf[6]), (int)(buf[7]), 				  (int)(buf[8]), (int)(buf[9]), (int)(buf[10])))#endif		}#ifdef SAVE_INPUT_FRAMES		if (pSendContext->f_compressed_frames >= 0)			write(pSendContext->f_compressed_frames, buf, size);#endif		if(pSendContext->ContiguousVideoLength == 0)			pSendContext->video_time_start = get_ustime();		pSendContext->ContiguousVideoLength +=size;		if(pSendContext->ContiguousVideoLength > CONTIGUOUS_LENGHT) {			pSendContext->video_time_end = get_ustime();		}		pSendContext->ContiguousAudioLength = 0;#ifndef WITH_MONO		if ((!pSendContext->isVC1) && (pSendContext->play_opt->savems)) {			// dump size, then data						RMstatus err;			RMuint32 dummy;			RMuint8 *buffer = (RMuint8*)&dummy;						RMuint32ToLeBuf(size, buffer);						RMDBGLOG((ENABLE, "frameSize %lu (0x%lx)\n", size, size));			err = dump_data_into_file(pSendContext->play_opt, RMVDEMUX_VIDEO, buffer, sizeof(RMuint32), Presentation_Time, Presentation_Time_valid, 0);			if (RMFAILED(err)) {				RMDBGLOG((ENABLE, "Cannot dump frameSize data %d\n", err));				goto return_from_callback;			}					}		{			RMstatus err;			err = dump_data_into_file(pSe

⌨️ 快捷键说明

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