📄 process_key.c
字号:
if (dcc_info->pStcSource) { DCCSTCStop(dcc_info->pStcSource); } dcc_info->state = RM_STOPPED; dcc_info->trickmode_id = RM_NO_TRICKMODE; *cmd = (key==KEY_CMD_STOP) ? RM_STOP : RM_STOP_SEEK_ZERO; break; case KEY_CMD_SLOW_FWD: if (dcc_info->trick_supported) { if ((dcc_info->state != RM_PLAYING) && (dcc_info->state != RM_PLAYING_TRICKMODE)) { fprintf(stderr, "Enter Play state first...\n"); break; } if (((dcc_info->pVideoSource) || (dcc_info->pAudioSource)) && (dcc_info->pStcSource)) { RMint32 N; RMuint32 M, positiveN; DCCSTCGetSpeed(dcc_info->pStcSource, &N, &M); if ((N == 0) || (M == 0)) { N = 1; M = 1; } positiveN = (N<0) ? (RMuint32) (-N) : (RMuint32) N; positiveN = 3*positiveN; M = 4*M; PGCD((RMint32 *)&positiveN, &M); if ((positiveN >= M) && (positiveN > MAX_SPEED)) { RMuint32 f = (positiveN + MAX_SPEED - 1) / MAX_SPEED; M = RMmax(1, M/f); positiveN = MAX_SPEED; } else if (M > MAX_SPEED) { RMuint32 f = (M + MAX_SPEED - 1) / MAX_SPEED; positiveN = RMmax(1, positiveN/f); M = MAX_SPEED; } N = (N<0) ? (RMint32) -positiveN : (RMint32) positiveN; DCCSTCSetSpeed(dcc_info->pStcSource, N, M); fprintf(stderr, "Slow forward %ld/%ld...\n", N, M); } if (dcc_info->pAudioSource) { err = DCCStopAudioSource(dcc_info->pAudioSource); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Error stopping audio source %d\n", err)); return err; } } dcc_info->state = RM_PLAYING_TRICKMODE; dcc_info->trickmode_id = RM_TRICKMODE_SLOW_FWD; } else { fprintf(stderr, "trickmodes not supported\n"); } *cmd = RM_PLAY; break; case KEY_CMD_FAST_FWD: if (dcc_info->trick_supported) { if ((dcc_info->state != RM_PLAYING) && (dcc_info->state != RM_PLAYING_TRICKMODE)) { fprintf(stderr, "Enter Play state first...\n"); break; } if (((dcc_info->pVideoSource) || (dcc_info->pAudioSource)) && (dcc_info->pStcSource)) { RMint32 N; RMuint32 M, positiveN; DCCSTCGetSpeed(dcc_info->pStcSource, &N, &M); if ((N == 0) || (M == 0)) { N = 1; M = 1; } positiveN = (N<0) ? (RMuint32) (-N) : (RMuint32) N; positiveN = 4*positiveN; M = 3*M; PGCD((RMint32 *)&positiveN, &M); if ((positiveN >= M) && (positiveN > MAX_SPEED)) { RMuint32 f = (positiveN + MAX_SPEED - 1) / MAX_SPEED; M = RMmax(1, M/f); positiveN = MAX_SPEED; } else if (M > MAX_SPEED) { RMuint32 f = (M + MAX_SPEED - 1) / MAX_SPEED; positiveN = RMmax(1, positiveN/f); M = MAX_SPEED; } N = (N<0) ? (RMint32) -positiveN : (RMint32) positiveN; DCCSTCSetSpeed(dcc_info->pStcSource, N, M); fprintf(stderr, "Fast forward %ld/%ld...\n", N, M); } if (dcc_info->pAudioSource) { err = DCCStopAudioSource(dcc_info->pAudioSource); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Error stopping audio source %d\n", err)); return err; } } if (dcc_info->state != RM_PLAYING_TRICKMODE) { dcc_info->state = RM_PLAYING_TRICKMODE; dcc_info->trickmode_id = RM_TRICKMODE_FAST_FWD; } } else { fprintf(stderr, "trickmodes not supported\n"); } *cmd = RM_PLAY; break; case KEY_CMD_SPEED_FACTOR: if ((dcc_info->state != RM_PLAYING) && (dcc_info->state != RM_PLAYING_TRICKMODE)) { fprintf(stderr, "Enter Play state first...\n"); break; } if ((dcc_info->pVideoSource) && (dcc_info->pStcSource)) { RMint32 N, speed; RMuint32 M; RMint32 direction; fprintf(stderr, "Speed factor [1/256] : "); RMTermGetUint32((RMuint32 *) &speed); direction = (speed > 0) ? 1 : -1; speed *= direction; if (speed >= 256) { M = 1; N = (speed * direction) / 256; } else { N = direction; M = 256 / speed; } DCCSTCSetSpeed(dcc_info->pStcSource, N, M); fprintf(stderr, "Fast forward %ld/%ld...\n", N, M); } if (dcc_info->pAudioSource) { err = DCCStopAudioSource(dcc_info->pAudioSource); if (RMFAILED(err)) { RMDBGLOG((ENABLE, "Error stopping audio source %d\n", err)); return err; } } if (dcc_info->state != RM_PLAYING_TRICKMODE) { dcc_info->state = RM_PLAYING_TRICKMODE; dcc_info->trickmode_id = RM_TRICKMODE_FAST_FWD; } *cmd = RM_PLAY; break; case KEY_CMD_IFRAME_FWD: if (dcc_info->iframe_supported) { if ((dcc_info->state != RM_PLAYING) && (dcc_info->state != RM_PLAYING_TRICKMODE)) { fprintf(stderr, "Enter Play state first...\n"); break; } fprintf(stderr, "Forward I-Frame mode. Use + to set the speed...\n"); dcc_info->state = RM_PLAYING_TRICKMODE; dcc_info->trickmode_id = RM_TRICKMODE_FWD_IFRAME; *cmd = RM_PLAY; } else { fprintf(stderr, "iframe mode not supported...\n"); } break; case KEY_CMD_IFRAME_BWD: if (dcc_info->iframe_supported) { if ((dcc_info->state != RM_PLAYING) && (dcc_info->state != RM_PLAYING_TRICKMODE)) { fprintf(stderr, "Enter Play state first...\n"); break; } fprintf(stderr, "Backward I-Frame mode. Use + to set the speed...\n"); dcc_info->state = RM_PLAYING_TRICKMODE; dcc_info->trickmode_id = RM_TRICKMODE_RWD_IFRAME; *cmd = RM_PLAY; } else { fprintf(stderr, "iframe mode not supported...\n"); } break; case KEY_CMD_SEEK: if (dcc_info->seek_supported) { fprintf(stderr, "Seeking ...\n"); fprintf(stderr, "Seek time (s) : "); RMTermGetUint32(&(dcc_info->seek_time)); dcc_info->state = RM_PLAYING; dcc_info->trickmode_id = RM_NO_TRICKMODE; if (dcc_info->pStcSource) DCCSTCSetSpeed(dcc_info->pStcSource, 1, 1); } else { fprintf(stderr, "Seeking not supported ...\n"); } *cmd = RM_SEEK; break; default: processed = FALSE; } } if (processed == TRUE) goto out_key; if (keyflags & SET_KEY_AUDIO) { processed = TRUE; switch (key) { case KEY_CMD_DUALMODE_AUDIO: *cmd = RM_DUALMODE_CHANGE; break; case KEY_CMD_VOLUME_PLUS: case KEY_CMD_VOLUME_MINUS: {#if 0 // Method to build the volume table. Volume = VOLUME_0DB * 2^(Gain/6), where Gain is expressed in dB.#define CTN216_M 1122462048 // 2^(1/6) = 1.12246204830937298...#define CTN216_N 1000000000 VolumeTable[VOLUME_INDEX_0DB] = VOLUME_0DB; for ( dcc_info->volume = VOLUME_INDEX_0DB; dcc_info->volume >= 0; dcc_info->volume-- ) { VolumeTable[dcc_info->volume-1] = (((RMuint64)VolumeTable[dcc_info->volume] * CTN216_N + CTN216_M/2)/ CTN216_M); } for ( dcc_info->volume = VOLUME_INDEX_0DB; dcc_info->volume < sizeof(VolumeTable)/sizeof(RMuint32); dcc_info->volume_index++ ) { VolumeTable[dcc_info->volume_index+1] = (((RMuint64)VolumeTable[dcc_info->volume_index] * CTN216_M + CTN216_N/2)/ CTN216_N); } for ( dcc_info->volume_index = 0; dcc_info->volume_index < sizeof(VolumeTable)/sizeof(RMuint32); dcc_info->volume_index++ ) { fprintf(stdout, "0x%08lx, // %2lddB\n", VolumeTable[dcc_info->volume_index], dcc_info->volume_index-VOLUME_INDEX_0DB); };#endif if ((key == KEY_CMD_VOLUME_PLUS) && (dcc_info->volume_index < 24)) dcc_info->volume_index++; else if ((key == KEY_CMD_VOLUME_MINUS) && (dcc_info->volume_index > -VOLUME_INDEX_0DB)) dcc_info->volume_index--; fprintf(stderr, "[0]Now volume is %ld dB = 0x%lx \n", dcc_info->volume_index, VolumeTable[VOLUME_INDEX_0DB+dcc_info->volume_index] ); err = DCCSetAudioSourceVolume(dcc_info->pAudioSource, VolumeTable[VOLUME_INDEX_0DB+dcc_info->volume_index]); { RMuint32 volume; err = DCCGetAudioSourceVolume(dcc_info->pAudioSource, &volume); if (err == RM_OK) RMDBGLOG((ENABLE, "volume for all channels is = 0x%lx \n", volume)); else fprintf(stderr, "error getting volume\n"); } } break; case KEY_CMD_VOLUME_MUTE: { RMuint32 vol; dcc_info->mute = !dcc_info->mute; vol = (dcc_info->mute) ? 0 : VolumeTable[VOLUME_INDEX_0DB+dcc_info->volume_index]; err = DCCSetAudioSourceVolume(dcc_info->pAudioSource, vol); } break; case KEY_CMD_SPEED_UP: case KEY_CMD_SPEED_DOWN: { if (key == KEY_CMD_SPEED_UP) ppm++; else ppm--; DCCSTCSetSpeedCleanDiv(dcc_info->pStcSource, 1000000 + ppm, 1000000); } break; default: processed = FALSE; } } if (processed == TRUE) goto out_key; if ((keyflags & SET_KEY_DISPLAY) && (dcc_info->disp_info != NULL) ) { processed = TRUE; switch (key) { case KEY_CMD_DAC_ON_OFF: { RMstatus err; static RMbool dac_on_off = TRUE; dac_on_off = !dac_on_off; while ((err = RUASetProperty(dcc_info->pRUA, DispDigitalOut, RMGenericPropertyID_Enable, &dac_on_off, sizeof(dac_on_off), 0)) == RM_PENDING); while ((err = RUASetProperty(dcc_info->pRUA, DispMainAnalogOut, RMGenericPropertyID_Enable, &dac_on_off, sizeof(dac_on_off), 0)) == RM_PENDING); while ((err = RUASetProperty(dcc_info->pRUA, DispComponentOut, RMGenericPropertyID_Enable, &dac_on_off, sizeof(dac_on_off), 0)) == RM_PENDING); while ((err = RUASetProperty(dcc_info->pRUA, DispCompositeOut, RMGenericPropertyID_Enable, &dac_on_off, sizeof(dac_on_off), 0)) == RM_PENDING); while ((err = RUASetProperty(dcc_info->pRUA, DispDigitalOut, RMGenericPropertyID_Validate, NULL, 0, 0)) == RM_PENDING); while ((err = RUASetProperty(dcc_info->pRUA, DispMainAnalogOut, RMGenericPropertyID_Validate, NULL, 0, 0)) == RM_PENDING); while ((err = RUASetProperty(dcc_info->pRUA, DispComponentOut, RMGenericPropertyID_Validate, NULL, 0, 0)) == RM_PENDING); while ((err = RUASetProperty(dcc_info->pRUA, DispCompositeOut, RMGenericPropertyID_Validate, NULL, 0, 0)) == RM_PENDING); } break; case KEY_CMD_CONTRAST_PLUS: case KEY_CMD_CONTRAST_MINUS: if ((key == KEY_CMD_CONTRAST_PLUS) && (dcc_info->disp_info->contrast < 240)) dcc_info->disp_info->contrast += 16; else if ((key == KEY_CMD_CONTRAST_MINUS) && (dcc_info->disp_info->contrast > 15)) dcc_info->disp_info->contrast -= 16; fprintf(stderr, "Now contrast is %hu\n", dcc_info->disp_info->contrast); while ((err = RUASetProperty(dcc_info->pRUA, DispDigitalOut, RMGenericPropertyID_Contrast, &(dcc_info->disp_info->contrast), sizeof(dcc_info->disp_info->contrast), 0)) == RM_PENDING); if (RMFAILED(err)) RMDBGLOG((ENABLE, "Cannot set the contrast on the Digital output\n")); while ((err = RUASetProperty(dcc_info->pRUA, DispMainAnalogOut, RMGenericPropertyID_Contrast, &(dcc_info->disp_info->contrast), sizeof(dcc_info->disp_info->contrast), 0)) == RM_PENDING); if (RMFAILED(err)) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -