diff options
Diffstat (limited to 'fmb_player_apl/src/scr/Screen.c')
-rw-r--r-- | fmb_player_apl/src/scr/Screen.c | 1361 |
1 files changed, 1361 insertions, 0 deletions
diff --git a/fmb_player_apl/src/scr/Screen.c b/fmb_player_apl/src/scr/Screen.c new file mode 100644 index 0000000..d918dc5 --- /dev/null +++ b/fmb_player_apl/src/scr/Screen.c @@ -0,0 +1,1361 @@ +/** +* @brief The function of the Screen collection module and the screen module is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <stdarg.h> +#include <termios.h> + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + + +//Local, static variable +static struct ScreenCollection _screens; +static BOOL _isEnable = FALSE; + +//The input buffer of Stdin is cleared. +static void FlushStdin(void); + +//It changes to the next screen. +static BOOL ChangeNextScreen(void); + +//The specified buffer is dumping edited. +static void LogKeyBuff(const char *keyBuff, size_t len); + +static enum FMBRequestEnum ClrAllLastRequest(void); + + +///Error screen message +struct ErrorScreenMessage g_ErrorScreenMessage; + +///select mark "*" +const char g_selectMarks[16][16] = { + {'*', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*'}, + }; + +const char *_videoBitrateRanges[] = { + "6000kbps -- 24000kbps(I) or 30000kbps(P)", + "5000kbps -- 24000kbps", + "4000kbps -- 24000kbps", + "2000kbps -- 10000kbps", + "2000kbps -- 10000kbps", +}; + +///Kind of result file access.(index by FMBFileResultEnum) +const char *_fileResult[] = { + "File Normal end", ///<Normal end + "File access fail", ///<File access fail + "File execution fail", ///<File execution fail + "File packet size fail", ///<File Packet Size fail + "File open fail", ///<File open fail +}; + +///Kind of confirmation screen.(index by ScreenConfTypeEnum) +const char *_confScreen[] = { + "Encoding", ///<1:Encoding + "Decoding", ///<2:Decoding + "Start and pause", ///<3:Start and pause + "", ///<4:reserve + "One-picture encoding", ///<5:One-picture encoding + "One-picture decoding", ///<6:One-picture decoding +}; + +///Kind of the sub menu setting screen.(index by ScreenSetSubMenuTypeEnum) +const char *_screenSubmenuTitle[2][2] = { + {"Encode settings - Sub menu", + " "}, + {"Decode settings - Sub menu", + " "} +}; + +///Invalid character code. +const int g_invalidCharaCode[] = { + FMB_CODE_QUOTATION_MARKS, + FMB_CODE_ASTERISK, + FMB_CODE_COLON, + FMB_CODE_LESS_THAN_SIGN, + FMB_CODE_GRATER_THAN_SIGN, + FMB_CODE_QUESTION_MARK, + FMB_CODE_BACKSLASH, + FMB_CODE_BERTIE_KALVER, +}; + +const enum FMBCheckVideoFormatEnum g_VideoFormatCheckEnc[FMBEnmVideoFmtMax][FMBEnmVideoFrmMax] = { + { + FMBEnmVFmtLimitations , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_60p + FMBEnmVFmtLimitations , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_5994p + FMBEnmVFmtLimitations , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_50p + FMBEnmVFmtOK , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_60i + FMBEnmVFmtOK , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_5994i + FMBEnmVFmtOK , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_50i + }, + { + FMBEnmVFmtNG , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_60p + FMBEnmVFmtNG , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_5994p + FMBEnmVFmtNG , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_50p + FMBEnmVFmtOK , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_60i + FMBEnmVFmtOK , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_5994i + FMBEnmVFmtOK , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_50i + }, + { + FMBEnmVFmtOK , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_60p + FMBEnmVFmtOK , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_5994p + FMBEnmVFmtOK , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_50p + FMBEnmVFmtNG , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_60i + FMBEnmVFmtNG , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_5994i + FMBEnmVFmtNG , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_50i + }, + { + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_60p + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_5994p + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_50p + FMBEnmVFmtOK , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_60i + FMBEnmVFmtOK , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_5994i + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_50i + }, + { + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_60p + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_5994p + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_50p + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_60i + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_5994i + FMBEnmVFmtOK , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_50i + } +}; + +const enum FMBCheckVideoFormatEnum g_VideoFormatCheckDec[FMBEnmVideoFmtMax][FMBEnmVideoFrmMax] = { + { + FMBEnmVFmtLimitations , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_60p + FMBEnmVFmtLimitations , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_5994p + FMBEnmVFmtLimitations , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_50p + FMBEnmVFmtOK , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_60i + FMBEnmVFmtOK , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_5994i + FMBEnmVFmtOK , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_50i + }, + { + FMBEnmVFmtNG , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_60p + FMBEnmVFmtNG , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_5994p + FMBEnmVFmtNG , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_50p + FMBEnmVFmtOK , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_60i + FMBEnmVFmtOK , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_5994i + FMBEnmVFmtOK , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_50i + }, + { + FMBEnmVFmtOK , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_60p + FMBEnmVFmtOK , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_5994p + FMBEnmVFmtOK , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_50p + FMBEnmVFmtNG , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_60i + FMBEnmVFmtNG , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_5994i + FMBEnmVFmtNG , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_50i + }, + { + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_60p + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_5994p + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_50p + FMBEnmVFmtOK , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_60i + FMBEnmVFmtOK , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_5994i + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_50i + }, + { + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_60p + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_5994p + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_50p + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_60i + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_5994i + FMBEnmVFmtOK , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_50i + } +}; + +enum FMBCheckAudioFormatEnum g_AudioFormatCheck[FMBEnmAudioFmtMax]= { + FMBEnmAFmtNG , //< FMBEnmAudioFmtMpeg1l2 + FMBEnmAFmtNG , //< FMBEnmAudioFmtAc3 + FMBEnmAFmtNG , //< FMBEnmAudioFmtAac + FMBEnmAFmtNG , //< FMBEnmAudioFmtLpcm +}; + +static const char *_screenStrErrorInfoBitrateEnc = "\ + Current screen %s - confirm\n\ + Video input %s\n\ + Stream output %s%s\n\ + Video format %s\n\ + Video rate control %s\n\ + Video bitrate %s\n\ + System bitrate %dkbps[Muxrate:%dkbps]\n\ + Audio format %s\n\ + Audio bitrate %s"; + +static const char *_screenStrErrorInfoFileIn = "\ + Current screen %s - confirm\n\ + Stream input %s%s\n\ + Result %s"; + +static const char *_screenStrErrorInfoFileOut = "\ + Current screen %s - confirm\n\ + Stream output %s%s\n\ + Result %s"; + +static const char *_screenStrErrorVideoFormat = "\ + Current screen %s - confirm\n\ + Video format %s\n\ + Video framerate %s\n\ + Video scaler %s"; + +static const char *_screenStrErrorPaketSizeIn = "\ + Current screen %s - confirm\n\ + Stream input %s%s"; + +static const char *_screenStrErrorPaketSizeOut = "\ + Current screen %s - confirm\n\ + Stream output %s%s"; + +static const char *_screenStrErrorInputPort = "\ + Current screen %s - confirm\n\ + Stream input %s%s"; + +static const char *_screenStrErrorOutputPort = "\ + Current screen %s - confirm\n\ + Stream output %s%s"; + +static char s_error_variable_factor[FMB_FACTOR_MAX_CHAR]={0}; + +//unsigned short g_Firm_LSI_Ver = 0x0000; +//unsigned long g_SubsystemId = 0x0000; +enum FMBRunModeEnum g_RunMode = FMBEnmRunModeNormal; + +/** +* @brief The Screen collection module is initialized. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void InitScreens(void) +{ + memset(&_screens, 0, sizeof(_screens)); + + FMB_FUNC(TRUE); + + InitMainMenu(&_screens.screens[ScrEnmMainMenu]); + InitSetSubMenuEnc(&_screens.screens[ScrEnmSetSubMenuEnc]); + InitSetSubMenuDec(&_screens.screens[ScrEnmSetSubMenuDec]); + InitSetAudioBitrateMpeg1l2Enc(&_screens.screens[ScrEnmSetAudioBitrateMpeg1l2Enc]); + InitSetAudioBitrateAc3Enc(&_screens.screens[ScrEnmSetAudioBitrateAc3Enc]); + InitSetAudioBitrateAacEnc(&_screens.screens[ScrEnmSetAudioBitrateAacEnc]); + InitSetAudioBitrateLpcmEnc(&_screens.screens[ScrEnmSetAudioBitrateLpcmEnc]); + InitSetAudioFormatEnc(&_screens.screens[ScrEnmSetAudioFormatEnc]); + InitSetAudioFormatDec(&_screens.screens[ScrEnmSetAudioFormatDec]); + InitSetInputPortDec(&_screens.screens[ScrEnmSetInputPortDec]); + InitSetOutputPortEnc(&_screens.screens[ScrEnmSetOutputPortEnc]); + InitSetVideoRatecontrol(&_screens.screens[ScrEnmSetVideoRatecontrol]); + InitSetVideoBitrateCbr(&_screens.screens[ScrEnmSetVideoBitrateCbr]); + InitSetVideoBitrateVbr(&_screens.screens[ScrEnmSetVideoBitrateVbr]); + InitSetVideoFormatEnc(&_screens.screens[ScrEnmSetVideoFormatEnc]); + InitSetVideoFormatDec(&_screens.screens[ScrEnmSetVideoFormatDec]); + InitSetVideoFrameEnc(&_screens.screens[ScrEnmSetVideoFrameEnc]); + InitSetVideoFrameDec(&_screens.screens[ScrEnmSetVideoFrameDec]); + InitSetVideoScalerEnc(&_screens.screens[ScrEnmSetVideoScalerEnc]); + InitConfEncoding(&_screens.screens[ScrEnmConfEncoding]); + InitConfDecNormal(&_screens.screens[ScrEnmConfDecNormal]); + InitConfDec1pic(&_screens.screens[ScrEnmConfDec1pic]); + InitConfPauseStart(&_screens.screens[ScrEnmConfPauseStart]); + InitConfEnc1pic(&_screens.screens[ScrEnmConfEnc1pic]); + InitEncoding(&_screens.screens[ScrEnmEncoding]); + InitDecPause(&_screens.screens[ScrEnmDecPause]); + InitDecNormal(&_screens.screens[ScrEnmDecNormal]); + InitDec1pic(&_screens.screens[ScrEnmDec1pic]); + InitDecSlow(&_screens.screens[ScrEnmDecSlow]); + InitEndOfPlay(&_screens.screens[ScrEnmEndOfPlay]); + InitSetFile(&_screens.screens[ScrEnmSetFile]); + InitSetFileStartPos(&_screens.screens[ScrEnmSetFileStartPos]); + InitSetSystemBitrate(&_screens.screens[ScrEnmSetSystemBitrate]); + InitSetSubMenuCom(&_screens.screens[ScrEnmSetSubMenuCom]); + InitSetTsPacketCom(&_screens.screens[ScrEnmSetTsPacketCom]); + InitSetPidTypeCom(&_screens.screens[ScrEnmSetPidTypeCom]); + InitSetInOutPidCom(&_screens.screens[ScrEnmSetInOutPidCom]); + InitSetTsTypeCom(&_screens.screens[ScrEnmSetTsTypeCom]); + InitSetFirmCom(&_screens.screens[ScrEnmSetFirmCom]); + InitSetConfigCom(&_screens.screens[ScrEnmSetConfigCom]); + InitScreenError(&_screens.screens[ScrEnmScreenError]); + InitSetOption(&_screens.screens[ScrEnmSetOption]); + InitSriptCommand(&_screens.screens[ScrEnmEecScriptCommand]); + InitSelSingleDev(&_screens.screens[ScrEnmSelSingleDev]); +#ifdef USE_MMUX // [ USE_MMUX + InitSelRecordDev(&_screens.screens[ScrEnmSelRecordDev]); +#else // USE_MMUX ] [ !USE_MMUX + InitSelMultiDev(&_screens.screens[ScrEnmSelMultiDev]); +#endif // !USE_MMUX ] + InitSetVideoIO(&_screens.screens[ScrEnmSetVideoInOut]); + InitSetVideoOut(&_screens.screens[ScrEnmSetVideoOut]); + InitSetVideoResolutionEnc(&_screens.screens[ScrEnmSetVideoRsltnEnc]); + InitSetVideoResolutionDec(&_screens.screens[ScrEnmSetVideoRsltnDec]); + InitSetVideoOutMode(&_screens.screens[ScrEnmSetVideoOutMode]); + InitSetVideoOutBypass(&_screens.screens[ScrEnmSetVideoOutBypass]); + InitSetVideoOutH264(&_screens.screens[ScrEnmSetVideoOutH264]); + + switch(g_RunMode){ + case FMBEnmRunModeCommand: + ChangeScreenAndModeTo(ScrEnmEecScriptCommand, ScrEnmScriptCommandMode); + ChangeNextScreen(); + break; + default: + ChangeScreenAndModeTo(ScrEnmMainMenu, ScrEnmNormalMode); + ChangeNextScreen(); + } + + _screens.inputMode[ScrEnmScriptCommandMode]=ScrEnmModeKeybuffer; + _screens.inputMode[ScrEnmOptionMode]=ScrEnmMode1key; + _screens.prevScreen[ScrEnmScriptCommandMode]=ScrEnmSetOption; + _screens.prevScreen[ScrEnmOptionMode]=ScrEnmSetOption; + _screens.currentScreen[ScrEnmScriptCommandMode]=ScrEnmEecScriptCommand; + _screens.currentScreen[ScrEnmOptionMode]=ScrEnmEecScriptCommand; + + FMB_FUNC(FALSE); +} + +/** +* @brief The screen is set to 1Key or the Key-Buffer mode. +* @param[in] inputMode Kind of screen input mode. +* @return The input mode before is returned. +* @note None +* @attention None +*/ +enum ScreenInputModeEnum SetScreenMode(enum ScreenInputModeEnum inputMode) +{ + static BOOL _isFirst = TRUE; + static struct termios _settingsOriginal; + static struct termios _settingsKeybuffer; + static struct termios _settings1Key; + int rc; + enum ScreenInputModeEnum previnputMode; + + if(_isFirst){ + rc = tcgetattr(STDIN_FILENO, &_settingsOriginal); + ASSERT_SYS(rc == 0, "tcgetattr"); + _settings1Key = _settingsOriginal; + _settings1Key.c_lflag &= ~ICANON; + _settings1Key.c_lflag &= ~ECHO; + _settings1Key.c_cc[VMIN] = 0; + _settings1Key.c_cc[VTIME] = 0; + + _settingsKeybuffer = _settingsOriginal; + _settingsKeybuffer.c_lflag |= ICANON; + _settingsKeybuffer.c_lflag |= ECHO; + _settingsKeybuffer.c_lflag |= ECHOCTL; + _isFirst = FALSE; + } + + FMB_FUNC(TRUE); + switch(inputMode){ + case ScrEnmMode1key: + rc = tcsetattr(STDIN_FILENO, TCSANOW, &_settings1Key); + ASSERT_SYS(rc == 0, "tcsetattr"); + break; + case ScrEnmModeKeybuffer: + rc = tcsetattr(STDIN_FILENO, TCSANOW, &_settingsKeybuffer); + ASSERT_SYS(rc == 0, "tcsetattr"); + break; + case ScrEnmModeOriginal: + rc = tcsetattr(STDIN_FILENO, TCSANOW, &_settingsOriginal); + ASSERT_SYS(rc == 0, "tcsetattr"); + break; + default: + ASSERT_USR(FALSE, "Invalid inputMode"); + } + previnputMode = _screens.inputMode[_screens.currentMode]; + _screens.inputMode[_screens.currentMode] = inputMode; + FMB_FUNC(FALSE); + return previnputMode; +} + +/** +* @brief Event when input is done to standard input +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +BOOL OnStdinInput(void) +{ + int rc; + BOOL isContinue = TRUE; + struct Screen *scr; + char keybuff[FMB_KEYBUFF_MAX_CHAR]; + char *geted; + size_t len; + + FMB_FUNC(TRUE); + + if(_screens.inputMode[_screens.currentMode] == ScrEnmMode1key){ + rc = read(STDIN_FILENO, keybuff, sizeof(keybuff)); //One character is read. + ASSERT_SYS(rc != -1, "read()"); + len = rc; + LogKeyBuff(keybuff, len); + if((len == 1) && (keybuff[0] == FMB_KEY_ESC)){ /* pgr0020 */ //If Esc-key, + if(_screens.currentScreen[_screens.currentMode] != ScrEnmMainMenu){ + FmbMultiCall(FmbCancelRequest); + fprintOut(stdout, "\n"); + ChangeScreenTo(ScrEnmMainMenu); + ChangeNextScreen(); + FMB_FUNC(FALSE); + return TRUE; + } + } + } + else{ + geted = fgets(keybuff, sizeof(keybuff), stdin); //1 line is read. + ASSERT_SYS(geted != NULL, "fgets()"); + len = strlen(keybuff); + LogKeyBuff(keybuff, len); + } + + if(GetInputEnabled()){ //If the input to the screen is effective, + if(keybuff[0] == FMB_KEY_CTRL_O){ //If Ctrl+o key, + if(_screens.currentScreen[_screens.currentMode] != ScrEnmSetOption){ + fprintOut(stdout, "\n"); + ChangeScreenAndModeTo(ScrEnmSetOption, ScrEnmOptionMode); + ChangeNextScreen(); + FMB_FUNC(FALSE); + return TRUE; + } + } + if(keybuff[0] == FMB_KEY_CTRL_X){ //If Ctrl+x key, + if(_screens.currentScreen[_screens.currentMode] != ScrEnmEecScriptCommand){ + fprintOut(stdout, "\n"); + ChangeScreenAndModeTo(ScrEnmEecScriptCommand, ScrEnmScriptCommandMode); + ChangeNextScreen(); + FMB_FUNC(FALSE); + return TRUE; + } + } + + scr = &_screens.screens[_screens.currentScreen[_screens.currentMode]]; + if(_screens.inputMode[_screens.currentMode] == ScrEnmMode1key){ + if(strchr(scr->validChars, keybuff[0]) == NULL){ + FMB_FUNC(FALSE); + return TRUE; + } + putchar(keybuff[0]); + if(keybuff[0] != '\n'){ + putchar('\n'); + } + ASSERT_USR(scr->OnKeyFunc != NULL, "Current OnKeyFunc is NULL."); + + LogScrEvent("OnKeyFunc\t%d\tkey\t%d", _screens.currentScreen[_screens.currentMode], keybuff[0]); + isContinue = scr->OnKeyFunc(keybuff[0]); + } + else{ + if(keybuff[len-1] != '\n'){ + MsgDispInputErr(FMB_INPUTERR_TOO_LONG_CHAR); + FlushStdin(); + FMB_FUNC(FALSE); + return TRUE; + } + ASSERT_USR(keybuff[len-1] == '\n', "Not terminated LF"); + keybuff[len-1] = '\0'; + ASSERT_USR(scr->OnLineInputFunc != NULL, "Current OnLineInputFunc is NULL."); + LogScrEvent("OnLineInputFunc\t%d\tkeybuff\t%s", _screens.currentScreen[_screens.currentMode], keybuff); + isContinue = scr->OnLineInputFunc(keybuff); + } + if(GetInputEnabled()){ + if ( gp_FmbComProperty->currentRequest == FMBEnmReqStartCommand){ + return TRUE; //Continue:TRUE End of AP:FALSE + } + ASSERT_USR(gp_FmbComProperty->currentRequest == FMBEnmReqNothing, "It is possible to input it though it is requesting. "); + } + + isContinue &= ChangeNextScreen(); + } + FMB_FUNC(FALSE); + return isContinue; //Continue:TRUE End of AP:FALSE +} + +/** +* @brief The specified buffer is dumping edited. +* @param[in] keybuff Target key buffer +* @param[in] len Size of key buffer +* @return None +* @note For output log. +* @attention None +*/ +static void LogKeyBuff(const char *keybuff, size_t len) +{ + char logStringBuff[FMB_KEYBUFF_MAX_CHAR * 3 +1]; + char *logString; + size_t i; + + FMB_FUNC(TRUE); + + if(! g_dbg.isScrLog){ + FMB_FUNC(FALSE); + return; + } + logString = logStringBuff; + logStringBuff[sizeof(logStringBuff) -1] = '\0'; + for(i = 0; i < len; i++){ + logString += snprintf(logString, 4, "%02x ", keybuff[i]); + } + ASSERT_USR(logStringBuff[sizeof(logStringBuff) -1] == '\0', "Buffer over run."); + LogScr("InputCharCode\t%s", logStringBuff); + + FMB_FUNC(FALSE); +} + +/** +* @brief Response of demand for FMB device. +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +BOOL OnFmbRequestResponse(void) +{ + struct Screen *scr; + enum FMBRequestEnum req; + BOOL isContinue; + + FMB_FUNC(TRUE); + + req = ClrAllLastRequest(); + + scr = &_screens.screens[_screens.currentScreen[_screens.currentMode]]; + ASSERT_USR(scr->OnFmbRequestCompleteFunc != NULL, "OnFmbRequestCompleteFunc is NULL."); + + LogScrEvent("OnFmbRequestCompleteFunc\t%d\treq\t%d", _screens.currentScreen[_screens.currentMode], req); + + scr->OnFmbRequestCompleteFunc(req); + + isContinue = ChangeNextScreen(); + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief The state of the screen (..can input.. impropriety) is set. +* @param[in] isEnable TRUE:Inputting enable FALSE:Inputting disable +* @return None +* @note None +* @attention None +*/ +void SetInputEnabled(BOOL isEnable) +{ + struct Screen *scr; + + FMB_FUNC(TRUE); + + if(isEnable){ + scr = &_screens.screens[_screens.currentScreen[_screens.currentMode]]; + if(scr->prompt != NULL){ + printOut("%s", scr->prompt); + } + printOut("%s?>", gp_FmbComProperty->deviceName); + fflush(stdout); + } + _isEnable = isEnable; + + FMB_FUNC(FALSE); +} + +/** +* @brief The state of the screen (..can input.. impropriety) is returned. +* @param[in] None +* @return TRUE Inputting enable +* @return FALSE Inputting disable +* @note None +* @attention None +*/ +BOOL GetInputEnabled(void) +{ + FMB_FUNC(TRUE); + FMB_FUNC(FALSE); + return _isEnable; +} + +/** +* @brief It changes to the specified screen. +* @param[in] scrEnm Enumeration that identifies screen. +* @return None +* @note None +* @attention None +*/ +void ChangeScreenTo(enum ScreenEnum scrEnm) +{ + FMB_FUNC(TRUE); + _screens.isScreenChanged = TRUE; + _screens.nextScreen = scrEnm; + FMB_FUNC(FALSE); +} + +/** +* @brief It changes to the specified screen and mode. +* @param[in] scrEnm Enumeration that identifies screen. +* @param[in] scrMode Enumeration that identifies mode. +* @return None +* @note None +* @attention None +*/ +void ChangeScreenAndModeTo(enum ScreenEnum scrEnm, enum ScreenMode scrMode) +{ + FMB_FUNC(TRUE); + _screens.isScreenChanged = TRUE; + _screens.isScreenModeChanged = TRUE; + _screens.nextScreen = scrEnm; + _screens.nextMode = scrMode; + FMB_FUNC(FALSE); +} + +/** +* @brief The message of the input error is displayed. +* @param[in] msg Error message +* @return None +* @note None +* @attention None +*/ +void MsgDispInputErr(char *msg) +{ + FMB_FUNC(TRUE); + + MsgDispInputErrNoPrompt(msg); + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); +} + +/** +* @brief The message of the input error is displayed. +* @param[in] msg Error message +* @return None +* @note Don't display prompt +* @attention None +*/ +void MsgDispInputErrNoPrompt(char *msg) +{ + FMB_FUNC(TRUE); + + fprintOut(stdout, "\x1b[31mInput Error:"); + + printOut( msg); + + fprintOut(stdout, "\x1b[m\n"); + + FMB_FUNC(FALSE); +} + +/* +Internal Functions +*/ + +/** +* @brief The input buffer of Stdin is cleared. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +static void FlushStdin(void) +{ + int ch; + + FMB_FUNC(TRUE); + do{ + ch = getchar(); + ASSERT_SYS(EOF != ch, "getchar()"); + LogScr("FlushStdin\tgetchar\t0x%02x", ch); + }while(ch != '\n'); + FMB_FUNC(FALSE); +} + +/** +* @brief It changes to the next screen. +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL ChangeNextScreen(void) +{ + struct Screen *scr; + BOOL isContinue; + + FMB_FUNC(TRUE); + if(_screens.isScreenChanged){ //if screen changed, + if(_screens.isScreenModeChanged){ + _screens.isScreenModeChanged = FALSE; + _screens.currentMode = _screens.nextMode; + } + _screens.isScreenChanged = FALSE; + _screens.prevScreen[_screens.currentMode] = _screens.currentScreen[_screens.currentMode]; + _screens.currentScreen[_screens.currentMode] = _screens.nextScreen; + DrawDelimitationLine(); + scr = &_screens.screens[_screens.currentScreen[_screens.currentMode]]; + ASSERT_USR(scr->OnShowFunc != NULL, "Next OnShowFunc is NULL."); + + if (scr->IsShowChildFunc != NULL && _screens.currentMode == ScrEnmNormalMode){ + if (scr->IsShowChildFunc()) { + _screens.prevScreen[_screens.currentMode] = _screens.currentScreen[_screens.currentMode]; + _screens.currentScreen[_screens.currentMode] = scr->childScreen; + DrawDelimitationLine(); + scr = &_screens.screens[_screens.currentScreen[_screens.currentMode]]; + ASSERT_USR(scr->OnShowFunc != NULL, "Next OnShowFunc is NULL."); + } + } + + LogScrEvent("OnShowFunc\t%d", _screens.currentScreen[_screens.currentMode]); + isContinue = scr->OnShowFunc(); + + //Case of Error Screen + if (_screens.nextScreen == ScrEnmScreenError){ + _screens.prevScreen[_screens.currentMode] = _screens.currentScreen[_screens.currentMode]; + _screens.currentScreen[_screens.currentMode] = _screens.nextScreen; + scr = &_screens.screens[_screens.currentScreen[_screens.currentMode]]; + ASSERT_USR(scr->OnShowFunc != NULL, "Next OnShowFunc is NULL."); + + LogScrEvent("OnShowFunc\t%d", _screens.currentScreen[_screens.currentMode]); + isContinue = scr->OnShowFunc(); + } + + FMB_FUNC(FALSE); + return isContinue; + } + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief The delimitation line is displayed. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void DrawDelimitationLine(void) +{ + fprintOut(stdout, "-------------------------------------------------------------------------------\n"); +} + +/** +* @brief The video bitrate character string is edited. +* @param[out] destBuff Buffer where edited character string is stored. +* @param[in] destBuffSize The size of the buffer is specified. + The application terminates abnormally when the edit result exceeds this. +* @return None +* @note None +* @attention None +*/ +void ScrEditVideoBitrateString(char *destBuff, int destBuffSize) +{ + int editedNumofChar = 0; + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + setmode = gp_FmbComProperty->setMode; + + if(gp_FmbProperty[setmode].videoBitrateProp.videoRateCtl == FMBEnmVideoRateCtlCbr){ + editedNumofChar = snprintf(destBuff, destBuffSize, "%dkbps", + gp_FmbProperty[setmode].videoBitrateProp.videoBitrateCbr); + } + else{ + editedNumofChar = snprintf(destBuff, destBuffSize, "Average:%dkbps, Peak:%dkbps", + gp_FmbProperty[setmode].videoBitrateProp.videoBitrateVbrAverage, + gp_FmbProperty[setmode].videoBitrateProp.videoBitrateVbrPeak); + } + + ASSERT_USR(editedNumofChar <= destBuffSize, "The size of the buffer is too small."); + + FMB_FUNC(FALSE); +} + +/** +* @brief The audio bitrate character string is edited. +* @param[out] destBuff Buffer where edited character string is stored. +* @param[in] destBuffSize The size of the buffer is specified. + The application terminates abnormally when the edit result exceeds this. +* @return None +* @note None +* @attention None +*/ +void ScrEditAudioBitrateString(char *destBuff, int destBuffSize) +{ + int editedNumofChar = 0; + enum FMBFuncModeEnum setmode; + enum FMBAudioFormatEnum afmt; + + FMB_FUNC(TRUE); + + setmode = gp_FmbComProperty->setMode; + + afmt = gp_FmbProperty[setmode].audioFmt; + + switch (afmt) { + case FMBEnmAudioFmtLpcm: + if(setmode == FMBEnmFuncModeEnc){ + if(_screens.currentScreen[_screens.currentMode] == ScrEnmSetSubMenuEnc){ + editedNumofChar = snprintf(destBuff, destBuffSize, ", %dkbps", + gp_FmbProperty[setmode].audioBitrateCbr[afmt]); + } + else{ + editedNumofChar = snprintf(destBuff, destBuffSize, "%dkbps", + gp_FmbProperty[setmode].audioBitrateCbr[afmt]); + } + break; + } /* pgr0007 */ + case FMBEnmAudioFmtMpeg1l2: + case FMBEnmAudioFmtAc3: + if((_screens.currentScreen[_screens.currentMode] == ScrEnmSetSubMenuEnc) ){ + //If current-screen is SetSubMenuEnc + editedNumofChar = snprintf(destBuff, destBuffSize, ", %dkbps", + gp_FmbProperty[setmode].audioBitrateCbr[afmt]); + } + else{ + editedNumofChar = snprintf(destBuff, destBuffSize, "%dkbps", + gp_FmbProperty[setmode].audioBitrateCbr[afmt]); + } + break; + case FMBEnmAudioFmtAac: + if((_screens.currentScreen[_screens.currentMode] == ScrEnmSetSubMenuEnc) ){ + //If current-screen is SetSubMenuEnc + editedNumofChar = snprintf(destBuff, destBuffSize, ", Average:%dkbps, Peak:%dkbps", + gp_FmbProperty[setmode].audioBitrateVbrAverage, + gp_FmbProperty[setmode].audioBitrateVbrPeak); + } + else{ + editedNumofChar = snprintf(destBuff, destBuffSize, "Average:%dkbps, Peak:%dkbps", + gp_FmbProperty[setmode].audioBitrateVbrAverage, + gp_FmbProperty[setmode].audioBitrateVbrPeak); + } + break; + default: + break; + } + + ASSERT_USR(editedNumofChar <= destBuffSize, "The size of the buffer is too small."); + + FMB_FUNC(FALSE); +} + + +/** +* @brief It returns to the previous screen mode. +* @param[in] scrMode Enumeration that identifies mode. +* @return None +* @note None +* @attention None +*/ +void ReturnToAnotherScreenMode(enum ScreenMode scrMode) +{ + FMB_FUNC(TRUE); + + _screens.isScreenModeChanged = FALSE; + _screens.currentMode = scrMode; + + fprintOut(stdout, "-------------------------------------------------------------------------------\n"); + fprintOut(stdout, "It returned to the former screen. \n"); + (void)SetScreenMode(_screens.inputMode[scrMode]); + SetInputEnabled(TRUE); + FMB_FUNC(FALSE); +} + + +/** +* @brief It changes to the previous screen. +* @param[in] scrEnm Enumeration that identifies screen. +* @return None +* @note None +* @attention None +*/ +void ChangePrevScreenTo(enum ScreenMode scrMode, enum ScreenEnum scrEnm) +{ + FMB_FUNC(TRUE); + + _screens.prevScreen[scrMode] = _screens.currentScreen[scrMode]; + _screens.currentScreen[scrMode] = scrEnm; + + FMB_FUNC(FALSE); +} + + +/** +* @brief The file character string is edited. +* @param[out] destBuff Buffer where edited character string is stored. +* @param[in] portenum port kind(input port : FMBEnmInPort / output port : FMBEnmOutPort) +* destBuffSize The size of the buffer is specified. + The application terminates abnormally when the edit result exceeds this. +* @return None +* @note None +* @attention None +*/ +void ScrEditFilePathString(enum FMBInOutPortEnum portenum, char *destBuff, int destBuffSize) +{ + int editedNumofChar = 0; + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + setmode = gp_FmbComProperty->setMode; + + switch (portenum){ + case FMBEnmOutPort: + if(gp_FmbProperty[setmode].outputPort == FMBEnmPortFile){ + editedNumofChar = snprintf(destBuff, destBuffSize, " %s", gp_FmbProperty[setmode].outputfile); + } + else{ + destBuff[0] = '\0'; + editedNumofChar = 1; + } + break; + case FMBEnmInPort: + if(gp_FmbProperty[setmode].inputPort == FMBEnmPortFile){ + editedNumofChar = snprintf(destBuff, destBuffSize, " %s", gp_FmbProperty[setmode].inputfile); + } + else{ + destBuff[0] = '\0'; + editedNumofChar = 1; + } + break; + default: + break; + } + + ASSERT_USR(editedNumofChar <= destBuffSize, "The size of the buffer is too small."); + + FMB_FUNC(FALSE); +} + +/** +* @brief The previous of the screen is returned. +* @param[in] None +* @return _screens.prevScreen Previous screen +* @note None +* @attention None +*/ +enum ScreenEnum GetPrevScreen(void) +{ + FMB_FUNC(TRUE); + FMB_FUNC(FALSE); + return _screens.prevScreen[_screens.currentMode]; +} + +/** +* @brief The file character string check. +* @param[in] destBuff Buffer where edited character string is stored. +* @param[in] len The size of the buffer is specified. +* @return FMBEnmNormal Normal end +* @return FMBEnmTooLongCharErr Too long char error +* @return FMBEnmInvalidValueErr Invalid value error +* @note None +* @attention None +*/ +enum FMBCharChkResultEnum ScrChkCodeStringBuff(char *destBuff, size_t len) +{ + size_t i; + int j; + + FMB_FUNC(TRUE); + + if (len > FMB_FILEPATH_MAX_CHAR){ + FMB_FUNC(FALSE); + return FMBEnmTooLongCharErr; + } + for(i = 0; i < len; i++){ + if ((destBuff[i] < FMB_FILEPATH_MIN_CODE_RANGE)|| + (destBuff[i] > FMB_FILEPATH_MAX_CODE_RANGE)){ + FMB_FUNC(FALSE); + return FMBEnmInvalidValueErr; + } + } + for(j= 0; j < FMB_CODE_INVALID_KIND; j++){ + if(strchr(destBuff, g_invalidCharaCode[j]) != NULL){ + FMB_FUNC(FALSE); + return FMBEnmInvalidValueErr; + } + } + + FMB_FUNC(FALSE); + return FMBEnmNormal; +} + +/** +* @brief The confirmation of setting data. +* @param[in] scrConfEnm Enumeration that identifies confirmation screen. +* @return TRUE Normal +* @return FALSE Error +* @note None +* @attention None +*/ +BOOL ScrConfSetData(enum ScreenConfTypeEnum scrConfEnm) +{ + enum FMBFuncModeEnum setmode; + enum FMBFileResultEnum ret_file_in = FMBEnmFileNormal; + enum FMBFileResultEnum ret_file_out = FMBEnmFileNormal; + char wk_msg[FMB_ERRINFO_MAX_CHAR]={0}; + char video_bitrate[FMB_BITRATE_MAX_CHAR]={0}; + char audio_bitrate[FMB_BITRATE_MAX_CHAR]={0}; + char inputfilepath[FMB_FILEPATH_MAX_CHAR+1]={0}; + char outputfilepath[FMB_FILEPATH_MAX_CHAR+1]={0}; + int errPacketCnt; + enum FMBCheckVideoFormatEnum checkVFmt; + enum FMBVideoFormatEnum videoFmt = FMBEnmVideoFmt1920x1080; + enum FMBVideoFrameEnum videoFrm = FMBEnmVideoFrm_5994i; + __off64_t fileSize; + __off64_t fileStartPos; + BOOL errVideoFormat = FALSE; + + FMB_FUNC(TRUE); + + setmode = gp_FmbComProperty->setMode; + + + if((setmode == FMBEnmFuncModeEnc) ){ + + if(! FmbCalcVideoBitrateParam(&gp_FmbProperty[gp_FmbComProperty->setMode].videoBitrateProp, + gp_FmbProperty[gp_FmbComProperty->setMode].videoFrm, + gp_FmbProperty[gp_FmbComProperty->setMode].audioFmt)){ + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_OVERFLOW; + + //(2)message information set + + ScrEditVideoBitrateString(video_bitrate, sizeof(video_bitrate)); + + ScrEditAudioBitrateString(audio_bitrate, sizeof(audio_bitrate)); + + ScrEditFilePathString(FMBEnmInPort, inputfilepath, sizeof(inputfilepath)); + + ScrEditFilePathString(FMBEnmOutPort, outputfilepath, sizeof(outputfilepath)); + + //Encode mode + sprintf(wk_msg, _screenStrErrorInfoBitrateEnc, + _confScreen[scrConfEnm], + g_FmbNamePort[gp_FmbProperty[setmode].inputPort], + g_FmbNamePort[gp_FmbProperty[setmode].outputPort], + outputfilepath, + g_FmbNameVideoFmts[gp_FmbProperty[setmode].videoFmt], + g_FmbNameVideoRateCtls[gp_FmbProperty[setmode].videoBitrateProp.videoRateCtl], + video_bitrate, + gp_FmbProperty[setmode].videoBitrateProp.systemMuxRate, + gp_FmbProperty[setmode].videoBitrateProp.videoBitrateParam.muxRate, + g_FmbNameAudioFmts[gp_FmbProperty[setmode].audioFmt], + audio_bitrate); + + strcpy(g_ErrorScreenMessage.information, wk_msg); + + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_OVERFLOW; + + FMB_FUNC(FALSE); + return FALSE; + } + } + + + if(((setmode == FMBEnmFuncModeDec) && (gp_FmbProperty[setmode].inputPort == FMBEnmPortFile)) ){ + + ret_file_in = FmbFileOpen( FMBEnmInFile, gp_FmbProperty[setmode].inputfile , &errPacketCnt); + + if(ret_file_in != FMBEnmFileNormal){ + switch (ret_file_in) { + case FMBEnmFileAccesFail: + case FMBEnmFileOtherFail: + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_INFILEPATH; + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_INFILEPATH; + + break; + case FMBEnmFilePacketSizeFail: + sprintf(s_error_variable_factor, FMB_ERRSCR_FACT_INPACKET_SIZE, errPacketCnt); + //(1)factor set + g_ErrorScreenMessage.factor = s_error_variable_factor; + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_INPACKET_SIZE; + + break; + case FMBEnmFileExecutionFail: + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_TERMINATING; + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_EXECRETRY; + + break; + default: + ASSERT_USR(FALSE, "Invalid return value."); + break; + } + //(2)message information set + ScrEditFilePathString(FMBEnmInPort, inputfilepath, sizeof(inputfilepath)); + + sprintf(wk_msg, _screenStrErrorInfoFileIn, + _confScreen[scrConfEnm], + g_FmbNamePort[gp_FmbProperty[setmode].inputPort], + inputfilepath, + _fileResult[ret_file_in]); + + strcpy(g_ErrorScreenMessage.information, wk_msg); + + FMB_FUNC(FALSE); + return FALSE; + } + if(gp_FmbComProperty->tsFormat[FMBEnmInputTsPacket] != FMBEnmTsFormat188){ + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_INPACKET_SIZE2; + + //(2)message information set + ScrEditFilePathString(FMBEnmInPort, inputfilepath, sizeof(inputfilepath)); + + sprintf(wk_msg, _screenStrErrorPaketSizeIn, + _confScreen[scrConfEnm], + g_FmbNamePort[gp_FmbProperty[setmode].inputPort], + inputfilepath); + + strcpy(g_ErrorScreenMessage.information, wk_msg); + + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_INPACKET_SIZE; + + FMB_FUNC(FALSE); + return FALSE; + } + if(scrConfEnm == ScrEnmConfDecNormalType || scrConfEnm == ScrEnmConfPauseStartType){ + fileStartPos = FmbGetStrmFilePos(FMBEnmStartPos); + fileSize = FmbGetFileSize(gp_FmbProperty[setmode].inputfile); + if(fileStartPos > fileSize){ + fileStartPos = 0; + FmbSetStrmFilePos(FMBEnmStartPos,fileStartPos); + } + } + } + + if((setmode == FMBEnmFuncModeDec) && (gp_FmbProperty[setmode].inputPort == FMBEnmPortStreamport)){ + if(scrConfEnm != ScrEnmConfDecNormalType){ + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_INPUTPORT; + + //(2)message information set + sprintf(wk_msg, _screenStrErrorInputPort, + _confScreen[scrConfEnm], + g_FmbNamePort[gp_FmbProperty[setmode].inputPort], + inputfilepath); + strcpy(g_ErrorScreenMessage.information, wk_msg); + + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_INPUTPORT; + + FMB_FUNC(FALSE); + return FALSE; + } + } + + if(((setmode == FMBEnmFuncModeEnc) && (gp_FmbProperty[setmode].outputPort == FMBEnmPortFile)) ){ + ret_file_out = FmbFileOpen( FMBEnmOutFile, gp_FmbProperty[setmode].outputfile , &errPacketCnt ); + + if(ret_file_out != FMBEnmFileNormal){ + switch (ret_file_out) { + case FMBEnmFileAccesFail: + case FMBEnmFileOtherFail: + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_OUTFILEPATH; + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_OUTFILEPATH; + + break; + case FMBEnmFilePacketSizeFail: + sprintf(s_error_variable_factor, FMB_ERRSCR_FACT_OUTPACKET_SIZE, errPacketCnt); + //(1)factor set + g_ErrorScreenMessage.factor = s_error_variable_factor; + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_OUTPACKET_SIZE; + + break; + case FMBEnmFileExecutionFail: + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_TERMINATING; + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_EXECRETRY; + + break; + default: + ASSERT_USR(FALSE, "Invalid return value."); + break; + } + //(2)message information set + ScrEditFilePathString(FMBEnmOutPort, outputfilepath, sizeof(outputfilepath)); + + sprintf(wk_msg, _screenStrErrorInfoFileOut, + _confScreen[scrConfEnm], + g_FmbNamePort[gp_FmbProperty[setmode].outputPort], + outputfilepath, + _fileResult[ret_file_out]); + + strcpy(g_ErrorScreenMessage.information, wk_msg); + + FMB_FUNC(FALSE); + return FALSE; + } + if(gp_FmbComProperty->tsFormat[FMBEnmOutputTsPacket] != FMBEnmTsFormat188){ + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_OUTPACKET_SIZE2; + + //(2)message information set + ScrEditFilePathString(FMBEnmOutPort, outputfilepath, sizeof(outputfilepath)); + + sprintf(wk_msg, _screenStrErrorPaketSizeOut, + _confScreen[scrConfEnm], + g_FmbNamePort[gp_FmbProperty[setmode].outputPort], + outputfilepath); + + strcpy(g_ErrorScreenMessage.information, wk_msg); + + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_OUTPACKET_SIZE; + + FMB_FUNC(FALSE); + return FALSE; + } + } + if((setmode == FMBEnmFuncModeEnc) && (gp_FmbProperty[setmode].outputPort == FMBEnmPortStreamport)){ + if(scrConfEnm != ScrEnmConfEncodingType){ + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_OUTPUTPORT; + + //(2)message information set + sprintf(wk_msg, _screenStrErrorOutputPort, + _confScreen[scrConfEnm], + g_FmbNamePort[gp_FmbProperty[setmode].outputPort], + outputfilepath); + strcpy(g_ErrorScreenMessage.information, wk_msg); + + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_OUTPUTPORT; + + FMB_FUNC(FALSE); + return FALSE; + } + } + + if(setmode == FMBEnmFuncModeEnc){ + videoFmt = gp_FmbProperty[setmode].videoFmt; + videoFrm = gp_FmbProperty[setmode].videoFrm; + } + else{ + videoFmt = gp_FmbProperty[setmode].videoFmt; + videoFrm = gp_FmbProperty[setmode].videoFrm; + } + checkVFmt = g_VideoFormatCheckEnc[videoFmt][videoFrm]; + + if(checkVFmt == FMBEnmVFmtNG){ + errVideoFormat = TRUE; + } + + if(checkVFmt == FMBEnmVFmtLimitations){ + if(gp_FmbDevInfo->subSystemId == 0xFFFFFFFE){ + errVideoFormat = TRUE; + } + else if(gp_FmbDevInfo->firmLSIVer != 0x41){ + errVideoFormat = TRUE; + } + } + + if(errVideoFormat == TRUE){ + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_VIDEOFORMAT; + + //(2)message information set + sprintf(wk_msg, _screenStrErrorVideoFormat, + _confScreen[scrConfEnm], + g_FmbNameVideoFmts[videoFmt], + g_FmbNameVideoFrms[videoFrm], + g_FmbNameVideoSclEncs[gp_FmbProperty[setmode].videoScalerEnc]); + strcpy(g_ErrorScreenMessage.information, wk_msg); + + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_VIDEOFORMAT; + + FMB_FUNC(FALSE); + return FALSE; + } + + if (g_AudioFormatCheck[gp_FmbProperty[gp_FmbComProperty->setMode].audioFmt] == FMBEnmAFmtBD){ + + if ( videoFrm == FMBEnmVideoFrm_60p || + videoFrm == FMBEnmVideoFrm_60i ){ + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_VIDEOFORMAT; + + //(2)message information set + sprintf(wk_msg, _screenStrErrorVideoFormat, + _confScreen[scrConfEnm], + g_FmbNameVideoFmts[videoFmt], + g_FmbNameVideoFrms[videoFrm], + g_FmbNameVideoSclEncs[gp_FmbProperty[setmode].videoScalerEnc]); + strcpy(g_ErrorScreenMessage.information, wk_msg); + + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_VIDEOFORMAT; + + FMB_FUNC(FALSE); + return FALSE; + + } + } + + FMB_FUNC(FALSE); + return TRUE; +} + +static enum FMBRequestEnum ClrAllLastRequest(void) +{ + enum FMBRequestEnum req = FMBEnmReqNothing; + enum FMBDeviceNumEnum devNum, devNum_old; + + FMB_FUNC(TRUE); + + devNum_old = FmbGetCurDeviceNum(); + for (devNum = FmbSetFirstDev(); devNum != FMBEnmDevice_NONE; devNum = FmbSetNextDev()) { + if (gp_FmbComProperty->lastRequest != FMBEnmReqNothing) { + ASSERT_USR(req == FMBEnmReqNothing || req == gp_FmbComProperty->lastRequest, "Request ?"); + req = gp_FmbComProperty->lastRequest; + } + + gp_FmbComProperty->lastRequest = FMBEnmReqNothing; + } + FmbSetCurDeviceNum(devNum_old); + ASSERT_USR(req != FMBEnmReqNothing, "Request is nothing."); + + FMB_FUNC(FALSE); + + return req; +} |