Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 Savoir-Faire Linux Inc. |
| 3 | * Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
| 19 | * Additional permission under GNU GPL version 3 section 7: |
| 20 | * |
| 21 | * If you modify this program, or any covered work, by linking or |
| 22 | * combining it with the OpenSSL project's OpenSSL library (or a |
| 23 | * modified version of that library), containing parts covered by the |
| 24 | * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. |
| 25 | * grants you additional permission to convey the resulting work. |
| 26 | * Corresponding Source for a non-source form of such a combination |
| 27 | * shall include the source code for the parts of OpenSSL used as well |
| 28 | * as that of the covered work. |
| 29 | */ |
| 30 | |
| 31 | #include "currentcallview.h" |
| 32 | |
| 33 | #include <gtk/gtk.h> |
| 34 | #include <call.h> |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 35 | #include <callmodel.h> |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 36 | #include "utils/drawing.h" |
| 37 | #include "video/video_widget.h" |
Stepan Salenikovich | 4ac89f1 | 2015-03-10 16:48:47 -0400 | [diff] [blame] | 38 | #include <video/previewmanager.h> |
Stepan Salenikovich | 6f68707 | 2015-03-26 10:43:37 -0400 | [diff] [blame^] | 39 | #include <contactmethod.h> |
| 40 | #include <person.h> |
| 41 | #include "delegates/pixbufdelegate.h" |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 42 | |
| 43 | struct _CurrentCallView |
| 44 | { |
| 45 | GtkBox parent; |
| 46 | }; |
| 47 | |
| 48 | struct _CurrentCallViewClass |
| 49 | { |
| 50 | GtkBoxClass parent_class; |
| 51 | }; |
| 52 | |
| 53 | typedef struct _CurrentCallViewPrivate CurrentCallViewPrivate; |
| 54 | |
| 55 | struct _CurrentCallViewPrivate |
| 56 | { |
| 57 | GtkWidget *image_peer; |
| 58 | GtkWidget *label_identity; |
| 59 | GtkWidget *label_status; |
| 60 | GtkWidget *label_duration; |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 61 | GtkWidget *frame_video; |
| 62 | GtkWidget *video_widget; |
Stepan Salenikovich | 4ac89f1 | 2015-03-10 16:48:47 -0400 | [diff] [blame] | 63 | GtkWidget *button_hangup; |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 64 | |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 65 | /* new renderers should be put into the queue for processing by a g_idle |
| 66 | * functions whose id should be saved into renderer_idle_source; |
| 67 | * this way when the CurrentCallView object is destroyed, we do not try |
| 68 | * to process any new renderers by stoping the g_idle function. |
| 69 | */ |
| 70 | guint renderer_idle_source; |
| 71 | GAsyncQueue *new_renderer_queue; |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 72 | |
| 73 | QMetaObject::Connection state_change_connection; |
| 74 | QMetaObject::Connection call_details_connection; |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 75 | QMetaObject::Connection local_renderer_connection; |
| 76 | QMetaObject::Connection remote_renderer_connection; |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | G_DEFINE_TYPE_WITH_PRIVATE(CurrentCallView, current_call_view, GTK_TYPE_BOX); |
| 80 | |
| 81 | #define CURRENT_CALL_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CURRENT_CALL_VIEW_TYPE, CurrentCallViewPrivate)) |
| 82 | |
| 83 | static void |
| 84 | current_call_view_dispose(GObject *object) |
| 85 | { |
| 86 | CurrentCallView *view; |
| 87 | CurrentCallViewPrivate *priv; |
| 88 | |
| 89 | view = CURRENT_CALL_VIEW(object); |
| 90 | priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 91 | |
| 92 | QObject::disconnect(priv->state_change_connection); |
| 93 | QObject::disconnect(priv->call_details_connection); |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 94 | QObject::disconnect(priv->local_renderer_connection); |
| 95 | QObject::disconnect(priv->remote_renderer_connection); |
| 96 | |
| 97 | /* dispose may be called multiple times, make sure |
| 98 | * not to call g_source_remove more than once */ |
| 99 | if (priv->renderer_idle_source) { |
| 100 | g_source_remove(priv->renderer_idle_source); |
| 101 | priv->renderer_idle_source = 0; |
| 102 | } |
| 103 | |
| 104 | if (priv->new_renderer_queue) { |
| 105 | g_async_queue_unref(priv->new_renderer_queue); |
| 106 | priv->new_renderer_queue = NULL; |
| 107 | } |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 108 | |
| 109 | G_OBJECT_CLASS(current_call_view_parent_class)->dispose(object); |
| 110 | } |
| 111 | |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 112 | static gboolean |
| 113 | check_renderer_queue(CurrentCallView *self) |
| 114 | { |
| 115 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), FALSE); |
| 116 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
| 117 | |
| 118 | /* get all the renderers in the queue */ |
| 119 | gpointer new_video_renderer = g_async_queue_try_pop(priv->new_renderer_queue); |
| 120 | while (new_video_renderer) { |
| 121 | video_widget_add_renderer(VIDEO_WIDGET(priv->video_widget), (const VideoRenderer *)new_video_renderer); |
| 122 | g_free(new_video_renderer); |
| 123 | new_video_renderer = g_async_queue_try_pop(priv->new_renderer_queue); |
| 124 | } |
| 125 | |
| 126 | return TRUE; /* keep going */ |
| 127 | } |
| 128 | |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 129 | static void |
| 130 | current_call_view_init(CurrentCallView *view) |
| 131 | { |
| 132 | gtk_widget_init_template(GTK_WIDGET(view)); |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 133 | |
| 134 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 135 | |
| 136 | /* init new renderer queue */ |
| 137 | priv->new_renderer_queue = g_async_queue_new_full((GDestroyNotify)g_free); |
Stepan Salenikovich | 213fd91 | 2015-03-26 15:07:57 -0400 | [diff] [blame] | 138 | /* check new render every 30 ms (30ms is "fast enough"); |
| 139 | * we don't use an idle function so it doesn't consume cpu needlessly */ |
| 140 | priv->renderer_idle_source = g_timeout_add_full( |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 141 | G_PRIORITY_DEFAULT_IDLE, |
Stepan Salenikovich | 213fd91 | 2015-03-26 15:07:57 -0400 | [diff] [blame] | 142 | 30, |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 143 | (GSourceFunc)check_renderer_queue, |
| 144 | view, |
| 145 | NULL); |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | static void |
| 149 | current_call_view_class_init(CurrentCallViewClass *klass) |
| 150 | { |
| 151 | G_OBJECT_CLASS(klass)->dispose = current_call_view_dispose; |
| 152 | |
| 153 | gtk_widget_class_set_template_from_resource(GTK_WIDGET_CLASS (klass), |
| 154 | "/cx/ring/RingGnome/currentcallview.ui"); |
| 155 | |
| 156 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, image_peer); |
| 157 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_identity); |
| 158 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_status); |
| 159 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, label_duration); |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 160 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, frame_video); |
Stepan Salenikovich | 4ac89f1 | 2015-03-10 16:48:47 -0400 | [diff] [blame] | 161 | gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), CurrentCallView, button_hangup); |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | GtkWidget * |
| 165 | current_call_view_new(void) |
| 166 | { |
| 167 | return (GtkWidget *)g_object_new(CURRENT_CALL_VIEW_TYPE, NULL); |
| 168 | } |
| 169 | |
| 170 | static void |
| 171 | update_state(CurrentCallView *view, Call *call) |
| 172 | { |
| 173 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 174 | |
| 175 | /* change state label */ |
| 176 | Call::State state = call->state(); |
| 177 | |
| 178 | switch(state) { |
Stepan Salenikovich | 46e3e99 | 2015-04-08 11:42:13 -0400 | [diff] [blame] | 179 | case Call::State::NEW: |
| 180 | gtk_label_set_text(GTK_LABEL(priv->label_status), "New."); |
| 181 | break; |
| 182 | case Call::State::ABORTED: |
| 183 | gtk_label_set_text(GTK_LABEL(priv->label_status), "Aborted."); |
| 184 | break; |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 185 | case Call::State::INCOMING: |
| 186 | gtk_label_set_text(GTK_LABEL(priv->label_status), "Incoming..."); |
| 187 | break; |
| 188 | case Call::State::RINGING: |
| 189 | gtk_label_set_text(GTK_LABEL(priv->label_status), "Ringing..."); |
| 190 | break; |
| 191 | case Call::State::CURRENT: |
| 192 | /* note: shouldn't be displayed, as the view should change */ |
| 193 | gtk_label_set_text(GTK_LABEL(priv->label_status), "In progress."); |
| 194 | break; |
| 195 | case Call::State::DIALING: |
| 196 | gtk_label_set_text(GTK_LABEL(priv->label_status), "Dialing..."); |
| 197 | break; |
| 198 | case Call::State::HOLD: |
| 199 | /* note: shouldn't be displayed, as the view should change */ |
| 200 | gtk_label_set_text(GTK_LABEL(priv->label_status), "On hold."); |
| 201 | break; |
| 202 | case Call::State::FAILURE: |
| 203 | gtk_label_set_text(GTK_LABEL(priv->label_status), "Failed."); |
| 204 | break; |
| 205 | case Call::State::BUSY: |
| 206 | gtk_label_set_text(GTK_LABEL(priv->label_status), "Busy."); |
| 207 | break; |
| 208 | case Call::State::TRANSFERRED: |
| 209 | /* note: shouldn't be displayed, as the view should change */ |
| 210 | gtk_label_set_text(GTK_LABEL(priv->label_status), "Transfered."); |
| 211 | break; |
| 212 | case Call::State::TRANSF_HOLD: |
| 213 | /* note: shouldn't be displayed, as the view should change */ |
| 214 | gtk_label_set_text(GTK_LABEL(priv->label_status), "Transfer hold."); |
| 215 | break; |
| 216 | case Call::State::OVER: |
| 217 | /* note: shouldn't be displayed, as the view should change */ |
| 218 | gtk_label_set_text(GTK_LABEL(priv->label_status), "Over."); |
| 219 | break; |
| 220 | case Call::State::ERROR: |
| 221 | gtk_label_set_text(GTK_LABEL(priv->label_status), "Error."); |
| 222 | break; |
| 223 | case Call::State::CONFERENCE: |
| 224 | /* note: shouldn't be displayed, as the view should change */ |
| 225 | gtk_label_set_text(GTK_LABEL(priv->label_status), "Conference."); |
| 226 | break; |
| 227 | case Call::State::CONFERENCE_HOLD: |
| 228 | /* note: shouldn't be displayed, as the view should change */ |
| 229 | gtk_label_set_text(GTK_LABEL(priv->label_status), "Conference hold."); |
| 230 | break; |
| 231 | case Call::State::INITIALIZATION: |
| 232 | gtk_label_set_text(GTK_LABEL(priv->label_status), "Initialization..."); |
| 233 | break; |
| 234 | case Call::State::COUNT__: |
| 235 | break; |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | static void |
| 240 | update_details(CurrentCallView *view, Call *call) |
| 241 | { |
| 242 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 243 | |
| 244 | /* update call duration */ |
| 245 | QByteArray ba_length = call->length().toLocal8Bit(); |
| 246 | gtk_label_set_text(GTK_LABEL(priv->label_duration), ba_length.constData()); |
| 247 | } |
| 248 | |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 249 | static void |
| 250 | push_new_renderer(CurrentCallView *self, Video::Renderer *renderer, VideoRendererType type) |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 251 | { |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 252 | g_return_if_fail(IS_CURRENT_CALL_VIEW(self)); |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 253 | |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 254 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 255 | |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 256 | VideoRenderer *new_video_renderer = g_new0(VideoRenderer, 1); |
| 257 | new_video_renderer->renderer = renderer; |
| 258 | new_video_renderer->type = type; |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 259 | |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 260 | g_async_queue_push(priv->new_renderer_queue, new_video_renderer); |
Stepan Salenikovich | 8e5c9d0 | 2015-03-11 14:07:10 -0400 | [diff] [blame] | 261 | } |
| 262 | |
Stepan Salenikovich | bfe9ac6 | 2015-03-11 12:49:20 -0400 | [diff] [blame] | 263 | static void |
| 264 | fullscreen_destroy(CurrentCallView *view) |
| 265 | { |
| 266 | g_return_if_fail(IS_CURRENT_CALL_VIEW(view)); |
| 267 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 268 | |
| 269 | /* check if the video widgets parent is the the fullscreen window */ |
| 270 | GtkWidget *parent = gtk_widget_get_parent(priv->video_widget); |
| 271 | if (parent != NULL && parent != priv->frame_video) { |
| 272 | /* put the videw widget back in the call view */ |
| 273 | g_object_ref(priv->video_widget); |
| 274 | gtk_container_remove(GTK_CONTAINER(parent), priv->video_widget); |
| 275 | gtk_container_add(GTK_CONTAINER(priv->frame_video), priv->video_widget); |
| 276 | g_object_unref(priv->video_widget); |
| 277 | /* destroy the fullscreen window */ |
| 278 | gtk_widget_destroy(parent); |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | static gboolean |
| 283 | fullscreen_handle_keys(GtkWidget *self, GdkEventKey *event, G_GNUC_UNUSED gpointer user_data) |
| 284 | { |
| 285 | if (event->keyval == GDK_KEY_Escape) |
| 286 | gtk_widget_destroy(self); |
| 287 | |
| 288 | /* the event has been fully handled */ |
| 289 | return TRUE; |
| 290 | } |
| 291 | |
| 292 | static gboolean |
| 293 | on_button_press_in_video_event(GtkWidget *self, GdkEventButton *event, CurrentCallView *view) |
| 294 | { |
| 295 | g_return_val_if_fail(IS_VIDEO_WIDGET(self), FALSE); |
| 296 | g_return_val_if_fail(IS_CURRENT_CALL_VIEW(view), FALSE); |
| 297 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 298 | |
| 299 | /* on double click */ |
| 300 | if (event->type == GDK_2BUTTON_PRESS) { |
| 301 | |
| 302 | /* get the parent to check if its in fullscreen window or not */ |
| 303 | GtkWidget *parent = gtk_widget_get_parent(GTK_WIDGET(self)); |
| 304 | if (parent == priv->frame_video){ |
| 305 | /* not fullscreen, so put it in a separate widget and make it so */ |
| 306 | GtkWidget *fullscreen_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
| 307 | gtk_window_set_decorated(GTK_WINDOW(fullscreen_window), FALSE); |
| 308 | gtk_window_set_transient_for(GTK_WINDOW(fullscreen_window), |
| 309 | GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(view)))); |
| 310 | g_object_ref(self); |
| 311 | gtk_container_remove(GTK_CONTAINER(priv->frame_video), self); |
| 312 | gtk_container_add(GTK_CONTAINER(fullscreen_window), self); |
| 313 | g_object_unref(self); |
| 314 | /* connect signals to make sure we can un-fullscreen */ |
| 315 | g_signal_connect_swapped(fullscreen_window, "destroy", G_CALLBACK(fullscreen_destroy), view); |
| 316 | g_signal_connect(view, "destroy", G_CALLBACK(fullscreen_destroy), NULL); |
| 317 | g_signal_connect(fullscreen_window, "key_press_event", G_CALLBACK(fullscreen_handle_keys), NULL); |
| 318 | /* present the fullscreen widnow */ |
| 319 | gtk_window_present(GTK_WINDOW(fullscreen_window)); |
| 320 | gtk_window_fullscreen(GTK_WINDOW(fullscreen_window)); |
| 321 | } else { |
| 322 | /* put it back in the call view */ |
| 323 | fullscreen_destroy(view); |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | /* the event has been fully handled */ |
| 328 | return TRUE; |
| 329 | } |
| 330 | |
| 331 | |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 332 | void |
| 333 | current_call_view_set_call_info(CurrentCallView *view, const QModelIndex& idx) { |
| 334 | CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(view); |
| 335 | |
Stepan Salenikovich | 6f68707 | 2015-03-26 10:43:37 -0400 | [diff] [blame^] | 336 | Call *call = CallModel::instance()->getCall(idx); |
| 337 | |
| 338 | /* get call image */ |
| 339 | QVariant var_i = PixbufDelegate::instance()->callPhoto(call, QSize(60, 60), false); |
| 340 | std::shared_ptr<GdkPixbuf> image = var_i.value<std::shared_ptr<GdkPixbuf>>(); |
| 341 | gtk_image_set_from_pixbuf(GTK_IMAGE(priv->image_peer), image.get()); |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 342 | |
| 343 | /* get name */ |
Stepan Salenikovich | 9c1f668 | 2015-03-09 16:21:28 -0400 | [diff] [blame] | 344 | QVariant var = idx.model()->data(idx, static_cast<int>(Call::Role::Name)); |
Stepan Salenikovich | 6f68707 | 2015-03-26 10:43:37 -0400 | [diff] [blame^] | 345 | QByteArray ba_name = var.toString().toUtf8(); |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 346 | gtk_label_set_text(GTK_LABEL(priv->label_identity), ba_name.constData()); |
| 347 | |
| 348 | /* change some things depending on call state */ |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 349 | update_state(view, call); |
| 350 | update_details(view, call); |
| 351 | |
| 352 | priv->state_change_connection = QObject::connect( |
| 353 | call, |
| 354 | &Call::stateChanged, |
| 355 | [=]() { update_state(view, call); } |
| 356 | ); |
| 357 | |
| 358 | priv->call_details_connection = QObject::connect( |
| 359 | call, |
| 360 | static_cast<void (Call::*)(void)>(&Call::changed), |
| 361 | [=]() { update_details(view, call); } |
| 362 | ); |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 363 | |
| 364 | /* video widget */ |
| 365 | priv->video_widget = video_widget_new(); |
| 366 | gtk_container_add(GTK_CONTAINER(priv->frame_video), priv->video_widget); |
| 367 | gtk_widget_show_all(priv->frame_video); |
| 368 | |
| 369 | /* check if we already have a renderer */ |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 370 | push_new_renderer(view, call->videoRenderer(), VIDEO_RENDERER_REMOTE); |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 371 | |
Stepan Salenikovich | 8e5c9d0 | 2015-03-11 14:07:10 -0400 | [diff] [blame] | 372 | /* callback for remote renderer */ |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 373 | priv->remote_renderer_connection = QObject::connect( |
Stepan Salenikovich | 9c1f668 | 2015-03-09 16:21:28 -0400 | [diff] [blame] | 374 | call, |
| 375 | &Call::videoStarted, |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 376 | [=](Video::Renderer *renderer) { |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 377 | push_new_renderer(view, renderer, VIDEO_RENDERER_REMOTE); |
Stepan Salenikovich | 36c025c | 2015-03-03 19:06:44 -0500 | [diff] [blame] | 378 | } |
| 379 | ); |
Stepan Salenikovich | 4ac89f1 | 2015-03-10 16:48:47 -0400 | [diff] [blame] | 380 | |
Stepan Salenikovich | 8e5c9d0 | 2015-03-11 14:07:10 -0400 | [diff] [blame] | 381 | /* local renderer */ |
Stepan Salenikovich | 5705880 | 2015-03-25 14:16:13 -0400 | [diff] [blame] | 382 | if (Video::PreviewManager::instance()->isPreviewing()) |
| 383 | push_new_renderer(view, Video::PreviewManager::instance()->previewRenderer(), VIDEO_RENDERER_LOCAL); |
Stepan Salenikovich | 8e5c9d0 | 2015-03-11 14:07:10 -0400 | [diff] [blame] | 384 | |
| 385 | /* callback for local renderer */ |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 386 | priv->local_renderer_connection = QObject::connect( |
Stepan Salenikovich | 8e5c9d0 | 2015-03-11 14:07:10 -0400 | [diff] [blame] | 387 | Video::PreviewManager::instance(), |
| 388 | &Video::PreviewManager::previewStarted, |
| 389 | [=](Video::Renderer *renderer) { |
Stepan Salenikovich | c5f0815 | 2015-03-19 00:53:23 -0400 | [diff] [blame] | 390 | push_new_renderer(view, renderer, VIDEO_RENDERER_LOCAL); |
Stepan Salenikovich | 8e5c9d0 | 2015-03-11 14:07:10 -0400 | [diff] [blame] | 391 | } |
| 392 | ); |
Stepan Salenikovich | bfe9ac6 | 2015-03-11 12:49:20 -0400 | [diff] [blame] | 393 | |
| 394 | /* catch double click to make full screen */ |
| 395 | g_signal_connect(priv->video_widget, "button-press-event", |
| 396 | G_CALLBACK(on_button_press_in_video_event), |
| 397 | view); |
Stepan Salenikovich | c64523b | 2015-02-27 16:31:00 -0500 | [diff] [blame] | 398 | } |