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

📄 detect_file_type.c

📁 1. 8623L平台
💻 C
📖 第 1 页 / 共 2 页
字号:
	case RMdetector3_streamType_VIDEO_VC1:	case RMdetector3_streamType_VIDEO_WMV:	case RMdetector3_streamType_VIDEO_XVID:		break;	// system	case RMdetector3_streamType_SYSTEM_ASF:	case RMdetector3_streamType_SYSTEM_AVI:	case RMdetector3_streamType_SYSTEM_DVD:		break;	case RMdetector3_streamType_SYSTEM_ID3:	case RMdetector3_streamType_SYSTEM_M1S:	case RMdetector3_streamType_SYSTEM_M2P:	case RMdetector3_streamType_SYSTEM_M2T:	case RMdetector3_streamType_SYSTEM_M2T_192:	case RMdetector3_streamType_SYSTEM_MP4:	case RMdetector3_streamType_SYSTEM_RIFFCDXA:	case RMdetector3_streamType_SYSTEM_RIFFWAVE:		break;	}		return;}static void audio_stream_callback(void *context, struct RM_Detection3_Specific_Info info, RMuint32 parentStreamID, RMuint32 streamID){	RMuint32 i;	if (parentStreamID == g_currentRootStreamID) {		for (i = 0; i < g_nestingLevel + 1; i++)			fprintf(stderr, "\t");	}	fprintf(stderr, "[%2lu %2lu ] %s", parentStreamID, streamID, print_type(info.type));	if (!info.data.video.PID_INFO_VALID)		fprintf(stderr, "\n");	else		fprintf(stderr, " (pid=%lu [0x%lx] subid=%lu [0x%lx] pidType=%lu [0x%lx])\n", 			info.data.video.pid, 			info.data.video.pid, 			info.data.video.subid, 			info.data.video.subid, 			info.data.video.pidType,			info.data.video.pidType);	if (!info.data.audio.SPECIFIC_INFO_VALID)		return;	switch (info.type) {	case RMdetector3_streamType_UNKNOWN:	case RMdetector3_streamType_ELEMENTARY_AUDIO:	case RMdetector3_streamType_ELEMENTARY_VIDEO:	case RMdetector3_streamType_SYSTEM:		break;	// elementary audio	case RMdetector3_streamType_AUDIO_AC3:		fprintf(stderr, "\tAC3: sampleRate %lu, channels %lu, bitrate %lu\n", 			info.data.audio.data.ac3.sampleRate, 			info.data.audio.data.ac3.channels, 			info.data.audio.data.ac3.bitrate);		break;	case RMdetector3_streamType_AUDIO_ADIF:		fprintf(stderr, "\tADIF: sampleRate %lu, channels %lu, bitrate %lu, isVBR %lu\n", 			info.data.audio.data.adif.sampleRate, 			info.data.audio.data.adif.channels, 			info.data.audio.data.adif.bitrate, 			(RMuint32)info.data.audio.data.adif.isVBR);		break;	case RMdetector3_streamType_AUDIO_ADTS:		fprintf(stderr, "\tADTS: sampleRate %lu, channels %lu, isVBR %lu\n", 			info.data.audio.data.adts.sampleRate, 			info.data.audio.data.adts.channels, 			(RMuint32)info.data.audio.data.adts.isVBR);		break;	case RMdetector3_streamType_AUDIO_DTS:		fprintf(stderr, "\tDTS: sampleRate %lu, channels %lu, bitrate %lu\n", 			info.data.audio.data.dts.sampleRate, 			info.data.audio.data.dts.channels, 			info.data.audio.data.dts.bitrate);		break;	case RMdetector3_streamType_AUDIO_DVD:		break;	case RMdetector3_streamType_AUDIO_LATM:		break;	case RMdetector3_streamType_AUDIO_MPEG1: //unused?		break;	case RMdetector3_streamType_AUDIO_MPEG1_LAYER3:		fprintf(stderr, "\tMPEG1layer3: sampleRate %lu, channels %lu, bitrate %lu, isVBR %lu\n", 			info.data.audio.data.mpegAudio.sampleRate, 			info.data.audio.data.mpegAudio.channels, 			info.data.audio.data.mpegAudio.bitrate, 			(RMuint32)info.data.audio.data.mpegAudio.isVBR);		break;	case RMdetector3_streamType_AUDIO_MPEG2: //unused?		fprintf(stderr, "\tMPEG2: sampleRate %lu, channels %lu, bitrate %lu, isVBR %lu\n", 			info.data.audio.data.mpegAudio.sampleRate, 			info.data.audio.data.mpegAudio.channels, 			info.data.audio.data.mpegAudio.bitrate, 			(RMuint32)info.data.audio.data.mpegAudio.isVBR);		break;	case RMdetector3_streamType_AUDIO_MPEG2_LAYER1:		fprintf(stderr, "\tMPEG2layer1: sampleRate %lu, channels %lu, bitrate %lu, isVBR %lu\n", 			info.data.audio.data.mpegAudio.sampleRate, 			info.data.audio.data.mpegAudio.channels, 			info.data.audio.data.mpegAudio.bitrate, 			(RMuint32)info.data.audio.data.mpegAudio.isVBR);		break;	case RMdetector3_streamType_AUDIO_MPEG2_LAYER2:		fprintf(stderr, "\tMPEG2layer2: sampleRate %lu, channels %lu, bitrate %lu, isVBR %lu\n", 			info.data.audio.data.mpegAudio.sampleRate, 			info.data.audio.data.mpegAudio.channels, 			info.data.audio.data.mpegAudio.bitrate, 			(RMuint32)info.data.audio.data.mpegAudio.isVBR);		break;	case RMdetector3_streamType_AUDIO_MPEG2_LAYER3:		fprintf(stderr, "\tMPEG2layer3: sampleRate %lu, channels %lu, bitrate %lu, isVBR %lu\n", 			info.data.audio.data.mpegAudio.sampleRate, 			info.data.audio.data.mpegAudio.channels, 			info.data.audio.data.mpegAudio.bitrate, 			(RMuint32)info.data.audio.data.mpegAudio.isVBR);		break;	case RMdetector3_streamType_AUDIO_PCM:		fprintf(stderr, 			"\tPCM/WAVE: format %lu, payloadOffset %lu payloadLength %lu\n"			"\t          sampleRate %lu, channels %lu, bitrate %lu, blockAlign %lu, bitsPerSample %lu\n",			info.data.audio.data.wave.format,				info.data.audio.data.wave.payloadOffset,			info.data.audio.data.wave.payloadLength,			info.data.audio.data.wave.sampleRate,			info.data.audio.data.wave.channels, 			info.data.audio.data.wave.bitrate, 			info.data.audio.data.wave.blockAlign,			info.data.audio.data.wave.bitsPerSample);		break;	case RMdetector3_streamType_AUDIO_REVERSE_PCM:		break;	case RMdetector3_streamType_AUDIO_WMA:		break;	case RMdetector3_streamType_AUDIO_WMAPRO:		break;	case RMdetector3_streamType_AUDIO_WMATS:		break;	// pictures	case RMdetector3_streamType_BMP:	case RMdetector3_streamType_JPEG:	case RMdetector3_streamType_TIFF:	case RMdetector3_streamType_PNG:	case RMdetector3_streamType_GIF:	// elementary video	case RMdetector3_streamType_VIDEO_DIVX3:	case RMdetector3_streamType_VIDEO_DIVX4:	case RMdetector3_streamType_VIDEO_H263:	case RMdetector3_streamType_VIDEO_H264:	case RMdetector3_streamType_VIDEO_MJPEG:	case RMdetector3_streamType_VIDEO_MPEG12:	case RMdetector3_streamType_VIDEO_MPEG4:	case RMdetector3_streamType_VIDEO_VC1:	case RMdetector3_streamType_VIDEO_WMV:	case RMdetector3_streamType_VIDEO_XVID:	// system	case RMdetector3_streamType_SYSTEM_ASF:	case RMdetector3_streamType_SYSTEM_AVI:	case RMdetector3_streamType_SYSTEM_DVD:	case RMdetector3_streamType_SYSTEM_ID3:	case RMdetector3_streamType_SYSTEM_M1S:	case RMdetector3_streamType_SYSTEM_M2P:	case RMdetector3_streamType_SYSTEM_M2T:	case RMdetector3_streamType_SYSTEM_M2T_192:	case RMdetector3_streamType_SYSTEM_MP4:	case RMdetector3_streamType_SYSTEM_RIFFCDXA:	case RMdetector3_streamType_SYSTEM_RIFFWAVE:		break;	}			return;}static void data_stream_callback(void *context, struct RM_Detection3_Specific_Info info, RMuint32 parentStreamID, RMuint32 streamID){	fprintf(stderr, "[%lu %lu] %s\n", parentStreamID, streamID, print_type(info.type));	// big switch...       	// get specific data	return;}int main(int argc, char **argv){	RMstatus err = RM_OK;	RMuint8 *filename = NULL;	RMint32 i;	struct RMdetector3Handle *pDetectorHandle = NULL;	RMfile filehandle = NULL;	RMuint32 parsing_length = DETECTION_THRESHOLD;	RMDBGLOG((ENABLE, "argc = %lu\n", argc));	for (i = 0; i < argc; i++)		RMDBGLOG((ENABLE, "argv[%lu] = %s\n", i, argv[i]));	if (argc < 2) {		fprintf(stderr, "usage: %s filename [parsing_length]\n", argv[0]);		fprintf(stderr, "          parsing_length is default to 512 [KB]\n");		return -1; // EXIT!	}	if (argc >= 2)		filename = (RMuint8 *)argv[1];	if (argc >= 3)		parsing_length = strtol(argv[2], NULL, 10);	parsing_length *= 1024;		if (filename) {				filehandle = RMOpenFile(filename, RM_FILE_OPEN_READ);		if (!filehandle) {			fprintf(stderr, "error %s couldn't open input file\n", RMstatusToString(err));			goto exit_with_error;		}					err = RMDetector3Create(&pDetectorHandle);		if (err != RM_OK) {			fprintf(stderr, "error %s creating dectector instance\n", RMstatusToString(err));			goto exit_with_error;		}		err = RMDetector3RegisterCallbacks(pDetectorHandle, 						   pDetectorHandle, 						   system_stream_callback,						   video_stream_callback,						   audio_stream_callback,						   data_stream_callback);		if (err != RM_OK) {			fprintf(stderr, "error %s registering callbacks\n", RMstatusToString(err));			goto exit_with_error;		}		fprintf(stderr, "----------------------------\n");		fprintf(stderr, "file: %s\n\n", filename);		err = RMDetector3DetectOpenFile(pDetectorHandle, filehandle, (RMascii *)filename, 0, parsing_length);		if (err != RM_OK) {			fprintf(stderr, "error %s detecting\n", RMstatusToString(err));			goto exit_with_error;		}		fprintf(stderr, "\n");		err = RMDetector3Destroy(pDetectorHandle);		if (err != RM_OK) {			fprintf(stderr, "error %s destroying detector instance\n", RMstatusToString(err));			goto exit_with_error;		}		if (filehandle)			RMCloseFile(filehandle);	}	//RMCheckAndReleaseMemory();	return 0; exit_with_error:	if (filehandle)		RMCloseFile(filehandle);	if (pDetectorHandle)		RMDetector3Destroy(pDetectorHandle);	//RMCheckAndReleaseMemory();	fprintf(stderr, "error %s\n", RMstatusToString(err));	return err;}

⌨️ 快捷键说明

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