Included modules in webrtc.gyp and fixed build errors.

Removed TODO from webrtc.gyp since it is done.

Tabs -> spaces.

Tabs -> spaces.

Tabs -> spaces.

Fixed compilation on Windows.

Added missing file.

Merge branch 'master' into fix_mac_modules

Fixed compilation errors for the modules.gyp on Mac. This included some pretty large refactorings.

 Please enter the commit message for your changes. Lines starting

BUG=
TEST=

Review URL: http://webrtc-codereview.appspot.com/269005

git-svn-id: http://webrtc.googlecode.com/svn/trunk@957 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
phoglund@webrtc.org 2011-11-16 15:36:44 +00:00
parent af26f64616
commit 337dc68992
17 changed files with 466 additions and 365 deletions

View File

@ -74,21 +74,20 @@
#define SEED_FILE "randseed.txt"
#endif
#ifdef WIN32
#define MY_MAX_DRIVE _MAX_DRIVE
#define MY_MAX_PATH _MAX_PATH
#define MY_MAX_FNAME _MAX_FNAME
#define MY_MAX_EXT _MAX_EXT
#else
#if defined(WEBRTC_LINUX)
#elif defined(WEBRTC_LINUX)
#include <linux/limits.h>
//#define MY_MAX_DRIVE 17 // arbitary number
#define MY_MAX_PATH PATH_MAX
//#define MY_MAX_FNAME NAME_MAX
//#define MY_MAX_EXT 17 // arbitary number
#endif
#endif
#elif defined(WEBRTC_MAC)
#include <sys/syslimits.h>
#define MY_MAX_PATH PATH_MAX
#endif // WEBRTC_MAC
/************/
/* Typedefs */

View File

