Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: talk/examples/peerconnection/client/linux/main_wnd.h

Issue 1235563006: Move talk/examples/* to webrtc/examples. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 201508051337 Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * libjingle
3 * Copyright 2012 Google Inc.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
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.
15 *
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.
26 */
27
28 #ifndef PEERCONNECTION_SAMPLES_CLIENT_LINUX_MAIN_WND_H_
29 #define PEERCONNECTION_SAMPLES_CLIENT_LINUX_MAIN_WND_H_
30
31 #include "talk/examples/peerconnection/client/main_wnd.h"
32 #include "talk/examples/peerconnection/client/peer_connection_client.h"
33
34 // Forward declarations.
35 typedef struct _GtkWidget GtkWidget;
36 typedef union _GdkEvent GdkEvent;
37 typedef struct _GdkEventKey GdkEventKey;
38 typedef struct _GtkTreeView GtkTreeView;
39 typedef struct _GtkTreePath GtkTreePath;
40 typedef struct _GtkTreeViewColumn GtkTreeViewColumn;
41
42 // Implements the main UI of the peer connection client.
43 // This is functionally equivalent to the MainWnd class in the Windows
44 // implementation.
45 class GtkMainWnd : public MainWindow {
46 public:
47 GtkMainWnd(const char* server, int port, bool autoconnect, bool autocall);
48 ~GtkMainWnd();
49
50 virtual void RegisterObserver(MainWndCallback* callback);
51 virtual bool IsWindow();
52 virtual void SwitchToConnectUI();
53 virtual void SwitchToPeerList(const Peers& peers);
54 virtual void SwitchToStreamingUI();
55 virtual void MessageBox(const char* caption, const char* text,
56 bool is_error);
57 virtual MainWindow::UI current_ui();
58 virtual void StartLocalRenderer(webrtc::VideoTrackInterface* local_video);
59 virtual void StopLocalRenderer();
60 virtual void StartRemoteRenderer(webrtc::VideoTrackInterface* remote_video);
61 virtual void StopRemoteRenderer();
62
63 virtual void QueueUIThreadCallback(int msg_id, void* data);
64
65 // Creates and shows the main window with the |Connect UI| enabled.
66 bool Create();
67
68 // Destroys the window. When the window is destroyed, it ends the
69 // main message loop.
70 bool Destroy();
71
72 // Callback for when the main window is destroyed.
73 void OnDestroyed(GtkWidget* widget, GdkEvent* event);
74
75 // Callback for when the user clicks the "Connect" button.
76 void OnClicked(GtkWidget* widget);
77
78 // Callback for keystrokes. Used to capture Esc and Return.
79 void OnKeyPress(GtkWidget* widget, GdkEventKey* key);
80
81 // Callback when the user double clicks a peer in order to initiate a
82 // connection.
83 void OnRowActivated(GtkTreeView* tree_view, GtkTreePath* path,
84 GtkTreeViewColumn* column);
85
86 void OnRedraw();
87
88 protected:
89 class VideoRenderer : public webrtc::VideoRendererInterface {
90 public:
91 VideoRenderer(GtkMainWnd* main_wnd,
92 webrtc::VideoTrackInterface* track_to_render);
93 virtual ~VideoRenderer();
94
95 // VideoRendererInterface implementation
96 virtual void SetSize(int width, int height);
97 virtual void RenderFrame(const cricket::VideoFrame* frame);
98
99 const uint8* image() const {
100 return image_.get();
101 }
102
103 int width() const {
104 return width_;
105 }
106
107 int height() const {
108 return height_;
109 }
110
111 protected:
112 rtc::scoped_ptr<uint8[]> image_;
113 int width_;
114 int height_;
115 GtkMainWnd* main_wnd_;
116 rtc::scoped_refptr<webrtc::VideoTrackInterface> rendered_track_;
117 };
118
119 protected:
120 GtkWidget* window_; // Our main window.
121 GtkWidget* draw_area_; // The drawing surface for rendering video streams.
122 GtkWidget* vbox_; // Container for the Connect UI.
123 GtkWidget* server_edit_;
124 GtkWidget* port_edit_;
125 GtkWidget* peer_list_; // The list of peers.
126 MainWndCallback* callback_;
127 std::string server_;
128 std::string port_;
129 bool autoconnect_;
130 bool autocall_;
131 rtc::scoped_ptr<VideoRenderer> local_renderer_;
132 rtc::scoped_ptr<VideoRenderer> remote_renderer_;
133 rtc::scoped_ptr<uint8> draw_buffer_;
134 int draw_buffer_size_;
135 };
136
137 #endif // PEERCONNECTION_SAMPLES_CLIENT_LINUX_MAIN_WND_H_
OLDNEW
« no previous file with comments | « talk/examples/peerconnection/client/linux/main.cc ('k') | talk/examples/peerconnection/client/linux/main_wnd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698