Renamed platform specific code to use GYP conventions.
Restructured GYP files a bit to clean up things. Removed copying of images to /tmp Fixed output location of DumpFileName.rtp. BUG=None TEST=Tested compiling and running on Mac, Win, Linux. Review URL: https://webrtc-codereview.appspot.com/406002 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1802 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
a368f86ff6
commit
132eccbb69
@ -113,6 +113,13 @@
|
||||
'mac/cocoa_full_screen_window.mm',
|
||||
],
|
||||
}],
|
||||
['OS=="mac"', {
|
||||
'direct_dependent_settings': {
|
||||
'include_dirs': [
|
||||
'mac',
|
||||
],
|
||||
},
|
||||
}],
|
||||
['OS!="win" or include_internal_video_render==0', {
|
||||
'sources!': [
|
||||
'windows/i_video_render_win.h',
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
@ -217,16 +217,6 @@ namespace {
|
||||
}
|
||||
|
||||
#define AutoTestSleep ::Sleep
|
||||
#define VIE_TEST_FILES_ROOT "/sdcard/vie_auto_test/"
|
||||
#else
|
||||
#define VIE_TEST_FILES_ROOT "/tmp/"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
FILE* OpenTestFile(const char* fileName) {
|
||||
char filePath[256];
|
||||
sprintf(filePath, "%s%s", VIE_TEST_FILES_ROOT, fileName);
|
||||
return fopen(filePath, "rb");
|
||||
}
|
||||
}
|
||||
#endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_DEFINES_H_
|
||||
|
@ -459,13 +459,6 @@ void ViEAutoTest::ViECaptureExternalCaptureTest()
|
||||
unsigned char* videoFrame = new unsigned char[videoFrameLength];
|
||||
memset(videoFrame, 128, 176 * 144);
|
||||
|
||||
// TODO: Find a file to use for testing.
|
||||
// FILE* foreman = OpenTestFile("akiyo_qcif.yuv");
|
||||
// if (foreman == NULL)
|
||||
// {
|
||||
// ViETest::Log("Failed to open file akiyo_qcif.yuv");
|
||||
// }
|
||||
|
||||
int frameCount = 0;
|
||||
webrtc::VideoCaptureCapability capability;
|
||||
capability.width = 176;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
@ -8,12 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
/*
|
||||
* vie_autotest_mac_carbon.cc
|
||||
*
|
||||
*/
|
||||
|
||||
#include "engine_configurations.h"
|
||||
#include "engine_configurations.h"
|
||||
|
||||
#if defined(CARBON_RENDERING)
|
||||
#include "vie_autotest_mac_carbon.h"
|
||||
@ -305,7 +300,8 @@ int main(int argc, const char * argv[])
|
||||
|
||||
[NSApplication sharedApplication];
|
||||
|
||||
// we have to run the test in a secondary thread because we need to run a runloop, which blocks
|
||||
// We have to run the test in a secondary thread because we need to run a
|
||||
// runloop, which blocks.
|
||||
if (argc > 1)
|
||||
{
|
||||
AutoTestClass * autoTestClass = [[AutoTestClass alloc]init];
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
@ -8,14 +8,11 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
//
|
||||
// vie_autotest_file.cc
|
||||
//
|
||||
|
||||
#include "vie_autotest_defines.h"
|
||||
#include "vie_autotest.h"
|
||||
#include "engine_configurations.h"
|
||||
|
||||
#include "testsupport/fileutils.h"
|
||||
#include "tb_interfaces.h"
|
||||
#include "tb_capture_device.h"
|
||||
|
||||
@ -149,21 +146,19 @@ void ViEAutoTest::ViEFileStandardTest()
|
||||
const int TEST_SPACING = 1000;
|
||||
const int VIDEO_LENGTH = 5000;
|
||||
|
||||
const std::string root = webrtc::test::ProjectRootPath() +
|
||||
"src/video_engine/test/auto_test/media/";
|
||||
const std::string renderStartImage = root + "renderStartImage.jpg";
|
||||
const std::string captureDeviceImage = root + "captureDeviceImage.jpg";
|
||||
const std::string renderTimeoutFile = root + "renderTimeoutImage.jpg";
|
||||
|
||||
const char renderStartImage[1024] =
|
||||
VIE_TEST_FILES_ROOT "renderStartImage.jpg";
|
||||
const char captureDeviceImage[1024] =
|
||||
VIE_TEST_FILES_ROOT "captureDeviceImage.jpg";
|
||||
const char renderTimeoutFile[1024] =
|
||||
VIE_TEST_FILES_ROOT "renderTimeoutImage.jpg";
|
||||
const char snapshotCaptureDeviceFileName[256] =
|
||||
VIE_TEST_FILES_ROOT "snapshotCaptureDevice.jpg";
|
||||
const char incomingVideo[1024] =
|
||||
VIE_TEST_FILES_ROOT "incomingVideo.avi";
|
||||
const char outgoingVideo[1024] =
|
||||
VIE_TEST_FILES_ROOT "outgoingVideo.avi";
|
||||
char snapshotRenderFileName[256] =
|
||||
VIE_TEST_FILES_ROOT "snapshotRenderer.jpg";
|
||||
const std::string output = webrtc::test::OutputPath();
|
||||
const std::string snapshotCaptureDeviceFileName =
|
||||
output + "snapshotCaptureDevice.jpg";
|
||||
const std::string incomingVideo = output + "incomingVideo.avi";
|
||||
const std::string outgoingVideo = output + "outgoingVideo.avi";
|
||||
const std::string snapshotRenderFileName =
|
||||
output + "snapshotRenderer.jpg";
|
||||
|
||||
webrtc::ViEPicture capturePicture;
|
||||
webrtc::ViEPicture renderPicture;
|
||||
@ -180,7 +175,7 @@ void ViEAutoTest::ViEFileStandardTest()
|
||||
"seconds", VIDEO_LENGTH);
|
||||
|
||||
EXPECT_EQ(0, ptrViEFile->StartRecordIncomingVideo(
|
||||
videoChannel, incomingVideo, webrtc::NO_AUDIO,
|
||||
videoChannel, incomingVideo.c_str(), webrtc::NO_AUDIO,
|
||||
audioCodec2, videoCodec));
|
||||
|
||||
AutoTestSleep(VIDEO_LENGTH);
|
||||
@ -199,15 +194,17 @@ void ViEAutoTest::ViEFileStandardTest()
|
||||
ViETest::Log("Reading video file information");
|
||||
|
||||
EXPECT_EQ(0, ptrViEFile->GetFileInformation(
|
||||
incomingVideo, fileVideoCodec, fileAudioCodec));
|
||||
incomingVideo.c_str(), fileVideoCodec, fileAudioCodec));
|
||||
PrintAudioCodec(fileAudioCodec);
|
||||
PrintVideoCodec(fileVideoCodec);
|
||||
}
|
||||
|
||||
// testing StartPlayFile and RegisterObserver
|
||||
{
|
||||
ViETest::Log("Start playing file: %s with observer", incomingVideo);
|
||||
EXPECT_EQ(0, ptrViEFile->StartPlayFile(incomingVideo, fileId));
|
||||
ViETest::Log("Start playing file: %s with observer",
|
||||
incomingVideo.c_str());
|
||||
EXPECT_EQ(0, ptrViEFile->StartPlayFile(incomingVideo.c_str(),
|
||||
fileId));
|
||||
|
||||
ViETest::Log("Registering file observer");
|
||||
EXPECT_EQ(0, ptrViEFile->RegisterObserver(fileId, fileObserver));
|
||||
@ -250,7 +247,7 @@ void ViEAutoTest::ViEFileStandardTest()
|
||||
ViETest::Log("Recording outgoing video (currently no audio) for %d "
|
||||
"seconds", VIDEO_LENGTH);
|
||||
EXPECT_EQ(0, ptrViEFile->StartRecordOutgoingVideo(
|
||||
videoChannel, outgoingVideo, webrtc::NO_AUDIO,
|
||||
videoChannel, outgoingVideo.c_str(), webrtc::NO_AUDIO,
|
||||
audioCodec2, videoCodec));
|
||||
|
||||
AutoTestSleep(VIDEO_LENGTH);
|
||||
@ -262,7 +259,7 @@ void ViEAutoTest::ViEFileStandardTest()
|
||||
// again testing GetFileInformation
|
||||
{
|
||||
EXPECT_EQ(0, ptrViEFile->GetFileInformation(
|
||||
incomingVideo, videoCodec, audioCodec2));
|
||||
incomingVideo.c_str(), videoCodec, audioCodec2));
|
||||
PrintAudioCodec(audioCodec2);
|
||||
PrintVideoCodec(videoCodec);
|
||||
}
|
||||
@ -299,8 +296,9 @@ void ViEAutoTest::ViEFileStandardTest()
|
||||
|
||||
ViETest::Log("Taking snapshot of videoChannel %d", captureId);
|
||||
EXPECT_EQ(0, ptrViEFile->GetRenderSnapshot(
|
||||
captureId, snapshotRenderFileName));
|
||||
ViETest::Log("Wrote image to file %s", snapshotRenderFileName);
|
||||
captureId, snapshotRenderFileName.c_str()));
|
||||
ViETest::Log("Wrote image to file %s",
|
||||
snapshotRenderFileName.c_str());
|
||||
ViETest::Log("Done\n");
|
||||
AutoTestSleep(TEST_SPACING);
|
||||
}
|
||||
@ -320,9 +318,9 @@ void ViEAutoTest::ViEFileStandardTest()
|
||||
ViETest::Log("Testing GetCaptureDeviceSnapshot(int, char*)");
|
||||
ViETest::Log("Taking snapshot from capture device %d", captureId);
|
||||
EXPECT_EQ(0, ptrViEFile->GetCaptureDeviceSnapshot(
|
||||
captureId, snapshotCaptureDeviceFileName));
|
||||
captureId, snapshotCaptureDeviceFileName.c_str()));
|
||||
ViETest::Log("Wrote image to file %s",
|
||||
snapshotCaptureDeviceFileName);
|
||||
snapshotCaptureDeviceFileName.c_str());
|
||||
ViETest::Log("Done\n");
|
||||
}
|
||||
|
||||
@ -333,7 +331,7 @@ void ViEAutoTest::ViEFileStandardTest()
|
||||
ViETest::Log("Testing SetCaptureDeviceImage(int, char*)");
|
||||
EXPECT_EQ(0, ptrViECapture->StopCapture(captureId));
|
||||
EXPECT_EQ(0, ptrViEFile->SetCaptureDeviceImage(
|
||||
captureId, captureDeviceImage));
|
||||
captureId, captureDeviceImage.c_str()));
|
||||
|
||||
ViETest::Log("you should see the capture device image now");
|
||||
AutoTestSleep(2 * RENDER_TIMEOUT);
|
||||
@ -365,7 +363,7 @@ void ViEAutoTest::ViEFileStandardTest()
|
||||
ViETest::Log("Stoping renderer, setting start image, then "
|
||||
"restarting");
|
||||
EXPECT_EQ(0, ptrViEFile->SetRenderStartImage(
|
||||
videoChannel, renderStartImage));
|
||||
videoChannel, renderStartImage.c_str()));
|
||||
EXPECT_EQ(0, ptrViECapture->StopCapture(captureId));
|
||||
EXPECT_EQ(0, ptrViERender->StopRender(videoChannel));
|
||||
|
||||
@ -409,7 +407,7 @@ void ViEAutoTest::ViEFileStandardTest()
|
||||
ViETest::Log("Stopping capture device to induce timeout of %d ms",
|
||||
RENDER_TIMEOUT);
|
||||
EXPECT_EQ(0, ptrViEFile->SetRenderTimeoutImage(
|
||||
videoChannel, renderTimeoutFile, RENDER_TIMEOUT));
|
||||
videoChannel, renderTimeoutFile.c_str(), RENDER_TIMEOUT));
|
||||
|
||||
// now stop sending frames to the remote renderer and wait for
|
||||
// timeout
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "tb_external_transport.h"
|
||||
#include "tb_interfaces.h"
|
||||
#include "tb_video_channel.h"
|
||||
#include "testsupport/fileutils.h"
|
||||
#include "vie_autotest.h"
|
||||
#include "vie_autotest_defines.h"
|
||||
|
||||
@ -612,7 +613,9 @@ void ViEAutoTest::ViERtpRtcpAPITest()
|
||||
#ifdef WEBRTC_ANDROID
|
||||
const char* dumpName = "/sdcard/DumpFileName.rtp";
|
||||
#else
|
||||
const char* dumpName = "DumpFileName.rtp";
|
||||
std::string output_file = webrtc::test::OutputPath() +
|
||||
"DumpFileName.rtp";
|
||||
const char* dumpName = output_file.c_str();
|
||||
#endif
|
||||
EXPECT_EQ(0, ViE.rtp_rtcp->StartRTPDump(
|
||||
tbChannel.videoChannel, dumpName, webrtc::kRtpIncoming));
|
||||
|
@ -1,214 +1,214 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
//
|
||||
// vie_autotest_windows.cc
|
||||
//
|
||||
|
||||
#include "vie_autotest_windows.h"
|
||||
|
||||
#include "vie_autotest_defines.h"
|
||||
#include "vie_autotest_main.h"
|
||||
|
||||
#include "engine_configurations.h"
|
||||
#include "critical_section_wrapper.h"
|
||||
#include "thread_wrapper.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef _DEBUG
|
||||
//#include "vld.h"
|
||||
#endif
|
||||
|
||||
// Disable Visual studio warnings
|
||||
// 'this' : used in base member initializer list
|
||||
#pragma warning(disable: 4355)
|
||||
// new behavior: elements of array 'XXX' will be default initialized
|
||||
#pragma warning(disable: 4351)
|
||||
|
||||
LRESULT CALLBACK ViEAutoTestWinProc(HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
LPARAM lParam) {
|
||||
switch (uMsg) {
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage( WM_QUIT);
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
break;
|
||||
}
|
||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
ViEAutoTestWindowManager::ViEAutoTestWindowManager()
|
||||
: _window1(NULL),
|
||||
_window2(NULL),
|
||||
_terminate(false),
|
||||
_eventThread(*webrtc::ThreadWrapper::CreateThread(
|
||||
EventProcess, this, webrtc::kNormalPriority,
|
||||
"ViEAutotestEventThread")),
|
||||
_crit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_hwnd1(NULL),
|
||||
_hwnd2(NULL),
|
||||
_hwnd1Size(),
|
||||
_hwnd2Size(),
|
||||
_hwnd1Title(),
|
||||
_hwnd2Title() {
|
||||
}
|
||||
|
||||
ViEAutoTestWindowManager::~ViEAutoTestWindowManager() {
|
||||
if (_hwnd1) {
|
||||
ViEDestroyWindow(_hwnd1);
|
||||
}
|
||||
if (_hwnd2) {
|
||||
ViEDestroyWindow(_hwnd1);
|
||||
}
|
||||
delete &_crit;
|
||||
}
|
||||
|
||||
void* ViEAutoTestWindowManager::GetWindow1() {
|
||||
return _window1;
|
||||
}
|
||||
|
||||
void* ViEAutoTestWindowManager::GetWindow2() {
|
||||
return _window2;
|
||||
}
|
||||
|
||||
int ViEAutoTestWindowManager::CreateWindows(AutoTestRect window1Size,
|
||||
AutoTestRect window2Size,
|
||||
void* window1Title,
|
||||
void* window2Title) {
|
||||
_hwnd1Size.Copy(window1Size);
|
||||
_hwnd2Size.Copy(window2Size);
|
||||
memcpy(_hwnd1Title, window1Title, TITLE_LENGTH);
|
||||
memcpy(_hwnd2Title, window2Title, TITLE_LENGTH);
|
||||
|
||||
unsigned int tId = 0;
|
||||
_eventThread.Start(tId);
|
||||
|
||||
do {
|
||||
_crit.Enter();
|
||||
if (_window1 != NULL) {
|
||||
break;
|
||||
}
|
||||
_crit.Leave();
|
||||
AutoTestSleep(10);
|
||||
} while (true);
|
||||
_crit.Leave();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ViEAutoTestWindowManager::TerminateWindows() {
|
||||
_eventThread.SetNotAlive();
|
||||
|
||||
_terminate = true;
|
||||
if (_eventThread.Stop()) {
|
||||
_crit.Enter();
|
||||
delete &_eventThread;
|
||||
_crit.Leave();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ViEAutoTestWindowManager::EventProcess(void* obj) {
|
||||
return static_cast<ViEAutoTestWindowManager*> (obj)->EventLoop();
|
||||
}
|
||||
|
||||
bool ViEAutoTestWindowManager::EventLoop() {
|
||||
_crit.Enter();
|
||||
|
||||
ViECreateWindow(_hwnd1, _hwnd1Size.origin.x, _hwnd1Size.origin.y,
|
||||
_hwnd1Size.size.width, _hwnd1Size.size.height, _hwnd1Title);
|
||||
ViECreateWindow(_hwnd2, _hwnd2Size.origin.x, _hwnd2Size.origin.y,
|
||||
_hwnd2Size.size.width, _hwnd2Size.size.height, _hwnd2Title);
|
||||
|
||||
_window1 = (void*) _hwnd1;
|
||||
_window2 = (void*) _hwnd2;
|
||||
MSG msg;
|
||||
while (!_terminate) {
|
||||
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
_crit.Leave();
|
||||
AutoTestSleep(10);
|
||||
_crit.Enter();
|
||||
}
|
||||
ViEDestroyWindow(_hwnd1);
|
||||
ViEDestroyWindow(_hwnd2);
|
||||
_crit.Leave();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int ViEAutoTestWindowManager::ViECreateWindow(HWND &hwndMain, int xPos,
|
||||
int yPos, int width, int height,
|
||||
TCHAR* className) {
|
||||
HINSTANCE hinst = GetModuleHandle(0);
|
||||
WNDCLASSEX wcx;
|
||||
wcx.hInstance = hinst;
|
||||
wcx.lpszClassName = className;
|
||||
wcx.lpfnWndProc = (WNDPROC) ViEAutoTestWinProc;
|
||||
wcx.style = CS_DBLCLKS;
|
||||
wcx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||
wcx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
||||
wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wcx.lpszMenuName = NULL;
|
||||
wcx.cbSize = sizeof(WNDCLASSEX);
|
||||
wcx.cbClsExtra = 0;
|
||||
wcx.cbWndExtra = 0;
|
||||
wcx.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
|
||||
|
||||
RegisterClassEx(&wcx);
|
||||
|
||||
// Create the main window.
|
||||
hwndMain = CreateWindowEx(0, // no extended styles
|
||||
className, // class name
|
||||
className, // window name
|
||||
WS_OVERLAPPED | WS_THICKFRAME, // overlapped window
|
||||
xPos, // horizontal position
|
||||
yPos, // vertical position
|
||||
width, // width
|
||||
height, // height
|
||||
(HWND) NULL, // no parent or owner window
|
||||
(HMENU) NULL, // class menu used
|
||||
hinst, // instance handle
|
||||
NULL); // no window creation data
|
||||
|
||||
if (!hwndMain) {
|
||||
int error = GetLastError();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Show the window using the flag specified by the program
|
||||
// that started the application, and send the application
|
||||
// a WM_PAINT message.
|
||||
ShowWindow(hwndMain, SW_SHOWDEFAULT);
|
||||
UpdateWindow(hwndMain);
|
||||
|
||||
::SetWindowPos(hwndMain, HWND_TOP, xPos, yPos, width, height,
|
||||
SWP_FRAMECHANGED);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ViEAutoTestWindowManager::ViEDestroyWindow(HWND& hwnd) {
|
||||
::DestroyWindow(hwnd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ViEAutoTestWindowManager::SetTopmostWindow() {
|
||||
// Meant to put terminal window on top
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
ViEAutoTestMain auto_test;
|
||||
return auto_test.RunTests(argc, argv);
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
//
|
||||
// vie_autotest_windows.cc
|
||||
//
|
||||
|
||||
#include "vie_autotest_windows.h"
|
||||
|
||||
#include "vie_autotest_defines.h"
|
||||
#include "vie_autotest_main.h"
|
||||
|
||||
#include "engine_configurations.h"
|
||||
#include "critical_section_wrapper.h"
|
||||
#include "thread_wrapper.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef _DEBUG
|
||||
//#include "vld.h"
|
||||
#endif
|
||||
|
||||
// Disable Visual studio warnings
|
||||
// 'this' : used in base member initializer list
|
||||
#pragma warning(disable: 4355)
|
||||
// new behavior: elements of array 'XXX' will be default initialized
|
||||
#pragma warning(disable: 4351)
|
||||
|
||||
LRESULT CALLBACK ViEAutoTestWinProc(HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
LPARAM lParam) {
|
||||
switch (uMsg) {
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage( WM_QUIT);
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
break;
|
||||
}
|
||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
ViEAutoTestWindowManager::ViEAutoTestWindowManager()
|
||||
: _window1(NULL),
|
||||
_window2(NULL),
|
||||
_terminate(false),
|
||||
_eventThread(*webrtc::ThreadWrapper::CreateThread(
|
||||
EventProcess, this, webrtc::kNormalPriority,
|
||||
"ViEAutotestEventThread")),
|
||||
_crit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_hwnd1(NULL),
|
||||
_hwnd2(NULL),
|
||||
_hwnd1Size(),
|
||||
_hwnd2Size(),
|
||||
_hwnd1Title(),
|
||||
_hwnd2Title() {
|
||||
}
|
||||
|
||||
ViEAutoTestWindowManager::~ViEAutoTestWindowManager() {
|
||||
if (_hwnd1) {
|
||||
ViEDestroyWindow(_hwnd1);
|
||||
}
|
||||
if (_hwnd2) {
|
||||
ViEDestroyWindow(_hwnd1);
|
||||
}
|
||||
delete &_crit;
|
||||
}
|
||||
|
||||
void* ViEAutoTestWindowManager::GetWindow1() {
|
||||
return _window1;
|
||||
}
|
||||
|
||||
void* ViEAutoTestWindowManager::GetWindow2() {
|
||||
return _window2;
|
||||
}
|
||||
|
||||
int ViEAutoTestWindowManager::CreateWindows(AutoTestRect window1Size,
|
||||
AutoTestRect window2Size,
|
||||
void* window1Title,
|
||||
void* window2Title) {
|
||||
_hwnd1Size.Copy(window1Size);
|
||||
_hwnd2Size.Copy(window2Size);
|
||||
memcpy(_hwnd1Title, window1Title, TITLE_LENGTH);
|
||||
memcpy(_hwnd2Title, window2Title, TITLE_LENGTH);
|
||||
|
||||
unsigned int tId = 0;
|
||||
_eventThread.Start(tId);
|
||||
|
||||
do {
|
||||
_crit.Enter();
|
||||
if (_window1 != NULL) {
|
||||
break;
|
||||
}
|
||||
_crit.Leave();
|
||||
AutoTestSleep(10);
|
||||
} while (true);
|
||||
_crit.Leave();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ViEAutoTestWindowManager::TerminateWindows() {
|
||||
_eventThread.SetNotAlive();
|
||||
|
||||
_terminate = true;
|
||||
if (_eventThread.Stop()) {
|
||||
_crit.Enter();
|
||||
delete &_eventThread;
|
||||
_crit.Leave();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ViEAutoTestWindowManager::EventProcess(void* obj) {
|
||||
return static_cast<ViEAutoTestWindowManager*> (obj)->EventLoop();
|
||||
}
|
||||
|
||||
bool ViEAutoTestWindowManager::EventLoop() {
|
||||
_crit.Enter();
|
||||
|
||||
ViECreateWindow(_hwnd1, _hwnd1Size.origin.x, _hwnd1Size.origin.y,
|
||||
_hwnd1Size.size.width, _hwnd1Size.size.height, _hwnd1Title);
|
||||
ViECreateWindow(_hwnd2, _hwnd2Size.origin.x, _hwnd2Size.origin.y,
|
||||
_hwnd2Size.size.width, _hwnd2Size.size.height, _hwnd2Title);
|
||||
|
||||
_window1 = (void*) _hwnd1;
|
||||
_window2 = (void*) _hwnd2;
|
||||
MSG msg;
|
||||
while (!_terminate) {
|
||||
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
_crit.Leave();
|
||||
AutoTestSleep(10);
|
||||
_crit.Enter();
|
||||
}
|
||||
ViEDestroyWindow(_hwnd1);
|
||||
ViEDestroyWindow(_hwnd2);
|
||||
_crit.Leave();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int ViEAutoTestWindowManager::ViECreateWindow(HWND &hwndMain, int xPos,
|
||||
int yPos, int width, int height,
|
||||
TCHAR* className) {
|
||||
HINSTANCE hinst = GetModuleHandle(0);
|
||||
WNDCLASSEX wcx;
|
||||
wcx.hInstance = hinst;
|
||||
wcx.lpszClassName = className;
|
||||
wcx.lpfnWndProc = (WNDPROC) ViEAutoTestWinProc;
|
||||
wcx.style = CS_DBLCLKS;
|
||||
wcx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||
wcx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
||||
wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wcx.lpszMenuName = NULL;
|
||||
wcx.cbSize = sizeof(WNDCLASSEX);
|
||||
wcx.cbClsExtra = 0;
|
||||
wcx.cbWndExtra = 0;
|
||||
wcx.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
|
||||
|
||||
RegisterClassEx(&wcx);
|
||||
|
||||
// Create the main window.
|
||||
hwndMain = CreateWindowEx(0, // no extended styles
|
||||
className, // class name
|
||||
className, // window name
|
||||
WS_OVERLAPPED | WS_THICKFRAME, // overlapped window
|
||||
xPos, // horizontal position
|
||||
yPos, // vertical position
|
||||
width, // width
|
||||
height, // height
|
||||
(HWND) NULL, // no parent or owner window
|
||||
(HMENU) NULL, // class menu used
|
||||
hinst, // instance handle
|
||||
NULL); // no window creation data
|
||||
|
||||
if (!hwndMain) {
|
||||
int error = GetLastError();
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Show the window using the flag specified by the program
|
||||
// that started the application, and send the application
|
||||
// a WM_PAINT message.
|
||||
ShowWindow(hwndMain, SW_SHOWDEFAULT);
|
||||
UpdateWindow(hwndMain);
|
||||
|
||||
::SetWindowPos(hwndMain, HWND_TOP, xPos, yPos, width, height,
|
||||
SWP_FRAMECHANGED);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ViEAutoTestWindowManager::ViEDestroyWindow(HWND& hwnd) {
|
||||
::DestroyWindow(hwnd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ViEAutoTestWindowManager::SetTopmostWindow() {
|
||||
// Meant to put terminal window on top
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
ViEAutoTestMain auto_test;
|
||||
return auto_test.RunTests(argc, argv);
|
||||
}
|
@ -109,45 +109,14 @@
|
||||
'source/vie_autotest_linux.cc',
|
||||
'source/vie_window_manager_factory_linux.cc',
|
||||
# Mac
|
||||
'source/vie_autotest_mac_cocoa.mm',
|
||||
'source/vie_autotest_mac_carbon.cc',
|
||||
'source/vie_autotest_cocoa_mac.mm',
|
||||
'source/vie_autotest_carbon_mac.cc',
|
||||
'source/vie_window_manager_factory_mac.mm',
|
||||
# Windows
|
||||
'source/vie_autotest_windows.cc',
|
||||
'source/vie_autotest_win.cc',
|
||||
'source/vie_window_manager_factory_win.cc',
|
||||
],
|
||||
'copies': [{
|
||||
'destination': '/tmp',
|
||||
'files': [
|
||||
'media/captureDeviceImage.bmp',
|
||||
'media/captureDeviceImage.jpg',
|
||||
'media/renderStartImage.bmp',
|
||||
'media/renderStartImage.jpg',
|
||||
'media/renderTimeoutImage.bmp',
|
||||
'media/renderTimeoutImage.jpg',
|
||||
],
|
||||
}],
|
||||
'conditions': [
|
||||
# TODO(andrew): rename these to be suffixed with _mac and _win. They
|
||||
# will then be automatically excluded.
|
||||
['OS!="mac"', {
|
||||
'sources!': [
|
||||
'source/vie_autotest_mac_cocoa.cc',
|
||||
'source/vie_autotest_mac_carbon.cc',
|
||||
'source/vie_window_manager_factory_mac.mm',
|
||||
],
|
||||
}],
|
||||
['OS!="win"', {
|
||||
'sources!': [
|
||||
'source/vie_autotest_windows.cc',
|
||||
],
|
||||
}],
|
||||
['OS!="linux"', {
|
||||
'sources!': [
|
||||
'source/vie_window_manager_factory_linux.cc',
|
||||
],
|
||||
}],
|
||||
|
||||
# TODO(andrew): this likely isn't an actual dependency. It should be
|
||||
# included in webrtc.gyp or video_engine.gyp instead.
|
||||
['OS=="win"', {
|
||||
@ -155,18 +124,7 @@
|
||||
'vie_win_test',
|
||||
],
|
||||
}],
|
||||
['OS=="linux"', {
|
||||
# TODO(andrew): these should be provided directly by the projects
|
||||
# which require them instead.
|
||||
'libraries': [
|
||||
'-lXext',
|
||||
'-lX11',
|
||||
],
|
||||
}],
|
||||
['OS=="mac"', {
|
||||
'include_dirs': [
|
||||
'../../../modules/video_render/main/source/mac',
|
||||
],
|
||||
'xcode_settings': {
|
||||
'OTHER_LDFLAGS': [
|
||||
'-framework Foundation -framework AppKit -framework Cocoa -framework OpenGL -framework CoreVideo -framework CoreAudio -framework AudioToolbox',
|
||||
|
Loading…
Reference in New Issue
Block a user