Implemented the "-upf" command-line parameter. It allows to forces the user
defined pixel format for the session.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@271 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/rfbplayer/OptionsDialog.h b/rfbplayer/OptionsDialog.h
index a673844..9bf9bbc 100644
--- a/rfbplayer/OptionsDialog.h
+++ b/rfbplayer/OptionsDialog.h
@@ -102,6 +102,7 @@
index = SendMessage(combo, CB_GETCOUNT, 0, 0) - 1;
}
SendMessage(combo, CB_SETCURSEL, index, 0);
+ options->pixelFormatIndex = index - 1;
}
}
return false;
diff --git a/rfbplayer/UserPixelFormatsDialog.h b/rfbplayer/UserPixelFormatsDialog.h
index 72244e9..fe2ad22 100644
--- a/rfbplayer/UserPixelFormatsDialog.h
+++ b/rfbplayer/UserPixelFormatsDialog.h
@@ -52,8 +52,7 @@
if (edit.showDialog(handle)) {
supportedPF->add(format_name, pf);
SendMessage(pfList, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)format_name);
- };
- (*supportedPF)[15];
+ }
}
break;
case IDC_REMOVE_BUTTON:
@@ -74,6 +73,11 @@
case IDC_EDIT_BUTTON:
{
int index = SendMessage(pfList, LB_GETCURSEL, 0, 0);
+ if (index == LB_ERR) {
+ MessageBox(handle, "You must select the pixel format for remove.",
+ "RfbPlayer", MB_OK | MB_ICONWARNING);
+ return false;
+ }
PixelFormat *pf =
&(supportedPF->operator[](index + supportedPF->getDefaultPFCount())->PF);
char *format_name =
@@ -83,7 +87,7 @@
SendMessage(pfList, LB_DELETESTRING, index, 0);
SendMessage(pfList, LB_INSERTSTRING, index, (LPARAM)(LPCTSTR)format_name);
SendMessage(pfList, LB_SETCURSEL, index, 0);
- };
+ }
}
break;
default:
diff --git a/rfbplayer/rfbplayer.cxx b/rfbplayer/rfbplayer.cxx
index 3e9357d..dc19857 100644
--- a/rfbplayer/rfbplayer.cxx
+++ b/rfbplayer/rfbplayer.cxx
@@ -56,6 +56,10 @@
" \t be - big endian byte order.\n"
" \t The r, g, b component is in any order.\n"
" \t Default: auto detect the pixel format.\n"
+ " -upf <name> \t- Forces the user defined pixel format for\n"
+ " \t the session. If <name> is empty then application\n"
+ " \t shows the list of user defined pixel formats.\n"
+ " \t Don't use this option with -pf.\n"
" -speed <value>\t- Sets playback speed, where 1 is normal speed,\n"
" \t is double speed, 0.5 is half speed. Default: 1.0.\n"
" -pos <ms> \t- Sets initial time position in the session file,\n"
@@ -1236,6 +1240,7 @@
// it is used only for run the player with command-line parameters
PlayerOptions playerOptions;
bool print_usage = false;
+bool print_upf_list = false;
bool processParams(int argc, char* argv[]) {
playerOptions.commandLineParam = true;
@@ -1300,6 +1305,23 @@
continue;
}
+ if ((strcasecmp(argv[i], "-upf") == 0) ||
+ (strcasecmp(argv[i], "/upf") == 0) && (i < argc-1)) {
+ if ((i == argc - 1) || (argv[++i][0] == '-')) {
+ print_upf_list = true;
+ return true;
+ }
+ PixelFormatList userPfList;
+ userPfList.readUserDefinedPF(HKEY_CURRENT_USER, UPF_REGISTRY_PATH);
+ int index = userPfList.getIndexByPFName(argv[i]);
+ if (index > 0) {
+ playerOptions.autoDetectPF = false;
+ playerOptions.setPF(&userPfList[index]->PF);
+ } else {
+ return false;
+ }
+ continue;
+ }
if ((strcasecmp(argv[i], "-speed") == 0) ||
(strcasecmp(argv[i], "/speed") == 0) && (i < argc-1)) {
@@ -1353,6 +1375,31 @@
programUsage();
return 0;
}
+ // Show the user defined pixel formats if required
+ if (print_upf_list) {
+ int list_size = 45;
+ char *upf_list = new char[list_size];
+ PixelFormatList userPfList;
+ userPfList.readUserDefinedPF(HKEY_CURRENT_USER, UPF_REGISTRY_PATH);
+ strcpy(upf_list, "The list of the user defined pixel formats:\n");
+ for (int i = userPfList.getDefaultPFCount(); i < userPfList.count(); i++) {
+ if ((list_size - strlen(upf_list) - 1) <
+ (strlen(userPfList[i]->format_name) + 2)) {
+ char *tmpStr = new char[list_size =
+ list_size + strlen(userPfList[i]->format_name) + 2];
+ strcpy(tmpStr, upf_list);
+ delete [] upf_list;
+ upf_list = new char[list_size];
+ strcpy(upf_list, tmpStr);
+ delete [] tmpStr;
+ }
+ strcat(upf_list, userPfList[i]->format_name);
+ strcat(upf_list, "\n");
+ }
+ MessageBox(0, upf_list, "RfbPlayer", MB_OK | MB_ICONINFORMATION);
+ delete [] upf_list;
+ return 0;
+ }
// Create the player
RfbPlayer *player = NULL;