@ -214,6 +214,7 @@
'../test/testAPI/cocoa_renderer.mm',
'../test/testAPI/testDefines.h',
'../test/testAPI/testAPI.cpp',
'../test/testAPI/testAPI_mac.mm',
'../test/testAPI/testCameraEncoder.cpp',
'../test/testAPI/testCameraEncoder.h',
'../test/testAPI/testExternalCapture.cpp',
@ -224,6 +225,11 @@
'../test/testAPI/Logger.cpp',
'../test/testAPI/Renderer.h',
'../test/testAPI/Renderer.cpp',
'../test/testAPI/renderer_win.cc',
'../test/testAPI/renderer_mac.mm',
'../test/testAPI/renderer_linux.cc',
# Note: renderer_android.cc is deliberately not listed since it
# doesn't build through gyp anyway.
], # source
'conditions': [
# DEFINE PLATFORM SPECIFIC SOURCE FILES

View File

@ -19,227 +19,13 @@
namespace webrtc
{
#if defined _WIN32
#define SLEEP_10_SEC ::Sleep(10000)
#define GET_TIME_IN_MS timeGetTime
LRESULT CALLBACK WinProc( HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch(uMsg)
{
case WM_DESTROY:
break;
case WM_COMMAND:
break;
}
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
int WebRtcCreateWindow(HWND &hwndMain,int winNum, int width, int height)
{
HINSTANCE hinst = GetModuleHandle(0);
WNDCLASSEX wcx;
wcx.hInstance = hinst;
wcx.lpszClassName = _T(" test camera delay");
wcx.lpfnWndProc = (WNDPROC)WinProc;
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);
// Register our window class with the operating system.
// If there is an error, exit program.
if ( !RegisterClassEx (&wcx) )
{
//MessageBox( 0, TEXT("Failed to register window class!"),TEXT("Error!"), MB_OK|MB_ICONERROR ) ;
//return 0;
}
// Create the main window.
hwndMain = CreateWindowEx(
0, // no extended styles
wcx.lpszClassName, // class name
_T("Test Camera Delay"), // window name
WS_OVERLAPPED |WS_THICKFRAME, // overlapped window
0, // horizontal position
0, // 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);
return 0;
}
void SetWindowPos(HWND &hwndMain, int x, int y, int width, int height, bool onTop)
{
/* if(onTop)
{
SetWindowPos(hwndMain,HWND_TOPMOST,x,y,width,height,0);
}
else*/
{
SetWindowPos(hwndMain,HWND_TOP,x,y,width,height,0);
}
}
#elif defined(WEBRTC_MAC_INTEL)
static int _screen = 0;
int WebRtcCreateWindow(CocoaRenderer*& cocoaRenderer,int winNum, int width, int height)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc]init];
_screen = winNum = 0;
// In Cocoa, rendering is not done directly to a window like in Windows and Linux.
// It is rendererd to a Subclass of NSOpenGLView
// create cocoa container window
NSRect outWindowFrame = NSMakeRect(200, 800, width + 20, height + 20);
NSArray* screens = [NSScreen screens];
if(_screen >= [screens count])
{
// requesting screen
return -1;
}
NSScreen* screen = (NSScreen*)[screens objectAtIndex:_screen];
NSWindow* outWindow = [[NSWindow alloc] initWithContentRect:outWindowFrame styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:NO screen:screen];
[outWindow orderOut:nil];
[outWindow setTitle:@"Cocoa Renderer"];
[outWindow setBackgroundColor:[NSColor blueColor]];
[[outWindow contentView] setAutoresizesSubviews:YES];
// // ***** TODO: test screen positioning *****
// // set to the appropriate screen
// NSArray* screens = [NSScreen screens];
// printf("TODO: test positioning to correct screen\n");
// switch(winNum){
// case 0:
// if([screens count] >= 1){
// [outWindow constrainFrameRect:outWindowFrame toScreen:(NSScreen*)[screens objectAtIndex:0]];
// }
// break;
// case 1:
// if([screens count] >= 2){
// [outWindow constrainFrameRect:outWindowFrame toScreen:(NSScreen*)[screens objectAtIndex:1]];
// }
// break;
// case 2:
// if([screens count] >= 3){
// [outWindow constrainFrameRect:outWindowFrame toScreen:(NSScreen*)[screens objectAtIndex:2]];
// }
// break;
// case 3:
// if([screens count] >= 4){
// [outWindow constrainFrameRect:outWindowFrame toScreen:(NSScreen*)[screens objectAtIndex:3]];
// }
// break;
// default:
// break;
//
// }//
// create renderer and attach to window
NSRect cocoaRendererFrame = NSMakeRect(10, 10, width, height);
cocoaRenderer = [[CocoaRenderer alloc] initWithFrame:cocoaRendererFrame];
[[outWindow contentView] addSubview:cocoaRenderer];
// must tell Cocoa to draw the window, but any GUI work must be done on the main thread.
[outWindow performSelector:@selector(display) onThread:[NSThread mainThread] withObject:nil waitUntilDone:YES];
[outWindow makeKeyAndOrderFront:NSApp];
[pool release];
return 0;
}
void SetWindowPos(CocoaRenderer*& cocoaRenderer, int x, int y, int width, int height, bool onTop)
{
NSWindow* ownerWindow = [cocoaRenderer window];
NSRect ownerNewRect = NSMakeRect(x, y, width, height);
[ownerWindow setFrame:ownerNewRect display:YES];
//NSRect cocoaRendererNewRect = {0, 0, 500, 500};
//NSArray* screens = [NSScreen screens];
//NSScreen* screen = (NSScreen*)[screens objectAtIndex:_screen];
//cocoaRendererNewRect = [cocoaRenderer constrainFrameRect:cocoaRendererNewRect toScreen:screen];
//[cocoaRenderer setFrame:cocoaRendererNewRect];
//[cocoaRenderer performSelector:@selector(display) onThread:[NSThread mainThread] withObject:nil waitUntilDone:YES];
//[cocoaRenderer performSelector:@selector(drawRect) onThread:[NSThread mainThread] withObject:cocoaRendererNewRect waitUntilDone:YES];
// *** Setting onTop is toooo on top. Can't get to anything underneath.
// [ownerWindow setLevel:NSNormalWindowLevel];
// if(YES == onTop){
// [ownerWindow setLevel:NSScreenSaverWindowLevel];
// }
// else{
// [ownerWindow setLevel:NSNormalWindowLevel];
// }
}
#elif defined(WEBRTC_ANDROID)
#define nil NULL
#define NO false
jobject Renderer::g_renderWindow=NULL;
int WebRtcCreateWindow(jobject &renderWin,int /*winNum*/, int /*width*/, int /*height*/)
{
renderWin=Renderer::g_renderWindow;
return 0;
}
void SetWindowPos(void *& /*hwndMain*/, int /*x*/, int /*y*/, int /*width*/, int /*height*/, bool /*onTop*/)
{
}
void Renderer::SetRenderWindow(jobject renderWindow)
{
__android_log_print(ANDROID_LOG_DEBUG, "VideoCaptureModule -testAPI", "Renderer::SetRenderWindow");
g_renderWindow=renderWindow;
}
#elif defined(WEBRTC_LINUX)
int WebRtcCreateWindow(HWND &hwndMain,int winNum, int width, int height)
{
return 0;
}
void SetWindowPos(HWND &hwndMain, int x, int y, int width, int height, bool onTop)
{
}
#endif
Renderer::Renderer(bool preview) :
_renderModule(NULL), _quiting(false), _renderWindow(NULL)
{
#ifndef _WIN32
if (-1 == WebRtcCreateWindow(_renderWindow, 0, 352, 288))
if (-1 == WebRtcCreateWindow((void**)(&_renderWindow), 0, 352, 288))
{
printf("ERROR** INVALID SCREEN\n");
}
@ -253,14 +39,9 @@ Renderer::Renderer(bool preview) :
SLEEP(10);
}// Wait until messageThread has created the window
_renderModule = VideoRender::CreateVideoRender(0, (void*) _renderWindow,
false);
#if defined(WEBRTC_MAC_INTEL)
_pool = [[NSAutoreleasePool alloc] init];
#endif
_renderProvider = _renderModule->AddIncomingRenderStream(0, 0, 0.0f, 0.0f,
1.0f, 1.0f);
@ -319,11 +100,7 @@ Renderer::~Renderer(void)
}
_messageThread->Stop();
#if defined(WEBRTC_MAC_INTEL)
[_pool release];
#endif
delete _messageThread;
}
bool Renderer::RenderThread(ThreadObj obj)
@ -333,10 +110,9 @@ bool Renderer::RenderThread(ThreadObj obj)
bool Renderer::RenderThreadProcess()
{
if (_quiting == false && _renderWindow == NULL) // Create the render window
{
WebRtcCreateWindow(_renderWindow, 0, 352, 288);
WebRtcCreateWindow((void**)&_renderWindow, 0, 352, 288);
}
#ifdef _WIN32
@ -384,7 +160,6 @@ void Renderer::RenderFrame(VideoFrame& videoFrame)
void Renderer::PaintBlue()
{
_videoFrame.VerifyAndAllocate(_frameWidth * _frameHeight * 3 / 2);
_videoFrame.SetHeight(_frameHeight);
_videoFrame.SetWidth(_frameWidth);

View File

@ -14,14 +14,11 @@
#include "testDefines.h"
#ifdef _WIN32
#include <windows.h>
#elif defined(WEBRTC_MAC_INTEL)
#import <AppKit/AppKit.h>
//#import "CocoaWindow.h"
#import "cocoa_renderer.h"
#elif defined (WEBRTC_ANDROID)
#include <JNI.h>
#elif defined(WEBRTC_LINUX)
typedef void* HWND;
#endif
@ -31,6 +28,16 @@ typedef void* HWND;
namespace webrtc
{
// Creates a window and fills in the os-specific handle type or pointer
// into os_window_handle. Returns 0 on success.
int WebRtcCreateWindow(void** os_window_handle,
int window_number,
int width, int height);
// Sets the window position in an OS-specific manner.
void SetWindowPos(void* os_window_handle, int x, int y,
int width, int height, bool onTop);
class Renderer
{
public:
@ -63,8 +70,7 @@ private:
#if defined(_WIN32)
HWND _renderWindow;
#elif defined(WEBRTC_MAC_INTEL)
NSAutoreleasePool* _pool;
CocoaRenderer* _renderWindow;
void* _renderWindow;
#elif defined (WEBRTC_ANDROID)
jobject _renderWindow; //this is a glsurface.
public:

View File

@ -0,0 +1,41 @@
/*
* 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.
*/
#include "Renderer.h"
#define nil NULL
#define NO false
namespace webrtc {
jobject Renderer::g_renderWindow = NULL;
int WebRtcCreateWindow(void** os_specific_handle, int /*winNum*/,
int /*width*/, int /*height*/) {
// jobject is a pointer type, hence a pointer to it is a
// pointer-to-pointer, which makes it castable from void**.
jobject* window = (jobject*)os_specific_handle;
*window = Renderer::g_renderWindow;
return 0;
}
void SetWindowPos(void ** /*os_specific_handle*/, int /*x*/, int /*y*/,
int /*width*/, int /*height*/, bool /*onTop*/) {
// Do nothing.
}
void Renderer::SetRenderWindow(jobject renderWindow) {
__android_log_print(ANDROID_LOG_DEBUG,
"VideoCaptureModule -testAPI",
"Renderer::SetRenderWindow");
g_renderWindow=renderWindow;
}
} // namespace webrtc

View File

@ -0,0 +1,25 @@
/*
* 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.
*/
#include "Renderer.h"
namespace webrtc {
int WebRtcCreateWindow(void** os_specific_handle, int winNum,
int width, int height) {
return 0;
}
void SetWindowPos(void** os_specific_handle, int x, int y,
int width, int height, bool onTop) {
// Do nothing.
}
} // namespace webrtc

View File

@ -0,0 +1,80 @@
/*
* 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.
*/
#include "Renderer.h"
#include <stdio.h>
#import <AppKit/AppKit.h>
#import "cocoa_renderer.h"
#include "thread_wrapper.h"
#include "tick_util.h"
static int _screen = 0;
namespace webrtc {
int WebRtcCreateWindow(void** os_specific_handle, int winNum, int width, int height)
{
CocoaRenderer** cocoaRenderer = reinterpret_cast<CocoaRenderer**> (os_specific_handle);
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc]init];
_screen = winNum = 0;
// In Cocoa, rendering is not done directly to a window like in Windows and Linux.
// It is rendererd to a Subclass of NSOpenGLView
// create cocoa container window
NSRect outWindowFrame = NSMakeRect(200, 800, width + 20, height + 20);
NSArray* screens = [NSScreen screens];
if(_screen >= [screens count])
{
// requesting screen
return -1;
}
NSScreen* screen = (NSScreen*)[screens objectAtIndex:_screen];
NSWindow* outWindow = [[NSWindow alloc] initWithContentRect:outWindowFrame
styleMask:NSTitledWindowMask
backing:NSBackingStoreBuffered
defer:NO screen:screen];
[outWindow orderOut:nil];
[outWindow setTitle:@"Cocoa Renderer"];
[outWindow setBackgroundColor:[NSColor blueColor]];
[[outWindow contentView] setAutoresizesSubviews:YES];
// create renderer and attach to window
NSRect cocoaRendererFrame = NSMakeRect(10, 10, width, height);
*cocoaRenderer = [[CocoaRenderer alloc] initWithFrame:cocoaRendererFrame];
[[outWindow contentView] addSubview:*cocoaRenderer];
// must tell Cocoa to draw the window, but any GUI work must be done on the main thread.
[outWindow performSelector:@selector(display)
onThread:[NSThread mainThread]
withObject:nil
waitUntilDone:YES];
[outWindow makeKeyAndOrderFront:NSApp];
[pool release];
return 0;
}
void SetWindowPos(void* os_specific_handle, int x, int y, int width, int height, bool onTop)
{
CocoaRenderer* cocoaRenderer = (CocoaRenderer*)os_specific_handle;
NSWindow* ownerWindow = [cocoaRenderer window];
NSRect ownerNewRect = NSMakeRect(x, y, width, height);
[ownerWindow setFrame:ownerNewRect display:YES];
}
} // namespace webrtc

View File

@ -0,0 +1,95 @@
/*
* 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.
*/
#include "Renderer.h"
#include <stdio.h>
#include <tchar.h>
#include <windows.h>
#include "thread_wrapper.h"
#include "tick_util.h"
#define SLEEP_10_SEC ::Sleep(10000)
#define GET_TIME_IN_MS timeGetTime
LRESULT CALLBACK WinProc( HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch(uMsg)
{
case WM_DESTROY:
break;
case WM_COMMAND:
break;
}
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
namespace webrtc {
int WebRtcCreateWindow(void** os_specific_handle, int winNum, int width, int height)
{
HWND* hwndMain = reinterpret_cast<HWND*> (os_specific_handle); // HWND is a pointer type
HINSTANCE hinst = GetModuleHandle(0);
WNDCLASSEX wcx;
wcx.hInstance = hinst;
wcx.lpszClassName = _T(" test camera delay");
wcx.lpfnWndProc = (WNDPROC)WinProc;
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);
// Register our window class with the operating system.
RegisterClassEx (&wcx);
// Create the main window.
*hwndMain = CreateWindowEx(0, // no extended styles
wcx.lpszClassName, // class name
_T("Test Camera Delay"), // window name
WS_OVERLAPPED |WS_THICKFRAME, // overlapped window
0, // horizontal position
0, // 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);
return 0;
}
void SetWindowPos(void* os_specific_handle, int x, int y, int width, int height, bool onTop)
{
HWND hwndMain = (HWND)os_specific_handle;
// Call the Windows API
SetWindowPos(hwndMain, HWND_TOP, x, y, width, height, 0);
}
} // namespace webrtc

View File

@ -8,6 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "testAPI.h"
#if defined(_WIN32)
#include <tchar.h>
#include <windows.h>
@ -21,15 +23,6 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <sys/time.h>
#elif defined(WEBRTC_MAC_INTEL)
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <AppKit/AppKit.h>
#import <QTKit/QTKit.h>
#import "cocoa_renderer.h"
#include <sys/time.h>
#include <iostream>
#endif
using namespace std;
@ -39,44 +32,33 @@ using namespace std;
#include "testPlatformDependent.h"
#include "testCameraEncoder.h"
void RunApiTest() {
int test_result = 0;
webrtc::testExternalCapture test;
test_result = test.DoTest();
printf("\nExternal capture test result %d\n", test_result);
webrtc::testPlatformDependent platform_dependent;
test_result = platform_dependent.DoTest();
printf("\nPlatform dependent test result %d\n", test_result);
webrtc::testCameraEncoder camera_encoder;
test_result = camera_encoder.DoTest();
printf("\nCamera encoder test result %d\n", test_result);
getchar();
}
// Note: The Mac main is implemented in testApi.mm.
#if defined(_WIN32)
int _tmain(int argc, _TCHAR* argv[])
#elif defined(WEBRTC_LINUX)
int main(int argc, char* argv[])
#elif defined(WEBRTC_MAC_INTEL)
int main (int argc, const char * argv[])
#endif
#endif // WEBRTC LINUX
#if !defined(WEBRTC_MAC)
{
#if defined(WEBRTC_MAC_INTEL)
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];
#endif
int testResult=0;
{
webrtc::testExternalCapture test;
testResult=test.DoTest();
printf("\nExternal capture test result %d\n",testResult);
}
{
webrtc::testPlatformDependent platformDependent;
testResult=platformDependent.DoTest();
printf("\nPlatform dependent test result %d\n",testResult);
}
{
webrtc::testCameraEncoder cameraEncoder;
testResult=cameraEncoder.DoTest();
printf("\nCamera encoder test result %d\n",testResult);
}
getchar();
#if defined (WEBRTC_MAC_INTEL)
[pool release];
#endif
RunApiTest();
return 0;
}
#endif // !WEBRTC_MAC

View File

@ -0,0 +1,18 @@
/*
* 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.
*/
#ifndef WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_TEST_TESTAPI_TESTAPI_H
#define WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_TEST_TESTAPI_TESTAPI_H
// Runs the API test.
void RunApiTest();
#endif // WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_TEST_TESTAPI_TESTAPI_H

View File

@ -0,0 +1,29 @@
/*
* 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.
*/
#include "testAPI.h"
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <AppKit/AppKit.h>
#import <QTKit/QTKit.h>
#import "cocoa_renderer.h"
#include <sys/time.h>
#include <iostream>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];
RunApiTest();
[pool release];
return 0;
}

View File

@ -10,7 +10,6 @@
#pragma once
#include "testDefines.h"
#include "video_capture_factory.h"
#include "Logger.h"
@ -30,7 +29,7 @@ struct CaptureSetting
{
WebRtc_Word32 settingID;
WebRtc_UWord8 captureName[256];
VideoCaptureCapability capability;
VideoCaptureCapability capability;
WebRtc_Word32 captureDelay;
WebRtc_Word64 lastRenderTimeMS;

View File

@ -148,6 +148,7 @@
],
'sources': [
'../test/testAPI/testAPI.cpp',
'../test/testAPI/testAPI_mac.mm',
],
'conditions': [
['OS=="mac" or OS=="linux"', {

View File

@ -8,8 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
// testAPI.cpp : Defines the entry point for the console application.
//
#include "testApi.h"
#include <stdio.h>
@ -30,18 +29,6 @@
#include <X11/Xutil.h>
#include <sys/time.h>
#elif defined(WEBRTC_MAC_INTEL)
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <AppKit/AppKit.h>
#import <QTKit/QTKit.h>
#include <sys/time.h>
#include <iostream>
using namespace std;
@class CocoaRenderView;
#endif
#include "common_types.h"
@ -103,6 +90,8 @@ unsigned long timeGetTime()
#elif defined(WEBRTC_MAC_INTEL)
#include <unistd.h>
#define GET_TIME_IN_MS timeGetTime()
#define SLEEP(x) usleep(x * 1000)
@ -274,31 +263,9 @@ int WebRtcCreateWindow(Window *outWindow, Display **outDisplay, int winNum, int
return 0;
}
#endif // LINUX
#elif defined(WEBRTC_MAC_INTEL) // LINUX
int WebRtcCreateWindow(CocoaRenderView*& cocoaRenderer, int winNum, int width, int height) // unsigned char* title, int titleLength)
{
// In Cocoa, rendering is not done directly to a window like in Windows and Linux.
// It is rendererd to a Subclass of NSOpenGLView
// create cocoa container window
NSRect outWindowFrame = NSMakeRect(200, 800, width + 20, height + 20);
NSWindow* outWindow = [[NSWindow alloc] initWithContentRect:outWindowFrame styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:NO];
[outWindow orderOut:nil];
[outWindow setTitle:@"Cocoa Renderer"];
[outWindow setBackgroundColor:[NSColor blueColor]];
// create renderer and attach to window
NSRect cocoaRendererFrame = NSMakeRect(10, 10, width, height);
cocoaRenderer = [[CocoaRenderView alloc] initWithFrame:cocoaRendererFrame];
[[outWindow contentView] addSubview:cocoaRenderer];
[outWindow makeKeyAndOrderFront:NSApp];
return 0;
}
#endif
// Note: Mac code is in testApi_mac.mm.
class MyRenderCallback: public VideoRenderCallback
{
@ -626,46 +593,13 @@ int TestExternalRender(VideoRender* renderModule) {
return 0;
}
#if defined(_WIN32)
int _tmain(int argc, _TCHAR* argv[])
#elif defined(WEBRTC_LINUX)
int main(int argc, char* argv[])
#elif defined(WEBRTC_MAC_INTEL)
int main (int argc, const char * argv[])
//int begin()
#endif
{
#ifdef WEBRTC_MAC_INTEL
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];
#endif
int myId = 12345;
// Create a window for testing
void* window = NULL;
#if defined (_WIN32)
HWND testHwnd;
WebRtcCreateWindow(testHwnd, 0, 352, 288);
window = (void*)testHwnd;
VideoRenderType windowType = kRenderWindows;
#elif defined(WEBRTC_LINUX)
Window testWindow;
Display* display;
WebRtcCreateWindow(&testWindow, &display, 0, 352, 288);
VideoRenderType windowType = kRenderX11;
window = (void*)testWindow;
#elif defined(WEBRTC_MAC_INTEL)
CocoaRenderView* testWindow;
WebRtcCreateWindow(testWindow, 0, 352, 288);
VideoRenderType windowType = kRenderCocoa;
window = (void*)testWindow;
#endif
void RunVideoRenderTests(void* window, VideoRenderType windowType) {
#ifndef WEBRTC_INCLUDE_INTERNAL_VIDEO_RENDER
windowType = kRenderExternal;
#endif
int myId = 12345;
// Create the render module
printf("Create render module\n");
VideoRender* renderModule = NULL;
@ -710,9 +644,32 @@ int main (int argc, const char * argv[])
renderModule = NULL;
printf("VideoRender unit tests passed.\n");
}
#if defined(WEBRTC_MAC_INTEL)
[pool release];
// Note: The Mac main is implemented in testApi_mac.mm.
#if defined(_WIN32)
int _tmain(int argc, _TCHAR* argv[])
#elif defined(WEBRTC_LINUX)
int main(int argc, char* argv[])
#endif
#if !defined(WEBRTC_MAC)
{
// Create a window for testing.
void* window = NULL;
#if defined (_WIN32)
HWND testHwnd;
WebRtcCreateWindow(testHwnd, 0, 352, 288);
window = (void*)testHwnd;
VideoRenderType windowType = kRenderWindows;
#elif defined(WEBRTC_LINUX)
Window testWindow;
Display* display;
WebRtcCreateWindow(&testWindow, &display, 0, 352, 288);
VideoRenderType windowType = kRenderX11;
window = (void*)testWindow;
#endif // WEBRTC_LINUX
RunVideoRenderTests(window, windowType);
return 0;
}
#endif // !WEBRTC_MAC

View File

@ -0,0 +1,71 @@
/*
* 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.
*/
#include "testApi.h"
#include <iostream>
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <AppKit/AppKit.h>
#import <QTKit/QTKit.h>
#include <sys/time.h>
using namespace std;
@class CocoaRenderView;
#include "common_types.h"
#include "module_common_types.h"
#include "process_thread.h"
#include "tick_util.h"
#include "trace.h"
#include "video_render_defines.h"
#include "video_render.h"
using namespace webrtc;
int WebRtcCreateWindow(CocoaRenderView*& cocoaRenderer, int winNum, int width, int height)
{
// In Cocoa, rendering is not done directly to a window like in Windows and Linux.
// It is rendererd to a Subclass of NSOpenGLView
// create cocoa container window
NSRect outWindowFrame = NSMakeRect(200, 800, width + 20, height + 20);
NSWindow* outWindow = [[NSWindow alloc] initWithContentRect:outWindowFrame
styleMask:NSTitledWindowMask
backing:NSBackingStoreBuffered
defer:NO];
[outWindow orderOut:nil];
[outWindow setTitle:@"Cocoa Renderer"];
[outWindow setBackgroundColor:[NSColor blueColor]];
// create renderer and attach to window
NSRect cocoaRendererFrame = NSMakeRect(10, 10, width, height);
cocoaRenderer = [[CocoaRenderView alloc] initWithFrame:cocoaRendererFrame];
[[outWindow contentView] addSubview:cocoaRenderer];
[outWindow makeKeyAndOrderFront:NSApp];
return 0;
}
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];
CocoaRenderView* testWindow;
WebRtcCreateWindow(testWindow, 0, 352, 288);
VideoRenderType windowType = kRenderCocoa;
void* window = (void*)testWindow;
RunVideoRenderTests(window, windowType);
[pool release];
}

View File

@ -0,0 +1,18 @@
/*
* 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.
*/
#ifndef WEBRTC_MODULES_VIDEO_RENDER_MAIN_TEST_TESTAPI_TESTAPI_H
#define WEBRTC_MODULES_VIDEO_RENDER_MAIN_TEST_TESTAPI_TESTAPI_H
#include "video_render_defines.h"
void RunVideoRenderTests(void* window, webrtc::VideoRenderType windowType);
#endif // WEBRTC_MODULES_VIDEO_RENDER_MAIN_TEST_TESTAPI_TESTAPI_H

View File

@ -17,8 +17,7 @@
'dependencies': [
'src/common_audio/common_audio.gyp:*',
'src/common_video/common_video.gyp:*',
# TODO(andrew): enable this when all tests build.
#'src/modules/modules.gyp:*',
'src/modules/modules.gyp:*',
'src/system_wrappers/source/system_wrappers.gyp:*',
'src/video_engine/video_engine.gyp:*',
'src/voice_engine/voice_engine.gyp:*',