summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorfbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-10 20:23:28 +0000
committerfbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-10 20:23:28 +0000
commit87182226a17a5f5cd69f8b783a38d704f3b9bf63 (patch)
tree0a0944467884a162d222fd66c13f6b20bd8982cd /media
parent4692966bece55451e05a794ae064f3a3d16e2aa2 (diff)
downloadchromium_src-87182226a17a5f5cd69f8b783a38d704f3b9bf63.zip
chromium_src-87182226a17a5f5cd69f8b783a38d704f3b9bf63.tar.gz
chromium_src-87182226a17a5f5cd69f8b783a38d704f3b9bf63.tar.bz2
MediaPlayer command line parser and -exit option, so a video can be played and then the player exits.
This will be useful for testing and gathering metrics. Test code has been added (but disabled) to time the full execution of the tool, so that pipeline latency can be measured and compared to Chrome. Review URL: http://codereview.chromium.org/123011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22948 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/player/mainfrm.h6
-rw-r--r--media/player/player_wtl.cc64
2 files changed, 60 insertions, 10 deletions
diff --git a/media/player/mainfrm.h b/media/player/mainfrm.h
index 0ff9e46..b20b172 100644
--- a/media/player/mainfrm.h
+++ b/media/player/mainfrm.h
@@ -140,7 +140,7 @@ class CMainFrame : public CFrameWindowImpl<CMainFrame>,
UpdateLayout();
}
- void UpdateTitleBar(wchar_t* lpstrTitle) {
+ void UpdateTitleBar(const wchar_t* lpstrTitle) {
CString strDefault;
strDefault.LoadString(IDR_MAINFRAME);
CString strTitle = strDefault;
@@ -409,13 +409,13 @@ class CMainFrame : public CFrameWindowImpl<CMainFrame>,
PostMessage(WM_CLOSE);
}
- bool IsMovie(wchar_t* file_name) {
+ bool IsMovie(const wchar_t* file_name) {
if (_tcsstr(file_name, L".bmp"))
return false;
return true;
}
- bool MovieOpenFile(wchar_t* file_name) {
+ bool MovieOpenFile(const wchar_t* file_name) {
bool success = false;
if (m_bPrintPreview)
diff --git a/media/player/player_wtl.cc b/media/player/player_wtl.cc
index 3b78cdb..0b31c21 100644
--- a/media/player/player_wtl.cc
+++ b/media/player/player_wtl.cc
@@ -23,8 +23,15 @@
#include <atlprint.h> // NOLINT
#include <atlscrl.h> // NOLINT
-// Note these headers are order sensitive.
#include "base/at_exit.h"
+#include "base/basictypes.h"
+#include "base/command_line.h"
+#include "base/file_path.h"
+#include "base/logging.h"
+#include "base/string_util.h"
+#include "base/time.h"
+
+// Note these headers are order sensitive.
#include "media/base/factory.h"
#include "media/base/pipeline_impl.h"
#include "media/player/movie.h"
@@ -43,11 +50,42 @@
#include "media/filters/ffmpeg_video_decoder.h"
#include "media/filters/file_data_source.h"
+// Enable timing code by turning on TESTING macro.
+// #define TESTING 1
+
+#ifdef TESTING
+#define _CRT_SECURE_NO_WARNINGS
+#include <windows.h> // NOLINT
+#include <stdio.h> // NOLINT
+#include <process.h> // NOLINT
+#include <string.h> // NOLINT
+
+// Fetch current time as milliseconds.
+// Return as double for high duration and precision.
+static inline double GetTime() {
+ LARGE_INTEGER perf_time, perf_hz;
+ QueryPerformanceFrequency(&perf_hz); // May change with speed step.
+ QueryPerformanceCounter(&perf_time);
+ return perf_time.QuadPart * 1000.0 / perf_hz.QuadPart; // Convert to ms.
+}
+#endif
+
+namespace switches {
+const wchar_t kExit[] = L"exit";
+} // namespace switches
+
+
CAppModule g_module;
-int Run(wchar_t* cmd_line, int cmd_show) {
+int Run(wchar_t* win_cmd_line, int cmd_show) {
base::AtExitManager exit_manager;
+ // Windows version of Init uses OS to fetch command line.
+ CommandLine::Init(0, NULL);
+ const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
+
+ std::vector<std::wstring> filenames(cmd_line->GetLooseValues());
+
CMessageLoop the_loop;
g_module.AddMessageLoop(&the_loop);
@@ -59,13 +97,13 @@ int Run(wchar_t* cmd_line, int cmd_show) {
wnd_main.ShowWindow(cmd_show);
- wchar_t* url = NULL;
- if (cmd_line && *cmd_line) {
- url = cmd_line;
+ if (!filenames.empty()) {
+ const wchar_t* url = filenames[0].c_str();
+ wnd_main.MovieOpenFile(url);
}
- if (url) {
- wnd_main.MovieOpenFile(url);
+ if (cmd_line->HasSwitch(switches::kExit)) {
+ wnd_main.OnOptionsExit(0, 0, 0);
}
int result = the_loop.Run();
@@ -78,6 +116,9 @@ int Run(wchar_t* cmd_line, int cmd_show) {
int WINAPI _tWinMain(HINSTANCE instance, HINSTANCE /*previous_instance*/,
wchar_t* cmd_line, int cmd_show) {
+#ifdef TESTING
+ double player_time_start = GetTime();
+#endif
INITCOMMONCONTROLSEX iccx;
iccx.dwSize = sizeof(iccx);
iccx.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES;
@@ -92,6 +133,15 @@ int WINAPI _tWinMain(HINSTANCE instance, HINSTANCE /*previous_instance*/,
int result = Run(cmd_line, cmd_show);
g_module.Term();
+#ifdef TESTING
+ double player_time_end = GetTime();
+ char outputbuf[512];
+ _snprintf_s(outputbuf, sizeof(outputbuf),
+ "player time %5.2f ms\n",
+ player_time_end - player_time_start);
+ OutputDebugStringA(outputbuf);
+ printf("%s", outputbuf);
+#endif
return result;
}