Home | History | Annotate | Download | only in testAPI
      1 /*
      2  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 #include "testAPI.h"
     12 
     13 #include <iostream>
     14 
     15 #import <Foundation/Foundation.h>
     16 #import <Cocoa/Cocoa.h>
     17 #import <AppKit/AppKit.h>
     18 #import <QTKit/QTKit.h>
     19 #include <sys/time.h>
     20 
     21 #import "webrtc/modules/video_render/mac/cocoa_render_view.h"
     22 #include "webrtc/common_types.h"
     23 #include "webrtc/modules/interface/module_common_types.h"
     24 #include "webrtc/modules/utility/interface/process_thread.h"
     25 #include "webrtc/modules/video_render/include/video_render.h"
     26 #include "webrtc/modules/video_render/include/video_render_defines.h"
     27 #include "webrtc/system_wrappers/interface/tick_util.h"
     28 #include "webrtc/system_wrappers/interface/trace.h"
     29 
     30 using namespace webrtc;
     31 
     32 int WebRtcCreateWindow(CocoaRenderView*& cocoaRenderer, int winNum, int width, int height)
     33 {
     34     // In Cocoa, rendering is not done directly to a window like in Windows and Linux.
     35     // It is rendererd to a Subclass of NSOpenGLView
     36 
     37     // create cocoa container window
     38     NSRect outWindowFrame = NSMakeRect(200, 800, width + 20, height + 20);
     39     NSWindow* outWindow = [[NSWindow alloc] initWithContentRect:outWindowFrame
     40                                                       styleMask:NSTitledWindowMask
     41                                                         backing:NSBackingStoreBuffered
     42                                                           defer:NO];
     43     [outWindow orderOut:nil];
     44     [outWindow setTitle:@"Cocoa Renderer"];
     45     [outWindow setBackgroundColor:[NSColor blueColor]];
     46 
     47     // create renderer and attach to window
     48     NSRect cocoaRendererFrame = NSMakeRect(10, 10, width, height);
     49     cocoaRenderer = [[CocoaRenderView alloc] initWithFrame:cocoaRendererFrame];
     50     [[outWindow contentView] addSubview:(NSView*)cocoaRenderer];
     51 
     52     [outWindow makeKeyAndOrderFront:NSApp];
     53 
     54     return 0;
     55 }
     56 
     57 int main (int argc, const char * argv[]) {
     58     NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
     59     [NSApplication sharedApplication];
     60 
     61     CocoaRenderView* testWindow;
     62     WebRtcCreateWindow(testWindow, 0, 352, 288);
     63     VideoRenderType windowType = kRenderCocoa;
     64     void* window = (void*)testWindow;
     65 
     66     RunVideoRenderTests(window, windowType);
     67 
     68     [pool release];
     69 }
     70