aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Green <andy.green@linaro.org>2012-11-22 19:01:10 +0800
committerAndy Green <andy.green@linaro.org>2012-11-22 19:01:10 +0800
commit228b2e0b30431223f322c94d3ca7db6f6a294840 (patch)
treeda1f31f27941e242d9697d70ede52fc1bdedc451
parent551c2e032fff941c279c66f0c7dffe6c6a60d413 (diff)
add automated commandline mode
Signed-off-by: Andy Green <andy.green@linaro.org>
-rw-r--r--README31
-rw-r--r--fmb_player_apl/include/FmbAp.h6
-rw-r--r--fmb_player_apl/src/com/FmbComStream.c3
-rw-r--r--fmb_player_apl/src/com/FmbComplayer.c151
-rw-r--r--fmb_player_apl/src/sce/FmbAp.c8
-rw-r--r--fmb_player_apl/src/scr/Screen.c4
6 files changed, 163 insertions, 40 deletions
diff --git a/README b/README
index 2074e1b..5739f9f 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-2012-11-14 Andy Green <andy.green@linaro.org>
+2012-11-22 Andy Green <andy.green@linaro.org>
Introduction
------------
@@ -18,15 +18,18 @@ Sources are marked up as GPL2, including the userland.
Restrictions
------------
-Right now there's a text-menu based control app which won't accept automation
-well.
+In automated commandline mode, 1080p60 capture is always used right now.
-Building
---------
+Requirements
+------------
You need your kernel build package to build an OOT module against.
+
+Building
+--------
+
The script ./install.sh attempts to build and install everything, then insert
the module and create the /dev node(s). I added a udev rule which should
do that automatically afterwards. The node is in "video" group.
@@ -39,7 +42,19 @@ Usage
The install script copies the menu app as "/usr/local/bin/hdcapture".
-You should be able to run this, use option 6 to select the capture rate and
-then option 1 to capture to the default file ./stream-0.mpg, until you
-press enter.
+This app is originally a very byzantine menu-based thing. I added a commandline
+mode which allows automated usage.
+
+In the commandline mode, the default mode of 1080p60 with CBR 30Mbps is
+selected. You can control the duration of the capture in seconds, and the
+output file path like this
+
+$ hdcapture -l 5 -o mystream.mpg
+
+Notice capture is always delayed by ~3s while firmware is sent.
+
+For menu mode, don't give any arguments to hd capture: use option 6 to select
+the capture rate and then option 1 to capture to the default file
+./stream-0.mpg, until you press enter.
+
diff --git a/fmb_player_apl/include/FmbAp.h b/fmb_player_apl/include/FmbAp.h
index 09ea9c9..8e19928 100644
--- a/fmb_player_apl/include/FmbAp.h
+++ b/fmb_player_apl/include/FmbAp.h
@@ -331,9 +331,9 @@ enum FMBDeviceNumEnum {
#define FMB_CODE_BACKSLASH 0x5C
#define FMB_CODE_BERTIE_KALVER 0x7C
-#define FMB_DEFUALT_BITRATE_CBR_ENC 6000
-#define FMB_DEFUALT_BITRATE_VBR_AVE_ENC 6000
-#define FMB_DEFUALT_BITRATE_VBR_PEAK_ENC 9000
+#define FMB_DEFUALT_BITRATE_CBR_ENC 30000
+#define FMB_DEFUALT_BITRATE_VBR_AVE_ENC 30000
+#define FMB_DEFUALT_BITRATE_VBR_PEAK_ENC 30000
#define FMB_DEFUALT_BITRATE_AUDIO 256
#define FMB_DEFUALT_BITRATE_AUDIO_LPCM 1536 //< 16bit 48Khz stereo2ch=(16*48*2)kbps
#define FMB_DEFUALT_FILEPATH_OUT_ENC "./outputstream.mpg"
diff --git a/fmb_player_apl/src/com/FmbComStream.c b/fmb_player_apl/src/com/FmbComStream.c
index 74fb7b2..7dc85d9 100644
--- a/fmb_player_apl/src/com/FmbComStream.c
+++ b/fmb_player_apl/src/com/FmbComStream.c
@@ -56,11 +56,13 @@ BOOL FmbStreamBegin( enum FMBStremThreadEnum threadKind, HANDLE sceHandle )
p_StreamThread = &p_deviceInfo->t_StreamThread_A[threadKind];
p_ComProperty = FmbGetComProperty(SceGetDevNum(sceHandle));
if (p_StreamThread->fd < 0){
+ fprintf(stderr, "Thread fd < 0 %d\n", p_StreamThread->fd);
FMB_FUNC(FALSE);
return FALSE;
}
if ( p_StreamThread->isThread == TRUE){
+ fprintf(stderr, "isThread TRUE\n");
FMB_FUNC(FALSE);
return FALSE;
}
@@ -70,6 +72,7 @@ BOOL FmbStreamBegin( enum FMBStremThreadEnum threadKind, HANDLE sceHandle )
p_StreamThread->fBuf = malloc(p_StreamThread->fSize);
if ( p_StreamThread->fBuf == NULL ){
+ fprintf(stderr, "Allocation failed for thread buffer\n");
fmbStreamClose(threadKind, p_StreamThread);
FMB_FUNC(FALSE);
return FALSE;
diff --git a/fmb_player_apl/src/com/FmbComplayer.c b/fmb_player_apl/src/com/FmbComplayer.c
index 0b3ec29..2eb3148 100644
--- a/fmb_player_apl/src/com/FmbComplayer.c
+++ b/fmb_player_apl/src/com/FmbComplayer.c
@@ -35,6 +35,12 @@
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/utsname.h>
+#include <getopt.h>
+#include <termio.h>
+#include <stdint.h>
+#include <errno.h>
+#include <limits.h>
+#include <sys/time.h>
#include "FmbCmn.h"
#include "FmbAp.h"
@@ -90,6 +96,12 @@ static enum FMBRequestEnum ClrCurrentRequest(void);
void sigint_handler(int sig);
void OnExit(void);
+static struct option options[] = {
+ { "help", no_argument, NULL, 'h' },
+ { "verbose", no_argument, NULL, 'v' },
+ { "length", required_argument, NULL, 'l' },
+};
+
/**
* @brief main function
* @param[in] argc Number of command line arguments
@@ -106,16 +118,28 @@ int main(int argc, char *argv[])
BOOL isContinue;
enum FMBResultEnum fmbRc;
struct sigaction sa;
- int index;
struct timeval timeout;
- int opt_cnt=0;
+// int opt_cnt=0;
struct utsname system_info;
- enum FMBDeviceNumEnum deviceNum, deviceNumOld;
+ enum FMBDeviceNumEnum devNum, deviceNum, deviceNumOld;
+ int n = 1;
+ char debug_flags[16];
+ char output_path[PATH_MAX];
#ifdef USE_MMUX // USE_MMUX [
struct MmuxVer mmuxVer;
#endif // USE_MMUX ]
void SceInitEncParam(void);
void SceInitDecParam(void);
+ double length = 0;
+ enum encode_script {
+ ES_WAIT_RESET_COMPLETION,
+ ES_WAIT_INIT_COMPLETION,
+ ES_STARTED,
+ ES_DONE,
+ };
+ enum encode_script encode_script = ES_WAIT_RESET_COMPLETION;
+ struct timeval tv;
+ double d, completion;
SceInitEncParam();
SceInitDecParam();
@@ -124,28 +148,56 @@ int main(int argc, char *argv[])
atexit(OnExit);
- /* -dbg */
- index = FmbgetArg("-dbg", argc , argv);
- if (index!=0){
- InitDbg(argv[index]);
- opt_cnt++;
- }
- else{
- InitDbg("0");
+ strcpy(debug_flags, "0");
+
+ while (n >= 0) {
+ n = getopt_long(argc, argv, "hd:o:l:",
+ options, NULL);
+ if (n < 0)
+ continue;
+ switch (n) {
+
+ case 'l':
+ length = atof(optarg);
+ break;
+
+ case 'd':
+ strncpy(debug_flags, optarg, sizeof(debug_flags) - 1);
+ debug_flags[sizeof(debug_flags) - 1] = '\0';
+ break;
+
+ case 'o':
+ strncpy(output_path, optarg, sizeof(output_path) - 1);
+ output_path[sizeof(output_path) - 1] = '\0';
+ break;
+
+ default:
+ case 'h':
+ fprintf(stderr,
+ "Usage: either... lava-fft > wav_file or\n"
+ " cat capture | lava-fft\n"
+ " [--verbose -v] Increase debug on stderr\n"
+ " [--rate -r <sample rate>] set sample rate "
+ "(default 48000)\n"
+ );
+ return 1;
+ }
}
+ InitDbg(debug_flags);
+
FmbInitInfo();
FmbCreatDevInfoAll();
FmbSetCurDeviceNum(FMBEnmDevice_0);
-
+#if 0
/* oprtion check */
if ( opt_cnt*2 != argc-1){
fprintOut(stdout,"Error:The specified argument is abnormal.\n");
return 0;
}
-
+#endif
rc = DrvBootAll();
if (rc != 0) {
@@ -187,7 +239,7 @@ int main(int argc, char *argv[])
FmbCheckAudioFormatAll();
- InitScreens(); //The screen is initialized.
+//sss InitScreens(); //The screen is initialized.
//signal handler is set.
sa.sa_handler = sigint_handler;
@@ -199,17 +251,17 @@ int main(int argc, char *argv[])
rc = sigaction(SIGQUIT, &sa, NULL);
ASSERT_SYS(rc == 0, "sigaction");
- rc = sigaction(SIGILL, &sa, NULL);
- ASSERT_SYS(rc == 0, "sigaction");
+// rc = sigaction(SIGILL, &sa, NULL);
+// ASSERT_SYS(rc == 0, "sigaction");
- rc = sigaction(SIGABRT, &sa, NULL);
- ASSERT_SYS(rc == 0, "sigaction");
+// rc = sigaction(SIGABRT, &sa, NULL);
+// ASSERT_SYS(rc == 0, "sigaction");
- rc = sigaction(SIGFPE, &sa, NULL);
- ASSERT_SYS(rc == 0, "sigaction");
+// rc = sigaction(SIGFPE, &sa, NULL);
+// ASSERT_SYS(rc == 0, "sigaction");
- rc = sigaction(SIGSEGV, &sa, NULL);
- ASSERT_SYS(rc == 0, "sigaction");
+// rc = sigaction(SIGSEGV, &sa, NULL);
+// ASSERT_SYS(rc == 0, "sigaction");
FD_ZERO(&readfds);
FD_SET(STDIN_FILENO, &readfds);
@@ -220,6 +272,26 @@ int main(int argc, char *argv[])
}
FmbSetCurDeviceNum(deviceNumOld);
+ if (output_path[0])
+ strcpy(gp_FmbProperty[FMBEnmFuncModeEnc].outputfile, output_path);
+
+ if (length) {
+ for (devNum = FmbSetFirstDev(); devNum != FMBEnmDevice_NONE; devNum = FmbSetNextDev()) {
+ gp_FmbComProperty->setMode = FMBEnmFuncModeEnc;
+
+ if(! ScrConfSetData(ScrEnmConfEncodingType)){
+ fprintf(stderr, "Setting encoding mode failed\n");
+ return 1;
+ }
+ }
+
+ FmbEnableDevUseAll();
+ FmbMultiCall(FmbReset); //FmbReset();
+ }
+
+ gettimeofday(&tv, NULL);
+ completion = (double)tv.tv_sec + (((double)tv.tv_usec) / 1000000) + length;
+
timeout.tv_sec = 0;
timeout.tv_usec = 100000;
isContinue = TRUE;
@@ -227,11 +299,20 @@ int main(int argc, char *argv[])
memcpy(&rfds, &readfds, sizeof(fd_set));
rc = select(fmbfd + 1, &rfds, NULL, NULL, &timeout);
ASSERT_SYS(rc != -1, "select()");
- if (timeout.tv_usec == 0) { //timeout
+ if (!rc) { //timeout
timeout.tv_sec = 0;
timeout.tv_usec = 100000;
}
-
+ if (length && encode_script == ES_STARTED) {
+ gettimeofday(&tv, NULL);
+ d = (double)tv.tv_sec + (((double)tv.tv_usec) / 1000000);
+ fprintf(stderr, " %d%% \r", (int)(((length - (completion - d)) * 100) / length));
+ if (d > completion) {
+ encode_script++;
+ fprintf(stderr, "ending capture...\n");
+ FmbStop();
+ }
+ }
if (rc == 0) {
continue;
}
@@ -256,6 +337,26 @@ int main(int argc, char *argv[])
FmbSetCurDeviceNum(deviceNumOld);
isContinue &= OnFmbRequestResponse();
}
+ if (length) {
+ switch(encode_script) {
+ case ES_WAIT_RESET_COMPLETION:
+ encode_script++;
+ fprintf(stderr, "Initing encoder...\n");
+ FmbInitEnc();
+ break;
+ case ES_WAIT_INIT_COMPLETION:
+ encode_script++;
+ fprintf(stderr, "Starting capture to %s...\n", gp_FmbProperty[FMBEnmFuncModeEnc].outputfile);
+ FmbStartEnc();
+ break;
+ case ES_DONE:
+ fprintf(stderr, "Completed capture...\n");
+ isContinue = 0;
+ break;
+ default:
+ break;
+ }
+ }
break;
default:
ASSERT_USR(FALSE, "Invalid return value from OnFmbMessage().");
@@ -271,7 +372,7 @@ int main(int argc, char *argv[])
FmbReleaseInfo();
SetScreenMode(ScrEnmModeOriginal);
- fprintOut(stdout, "Bye.\n");
+ fprintOut(stderr, "Bye.\n");
FMB_FUNC(FALSE);
return 0;
diff --git a/fmb_player_apl/src/sce/FmbAp.c b/fmb_player_apl/src/sce/FmbAp.c
index bd0bfac..9a4ff7b 100644
--- a/fmb_player_apl/src/sce/FmbAp.c
+++ b/fmb_player_apl/src/sce/FmbAp.c
@@ -501,8 +501,8 @@ int FmbInit(struct FMBDeviceInfo *p_DevInfo, enum FMBDeviceNumEnum deviceNum)
p_FmbProperty[setmode].videoBitrateProp.videoBitrateVbrPeak = FMB_DEFUALT_BITRATE_VBR_PEAK_ENC;
p_FmbProperty[setmode].videoFmt = FMBEnmVideoFmt1920x1080;
- p_FmbProperty[setmode].videoFrm = FMBEnmVideoFrm_5994i;
- p_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_1920_1080_59i;
+ p_FmbProperty[setmode].videoFrm = FMBEnmVideoFrm_60p;
+ p_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_1920_1080_60p;
p_FmbProperty[setmode].videoScalerEnc = FMBEnmVideoSclEnc_NotUse;
p_FmbProperty[setmode].speedSlow = 0;
p_FmbProperty[setmode].isMute = FALSE;
@@ -524,8 +524,8 @@ int FmbInit(struct FMBDeviceInfo *p_DevInfo, enum FMBDeviceNumEnum deviceNum)
strcat(p_FmbProperty[setmode].inputfile, cDevcienumA);
strcat(p_FmbProperty[setmode].inputfile, FMB_DEFUALT_FILENAME_EXT);
p_FmbProperty[setmode].videoFmt = FMBEnmVideoFmt1920x1080;
- p_FmbProperty[setmode].videoFrm = FMBEnmVideoFrm_5994i;
- p_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_1920_1080_59i;
+ p_FmbProperty[setmode].videoFrm = FMBEnmVideoFrm_60p;
+ p_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_1920_1080_60p;
p_FmbProperty[setmode].speedSlow = 0;
p_FmbProperty[setmode].isMute = FALSE;
diff --git a/fmb_player_apl/src/scr/Screen.c b/fmb_player_apl/src/scr/Screen.c
index 0ab463f..31f2ca5 100644
--- a/fmb_player_apl/src/scr/Screen.c
+++ b/fmb_player_apl/src/scr/Screen.c
@@ -550,6 +550,10 @@ BOOL OnFmbRequestResponse(void)
req = ClrAllLastRequest();
scr = &_screens.screens[_screens.currentScreen[_screens.currentMode]];
+
+ if (scr->OnFmbRequestCompleteFunc == NULL)
+ return TRUE;
+
ASSERT_USR(scr->OnFmbRequestCompleteFunc != NULL, "OnFmbRequestCompleteFunc is NULL.");
LogScrEvent("OnFmbRequestCompleteFunc\t%d\treq\t%d", _screens.currentScreen[_screens.currentMode], req);