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

📄 fileplayer.c

📁 Sample code for use on smp 863x processor.
💻 C
📖 第 1 页 / 共 5 页
字号:
						audio_opt->OutputDualMode = DualMode_MixMono;						break;					case 2:						audio_opt->PcmCdaParams.ChannelAssign = LpcmVob2_LR;						audio_opt->OutputDualMode = DualMode_Stereo;						break;					}					RMDBGLOG((LOCALDBG, "Setting audio frequency to %ld\n", audio_opt->SampleRate));					got_audio = TRUE;				}				else					fprintf(stderr, "ignore this audio stream, another one was already found\n");				break;			case STREAM_TYPE_MPEG1_VIDEO:			case STREAM_TYPE_MPEG2_VIDEO:				fprintf(stderr, "system video mpeg12\n");				if (!got_video) {					VideoFormatToCodec(RM_VIDEO_MPEG12, video_opt, detect_opt);					stream_info->video_type = RM_VIDEO_MPEG12;				}				else					fprintf(stderr, "ignore this video stream, another one was already found (type %lu)\n", (RMuint32)stream_info->video_type);				got_video = TRUE;				break;			case STREAM_TYPE_MPEG4_VIDEO:				fprintf(stderr, "system video mpeg4\n");				if (!got_video) {					VideoFormatToCodec(RM_VIDEO_MPEG4, video_opt, detect_opt);					stream_info->video_type = RM_VIDEO_MPEG4;				}				else					fprintf(stderr, "ignore this video stream, another one was already found (type %lu)\n", (RMuint32)stream_info->video_type);				got_video = TRUE;				break;			case STREAM_TYPE_H264_VIDEO:				fprintf(stderr, "system video h264\n");				if (!got_video) {					VideoFormatToCodec(RM_VIDEO_H264, video_opt, detect_opt);					stream_info->video_type = RM_VIDEO_H264;				}				else					fprintf(stderr, "ignore this video stream, another one was already found (type %lu)\n", (RMuint32)stream_info->video_type);				got_video = TRUE;				break;			case STREAM_TYPE_VC1_VIDEO:				fprintf(stderr, "system video vc1\n");				if (!got_video) {					VideoFormatToCodec(RM_VIDEO_VC1, video_opt, detect_opt);					stream_info->video_type = RM_VIDEO_VC1;				}				else					fprintf(stderr, "ignore this video stream, another one was already found (type %lu)\n", (RMuint32)stream_info->video_type);				got_video = TRUE;				break;			case STREAM_TYPE_AC3:			case STREAM_TYPE_DTS:				fprintf(stderr, "system audio %s\n", (streamType==STREAM_TYPE_AC3)?"ac3":"dts");				if (!got_audio) {										/*take three last bits of substream for audio_subid*/					demux_opt->audio_subid = 0x7 & subId;					//detection_info.audio_type = (streamType==STREAM_TYPE_AC3)?eAudioFormat_AC3:eAudioFormat_DTS;					if(app_params->noDolby){						RMDBGLOG((ENABLE, "NO DOLBY\n"));						audio_opt->Spdif = OutputSpdif_NoDecodeCompressed;					}					got_audio = TRUE;				}				else					fprintf(stderr, "ignore this audio stream, another one was already found\n");				break;			case STREAM_TYPE_MPEG4_AUDIO:				fprintf(stderr, "system audio latm\n");				detection_info.audio_type = eAudioFormat_AAC_LATM;				demux_opt->audio_subid = 0x7 & subId;				got_audio = TRUE;				//RMDBGLOG((LOCALDBG, "Found LATM audio stream on pid %d. This format is unsupported.\n", pid));				break;			case STREAM_TYPE_AAC_ADTS:				fprintf(stderr, "system audio aac_adts\n");				if (!got_audio) {					struct RM_Detection_Specific_Info specificInfo;					err = RMFGetAudioSpecificInfo(detector, eAudioFormat_AAC_ADTS, &specificInfo);					if (err != RM_OK) {						RMDBGLOG((ENABLE, "error getting specific information!\n"));						ERROR_CLEANUP(-1);					}					if (specificInfo.audioType == eAudioFormat_AAC_ADTS) {						bitrate = 0;						frequency = specificInfo.data.adts.sampleRate;						channel_count = specificInfo.data.adts.channels;											detection_info.audio_type = eAudioFormat_AAC_ADTS;												detection_info.audio_freq = frequency;						RMDBGLOG((LOCALDBG, "Audio is AAC_ADTS: Setting audio frequency to %ld\n", detection_info.audio_freq));						got_audio = TRUE;					}				}				else					fprintf(stderr, "ignore this audio stream, another one was already found\n"); 				break;			case STREAM_TYPE_MPEG1_AUDIO:						fprintf(stderr, "system audio mpeg1\n");				if (!got_audio) {					detection_info.audio_type = eAudioFormat_MPEG1;					demux_opt->audio_subid = 0x7 & subId;					got_audio = TRUE;				}				else					fprintf(stderr, "ignore this audio stream, another one was already found\n");				break;			case STREAM_TYPE_MPEG2_AUDIO:				fprintf(stderr, "system audio mpeg2\n");				if (!got_audio) {					detection_info.audio_type = eAudioFormat_MPEG2;					demux_opt->audio_subid = 0x7 & subId;					got_audio = TRUE;				}				else					fprintf(stderr, "ignore this audio stream, another one was already found\n");				break;			case STREAM_TYPE_RESERVED:			case STREAM_TYPE_MPEG2_PRIVATE:					case STREAM_TYPE_MPEG2_PES_PRIVATE:					case STREAM_TYPE_MHEG:					case STREAM_TYPE_DSMCC:					case STREAM_TYPE_H222:					case STREAM_TYPE_DSMCC_A:					case STREAM_TYPE_DSMCC_B:					case STREAM_TYPE_DSMCC_C:					case STREAM_TYPE_DSMCC_D:					case STREAM_TYPE_MPEG1_AUX:					case STREAM_TYPE_FLEXMUX_PES:					case STREAM_TYPE_FLEXMUX_SYSTEM:					case STREAM_TYPE_DSMCC_SDP:					case STREAM_TYPE_SUBPICTURE:					case STREAM_TYPE_NAVIGATION:					case STREAM_TYPE_MLP:						fprintf(stderr, "system: unsupported stream\n");				RMDBGLOG((ENABLE, "Found unsupported stream on pid %d\n", pid));				break;			}		}				if(!got_video){			RMDBGLOG((ENABLE, "Did not find an MPEG1, MPEG2 or MPEG4 video stream\n"));			ERROR_CLEANUP(-1);		}		if (got_audio)			detection_info.audio_detected = TRUE;		if(detection_info.audio_detected && AudioFormatToCodec(detection_info.audio_type, audio_opt)){			stream_info->audio_type = detection_info.audio_type;			audio_opt->SampleRate = detection_info.audio_freq;			audio_opt->ForceSampleRate = TRUE;			RMDBGLOG((LOCALDBG, "Setting audio frequency to %ld\n", audio_opt->SampleRate));		}		else{			play_opt->send_audio = FALSE;			fprintf(stderr, "Audio stream not found (sending only video)\n");		}				index = 0;		detection_info.last_pts = 0;		while ((detection_info.last_pts == 0) && (index < 512)) {			RMuint32 parsed_bytes;			index ++;			RMvdemuxResetState(demux);			if (RMSeekFile(file, -262144*index, RM_FILE_SEEK_END) != RM_OK) {				RMDBGLOG((ENABLE, "error seeking file to the last %ld K\n", index*64));				break;			}			parsed_bytes = 0;			while (1) {				err = RMReadFile(file, buf, 512, &count);								if (err == RM_ERRORREADFILE) {					RMDBGLOG((ENABLE, "Error reading file %d", err));					detection_info.last_pts = 0;					break;				}								if (err == RM_ERRORENDOFFILE) {					break;				}								RMvdemuxDemux(demux, buf, count);				parsed_bytes += count;				if(parsed_bytes > 262144){					break;				}							}			RMFDetectorReset(detection_info.detector);		}				if(detection_info.last_pts == 0) {			RMDBGLOG((ENABLE, "Could not find last valid PTS!!\n"));			detection_info.first_pts = 0;		}		play_opt->duration = (detection_info.last_pts - detection_info.first_pts)/90;		RMDBGLOG((LOCALDBG, "Detected duration is %lld [ms](first pts %lld - last pts %lld)\n", 			  play_opt->duration, 			  detection_info.first_pts,			  detection_info.last_pts ));		if (play_opt->duration) {			video_opt->first_pts_in_stream = detection_info.first_pts / 90;			RMDBGLOG((LOCALDBG, "first_pts_in_stream %lld [ms]\n", video_opt->first_pts_in_stream));		}		err = RMDeleteVdemux(demux);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "Cannot delete demux %d\n", err));			ERROR_CLEANUP(-1);		}				}	if (stream_info->system_type == RM_SYSTEM_ASF) {		err = detect_asf_duration(file, &play_opt->duration);		if (err != RM_OK) {			RMDBGLOG((ENABLE, "error getting asf duration\n"));		}		RMDBGLOG((ENABLE, "ASF Detected duration is %lld [ms]\n", play_opt->duration));	}		if(app)		*app = get_app_from_stream_info(stream_info);	 cleanup:	if (detector)		RMFDetectorDestruct(detector);	if(error)		return RM_ERROR;	return RM_OK;}RMstatus rfp_play(struct mono_info *app_params, enum rfp_application app){	RMint32 error = 0;	struct playback_cmdline local_play_opt;	struct video_cmdline local_video_opt;	struct audio_cmdline local_audio_opt[MAX_AUDIO_DECODER_INSTANCES];	struct demux_cmdline local_demux_opt;	struct mono_info local_app_params;	// copy app_params	if (app_params->play_opt)		RMMemcpy(&local_play_opt, app_params->play_opt, sizeof(local_play_opt));	if (app_params->demux_opt)		RMMemcpy(&local_demux_opt, app_params->demux_opt, sizeof(local_demux_opt));	if (app_params->audio_opt)		RMMemcpy(&local_audio_opt, app_params->audio_opt, sizeof(local_audio_opt));	if (app_params->video_opt) 		RMMemcpy(&local_video_opt, app_params->video_opt, sizeof(local_video_opt));	if (app_params)		RMMemcpy(&local_app_params, app_params, sizeof(local_app_params));	/* de-activate closed caption if not supported by the app */	if((app != APP_DEMUX) && 	   (app != APP_DEMUX_SOFT) && 	   (app != APP_VIDEO)){		app_params->video_opt->display_cc = FALSE;	}	/* a quick and dirty change to swtich to software jpeg, shall be removed when jpeg 444 support is up*/	if( app == APP_VIDEO && app_params->video_opt->vcodec_profile == EMhwlib_JPEG_Invalid_Profile ) {  		RMDBGLOG((ENABLE, "Unsupported picture format, use software decoder\n"));		app = APP_PICTURE;	}	switch(app){	case APP_DEMUX:		RMDBGLOG((LOCALDBG, "calling psf hw demux\n"));		display_key_usage(AUDIO_VIDEO_KEYFLAGS);		error = (RMint32)main_psfdemux(app_params);		break;	case APP_DEMUX_SOFT:		RMDBGLOG((LOCALDBG, "calling soft demux\n"));		display_key_usage(AUDIO_VIDEO_KEYFLAGS);		error = (RMint32)main_demux(app_params);		break;	case APP_VIDEO:		RMDBGLOG((LOCALDBG, "calling video\n"));		display_key_usage(VIDEO_KEYFLAGS);		error = (RMint32)main_video(app_params);		break;	case APP_AUDIO: 		RMDBGLOG((LOCALDBG, "calling audio\n"));		display_key_usage(AUDIO_KEYFLAGS);		error = (RMint32)main_audio(app_params);		break;	case APP_PICTURE:		RMDBGLOG((LOCALDBG, "calling picture\n"));		display_key_usage(VIDEO_KEYFLAGS);		error = (RMint32)main_picture(app_params);		if(error && (app_params->osd_scaler != 0)){			app_params->osd_scaler = 0;			error = (RMint32)main_picture(app_params);		}		break;	case APP_AVI:		RMDBGLOG((LOCALDBG, "calling avi push\n"));		display_key_usage(AUDIO_VIDEO_KEYFLAGS);		error = (RMint32)main_avi_push(app_params);		break;	case APP_AVI_PULL:		RMDBGLOG((ENABLE, "AVI DEMUX PULL MODEL IS NOT SUPPORTED\n"));		return RM_ERROR;	case APP_ASF:		RMDBGLOG((LOCALDBG, "calling asf\n"));		display_key_usage(AUDIO_VIDEO_KEYFLAGS);		error = (RMint32)main_asf(app_params);		break;	case APP_MP4:		RMDBGLOG((LOCALDBG, "calling mp4\n"));		display_key_usage(AUDIO_VIDEO_KEYFLAGS);		error = (RMint32)main_mp4(app_params);		break;	case NOT_SUPPORTED:		// params haven't been changed so no need to restore them		return RM_ERROR;	}		// restore app_params	if (app_params->play_opt)		RMMemcpy(app_params->play_opt, &local_play_opt, sizeof(local_play_opt));	if (app_params->demux_opt)		RMMemcpy(app_params->demux_opt, &local_demux_opt, sizeof(local_demux_opt));	if (app_params->audio_opt)		RMMemcpy(app_params->audio_opt, &local_audio_opt, sizeof(local_audio_opt));	if (app_params->video_opt)		RMMemcpy(app_params->video_opt, &local_video_opt, sizeof(local_video_opt));	if (app_params)		RMMemcpy(app_params, &local_app_params, sizeof(local_app_params));	if (error > 0)		return error;	else if (error < 0)		return RM_ERROR;	else		return RM_OK;	}RMstatus play_file(struct mono_info *app_params, struct player_options *player_conf){	RMstatus status;	struct rfp_detect_options detect_opt;	enum rfp_application app;	struct rfp_stream_info stream_info;	/* #### Begin CARDEA code #### */	{		if (  find_cardea_url(app_params->play_opt->filename) != NULL ){			RMDBGLOG((LOCALDBG,"Playing cardea file, skip detection ... (only ASF supported).\n"));			app = APP_ASF;			goto skip_detection;		}	}	/* #### End CARDEA code #### */ 	/* keep compatibility with deprecated player_conf struct */	detect_opt.force_sd = player_conf->forceSD;	status = rfp_detect(app_params, &detect_opt, &app, &stream_info);	if(RMFAILED(status)){		RMDBGLOG((ENABLE, "Detection failed\n"));		return status;	}	/* keep compatibility with old player_conf struct */	if((app == APP_DEMUX) && (!player_conf->use_hwdemux)){		app = APP_DEMUX_SOFT;	}	if((app == APP_AVI) && (!player_conf->use_avi_push)){		app = APP_AVI_PULL;	}	/* #### Begin CARDEA code #### */ skip_detection:	/* #### End CARDEA code #### */	status = rfp_play(app_params, app);	if(RMFAILED(status)){		RMDBGLOG((ENABLE, "Playback failed\n"));		return status;	}	return RM_OK;}

⌨️ 快捷键说明

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