📄 play_psfdemux_checksum.c
字号:
static RMstatus SwitchAudioDecoder(struct context_per_task *context, enum AudioDecoder_Codec_type ACodec){ RMstatus err = RM_OK; if (context->audio_opt->Codec == ACodec) return err; RMDBGLOG((ENABLE, "%lx_SwitchAudioDecoder: from %u to %u SPDIF[%u]\n", context->id, context->audio_opt->Codec, ACodec, context->audio_opt->Spdif)); context->audio_opt->Codec = ACodec; if (ACodec == AudioDecoder_Codec_AC3) { context->audio_opt->Ac3Params.OutputChannels = Ac3_LR; if (!context->audio_opt->OutputChannelsExplicitAssign) context->audio_opt->OutputChannels = Audio_Out_Ch_LR; } /* apply the audio format - uninit, set codec, set specific parameters, init */ err = apply_audio_decoder_options(context->dcc_info, context->audio_opt); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%lx_Error applying audio_decoder_options err=%d\n", context->id, err)); return RM_ERROR; } apply_dvi_hdmi_audio_options(context->dcc_info, context->audio_opt, 0, FALSE, FALSE, FALSE); err = Play(context, RM_DEVICES_AUDIO, VideoDecoder_Command_PlayFwd); return err;}static RMstatus SwitchVideoDecoder(struct context_per_task *context, enum VideoDecoder_Codec_type VCodec, enum MPEG_Profile MPEGProfile){ RMstatus err = RM_OK; RMuint32 dummy; struct ReceiveThreshold_type rec_thr; struct DemuxOutput_Connect_type connect; RMuint32 demux_output; if ((context->video_opt->MPEGProfile == MPEGProfile) && (context->video_opt->Codec == VCodec)) return err; fprintf(stderr, "\nSwitch Video Codec from %u to %u Profile from %u to %u\n", context->video_opt->Codec, VCodec, context->video_opt->MPEGProfile, MPEGProfile); demux_output = EMHWLIB_MODULE(DemuxOutput, context->videoDemuxOutputIndex + output_count_per_task * context->id); err = RUASetProperty(context->pRUA, demux_output, RMDemuxOutputPropertyID_Close, &dummy, sizeof(dummy), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "SwitchVideoDecoder cannot close DemuxOutput %lu err=%d\n", demux_output, err)); return err; } RMDBGLOG((LOCALDBG, "SwitchVideoDecoder: CloseVideoSource %p\n", context->dcc_info->pVideoSource)); err = DCCCloseVideoSource(context->dcc_info->pVideoSource); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%lx_Error cannot close video decoder err=%d\n", context->id, err)); return err; } clear_video_options(context->dcc_info, context->video_opt);#ifndef WITH_MONO clear_display_options(context->dcc_info, context->disp_opt);#endif context->video_opt->Codec = VCodec; context->video_opt->MPEGProfile = MPEGProfile; err = OpenVideoDecoder(context); /* spu_hack: this will open the SpuDecoder too */ if (RMFAILED(err)) { RMDBGLOG((ENABLE, "SwitchVideoDecoder: can NOT open video decoder\n")); return err; } /* the decoder will provide the bitstream, pts and inband fifo - no need to open a DemuxOutput, just connect */ context->output_table[context->videoDemuxOutputIndex].consumer_module_id = context->dcc_info->video_decoder; connect.demux_task_module_id = context->demux_task; connect.consumer_module_id = context->output_table[context->videoDemuxOutputIndex].consumer_module_id; err = RUASetProperty(context->pRUA, demux_output, RMDemuxOutputPropertyID_Connect, &connect, sizeof(connect), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "SwitchVideoDecoder: DemuxOutput %ld failed to connect consumer=0x%lx\n", demux_output, connect.consumer_module_id)); return err; } err = DCCXSetVideoDecoderSourceCodec(context->dcc_info->pVideoSource, context->vcodec); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot set video decoder codec %d\n", err)); return err; } /* apply the fixed vop rate if required */ err = apply_video_decoder_options(context->dcc_info, context->video_opt); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%lx_Error applying video_decoder_options err=%d\n", context->id, err)); return RM_ERROR; } if ((! context->video_opt->VopInfo.FixedVopRate) && (! context->video_opt->vtimescale.enable)) { /* time stamps are in 45k, ask the decoder to interpolate the time info from stream. For m4v the property will succeed. */ context->video_opt->vtimescale.enable = TRUE; context->video_opt->vtimescale.time_resolution = 90000; err = RUASetProperty(context->dcc_info->pRUA, context->dcc_info->video_decoder, RMVideoDecoderPropertyID_VideoTimeScale, &context->video_opt->vtimescale, sizeof(context->video_opt->vtimescale), 0 ); if (RMSUCCEEDED(err)) { RMDBGLOG((ENABLE, "set video time scale: %ld ticks per second\n", context->video_opt->vtimescale.time_resolution)); } else if (0) { /* time scaling is not supported - it happens for NO M4V decoders. We have to use fixed vop rate. */ context->video_opt->VopInfo.FixedVopRate = TRUE; context->video_opt->VopInfo.VopTimeIncrementResolution = 90000; context->video_opt->VopInfo.FixedVopTimeIncrement = 3000; err = RUASetProperty(context->dcc_info->pRUA, context->dcc_info->video_decoder, RMVideoDecoderPropertyID_VopInfo, &context->video_opt->VopInfo, sizeof(context->video_opt->VopInfo), 0 ); if (RMSUCCEEDED(err)) { RMDBGLOG((ENABLE, "video time scale not supported. Set fixed vop rate: %ld / %ld frames per second\n", context->video_opt->VopInfo.VopTimeIncrementResolution, context->video_opt->VopInfo.FixedVopTimeIncrement)); } else { RMDBGLOG((ENABLE,"video time scale not supported. Error setting fixed VOP rate : %d !\n", err)); } } } RUASetProperty(context->pRUA, demux_output, RMDemuxOutputPropertyID_Enable, &dummy, sizeof(dummy), 0); RUASetProperty(context->pRUA, demux_output, RMDemuxOutputPropertyID_DataType, &context->output_table[context->videoDemuxOutputIndex].type, sizeof(context->output_table[context->videoDemuxOutputIndex].type), 0); /* set to 0 the threshold because in case of playback I don't need the interrupts for receive */ rec_thr.partial_read = FALSE; rec_thr.size = 0; RUASetProperty(context->pRUA, demux_output, RMGenericPropertyID_Threshold, &rec_thr, sizeof(rec_thr), 0); /* by default the output has the pts enabled */ if (!context->play_opt->send_video_pts) { err = RUASetProperty(context->dcc_info->pRUA, demux_output, RMDemuxOutputPropertyID_EnablePts, &context->play_opt->send_video_pts, sizeof(context->play_opt->send_video_pts), 0 ); } err = Play(context, RM_DEVICES_VIDEO, VideoDecoder_Command_PlayFwd); return err;}static RMstatus SwitchCodec(struct context_per_task *context){ enum AudioDecoder_Codec_type ACodec; enum VideoDecoder_Codec_type VCodec; enum MPEG_Profile MPEGProfile; RMuint32 index; RMstatus err; if (! context->video_opt->auto_detect_codec) goto audio_codec; for (index = 0; index < context->VideoPidList.count; index++) { if (context->VideoPidList.elementary_pid[index] == context->video_pid) break; } if (index >= context->VideoPidList.count) goto audio_codec; switch (context->VideoPidList.stream_type[index]) { case 1: // mpeg 1 video RMDBGLOG((ENABLE, "mpeg1 video detected, error\n")); return RM_ERROR; break; case 2: // mpeg 2 video RMDBGLOG((LOCALDBG, "mpeg2 video detected\n")); MPEGProfile = Profile_MPEG2_HD; VCodec = VideoDecoder_Codec_MPEG2_HD; break; case 0x10: // mpeg 4 video RMDBGLOG((LOCALDBG, "mpeg4 video detected\n")); MPEGProfile = Profile_MPEG4_HD; VCodec = VideoDecoder_Codec_MPEG4_HD; break; case 0x1b: // H264 video RMDBGLOG((LOCALDBG, "h264 video detected\n")); MPEGProfile = Profile_H264_HD; VCodec = VideoDecoder_Codec_H264_HD; break; case 0xea: // VC-1 video RMDBGLOG((LOCALDBG, "VC-1 video detected\n")); MPEGProfile = Profile_VC1_HD; VCodec = VideoDecoder_Codec_VC1_HD; default: RMDBGLOG((ENABLE, "%lx_SwitchCodec: video codec unknown, don't SwitchVideoDecoder !\n", context->id)); goto audio_codec; } err = SwitchVideoDecoder(context, VCodec, MPEGProfile); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%lx_Error Switch video decoder err=%d\n", context->id, err)); return RM_ERROR; } audio_codec: if (! context->audio_opt->auto_detect_codec) return RM_OK; for (index = 0; index < context->AudioPidList.count; index++) { if (context->AudioPidList.elementary_pid[index] == context->audio_pid) break; } if (index >= context->AudioPidList.count) return RM_OK; switch (context->AudioPidList.stream_type[index]) { case 3: // mpeg 1 audio case 4: // mpeg 2 audio RMDBGLOG((ENABLE, "%lx_SwitchCodec: mpeg audio detected\n", context->id)); ACodec = AudioDecoder_Codec_MPEG1; break; case 6: // private, can be DTS audio RMDBGLOG((ENABLE, "%lx_SwitchCodec: private stream_type = 6, by default DTS\n", context->id)); ACodec = stream_type_6; break; case 0x0f: // ISO/IEC 13818-7 Audio with ADTS transport syntax RMDBGLOG((ENABLE, "%lx_SwitchCodec: ADTS audio detected\n", context->id)); ACodec = AudioDecoder_Codec_AAC; context->audio_opt->AACParams.InputFormat = 1; // adif, no sync word context->audio_opt->AACParams.OutputChannels = Aac_LR; break; case 0x80: // 0x80 = bdlpcm RMDBGLOG((ENABLE, "%lx_SwitchCodec: bdlpcm audio detected\n", context->id)); ACodec = AudioDecoder_Codec_PCM; context->audio_opt->SubCodec = 3; context->audio_opt->PcmCdaParams.ChannelAssign = PcmCda2_LR; context->audio_opt->PcmCdaParams.BitsPerSample = 16; if (!context->audio_opt->OutputChannelsExplicitAssign) context->audio_opt->OutputChannels = Audio_Out_Ch_LR; break; case 0x81: // 0x81 = ac3 case 0x83: // 0x83 = dolby lossless - to check case 0x84: // 0x84 = dolby digital plus - to check RMDBGLOG((ENABLE, "%lx_SwitchCodec: ac3 audio detected\n", context->id)); ACodec = AudioDecoder_Codec_AC3; break; case 0x82: // 0x82 = dts case 0x85: // 0x85 = dts hd - to check RMDBGLOG((ENABLE, "%lx_SwitchCodec: dts audio detected\n", context->id)); ACodec = AudioDecoder_Codec_DTS; break; case 0xe6: // 0xe6 = wmaTS - Vincent case 0x11: // 0x11, audio with LATM transport syntax as defined in ISO/IEC 14496-3 / AMD 1 default: RMDBGLOG((ENABLE, "%lx_SwitchCodec: audio codec unknown, don't SwitchAudioDecoder !\n", context->id)); return RM_OK; } err = SwitchAudioDecoder(context, ACodec); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "%lx_SwitchCodec: SwitchAudioDecoder Error=%d\n", context->id, err)); return RM_ERROR; } return RM_OK;}static RMstatus send_disable_output_demux_command(struct RUA *pRUA, RMuint32 demux, struct EMhwlibOutputMask_type *discmd) { struct RUAEvent evt; RMuint32 index; RMstatus err; evt.ModuleID = demux; evt.Mask = RUAEVENT_COMMANDCOMPLETION; err = RUAResetEvent(pRUA, &evt); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot reset demux OutputDisableCommand completion event, %s\n", RMstatusToString(err))); return err; } err = RUASetProperty(pRUA, demux, RMDemuxTaskPropertyID_OutputDisableCommand, discmd, sizeof(struct EMhwlibOutputMask_type), 0); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Cannot send demux OutputDisableCommand, %s\n", RMstatusToString(err))); return err; } evt.ModuleID = demux; evt.Mask = RUAEVENT_COMMANDCOMPLETION; err = RUAWaitForMultipleEvents(pRUA, &evt, 1, TIMEOUT_100MS, &index); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "wait for demux OutputDisableCommand completion %d failed, %s\n", RMstatusToString(err))); return err; } return RM_OK;}static void GetPidsFromAVListOrCmdLine(struct context_per_task *context){ if (!(context->av_flags & VIDEO_PID_FROM_CMDLINE)) { if (context->VideoPidList.count) { fprintf(stderr, "vpid[%lu]= 0x%04x(0x%02x) ", context->VideoPidList.index, context->VideoPidList.elementary_pid[context->VideoPidList.index], context->VideoPidList.stream_type[context->VideoPidList.index]); context->video_pid = context->VideoPidList.elementary_pid[context->VideoPidList.index]; } else { context->video_pid = 0x1fff; fprintf(stderr, " vpid= NO pid in the list "); } } if (!(context->av_flags & ECM0_PID_FROM_CMDLINE)) { if (context->VideoPidList.count) { context->ecm_pid[0] = context->VideoPidList.es_ecm_pid[context->VideoPidList.index]; } } if (!(context->av_flags & AUDIO_PID_FROM_CMDLINE)) { if (context->AudioPidList.count) { fprintf(stderr, "apid[%lu]= 0x%04x(0x%02x) ", context->AudioPidList.index, context->AudioPidList.elementary_pid[context->AudioPidList.index], context->AudioPidList.stream_type[context->AudioPidList.index]); context->audio_pid = context->AudioPidList.elementary_pid[context->AudioPidList.index]; } else { context->audio_pid = 0x1fff; fprintf(stderr, " apid= NO pid in the list "); } } if (!(context->av_flags & ECM1_PID_FROM_CMDLINE)) { if (context->AudioPidList.count) { context->ecm_pid[1] = context->AudioPidList.es_ecm_pid[context->A
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -