?? fileplayer.cpp
字號:
break; } } else if(m_streamType == RMStreamInfoIsType_AVI) { if(m_aviInfo.audioStreams > 1) { status = RMInsertLastCoreQueue(remote_cmd_queue, (void *) KEY_CMD_CYCLE_AUDIO); if(status != RM_OK) break; break; } } asf_get_audio_stream_count(&nbAudioStreams); RMDBGLOG((ENABLE, "number of streams %d, want to switch to %ld\n", nbAudioStreams, *(RMuint32*)val)); // get current asf_get_current_audio_stream(&selectedAudioStream); RMDBGLOG((ENABLE, "current stream %d\n", selectedAudioStream)); if(nbAudioStreams > 1){ if(val != NULL){ audioStream = *(RMuint32*)val; if(audioStream >= (RMuint32)nbAudioStreams){ return RM_ERROR; } else{ // set next audioStream = (selectedAudioStream == nbAudioStreams ? 1 : (selectedAudioStream + 1)); } RMDBGLOG((ENABLE, "Switching audio stream %lu -> %lu\n", selectedAudioStream, audioStream)); status = RMInsertLastCoreQueue(remote_cmd_queue, (void *) KEY_CMD_CHANGE_AUDIO); if(status != RM_OK) break; status = RMInsertLastCoreQueue(remote_param_queue, (void *) audioStream); if(status != RM_OK) break; SendMessage(CURACAO_MESSAGE_AUDIOSTREAM_CHANGE, &audioStream); } } else{ RMDBGLOG((ENABLE, "Cannot switch audio stream : only one audio stream.\n")); } break; } case RM_HW_NEXT_TRACK: if(m_streamType == RMStreamInfoIsType_MPEG4) { if(m_mp4Info.isNero) { status = RMInsertLastCoreQueue(remote_cmd_queue, (void *) KEY_CMD_NERO_NEXT_CHAPTER); if(status != RM_OK) break; } } break; case RM_HW_PREV_TRACK: if(m_streamType == RMStreamInfoIsType_MPEG4) { if(m_mp4Info.isNero) { status = RMInsertLastCoreQueue(remote_cmd_queue, (void *) KEY_CMD_NERO_PREV_CHAPTER); if(status != RM_OK) break; } } break; case RM_HW_SUB_TITLE: if(m_streamType == RMStreamInfoIsType_MPEG4) { // check here if memory is available for the spu as well if(m_mp4Info.spuStreams >= 1 && osd_subt.pSPU_double_buffer_source) { m_subpictureStream = (m_subpictureStream < m_mp4Info.spuStreams ? m_subpictureStream + 1 : 0); status = RMInsertLastCoreQueue(remote_cmd_queue, (void *) KEY_CMD_NERO_CYCLE_SUBTITLE); if(status != RM_OK) break; SendMessage(CURACAO_MESSAGE_SUBTITLESTREAM_CHANGE, &m_subpictureStream); break; } } break; default: status = RM_ERROR; break; } } } else status = RM_OK; return status;}void* SubtThreadEntry(void *p){ RMfilePlayer * fileplayer = (RMfilePlayer *)p; struct RUA *pRua = context.gui->m_pRua;//(RUA*) context.decoder->GetRUAInstance(); timespec time;// RMuint64 n = 0;// RMuint16 m = 0;// while(fileplayer typeMediaPlayerSate state;// state = context.player->GetState(); time.tv_sec = (RMuint32)0; time.tv_nsec = ((RMuint32)1000 % 1000000) * 1000;// time.tv_sec = 1;// time.tv_nsec = 1000 000 000; printf("enter\n"); printf("use time :%d\n", (RMuint16) subs.data->sub_uses_time); while(1){ nanosleep(&time, NULL); state = context.player->GetState(); if((state == STATE_PLAY) || (state == STATE_STEP) || (state == STATE_PAUSE) || (state == STATE_FAST_FORWARD) || (state == STATE_FAST_REWIND) || (state == STATE_SLOW_FORWARD)) { if(state == STATE_PAUSE || subs.osd == TRUE) continue; else if(((RMem86xxDecoder*)(context.decoder))->m_pStcSource && fileplayer) { RMuint64 timeframe; RMuint32 tir; RMstatus status; status = DCCSTCGetTimeResolution(((RMem86xxDecoder*)(context.decoder))->m_pStcSource, DCC_Video, &tir); if(status == RM_OK) status = DCCSTCGetTime(((RMem86xxDecoder*)(context.decoder))->m_pStcSource, &timeframe, tir); else continue; // = context.decoder->GetTimeDisplayedFrame(fileplayer->m_sampletype, &timeframe); if(RMSUCCEEDED(status)) { if(tir != 0 ){ if(subs.data->sub_uses_time) timeframe *= 100; subtitle* old = subs.vo_sub; if(subs.data->sub_uses_time) { // printf("time: %lu\n", (RMuint32) (timeframe/tir)); find_sub(subs.data, (RMint32) (timeframe /tir)); } else { //ugly hack but should work if(tir == 24000) find_sub(subs.data, (RMint32) (timeframe / 1001)); else find_sub(subs.data, (RMint32) (timeframe / 1000)); } if((state == STATE_FAST_FORWARD) || (state == STATE_FAST_REWIND) || (state == STATE_SLOW_FORWARD)) { find_sub(subs.data, (RMint32) (-1)); DrawSubtitles(pRua); } else if(old != subs.vo_sub) { DrawSubtitles(pRua); } } } } else continue; } else { find_sub(subs.data, (RMint32) (-1)); DrawSubtitles(pRua); if(subs.data) { sub_free(subs.data); subs.data = NULL; } printf("endplay\n"); break; } } printf("leave\n"); return NULL;}void* PlaybackThreadEntry(void* p){#ifndef USE_SAME_THREAD {// struct timespec usleep_req = { 0, 100000000 };// nanosleep(&usleep_req, 0); }#endif timespec usleep_req = { 2, 0 }; RMstatus err; struct mono_info app_params; struct player_options player_conf; RMuint8 channels; enum OutputSpdif_type mode; RMfilePlayer * fileplayer = (RMfilePlayer *)p; usleep_req.tv_sec = (RMuint32)0; usleep_req.tv_nsec = ((RMuint32)100000 % 1000000) * 1000; app_params.pRUA = (RUA *) context.decoder->GetRUAInstance(); app_params.pDCC = (DCC *) context.decoder->GetDCCInstance(); app_params.play_opt = &play_opt; app_params.video_opt = &video_opt; app_params.audio_opt = &audio_opt; app_params.demux_opt = &demux_opt; app_params.video_scaler = 0; app_params.osd_scaler = 0; player_conf.forceSD = FALSE;#ifdef WITH_DALLAS_DEMUX // dallas demux has problems playing mpeg files player_conf.use_hwdemux = FALSE;#else player_conf.use_hwdemux = TRUE;#endif player_conf.use_avi_push = TRUE; context.decoder->GetAudioOutputChannels(&channels); // set wanted audio channels for some formats -- will be ignored if not applicable audio_opt.WmaParams.OutputChannels = (channels == 6 ? Wmapro_6 : Wmapro_2); audio_opt.Ac3Params.OutputLfe = (channels == 6 ? TRUE : FALSE); audio_opt.Ac3Params.OutputChannels = (channels == 6 ? Ac3_LCRLsRs : Ac3_LR);// audio_opt.AACParams.OutputChannels = (channels == 6 ? Aac_LCRLsRs : Aac_LR); app_params.audio_opt->OutputChannels = (channels == 6 ? Audio_Out_Ch_LCRLsRs : Audio_Out_Ch_LR); app_params.audio_opt->OutputChannelsExplicitAssign = TRUE; RMDBGLOG((ENABLE, "Output Channels %s\n", channels == 6 ? "5.1" : "2")); play_opt.video_delay_ms = 1000; play_opt.audio_delay_ms = 1000; if(context.gui->IsTv()) { play_opt.start_ms = 1; //false set for delay this is sign to double MPEG TS check } else { play_opt.start_ms = 0; } video_opt.fifo_size = 4096 * 1024; audio_opt.fifo_size = 4096 * 1024; // set wanted spdif mode context.decoder->GetSpdifMode(&mode); audio_opt.Spdif = mode; // init stream info fileplayer->SetStreamInfo(NULL);// context.gui->BeginWaitCursor(); start_leak(); err = play_file(&app_params, &player_conf);// context.gui->EndWaitCursor(); printf("waiting for release of lock\n"); if(RMFAILED(err)){ RMDBGLOG((ENABLE, "Could not play file %d\n", err)); sleep(2);//#ifdef __ERRHANDLE fileplayer->FlagDiscError();//#endif } ((RMem86xxDecoder *) context.decoder)->ResetDCCLeaveDisplay(); context.decoder->ResetDCCInfo(); //end_leak(); fileplayer->SetEOS(); if(g_subthread) { struct timespec usleep_req = { 0, 100000000 }; RMWaitForThreadToFinish(g_subthread); nanosleep(&usleep_req, 0); g_subthread = NULL; }// end_leak((void*)"rmmmimplementation"); return NULL;}//#ifdef __ERRHANDLEvoid RMfilePlayer::FlagDiscError() { SendMessage(CURACAO_MESSAGE_FILE_ERROR, NULL);}//#endifRMstatus RMfilePlayer::Open(RMascii *name){ RMstatus status = RM_ERROR;// RMascii filename[512];// RMascii** files; m_eos = FALSE; if(!m_initialized){ RMDBGLOG((FILEPLAYERDBG, "Open() : Already open or not initialized\n")); return RM_ERROR; } init_playback_options(&play_opt); init_video_options(&video_opt); init_audio_options(&audio_opt); static RMascii path[1024]; RMCopyAscii(path, name); play_opt.filename = path; RMDBGLOG((FILEPLAYERDBG, "About to Play %s\n", play_opt.filename)); m_stop_pending = FALSE; m_about_to_play = TRUE; RMASSERT(g_thread == NULL); g_thread = RMCreateThread("PlaybackThread", PlaybackThreadEntry, this); if(g_thread == NULL) return RM_ERROR;// fileplayer->SetSampleType();// if(fileplayer->m_sampletype == VIDEO_SAMPLE) { timespec time;// RMuint32 picture_rate = 0;// RUAGetProperty(context.decoder->GetRUAInstance(), ((RMem86xxDecoder*)(context.decoder))->m_video_decoder, RMVideoDecoderPropertyID_FrameRate, &picture_rate, sizeof(RMuint32)); time.tv_sec = (RMuint32)300000 / 1000000; time.tv_nsec = ((RMuint32)300000 % 1000000) * 1000; nanosleep(&time, NULL); RMuint32 tir = 0; if(((RMem86xxDecoder*)(context.decoder))->m_pStcSource) status = DCCSTCGetTimeResolution(((RMem86xxDecoder*)(context.decoder))->m_pStcSource, DCC_Video, &tir); if(tir && RMSUCCEEDED(status)) { printf("SUBTITLE TIME %lu\n", tir); //files = sub_filenames(path, path); //printf("SUBTITLE FILE %s\n", files[0]); if(subs.subs_path) { tir /= 1000; subs.data = sub_read_file(subs.subs_path, tir); if(subs.data){ printf("SUBTITLE FILE %p %lu\n", subs.data, subs.data->sub_num); RMASSERT(g_subthread == NULL); g_subthread = RMCreateThread("SubThread", SubtThreadEntry, this); // if(g_subthread == NULL) // return RM_ERROR; }// int i = 0;// do// {// RFREE(files[i]);// files[i] = NULL;// }while(files[++i] != 0); }// RFREE(files); } } status = RM_OK; return status;}void RMfilePlayer::SetEOS(){ printf("set eos\n"); m_eos = TRUE; m_about_to_play = FALSE; m_stop_pending = FALSE;}void RMfilePlayer::SetSampleType(){ RMuint64 time; // attempt to use audio sample otherwise video sample m_sampletype = VIDEO_SAMPLE; if(RMFAILED(m_context->decoder->GetTimeDisplayedFrame(m_sampletype, &time))) m_sampletype = AUDIO_SAMPLE;}RMstatus RMfilePlayer::Close(){ return Close(FALSE);}RMstatus RMfilePlayer::Close(RMbool playNextFile){ RMstatus status = RM_OK;#ifndef WITH_MONO if(!m_initialized || !m_fileOpen){ RMDBGLOG((FILEPLAYERDBG, "Close() : Not open or not initialized\n")); return RM_ERROR; } if(GetState() != STATE_STOP) { status = RMFStopFile(m_ctrl_file); if(status == RM_OK) SetState(STATE_STOP, 0); } status = m_context->decoder->Close(); m_fileOpen = FALSE;#else // WITH_MONO if(GetState() == STATE_CLOSE) { RMDBGLOG((FILEPLAYERDBG, "Close() : Not open\n")); // happens when user stops before the file actually gets played if(m_about_to_play) { m_about_to_play = FALSE; m_stop_pending = TRUE; } if(m_stop_pending) { return RM_ERROR_QUEUE_COMMAND; } else return RM_OK; } if(GetState() != STATE_STOP) { status = InterpretCommand(RM_HW_STOP, NULL); if(status != RM_OK) { return RM_ERROR_QUEUE_COMMAND; } }#ifndef USE_SAME_THREAD if (g_thread) { RMWaitForThreadToFinish(g_thread); g_thread = NULL; }#endif if (osd_subt.pSPU_double_buffer_source) { RMDBGLOG((ENABLE, "close doubleBufferOSD\n")); status = RMCloseSPU(); if (RMFAILED(status)) { RMDBGLOG((ENABLE, "Cannot close SPU doubleBuffer source %d\n", status)); } }#endif // WITH_MONO m_stop_pending = FALSE; RMDBGLOG((FILEPLAYERDBG, "Closing fileplayer\n")); printf("alabala\n"); SetState(STATE_CLOSE, (void*) &playNextFile); printf("alabala\n"); RMDBGLOG((FILEPLAYERDBG, "Fileplayer closed\n")); m_eos = FALSE; return status;}void RMfilePlayer::ProcessData(){#ifndef WITH_MONO if(m_eos){ RMbool playNextFile = TRUE; //m_context->gui->SendKey(RM_HW_STOP); InterpretCommand(RM_HW_STOP, (void*)&playNextFile); m_eos = FALSE; }// RMDBGLOG((ENABLE, "In process data (to = %lu)\n", m_context->remoteTimeout));#else if(m_eos){ printf("EOS\n");
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -