3 * Copyright 2012, Google Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #ifndef PEERCONNECTION_SAMPLES_CLIENT_LINUX_MAIN_WND_H_
30 #define PEERCONNECTION_SAMPLES_CLIENT_LINUX_MAIN_WND_H_
32 #include "talk/examples/peerconnection/client/main_wnd.h"
33 #include "talk/examples/peerconnection/client/peer_connection_client.h"
35 // Forward declarations.
36 typedef struct _GtkWidget GtkWidget;
37 typedef union _GdkEvent GdkEvent;
38 typedef struct _GdkEventKey GdkEventKey;
39 typedef struct _GtkTreeView GtkTreeView;
40 typedef struct _GtkTreePath GtkTreePath;
41 typedef struct _GtkTreeViewColumn GtkTreeViewColumn;
43 // Implements the main UI of the peer connection client.
44 // This is functionally equivalent to the MainWnd class in the Windows
46 class GtkMainWnd : public MainWindow {
48 GtkMainWnd(const char* server, int port, bool autoconnect, bool autocall);
51 virtual void RegisterObserver(MainWndCallback* callback);
52 virtual bool IsWindow();
53 virtual void SwitchToConnectUI();
54 virtual void SwitchToPeerList(const Peers& peers);
55 virtual void SwitchToStreamingUI();
56 virtual void MessageBox(const char* caption, const char* text,
58 virtual MainWindow::UI current_ui();
59 virtual void StartLocalRenderer(webrtc::VideoTrackInterface* local_video);
60 virtual void StopLocalRenderer();
61 virtual void StartRemoteRenderer(webrtc::VideoTrackInterface* remote_video);
62 virtual void StopRemoteRenderer();
64 virtual void QueueUIThreadCallback(int msg_id, void* data);
66 // Creates and shows the main window with the |Connect UI| enabled.
69 // Destroys the window. When the window is destroyed, it ends the
73 // Callback for when the main window is destroyed.
74 void OnDestroyed(GtkWidget* widget, GdkEvent* event);
76 // Callback for when the user clicks the "Connect" button.
77 void OnClicked(GtkWidget* widget);
79 // Callback for keystrokes. Used to capture Esc and Return.
80 void OnKeyPress(GtkWidget* widget, GdkEventKey* key);
82 // Callback when the user double clicks a peer in order to initiate a
84 void OnRowActivated(GtkTreeView* tree_view, GtkTreePath* path,
85 GtkTreeViewColumn* column);
90 class VideoRenderer : public webrtc::VideoRendererInterface {
92 VideoRenderer(GtkMainWnd* main_wnd,
93 webrtc::VideoTrackInterface* track_to_render);
94 virtual ~VideoRenderer();
96 // VideoRendererInterface implementation
97 virtual void SetSize(int width, int height);
98 virtual void RenderFrame(const cricket::VideoFrame* frame);
100 const uint8* image() const {
113 rtc::scoped_ptr<uint8[]> image_;
116 GtkMainWnd* main_wnd_;
117 rtc::scoped_refptr<webrtc::VideoTrackInterface> rendered_track_;
121 GtkWidget* window_; // Our main window.
122 GtkWidget* draw_area_; // The drawing surface for rendering video streams.
123 GtkWidget* vbox_; // Container for the Connect UI.
124 GtkWidget* server_edit_;
125 GtkWidget* port_edit_;
126 GtkWidget* peer_list_; // The list of peers.
127 MainWndCallback* callback_;
132 rtc::scoped_ptr<VideoRenderer> local_renderer_;
133 rtc::scoped_ptr<VideoRenderer> remote_renderer_;
134 rtc::scoped_ptr<uint8> draw_buffer_;
135 int draw_buffer_size_;
138 #endif // PEERCONNECTION_SAMPLES_CLIENT_LINUX_MAIN_WND_H_