?? fileplayer.cpp
字號:
m_eos = FALSE; SetState(STATE_STOP, 0); Close(); } else if(m_stop_pending) { RMDBGLOG((ENABLE, "going to stop...\n")); InterpretCommand(RM_HW_STOP, NULL); }#endif}RMstatus RMfilePlayer::UpdateDisplayInfo(){ if(m_context->fipHandler >= 0 && m_context->decoder != NULL) { RMstatus status = RM_ERROR; RMuint64 time = 0; status = m_context->decoder->GetTimeDisplayedFrame(m_sampletype, &time); if(RMSUCCEEDED(status)) { if(time == 0) { m_has_init_time = FALSE; return status; } if(! m_has_init_time) { // force on first non zero time (may lose half a second precision) m_init_time = time; m_has_init_time = TRUE; } time -= m_init_time; SendMessage(CURACAO_MESSAGE_DISPLAY_INFO, &time); } return status; } return RM_ERROR;}RMstatus RMfilePlayer::UpdateMediaInfo(){ if(m_context->gui && m_context->decoder != NULL) { RMstatus status = RM_ERROR; RMuint64 time; typeCuracaoFileInfo info; status = m_context->decoder->GetTimeDisplayedFrame(m_sampletype, &time); if(RMSUCCEEDED(status)) { if(time == 0) { m_has_init_time = FALSE; return status; } if(! m_has_init_time) { // force on first non zero time (may lose half a second precision) m_init_time = time; m_has_init_time = TRUE; } if(time <= m_init_time) time = 0; else time -= m_init_time; info.time = (RMuint32)time;// printf("time\n"); SendMessage(CURACAO_MESSAGE_MEDIA_INFO, &info); } return status; } return RM_ERROR;}RMstatus RMfilePlayer::GetInfo(typeCuracaoMessage message, void *val){ RMstatus status = RM_ERROR;#ifndef WITH_MONO RMTcontrolInterface ctrl; RMTpropertyControl ctrl_prop; ctrl = m_context->decoder->GetControl(); if(ctrl == 0){ RMDBGLOG((FILEPLAYERDBG, "Invalid control after OpenUrl\n")); return RM_ERROR; } RMFGetControlHandle((void **) &ctrl_prop, RM_CONTROL_PROPERTY, ctrl);#else RMuint32 retval;#endif switch (message){ case CURACAO_MESSAGE_FILE_DURATION:#ifndef WITH_MONO status = RMFGetGenericProperty(ctrl_prop, RM_PROPERTY_EXTERNAL, "VIDEO", "DURATION", val, sizeof(RMuint64));#else status = RM_OK; if(play_opt.duration != 0){ *(RMuint32*)val = play_opt.duration / 1000; } else if(m_streamType == RMStreamInfoIsType_MPEG4){ *(RMuint32*)val = m_mp4Info.duration; } else if(m_streamType == RMStreamInfoIsType_AVI){ *(RMuint32*)val = m_aviInfo.duration; } else{ status = RM_ERROR; }#endif if(status == RM_OK) RMDBGLOG((FILEPLAYERDBG, "!!!!! Duration : %lu\n", *(RMuint32*)val)); else RMDBGLOG((FILEPLAYERDBG, "!!!!! Failed to get duration\n")); break; case CURACAO_MESSAGE_FILE_SEEK_WHERE:#ifndef WITH_MONO status = RMFGetGenericProperty(ctrl_prop, RM_PROPERTY_EXTERNAL, "ASFDEMUX", "SEEK_WHERE", val, sizeof(RMuint64));#else status = asf_get_real_seek_position(*(RMuint32*)val, &retval); *(RMuint32*)val = retval;#endif if(status == RM_OK){ RMDBGLOG((FILEPLAYERDBG, "!!!!! Position : %lu\n", *(RMuint32*)val)); } else{ RMDBGLOG((FILEPLAYERDBG, "!!!!! Failed to get position\n")); } break; case CURACAO_MESSAGE_FILE_HAS_CHAPTERS: // only case we handle for now *(RMuint32*)val = (m_streamType == RMStreamInfoIsType_MPEG4 ? m_mp4Info.chapters : 0); status = RM_OK; break; default: status = RM_PROPERTY_NOT_SUPPORTED; break; } return status;}RMstatus RMfilePlayer::DetectUsingExtension(RMascii *name, RMFDetector_type *type){ char *ext; char *nameLowercase; int sizeName; int i; RMstatus status; if(name == (RMascii*)NULL) return RM_ERROR; sizeName = strlen(name); nameLowercase = (char*)MALLOC(sizeName); for(i=0;i<sizeName;i++) nameLowercase[i] = tolower(name[i]); ext = strrchr(nameLowercase,'.'); RMDBGLOG((FILEPLAYERDBG, "!!!!! In file detection based on extension ...\n")); if(ext != (char*)NULL){ if(strstr(ext,"mp4") != (char*)NULL){ *type = DETECTOR_SYSTEM_MP4; status = RM_OK; } else if(strstr(ext,"pcm") != (char*)NULL){ *type = DETECTOR_AUDIO_PCM; status = RM_OK; } else if(strstr(ext,"rpcm") != (char*)NULL){ *type = DETECTOR_AUDIO_RPCM; status = RM_OK; } else if(strstr(ext,"mp3") != (char*)NULL){ *type = DETECTOR_AUDIO_MPEG1_LAYER3; status = RM_OK; } else if(strstr(ext,"m1v") != (char*)NULL){ *type = DETECTOR_VIDEO_MPEG1; status = RM_OK; } else if(strstr(ext,"m2v") != (char*)NULL){ *type = DETECTOR_VIDEO_MPEG2; status = RM_OK; } else if(strstr(ext,"m4v") != (char*)NULL){ *type = DETECTOR_VIDEO_MPEG4; status = RM_OK; } else if((strstr(ext,"mpeg") != (char*)NULL) || (strstr(ext,"mpg") != (char*)NULL) || (strstr(ext,"m1s") != (char*)NULL)){ *type = DETECTOR_SYSTEM_M1S; status = RM_OK; } else if(strstr(ext,"m2p") != (char*)NULL){ *type = DETECTOR_SYSTEM_M2P; status = RM_OK; } else if(strstr(ext,"m2t") != (char*)NULL){ *type = DETECTOR_SYSTEM_M2T; status = RM_OK; } else if(strstr(ext,"m4t") != (char*)NULL){ *type = DETECTOR_SYSTEM_M4T; status = RM_OK; } else if(strstr(ext,"m4p") != (char*)NULL){ *type = DETECTOR_SYSTEM_M4P; status = RM_OK; } else if(strstr(ext,"vob") != (char*)NULL){ *type = DETECTOR_SYSTEM_VOB; status = RM_OK; } else if((strstr(ext,"divx") != (char*)NULL) || (strstr(ext,"avi") != (char*)NULL)){ *type = DETECTOR_SYSTEM_DIVX_MP3; status = RM_OK; } else if((strstr(ext,"asf") != (char*)NULL) || (strstr(ext,"wmv9") != (char*)NULL) || (strstr(ext,"wmv") != (char*)NULL)){ *type = DETECTOR_SYSTEM_ASF; status = RM_OK; } else { status = RM_ERROR; *type = DETECTOR_TYPE_UNKNOWN; } } else { status = RM_ERROR; *type = DETECTOR_TYPE_UNKNOWN; } RFREE(nameLowercase); return status;}// based on Compliance rules for WMDRMRMstatus RMfilePlayer::HandleDRMOPL(RMuint32 val){ if(m_context->decoder == NULL) return RM_ERROR; RMuint32 protecttype; RMuint32 analog_videoopl = OPL_EXTRACT_ANALOG_VIDEO(val); RMDBGLOG((ENABLE, "Analog Video = %lu\n", OPL_EXTRACT_ANALOG_VIDEO(val))); switch(analog_videoopl){ case 0: // level 0-100 // nothing to be done break; case 1: // 101-200 // enable CGMS-A -- see 5.2.5.2 protecttype = (11 << 16) | RMWmvMacrovisionProtect; //Macrovision level 11); m_context->decoder->UpdateOutputProtection(RMWmvProtect, protecttype); break; default: // 201 or greater // DO NOT PASS OUTPUT -- see 5.2.5.3 Close(); protecttype = RMWmvNoPlaybackProtect; SendMessage(CURACAO_MESSAGE_DRM_OPL, &protecttype); break; } RMuint32 compresseddigital_videoopl = OPL_EXTRACT_COMPRESSED_DIGITAL_VIDEO(val); RMDBGLOG((ENABLE, "Compressed Digital Video = %lu\n", OPL_EXTRACT_COMPRESSED_DIGITAL_VIDEO(val))); if(compresseddigital_videoopl > 0){ // DO NOT PASS OUTPUT -- see 5.2.3 Close(); protecttype = RMWmvNoPlaybackProtect; SendMessage(CURACAO_MESSAGE_DRM_OPL, &protecttype); } RMuint32 ucompresseddigital_videoopl = OPL_EXTRACT_UNCOMPRESSED_DIGITAL_VIDEO(val); RMDBGLOG((ENABLE, "Uncompressed Digital Video = %lu\n", OPL_EXTRACT_UNCOMPRESSED_DIGITAL_VIDEO(val))); switch(ucompresseddigital_videoopl){ case 0: // level 0-100 // nothing to be done // see 5.2.4.1 break; case 1: // 101-200 case 2: // 201-300 // enable HDCP -- see 5.2.4.2 protecttype = RMWmvHDCPProtect; m_context->decoder->UpdateOutputProtection(RMWmvProtect, protecttype);//HDCP on DVI SendMessage(CURACAO_MESSAGE_DRM_OPL, &protecttype); break; default: // 301 or greater // DO NOT PASS OUTPUT -- see 5.2.4.3 Close(); protecttype = RMWmvNoPlaybackProtect; SendMessage(CURACAO_MESSAGE_DRM_OPL, &protecttype); break; } RMuint32 autogainctrlcolorstripeopl = OPL_EXTRACT_AUTOMATIC_GAIN_CONTROL_COLOR_STRIPE(val); RMDBGLOG((ENABLE, "Automatic Gain Control Color Stripe = %lu\n", OPL_EXTRACT_AUTOMATIC_GAIN_CONTROL_COLOR_STRIPE(val))); if(autogainctrlcolorstripeopl){ // see 5.2.6.1 // APSTB values? // 00 no macrovision ACP // 4, turn macrovision off // 01 AGC only // 5 // 02 AGC and 2 line colorstripe // 6 // 03 AGC and 4 line Colorstripe // 7 //m_context->decoder->UpdateOutputProtection(RMWmvProtect, 4/*or 5, 6, 7*/);// APSTB value } RMuint32 compresseddigital_audioopl = OPL_EXTRACT_COMPRESSED_DIGITAL_AUDIO(val); RMDBGLOG((ENABLE, "Compressed Digital Audio = %lu\n", OPL_EXTRACT_COMPRESSED_DIGITAL_AUDIO(val))); switch(compresseddigital_audioopl){ case 0: // level 0-100 // nothing to be done -- see 5.2.1.1 break; case 1: // 101-200 // assuming secure driver, nothing to be done -- see 5.2.1.2 break; case 2: // 201-300 // assuming secure driver (unrestricted output?), nothing to be done -- see 5.2.1.3 break; default:// 301 or greater // NO AUDIO CAN BE SENT -- see 5.2.1.4 protecttype = RMWmvNoAudioProtect; m_context->decoder->UpdateOutputProtection(RMWmvProtect, protecttype);// shut off audio SendMessage(CURACAO_MESSAGE_DRM_OPL, &protecttype); break; } RMuint32 ucompresseddigital_audioopl = OPL_EXTRACT_UNCOMPRESSED_DIGITAL_AUDIO(val); RMDBGLOG((ENABLE, "Uncompressed Digital Audio = %lu\n", OPL_EXTRACT_UNCOMPRESSED_DIGITAL_AUDIO(val))); switch(ucompresseddigital_audioopl){ case 0: // level 0-100 // nothing to be done -- see 5.2.2.1 break; case 1: // 101-200 // assuming secure, nothing to be done -- see 5.2.2.2 break; case 2: // 201-300 // assuming secure driver (unrestricted output?), nothing to be done -- see 5.2.2.3 break; default: // 201 or greater // DO NOT PASS OUTPUT -- see 5.2.2.4 protecttype = RMWmvNoAudioProtect; m_context->decoder->UpdateOutputProtection(RMWmvProtect, protecttype);// shut off audio SendMessage(CURACAO_MESSAGE_DRM_OPL, &protecttype); break; } return RM_OK;}// only works with asf for now !!RMstatus RMfilePlayer::GetAudioStreamID(RMuint8 stream, RMascii *str){ RMasfdemuxLanguageID langID; RMuint8 index; RMstatus status;#ifndef WITH_MONO RMTcontrolInterface ctrl; RMTpropertyControl ctrl_prop; ctrl = m_context->decoder->GetControl(); if(ctrl == 0){ RMDBGLOG((ENABLE, "Invalid control after OpenUrl\n")); return RM_ERROR; } RMFGetControlHandle((void **) &ctrl_prop, RM_CONTROL_PROPERTY, ctrl); langID.languageIDIndex = 0; // --> set the first index to 0 RMFGetGenericProperty(ctrl_prop, RM_PROPERTY_EXTERNAL, "ASFDEMUX", "LanguageID", &langID, sizeof(RMasfdemuxLanguageID)); langID.languageIDIndex = stream; status = RMFGetGenericProperty(ctrl_prop, RM_PROPERTY_EXTERNAL, "ASFDEMUX", "LanguageID", &langID,sizeof(RMasfdemuxLanguageID));#else langID.languageIDIndex = stream; status = asf_get_audio_languageId(&langID);#endif if(RMFAILED(status)) return RM_ERROR; index = 0; for(RMuint8 i = 0; i < langID.languageIDLength; i++){ if(i % 2 == 0){ str[index++] = langID.languageID[i]; } } str[index] = '\0'; return (index != 0 ? RM_OK : RM_ERROR);}RMstatus RMfilePlayer::GetCurrentAudioStream(RMuint8 *stream){ RMstatus status;#ifndef WITH_MONO RMTcontrolInterface ctrl; RMTpropertyControl ctrl_prop; RMint32 val; ctrl = m_context->decoder->GetControl(); if(ctrl == 0){ RMDBGLOG((ENABLE, "Invalid control after OpenUrl\n")); return RM_ERROR; } RMFGetControlHandle((void **) &ctrl_prop, RM_CONTROL_PROPERTY, ctrl); // get current status =RMFGetGenericProperty(ctrl_prop, RM_PROPERTY_EXTERNAL, "FILE", "SELECTED_AUDIO_STREAM", &val, sizeof(RMint32)); if(RMSUCCEEDED(status)) *stream = (RMuint8)val;#else RMuint32 val; status = asf_get_current_audio_stream(&val); if(RMSUCCEEDED(status)) *stream = (RMuint8)val;#endif RMDBGLOG((ENABLE, "current stream %d\n", *stream)); return status;}RMstatus RMfilePlayer::SetStreamInfo(struct RMFileStreamInfo *streamInfo){ if(streamInfo == NULL){ m_streamType = RMStreamInfoIsType_Unknown; m_subpictureStream = 1; // starts with first subpicture on -- may change m_audioStream = 1; RMMemset(&m_mp4Info, 0, sizeof(RMMP4StreamInfo)); RMMemset(&m_aviInfo, 0, sizeof(RMAVIStreamInfo)); m_has_init_time = FALSE; m_init_time = 0; return RM_OK; } m_streamType = streamInfo->streamType; switch(m_streamType) { case RMStreamInfoIsType_Unknown: RMDBGLOG((ENABLE, "unknown type!\n")); break; case RMStreamInfoIsType_MPEG4: RMDBGLOG((ENABLE, "type is MPEG4\n")); RMMemcpy(&m_mp4Info, &(streamInfo->data.mp4Info), sizeof(RMMP4StreamInfo)); if (m_mp4Info.isNero){ RMDBGLOG((ENABLE, "isNero\n")); SendMessage(CURACAO_MESSAGE_NERO_MPEG4, NULL); } if (m_mp4Info.isPlayable) RMDBGLOG((ENABLE, "playback allowed\n")); else{ RMDBGLOG((ENABLE, "DRM prevents playback\n")); SendMessage(CURACAO_MESSAGE_DRM_ERROR, NULL); } RMDBGLOG((ENABLE, "%lu chapter(s), %lu audio stream(s), %lu subpicture stream(s)\n", m_mp4Info.chapters, m_mp4Info.audioStreams, m_mp4Info.spuStreams)); break; case RMStreamInfoIsType_AVI: RMDBGLOG((ENABLE, "type is AVI\n")); RMMemcpy(&m_aviInfo, &(streamInfo->data.aviInfo), sizeof(RMAVIStreamInfo)); if(streamInfo->data.aviInfo.audioSwitched) { m_aviInfo.audioStreamSwitched = streamInfo->data.aviInfo.audioStreamSwitched; RMuint32 displayedStreamNumber = m_aviInfo.audioStreamSwitched + 1; SendMessage(CURACAO_MESSAGE_AUDIOSTREAM_CHANGE, &displayedStreamNumber); } break; default: RMDBGLOG((ENABLE, "unhandled stream type!\n")); break; }; return RM_OK;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -