📄 test_pfs.c
字号:
/* test bench for rmpfs.c functionsto use threads:-include 'librmpthreadw/librmpthreadw.a' to the lib_list in the Makefile-export COMPILKIND += withthreads*/#include <stdio.h>#include <stdlib.h>#include <string.h>#define ALLOW_OS_CODE 1#include <sys/types.h>#include "../samples/common.h"#include "../samples/command_ids.h"#include "rmlocalremote.h"#include "../rmremoteapi/include/rmremoteapi.h"#include "../rmrtk/include/rmrtk.h"/* #### Begin CARDEA code #### */#include "rmupnp/rmlibwmdrmnd/include/ms_cardea.h"/* #### End CARDEA code #### */#ifdef WITH_THREADS#include "../rmlibcw/include/rmthreads.h"#endif#include "mono.h"#if 1#define MONODBG ENABLE#else#define MONODBG DISABLE#endif#define MAX_DIR_RECURSION 8#define ERROR_CLEANUP(i) do { error = (i); goto cleanup; } while(0)// callback for the application to receive dcc contextvoid RMDCCInfo(struct dcc_context *dcc_info){ RMDBGLOG((ENABLE, "got dcc info @ 0x%08lx\n", (RMuint32) dcc_info)); // nothing to do for mono}// callback to pass stream information to the application, DRM protected, number of chapters, etcvoid RMFileStreamInfoCallback(struct RMFileStreamInfo *streamInfo){ // nothing to do for mono RMDBGLOG((ENABLE, "got stream info!\n"));}RM_EXTERN_C_BLOCKSTARTvoid RMremoteResetState(void);RM_EXTERN_C_BLOCKENDstatic struct playback_cmdline play_opt;static struct display_cmdline disp_opt;static struct video_cmdline video_opt;static struct demux_cmdline demux_opt;struct mono_context mono_opt;/* returns TRUE to play the file and FALSE to skip it */static RMascii *filename;RMremoteHandle rh = (RMremoteHandle) NULL;struct dcc_context dcc_info = {0,};RMbool osd_enabled = FALSE;/* this is the EOS callback, must be implemented by curacao */void RMEOSCallback(){ /* mono doesnt do anything */ RMDBGLOG((ENABLE, "RMEOSCallback() called, awaiting a command\n")); RMDBGLOG((ENABLE, "reset remote state to playing\n")); RMremoteResetState(); }static inline enum rfp_application get_app(struct rfp_stream_info *stream_info){ switch(stream_info->system_type){ case RM_SYSTEM_MPEG4: RMDBGLOG((ENABLE, "play_mp4\n")); return APP_MP4; case RM_SYSTEM_ASF: RMDBGLOG((ENABLE, "play_asf\n")); return APP_ASF; case RM_SYSTEM_ELEMENTARY_VIDEO: switch(stream_info->video_type){ case RM_VIDEO_MPEG12: case RM_VIDEO_MPEG4: case RM_VIDEO_H263: case RM_VIDEO_H264: case RM_VIDEO_WMV: case RM_VIDEO_VC1: case RM_VIDEO_DIVX3: case RM_VIDEO_DIVX4: case RM_VIDEO_XVID: case RM_VIDEO_MJPEG: RMDBGLOG((ENABLE, "play_video\n")); return APP_VIDEO; case RM_VIDEO_BMP: case RM_VIDEO_TIFF: case RM_VIDEO_GIF: case RM_VIDEO_PNG: RMDBGLOG((ENABLE, "play_picture\n")); return APP_PICTURE; case RM_VIDEO_JPEG: switch(mono_opt.jpeg_decode){ case mono_decode_soft: return APP_PICTURE; case mono_decode_hard: return APP_VIDEO; case mono_decode_auto: return APP_PICTURE; } case RM_VIDEO_UNKNOWN: RMDBGLOG((ENABLE, "unknwon\n")); break; } break; case RM_SYSTEM_ELEMENTARY_AUDIO: RMDBGLOG((ENABLE, "play_audio\n")); return APP_AUDIO; case RM_SYSTEM_MPEG1: case RM_SYSTEM_MPEG2_TRANSPORT: case RM_SYSTEM_MPEG2_TRANSPORT_192: case RM_SYSTEM_MPEG2_PROGRAM: case RM_SYSTEM_MPEG2_DVD: RMDBGLOG((ENABLE, "play_psfdemux\n")); switch(mono_opt.demux_decode){ case mono_decode_soft: return APP_DEMUX_SOFT; case mono_decode_hard: return APP_DEMUX; case mono_decode_auto: return APP_DEMUX; } break; case RM_SYSTEM_AVI: RMDBGLOG((ENABLE, "play_avi_push\n")); return APP_AVI; case RM_SYSTEM_MPEG2_DVD_AUDIO: case RM_SYSTEM_DIVX_MP3: case RM_SYSTEM_DIVX_AC3: case RM_SYSTEM_DIVX_MPEG1: case RM_SYSTEM_DIVX_PCM: case RM_SYSTEM_DIVX_WMA: case RM_SYSTEM_DIVX_WMV9_MP3: case RM_SYSTEM_DIVX_WMV9_AC3: case RM_SYSTEM_DIVX_WMV9_MPEG1: case RM_SYSTEM_DIVX_WMV9_PCM: case RM_SYSTEM_DIVX3_MP3: case RM_SYSTEM_DIVX3_AC3: case RM_SYSTEM_DIVX3_MPEG1: case RM_SYSTEM_DIVX3_PCM: case RM_SYSTEM_RIFFCDXA: case RM_SYSTEM_ID3: case RM_SYSTEM_UNKNOWN: break; } return NOT_SUPPORTED;}static struct playback_cmdline local_play_opt;static struct display_cmdline local_disp_opt;static struct demux_cmdline local_demux_opt;static struct mono_context local_mono_opt;static struct dcc_context local_dcc_info;static RMstatus play_file_app( struct mono_info *app_params, enum rfp_application app){ RMuint32 i; RMDBGLOG((ENABLE, "instances %lu\n", mono_opt.audio_instances)); app_params->audio_opt[0].audioInstances = mono_opt.audio_instances; /* replicate audio_opt[0] which was filled by rfp_detect to the rest of the audio instances; setup engineID and decoderID accordingly, and restore data lost during replication */ for (i = 1; i < mono_opt.audio_instances; i++) { RMMemcpy(&(app_params->audio_opt[i]), &(app_params->audio_opt[0]), sizeof(struct audio_cmdline)); // we have to restore these settings according to set_audio_options app_params->audio_opt[i].thisAudioInstance = i; app_params->audio_opt[i].audioInstances = mono_opt.audio_instances; //app_params->audio_opt[i].dh_info = &dh_info; // setup engineID and decoderID switch (i) { case 1: // this is the second instance, assign it to engine 1, decoder 0 (the first instance is default engine=0 decoder=0) app_params->audio_opt[i].AudioEngineID = 1; app_params->audio_opt[i].AudioDecoderID = 0; break; case 2: // this is the third instance, assign it to engine 0, decoder 1 app_params->audio_opt[i].AudioEngineID = 0; app_params->audio_opt[i].AudioDecoderID = 1; break; case 3: // this is the fourth instance, assign it to engine 1, decoder 1 app_params->audio_opt[i].AudioEngineID = 1; app_params->audio_opt[i].AudioDecoderID = 1; break; default: fprintf(stderr, "error when replicating %lu audio instances\n", mono_opt.audio_instances); break; } } print_parsed_audio_options(app_params->audio_opt); return rfp_play(app_params, app);}static void show_usage(char *progname){ fprintf(stderr, "MONO OPTIONS\n" "\t-forceSD: SD profile used instead of HD\n" "\t-R: If filename is a directory, play its sub-directories recursively\n" "\t-nogui: don't display the GUI (defaut is yes)\n" "\t-demux <soft|hard|auto>: Set demuxing method (default is auto)\n" "\t-jpeg <soft|hard|auto>: Set jpeg decompression method (default is auto)\n" "\t-cc <tv|soft|608soft|708soft>: Selects the closed caption display mode.\n" "\t-sat: send audio while in trickmode (default is not to send it)\n"); show_playback_options(); show_display_options(); fprintf(stderr, "------------------------------------------------m-0-n-o-----\n"); fprintf(stderr, "Minimum cmd line: %s filename [remote control device (Ex: /dev/ttyS0)] \n", progname); fprintf(stderr, "------------------------------------------------------------\n"); exit(1);}static void parse_cmdline(int argc, char *argv[], struct mono_info *opts){ int i; RMstatus err; // FIXME: temp soln to "internal error--unrecognizable insn" // moved 'app_params.noDolby = FALSE' from main() to here opts->noDolby = FALSE; if (argc < 2) show_usage(argv[0]); i = 1; while ((argc > i)) { /* RMDBGLOG((ENABLE,"Arg %d : %s\n", i, argv[i])); */ err = RM_OK; if (argv[i][0] != '-') { if (filename == NULL) { filename = argv[i]; i++; } else show_usage(argv[0]); } else if ( ! strcmp(argv[i], "-R")) { mono_opt.recurse_dirs = TRUE; i++; } else if ( ! strcmp(argv[i], "-nogui")) { mono_opt.use_gui = FALSE; i++; } else if ( ! strcmp(argv[i], "-use_multiple_audio")) { if (argc > i+1) { RMuint32 instances; RMasciiToUInt32(argv[i+1], &instances); i += 2; if ((instances > MAX_AUDIO_DECODER_INSTANCES) || (instances <= 0)) show_usage(argv[0]); mono_opt.audio_instances = instances; } else show_usage(argv[0]); } else if ( ! strcmp(argv[i], "-demux")) { if (argc > i+1) { if( ! strcmp(argv[i+1], "soft")) { mono_opt.demux_decode = mono_decode_soft; } else if( ! strcmp(argv[i+1], "hard")) { mono_opt.demux_decode = mono_decode_hard; } else if( ! strcmp(argv[i+1], "auto")) { mono_opt.demux_decode = mono_decode_auto; } else{ show_usage(argv[0]); } i+=2; } } else if ( ! strcmp(argv[i], "-jpeg")) { RMDBGLOG((ENABLE, "jpeg, and next is %s\n", argv[i+1])); if (argc > i+1) { if( ! strcmp(argv[i+1], "soft")) { mono_opt.jpeg_decode = mono_decode_soft; } else if( ! strcmp(argv[i+1], "hard")) { mono_opt.jpeg_decode = mono_decode_hard; } else if( ! strcmp(argv[i+1], "auto")) { mono_opt.jpeg_decode = mono_decode_auto; } else{ show_usage(argv[0]); } i+=2; } else{ show_usage(argv[0]); } } else if ( ! strcmp(argv[i], "-sw")) { mono_opt.demux_decode = mono_decode_soft; i++; } else if ( ! strcmp(argv[i], "-forceSD")) { mono_opt.force_sd = TRUE; i++; } else if (! strcmp(argv[i], "-nodolby")) { opts->noDolby = TRUE; i++; } else if ( ! strcmp(argv[i], "-past")) { opts->play_opt->require_video_audio = FALSE; i++; } else if ( ! strcmp(argv[i], "-disk_control")) { /* from bug #4005 comment #18: for disk_ctrl_low_level i assume that i takes about 1 second to resume the harddisk, which gives 16 blocks at a blocksize of 128 kb at 2 mb/s stream. */ opts->play_opt->disk_ctrl_state = DISK_CONTROL_STATE_RUNNING; opts->play_opt->disk_ctrl_low_level = 16; opts->play_opt->prebuf_max = 1024 * 1024; fprintf(stderr, ">> disk control enabled, low level is %lu, prebuf_max is %lu bytes\n", opts->play_opt->disk_ctrl_low_level, opts->play_opt->prebuf_max); i++; } else if ( ! strcmp(argv[i], "-max_mem")) { if (argc > i+1) { RMasciiToUInt32(argv[i+1], &(opts->play_opt->disk_ctrl_max_mem)); opts->play_opt->disk_ctrl_max_mem *= 1024; i += 2; } else show_usage(argv[0]); } else if ( ! strcmp(argv[i], "-max_usable_RUA_mem")) { if (argc > i+1) { RMasciiToUInt32(argv[i+1], &(opts->play_opt->max_usable_RUA_mem)); opts->play_opt->max_usable_RUA_mem *= 1024; i += 2; } else show_usage(argv[0]); } else if ( ! strcmp(argv[i], "-block_size")) { if (argc > i+1) { RMasciiToUInt32(argv[i+1], &(opts->play_opt->disk_ctrl_log2_block_size)); i += 2; } else show_usage(argv[0]); } else if (! strcmp(argv[i], "-cc")) { if (argc > i+1) { if (RMCompareAscii(argv[i+1], "tv")) { mono_opt.display_cc = TRUE; mono_opt.use_soft_cc_decoder = 0; } else if (RMCompareAscii(argv[i+1], "soft") || RMCompareAscii(argv[i+1], "608soft") || RMCompareAscii(argv[i+1], "cc1")) { mono_opt.display_cc = TRUE; mono_opt.use_soft_cc_decoder = 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -