📄 fileplayer.cpp
字号:
/* this is the Subtitle callback */void RMSubtitleCallback(RMuint8 *string, RMuint64 pts, RMbool usePTS){ RMDBGLOG((ENABLE, "Received RMsubtitleCallback!!\n"));}/* returns TRUE to play the file and FALSE to skip it */RMbool RMPlayNonInterleavedAVI(void){ printf("AVI file not interleaved. Do not play it!\n"); return TRUE; // force to play non-interleaved avi because other players do that}#include <stdio.h>#include <stdlib.h>#include <sys/types.h>#include <sys/time.h>#include "samples/command_ids.h"#define REMOTE_CMD_FIFO_SIZE 16static RMcoreQueue remote_cmd_queue = 0;static RMcoreQueue remote_param_queue = 0;#ifdef USE_SAME_THREADstatic RMascii interpret_symbol(RMremoteKey key){ if (context.gui->SendKey(key) == RM_OK && RMGetCountCoreQueue(remote_cmd_queue) > 0){ void *item; RMRemoveFirstCoreQueue(remote_cmd_queue, &item); return (RMascii) (RMuint32) item; } return KEY_CMD_NONE1;}#endif/*void RMTermInit(RMbool block_int){}void RMTermExit(void){}void RMSignalInit(void (*cleanup)(void *param), void *param){}*/RMbool RMKeyAvailable(void){ if (remote_cmd_queue != 0 && RMGetCountCoreQueue (remote_cmd_queue) > 0) return TRUE;#ifdef USE_SAME_THREAD if (g_useKeyboard){ struct timeval tv; fd_set readfds; tv.tv_sec = 0; tv.tv_usec = 0; FD_ZERO(&readfds); FD_SET(STDIN_FILENO, &readfds); return (select(STDIN_FILENO + 1, &readfds, NULL, NULL, &tv) > 0); } else return RMFremoteSymbolAvailable(context.rh);#else return FALSE;#endif}RMascii RMGetKey(void){ RMascii c = KEY_CMD_NONE1; if (remote_cmd_queue != 0 && RMGetCountCoreQueue (remote_cmd_queue) > 0) { void *item; RMRemoveFirstCoreQueue(remote_cmd_queue, &item); c = (RMascii) (RMuint32) item; }#ifdef USE_SAME_THREAD else { RMremoteKey key; if(!g_useKeyboard) key = RMFremoteWaitSymbol(context.rh, context.remoteTimeout); else key = readFromKeyboard(context.remoteTimeout); c = interpret_symbol(key); }#endif if (c != KEY_CMD_NONE1) { RMDBGLOG((MONODBG, "*** RMGetKey: 0x%02x\n", c)); if(c == 0x3d) context.gui->EndWaitCursor(); } //context.gui->EndWaitCursor(); return c;}RMbool RMGetKeyNoWait(RMascii *pKey){ if (remote_cmd_queue != 0 && RMGetCountCoreQueue (remote_cmd_queue) > 0) { void *item; RMRemoveFirstCoreQueue(remote_cmd_queue, &item); *pKey = (RMascii) (RMuint32) item; if (*pKey != KEY_CMD_NONE1) RMDBGLOG((MONODBG, "*** RMGetKeyNoWait: 0x%02x\n", *pKey)); return TRUE; }#ifdef USE_SAME_THREAD else { RMremoteKey key; if(!g_useKeyboard) key = RMFremoteWaitSymbol(context.rh, context.remoteTimeout); else key = readFromKeyboard(context.remoteTimeout); if (key != RM_HW_TIMEOUT) { *pKey = interpret_symbol(key); RMDBGLOG((MONODBG, "*** RMGetKeyNoWait: 0x%02x\n", *pKey)); return TRUE; } else return FALSE; }#endif return FALSE;}/*void RMTermEnableEcho(){}void RMTermDisableEcho(){}*/void RMTermGetUint32(RMuint32 *data){ if (remote_param_queue != 0 && RMGetCountCoreQueue (remote_param_queue) > 0) { void *item; RMRemoveFirstCoreQueue(remote_param_queue, &item); *data = (RMuint32) item; RMDBGLOG((MONODBG, "*** RMTermGetUint32: %li\n", *data)); context.gui->EndWaitCursor(); } return;}#endif // WITH_MONO//#include <stdio.h>//#include <stdlib.h>#include <string.h>#include <sys/mount.h>#include <mntent.h>#include <ctype.h>#include "../rmgfx_library/include/subreader.h"#include "../rmgfx_library/include/gfx_drawlib.h"extern sub_context subs;#if 1#define FILEPLAYERDBG ENABLE#else#define FILEPLAYERDBG DISABLE#endif#define MONODBG ENABLERMfilePlayer::RMfilePlayer(typeCuracaoContext *context) : RMmediaPlayerIface(context, FILE_PLAYER),#ifndef WITH_MONO m_ctrl_file(0), m_fileOpen(FALSE), m_prefix((RMascii*)NULL),#endif m_eos(FALSE), m_initialized(TRUE){// int res; m_streamType = RMStreamInfoIsType_Unknown; m_audioStream = 1; m_subpictureStream = 1; m_detector = RMFDetectorCreate(); init_subs();// if (context->disc != NULL) {// RMDBGLOG((FILEPLAYERDBG, "Mount device %s on %s\n", context->device, MOUNT_POINT));// res = mount((const char *)context->device, (const char *)MOUNT_POINT, "udf", 0xC0ED0000 | MS_NOSUID | MS_RDONLY, "");// if(res != 0)// res = mount((const char *)context->device, (const char *)MOUNT_POINT, "iso9660", 0xC0ED0000 | MS_NOSUID | MS_RDONLY, "");// if(res != 0) {// RMDBGLOG((FILEPLAYERDBG, "Cannot mount %s on %s\n", context->device, MOUNT_POINT));// perror("mount");// }// else// RMDBGLOG((FILEPLAYERDBG, "Succeeded\n"));// }#ifdef WITH_MONO if (remote_cmd_queue == 0) remote_cmd_queue = RMCreateCoreQueue(REMOTE_CMD_FIFO_SIZE); if (remote_param_queue == 0) remote_param_queue = RMCreateCoreQueue(REMOTE_CMD_FIFO_SIZE);#endif m_about_to_play = FALSE; m_stop_pending = FALSE; osd_subt.pSPU_double_buffer_source = NULL;}RMfilePlayer::~RMfilePlayer(){#ifndef WITH_MONO if(m_fileOpen){ RMFStopFile(m_ctrl_file); SetState(STATE_STOP, 0); }#else if (remote_cmd_queue){ RMDeleteCoreQueue(remote_cmd_queue); remote_cmd_queue = 0; } if (remote_param_queue){ RMDeleteCoreQueue(remote_param_queue); remote_param_queue = 0; }#endif Close(); clear_subs();// context.decoder->Close(); RMDBGLOG((FILEPLAYERDBG, "Umount file system ...\n"));// if (m_context->disc != NULL) {// if(umount((const char *)MOUNT_POINT) != 0) {// RMDBGLOG((FILEPLAYERDBG, "Cannot umount %s\n", MOUNT_POINT));// perror("umount");// }// else// RMDBGLOG((FILEPLAYERDBG, "Succeeded\n"));// } RMFDetectorDestruct(m_detector);}RMstatus RMfilePlayer::Reset(){ return RM_ERROR;}RMstatus RMfilePlayer::InterpretCommand(RMremoteKey c, void *val){ RMstatus status = RM_ERROR; typeMediaPlayerSate state = GetState(); if(!context.gui->BlockedKEY()) { if(m_initialized && state != STATE_CLOSE) { status = RM_OK; switch(c) { case RM_HW_SELECT: case RM_HW_PLAY_PAUSE: // play/pause transition if(context.gui->IsTv()) break; if (state != STATE_PLAY) { m_speed = 0; status = RMInsertLastCoreQueue(remote_cmd_queue, (void *) KEY_CMD_PLAY); if(status != RM_OK) break; SetState(STATE_PLAY, 0); } else { status = RMInsertLastCoreQueue(remote_cmd_queue, (void *) KEY_CMD_PAUSE); if(status != RM_OK) break; SetState(STATE_PAUSE, 0); } break; case RM_HW_PAUSE_PLAY: // pause/play transition if(context.gui->IsTv()) break; if (state == STATE_PAUSE || state == STATE_STEP) { status = RMInsertLastCoreQueue(remote_cmd_queue, (void *) KEY_CMD_NEXT_PICTURE); if(status != RM_OK) break; SetState(STATE_STEP, 0); } else {// if (state != STATE_PLAY)// RMInsertLastCoreQueue(remote_cmd_queue, (void *) KEY_CMD_PLAY); status = RMInsertLastCoreQueue(remote_cmd_queue, (void *) KEY_CMD_PAUSE); if(status != RM_OK) break; SetState(STATE_PAUSE, 0); } break; case RM_HW_STOP: case RM_HW_RETURN: case RM_HW_SC1: case RM_HW_SC2: case RM_HW_SC3: case RM_HW_SC4: case RM_HW_SC5: case RM_HW_SC6: case RM_HW_SC7: case RM_HW_SC8: if (state == STATE_STOP) status = RM_ERROR; else { status = RMInsertLastCoreQueue(remote_cmd_queue, (void *) KEY_CMD_QUIT); if(status != RM_OK) break; SetState(STATE_STOP, 0); } break; case RM_HW_RIGHT: case RM_HW_FAST_FORWARD: { if(context.gui->IsTv()) break; RMint32 speed = 8; context.gui->BeginWaitCursor(); if (state == STATE_FAST_FORWARD) { speed = m_speed * 2; if (speed > 32) speed = 8; } else { if (state == STATE_PAUSE || state == STATE_STEP) { status = RMInsertLastCoreQueue(remote_cmd_queue, (void *) KEY_CMD_PLAY); if(status != RM_OK) break; } status = RMInsertLastCoreQueue(remote_cmd_queue, (void *) KEY_CMD_IFRAME_FWD); if(status != RM_OK) break; } m_speed = speed; speed *= 256; status = RMInsertLastCoreQueue(remote_cmd_queue, (void *) KEY_CMD_SPEED_FACTOR); if(status != RM_OK) break; status = RMInsertLastCoreQueue(remote_param_queue, (void *) speed); if(status != RM_OK) break; SetState(STATE_FAST_FORWARD, &m_speed); break; } case RM_HW_LEFT: case RM_HW_FAST_REWIND: { if(context.gui->IsTv()) break; RMint32 speed = 8; context.gui->BeginWaitCursor(); if (state == STATE_FAST_REWIND) { speed = m_speed * 2; if (speed > 32) speed = 8; } else { if (state == STATE_PAUSE || state == STATE_STEP) { status = RMInsertLastCoreQueue(remote_cmd_queue, (void *) KEY_CMD_PLAY); if(status != RM_OK) break; } status = RMInsertLastCoreQueue(remote_cmd_queue, (void *) KEY_CMD_IFRAME_BWD); if(status != RM_OK) break; } m_speed = speed; speed *= -256; status = RMInsertLastCoreQueue(remote_cmd_queue, (void *) KEY_CMD_SPEED_FACTOR); if(status != RM_OK) break; status = RMInsertLastCoreQueue(remote_param_queue, (void *) speed); if(status != RM_OK) break; SetState(STATE_FAST_REWIND, &m_speed); break; } case RM_HW_SLOW_FORWARD: { RMint32 speed = 2; context.gui->BeginWaitCursor(); if (state == STATE_SLOW_FORWARD) { speed = m_speed * 2; if (speed > 8) speed = 2; } m_speed = speed; speed = 256 / speed; status = RMInsertLastCoreQueue(remote_cmd_queue, (void *) KEY_CMD_SPEED_FACTOR); if(status != RM_OK) break; status = RMInsertLastCoreQueue(remote_param_queue, (void *) speed); if(status != RM_OK) break; SetState(STATE_SLOW_FORWARD, &m_speed); break; } case RM_HW_SEARCH: { RMuint32 time = 0; if (val) time = *(RMuint32*)val; status = RMInsertLastCoreQueue(remote_cmd_queue, (void *) KEY_CMD_SEEK); if(status != RM_OK) break; status = RMInsertLastCoreQueue(remote_param_queue, (void *) time); if(status != RM_OK) break; SetState(STATE_PLAY, 0); break; } case RM_HW_LANGUAGE:{ RMuint32 nbAudioStreams = 1; RMuint32 selectedAudioStream; RMuint32 audioStream; if(m_streamType == RMStreamInfoIsType_MPEG4){ if(m_mp4Info.audioStreams > 1){ m_audioStream = (m_audioStream < m_mp4Info.audioStreams ? m_audioStream + 1 : 1); status = RMInsertLastCoreQueue(remote_cmd_queue, (void *) KEY_CMD_CYCLE_AUDIO); if(status != RM_OK) break; SendMessage(CURACAO_MESSAGE_AUDIOSTREAM_CHANGE, &m_audioStream);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -