2013-07-10 00:45:36 +00:00
|
|
|
/*
|
2015-08-05 15:48:13 -07:00
|
|
|
* Copyright 2012 The WebRTC Project Authors. All rights reserved.
|
2013-07-10 00:45:36 +00:00
|
|
|
*
|
2015-08-05 15:48:13 -07:00
|
|
|
* 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.
|
2013-07-10 00:45:36 +00:00
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef EXAMPLES_PEERCONNECTION_CLIENT_LINUX_MAIN_WND_H_
|
|
|
|
|
#define EXAMPLES_PEERCONNECTION_CLIENT_LINUX_MAIN_WND_H_
|
2015-12-09 14:18:14 -08:00
|
|
|
|
2018-11-28 16:47:49 +01:00
|
|
|
#include <stdint.h>
|
2019-07-05 19:08:33 +02:00
|
|
|
|
2016-05-01 14:53:46 -07:00
|
|
|
#include <memory>
|
2015-12-09 14:18:14 -08:00
|
|
|
#include <string>
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/media_stream_interface.h"
|
2019-01-25 20:26:48 +01:00
|
|
|
#include "api/scoped_refptr.h"
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "api/video/video_frame.h"
|
|
|
|
|
#include "api/video/video_sink_interface.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "examples/peerconnection/client/main_wnd.h"
|
|
|
|
|
#include "examples/peerconnection/client/peer_connection_client.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Forward declarations.
|
|
|
|
|
typedef struct _GtkWidget GtkWidget;
|
|
|
|
|
typedef union _GdkEvent GdkEvent;
|
|
|
|
|
typedef struct _GdkEventKey GdkEventKey;
|
|
|
|
|
typedef struct _GtkTreeView GtkTreeView;
|
|
|
|
|
typedef struct _GtkTreePath GtkTreePath;
|
|
|
|
|
typedef struct _GtkTreeViewColumn GtkTreeViewColumn;
|
2016-12-13 02:57:43 -08:00
|
|
|
typedef struct _cairo cairo_t;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Implements the main UI of the peer connection client.
|
|
|
|
|
// This is functionally equivalent to the MainWnd class in the Windows
|
|
|
|
|
// implementation.
|
|
|
|
|
class GtkMainWnd : public MainWindow {
|
|
|
|
|
public:
|
|
|
|
|
GtkMainWnd(const char* server, int port, bool autoconnect, bool autocall);
|
|
|
|
|
~GtkMainWnd();
|
|
|
|
|
|
|
|
|
|
virtual void RegisterObserver(MainWndCallback* callback);
|
|
|
|
|
virtual bool IsWindow();
|
|
|
|
|
virtual void SwitchToConnectUI();
|
|
|
|
|
virtual void SwitchToPeerList(const Peers& peers);
|
|
|
|
|
virtual void SwitchToStreamingUI();
|
|
|
|
|
virtual void MessageBox(const char* caption, const char* text, bool is_error);
|
|
|
|
|
virtual MainWindow::UI current_ui();
|
|
|
|
|
virtual void StartLocalRenderer(webrtc::VideoTrackInterface* local_video);
|
|
|
|
|
virtual void StopLocalRenderer();
|
|
|
|
|
virtual void StartRemoteRenderer(webrtc::VideoTrackInterface* remote_video);
|
|
|
|
|
virtual void StopRemoteRenderer();
|
|
|
|
|
|
|
|
|
|
virtual void QueueUIThreadCallback(int msg_id, void* data);
|
|
|
|
|
|
|
|
|
|
// Creates and shows the main window with the |Connect UI| enabled.
|
|
|
|
|
bool Create();
|
|
|
|
|
|
|
|
|
|
// Destroys the window. When the window is destroyed, it ends the
|
|
|
|
|
// main message loop.
|
|
|
|
|
bool Destroy();
|
|
|
|
|
|
|
|
|
|
// Callback for when the main window is destroyed.
|
|
|
|
|
void OnDestroyed(GtkWidget* widget, GdkEvent* event);
|
|
|
|
|
|
|
|
|
|
// Callback for when the user clicks the "Connect" button.
|
|
|
|
|
void OnClicked(GtkWidget* widget);
|
|
|
|
|
|
|
|
|
|
// Callback for keystrokes. Used to capture Esc and Return.
|
|
|
|
|
void OnKeyPress(GtkWidget* widget, GdkEventKey* key);
|
|
|
|
|
|
|
|
|
|
// Callback when the user double clicks a peer in order to initiate a
|
|
|
|
|
// connection.
|
|
|
|
|
void OnRowActivated(GtkTreeView* tree_view,
|
|
|
|
|
GtkTreePath* path,
|
|
|
|
|
GtkTreeViewColumn* column);
|
|
|
|
|
|
|
|
|
|
void OnRedraw();
|
|
|
|
|
|
2016-12-13 02:57:43 -08:00
|
|
|
void Draw(GtkWidget* widget, cairo_t* cr);
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
protected:
|
Reland of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #1 id:1 of https://codereview.webrtc.org/2471783002/ )
Reason for revert:
Relanding after known downstream breakages have been fixed.
Original issue's description:
> Revert of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #7 id:120001 of https://codereview.webrtc.org/2383093002/ )
>
> Reason for revert:
> Breaks chrome, see https://build.chromium.org/p/chromium.webrtc.fyi/builders/Mac%20Builder/builds/19019/steps/compile/logs/stdio
>
> Analysis: Chrome uses cricket::VideoFrame, without explicitly including webrtc/media/base/videoframe.h, and breaks when that file is no longer included by any other webrtc headers. Will reland after updating Chrome.
>
> Original issue's description:
> > Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame.
> >
> > Replaced with webrtc::VideoFrame.
> >
> > TBR=mflodman@webrtc.org
> > BUG=webrtc:5682
> >
> > Committed: https://crrev.com/45c8b8940042bd2574c39920804ade8343cefdba
> > Cr-Commit-Position: refs/heads/master@{#14885}
>
> TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5682
>
> Committed: https://crrev.com/7341ab8e2505c9763d208e069bda269018357e7d
> Cr-Commit-Position: refs/heads/master@{#14886}
TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5682
Review-Url: https://codereview.webrtc.org/2487633002
Cr-Commit-Position: refs/heads/master@{#15039}
2016-11-11 03:55:13 -08:00
|
|
|
class VideoRenderer : public rtc::VideoSinkInterface<webrtc::VideoFrame> {
|
2013-07-10 00:45:36 +00:00
|
|
|
public:
|
|
|
|
|
VideoRenderer(GtkMainWnd* main_wnd,
|
|
|
|
|
webrtc::VideoTrackInterface* track_to_render);
|
|
|
|
|
virtual ~VideoRenderer();
|
|
|
|
|
|
2016-03-23 10:33:07 +01:00
|
|
|
// VideoSinkInterface implementation
|
Reland of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #1 id:1 of https://codereview.webrtc.org/2471783002/ )
Reason for revert:
Relanding after known downstream breakages have been fixed.
Original issue's description:
> Revert of Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame. (patchset #7 id:120001 of https://codereview.webrtc.org/2383093002/ )
>
> Reason for revert:
> Breaks chrome, see https://build.chromium.org/p/chromium.webrtc.fyi/builders/Mac%20Builder/builds/19019/steps/compile/logs/stdio
>
> Analysis: Chrome uses cricket::VideoFrame, without explicitly including webrtc/media/base/videoframe.h, and breaks when that file is no longer included by any other webrtc headers. Will reland after updating Chrome.
>
> Original issue's description:
> > Delete all use of cricket::VideoFrame and cricket::WebRtcVideoFrame.
> >
> > Replaced with webrtc::VideoFrame.
> >
> > TBR=mflodman@webrtc.org
> > BUG=webrtc:5682
> >
> > Committed: https://crrev.com/45c8b8940042bd2574c39920804ade8343cefdba
> > Cr-Commit-Position: refs/heads/master@{#14885}
>
> TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5682
>
> Committed: https://crrev.com/7341ab8e2505c9763d208e069bda269018357e7d
> Cr-Commit-Position: refs/heads/master@{#14886}
TBR=perkj@webrtc.org,pthatcher@webrtc.org,tkchin@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5682
Review-Url: https://codereview.webrtc.org/2487633002
Cr-Commit-Position: refs/heads/master@{#15039}
2016-11-11 03:55:13 -08:00
|
|
|
void OnFrame(const webrtc::VideoFrame& frame) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
const uint8_t* image() const { return image_.get(); }
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
int width() const { return width_; }
|
|
|
|
|
|
|
|
|
|
int height() const { return height_; }
|
|
|
|
|
|
|
|
|
|
protected:
|
2016-03-23 10:33:07 +01:00
|
|
|
void SetSize(int width, int height);
|
2016-05-01 14:53:46 -07:00
|
|
|
std::unique_ptr<uint8_t[]> image_;
|
2013-07-10 00:45:36 +00:00
|
|
|
int width_;
|
|
|
|
|
int height_;
|
|
|
|
|
GtkMainWnd* main_wnd_;
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_refptr<webrtc::VideoTrackInterface> rendered_track_;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
GtkWidget* window_; // Our main window.
|
|
|
|
|
GtkWidget* draw_area_; // The drawing surface for rendering video streams.
|
|
|
|
|
GtkWidget* vbox_; // Container for the Connect UI.
|
|
|
|
|
GtkWidget* server_edit_;
|
|
|
|
|
GtkWidget* port_edit_;
|
|
|
|
|
GtkWidget* peer_list_; // The list of peers.
|
|
|
|
|
MainWndCallback* callback_;
|
|
|
|
|
std::string server_;
|
|
|
|
|
std::string port_;
|
|
|
|
|
bool autoconnect_;
|
|
|
|
|
bool autocall_;
|
2016-05-01 14:53:46 -07:00
|
|
|
std::unique_ptr<VideoRenderer> local_renderer_;
|
|
|
|
|
std::unique_ptr<VideoRenderer> remote_renderer_;
|
2016-12-13 02:57:43 -08:00
|
|
|
int width_;
|
|
|
|
|
int height_;
|
2016-05-01 14:53:46 -07:00
|
|
|
std::unique_ptr<uint8_t[]> draw_buffer_;
|
2013-07-10 00:45:36 +00:00
|
|
|
int draw_buffer_size_;
|
|
|
|
|
};
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // EXAMPLES_PEERCONNECTION_CLIENT_LINUX_MAIN_WND_H_
|