1// libjingle
2// Copyright 2010 Google Inc.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are met:
6//
7//  1. Redistributions of source code must retain the above copyright notice,
8//     this list of conditions and the following disclaimer.
9//  2. Redistributions in binary form must reproduce the above copyright notice,
10//     this list of conditions and the following disclaimer in the documentation
11//     and/or other materials provided with the distribution.
12//  3. The name of the author may not be used to endorse or promote products
13//     derived from this software without specific prior written permission.
14//
15// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
16// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
18// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25//
26// A factory to create a GUI video renderer.
27
28#ifndef TALK_MEDIA_DEVICES_VIDEORENDERERFACTORY_H_
29#define TALK_MEDIA_DEVICES_VIDEORENDERERFACTORY_H_
30
31#include "talk/media/base/videorenderer.h"
32#if defined(LINUX) && defined(HAVE_GTK)
33#include "talk/media/devices/gtkvideorenderer.h"
34#elif defined(OSX) && !defined(CARBON_DEPRECATED)
35#include "talk/media/devices/carbonvideorenderer.h"
36#elif defined(WIN32)
37#include "talk/media/devices/gdivideorenderer.h"
38#endif
39
40namespace cricket {
41
42class VideoRendererFactory {
43 public:
44  static VideoRenderer* CreateGuiVideoRenderer(int x, int y) {
45  #if defined(LINUX) && defined(HAVE_GTK)
46    return new GtkVideoRenderer(x, y);
47  #elif defined(OSX) && !defined(CARBON_DEPRECATED)
48    CarbonVideoRenderer* renderer = new CarbonVideoRenderer(x, y);
49    // Needs to be initialized on the main thread.
50    if (renderer->Initialize()) {
51      return renderer;
52    } else {
53      delete renderer;
54      return NULL;
55    }
56  #elif defined(WIN32)
57    return new GdiVideoRenderer(x, y);
58  #else
59    return NULL;
60  #endif
61  }
62};
63
64}  // namespace cricket
65
66#endif  // TALK_MEDIA_DEVICES_VIDEORENDERERFACTORY_H_
67