aboutsummaryrefslogtreecommitdiff
path: root/fmb_player_apl/src/scr/ConfRecording.c
blob: f2a31bf7239e28aa10d8e8b3147ad36c75ee85c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/**
*	@brief 		The function of the encode confirmation screen 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 <string.h>

#include "FmbCmn.h"
#include "Screen.h"
#include "FmbAp.h"

static const char	*_screenStrTitle = "\
[[[ Encoding - confirm  ->  Encoding ]]]\n\
          'B'<-~~~~~~~->Enter\n\
";
static const char	*_screenStrList = "\
Current settings\n\
  Stream output          %s%s\n\
  Video format           %s\n\
  Video framerate        %s\n\
  Video rate control     %s\n\
  Video bitrate          %s\n\
  Audio format           %s\n\
  Audio bitrate          %s\n\
";
static const char	*_screenStrEnd = "\
Press <Enter> key to start encoding.\n\
";


static const char validChars[] = "bB\n";

//Event function when key is input.
static BOOL OnKeyHit(char InputCharacterCode);

//Event function when fmb-request is complete.
static BOOL OnFmbRequestComplete(enum FMBRequestEnum	req);

//Event function when show the screen.
static BOOL OnShow(void);

/**
*	@brief		Initial screen of the encoding confirmation.
*	@param[out]	scr	Screen property
*	@return		None
*	@note		None
*	@attention	None
*/
void InitConfEncoding(struct Screen	*scr)
{
	FMB_FUNC(TRUE);
	//scr->displayString = _screenStr;
	scr->OnKeyFunc = OnKeyHit;
	scr->OnFmbRequestCompleteFunc = OnFmbRequestComplete;
	scr->OnShowFunc = OnShow;
	scr->validChars = validChars;
	scr->IsShowChildFunc = FmbIsNotDeviceSelecting;
#ifdef USE_MMUX	// [ USE_MMUX
	scr->childScreen = ScrEnmSelRecordDev;
#else	// USE_MMUX ] [ !USE_MMUX
	scr->childScreen = ScrEnmSelMultiDev;
#endif	// !USE_MMUX ]
	FMB_FUNC(FALSE);
}

/**
*	@brief		Screen display event
*	@param[in]	None
*	@return		TRUE	Application execution continuance
*	@return		FALSE	Application end
*	@note		None
*	@attention	None
*/
static BOOL OnShow(void)
{
	enum FMBDeviceNumEnum devNum, devNum_old;
	
	FMB_FUNC(TRUE);

	devNum_old = FmbGetCurDeviceNum();
	for (devNum = FmbSetFirstDev(); devNum != FMBEnmDevice_NONE; devNum = FmbSetNextDev()) {
		gp_FmbComProperty->setMode = FMBEnmFuncModeEnc;

		if(! ScrConfSetData(ScrEnmConfEncodingType)){
			ChangeScreenTo(ScrEnmScreenError);
			FMB_FUNC(FALSE);
			return TRUE;
		}
	}
	FmbMultiCall(FmbInitEnc);

	FmbSetCurDeviceNum(devNum_old);

	SetInputEnabled(FALSE);

	FMB_FUNC(FALSE);
	return TRUE;
}

/**
*	@brief		Event function when key is input.
*	@param[in]	InputCharacterCode	Input character-code
*	@return		TRUE	Application execution continuance
*	@return		FALSE	Application end
*	@note		None
*	@attention	None
*/
static BOOL OnKeyHit(char InputCharacterCode)
{
	FMB_FUNC(TRUE);
	switch(InputCharacterCode){
	case	'b':
	case	'B':
		ChangeScreenTo(ScrEnmMainMenu);
		FMB_FUNC(FALSE);
		return TRUE;
		break;
	default:
		//'\n'
		ASSERT_USR(InputCharacterCode=='\n', "Invalid character code.");
		break;
	};

	ChangeScreenTo(ScrEnmEncoding);
	FMB_FUNC(FALSE);
	return TRUE;
}

/**
*	@brief		Event function when fmb-request is complete.
*	@param[in]	req	Kind of completed request
*	@return		TRUE	Application execution continuance
*	@return		FALSE	Application end
*	@note		None
*	@attention	None
*/
static BOOL OnFmbRequestComplete(enum FMBRequestEnum	req)
{
	char	video_bitrate[FMB_BITRATE_MAX_CHAR]={0};
	char	audio_bitrate[FMB_BITRATE_MAX_CHAR]={0};
	char	outputfilepath[FMB_FILEPATH_MAX_CHAR+1]={0};
	enum FMBFuncModeEnum	setmode;
	enum FMBDeviceNumEnum devNum, devNum_old;

	FMB_FUNC(TRUE);

	printOut(_screenStrTitle);
	devNum_old = FmbGetCurDeviceNum();
	for (devNum = FmbSetFirstDev(); devNum != FMBEnmDevice_NONE; devNum = FmbSetNextDev()) {

		ASSERT_USR(req == FMBEnmReqInitEnc, "Invalid request mode.");
		ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal.");

		setmode = gp_FmbComProperty->setMode;

		ScrEditVideoBitrateString(video_bitrate, sizeof(video_bitrate));

		ScrEditAudioBitrateString(audio_bitrate, sizeof(audio_bitrate));

		ScrEditFilePathString(FMBEnmOutPort, outputfilepath, sizeof(outputfilepath));

		printOut(_screenStrList,
			g_FmbNamePort[gp_FmbProperty[setmode].outputPort],
			outputfilepath,
			g_FmbNameVideoFmts[gp_FmbProperty[setmode].videoFmt],
			g_FmbNameVideoFrms[gp_FmbProperty[setmode].videoFrm],
			g_FmbNameVideoRateCtls[gp_FmbProperty[setmode].videoBitrateProp.videoRateCtl],
			video_bitrate,
			g_FmbNameAudioFmts[gp_FmbProperty[setmode].audioFmt],
			audio_bitrate);
	}
	FmbSetCurDeviceNum(devNum_old);
	printOut(_screenStrEnd);

	SetInputEnabled(TRUE);

	FMB_FUNC(FALSE);
	return TRUE;
}