Esempio n. 1
0
gboolean
gst_switch_server_set_composite_mode (GstSwitchServer * srv, gint mode)
{
  gboolean result = FALSE;

  GST_SWITCH_SERVER_LOCK_PIP (srv);

  if (mode == srv->composite->mode) {
    WARN ("ignore the same composite mode %d", mode);
    goto end;
  }

  g_object_set (srv->composite, "mode", mode, NULL);

  result = (mode == srv->composite->mode);

  if (result) {
    srv->pip_x = srv->composite->b_x;
    srv->pip_y = srv->composite->b_y;
    srv->pip_w = srv->composite->b_width;
    srv->pip_h = srv->composite->b_height;
  }

 end:
  GST_SWITCH_SERVER_UNLOCK_PIP (srv);
  return result;
}
Esempio n. 2
0
guint
gst_switch_server_adjust_pip (GstSwitchServer * srv,
    gint dx, gint dy, gint dw, gint dh)
{
  guint result = 0;

  g_return_val_if_fail (GST_IS_COMPOSITE (srv->composite), 0);

  GST_SWITCH_SERVER_LOCK_PIP (srv);

  srv->pip_x += dx, srv->pip_y += dy;
  srv->pip_w += dw, srv->pip_h += dh;
  if (srv->pip_x < 0) srv->pip_x = 0;
  if (srv->pip_y < 0) srv->pip_y = 0;
  if (srv->pip_w < GST_SWITCH_COMPOSITE_MIN_PIP_W)
    srv->pip_w   = GST_SWITCH_COMPOSITE_MIN_PIP_W;
  if (srv->pip_h < GST_SWITCH_COMPOSITE_MIN_PIP_H)
    srv->pip_h   = GST_SWITCH_COMPOSITE_MIN_PIP_H;

  result = gst_composite_adjust_pip (srv->composite,
      srv->pip_x, srv->pip_y, srv->pip_w, srv->pip_h);

  if (dx != 0) result |= (1 << 0);
  if (dy != 0) result |= (1 << 1);
  if (dw != 0) result |= (1 << 2);
  if (dh != 0) result |= (1 << 3);

  GST_SWITCH_SERVER_UNLOCK_PIP (srv);
  return result;
}
Esempio n. 3
0
/**
 * gst_switch_server_prepare_composite:
 * @return TRUE if the composite worker is prepared.
 *
 * Preparing the composite worker.
 */
static gboolean
gst_switch_server_prepare_composite (GstSwitchServer * srv,
    GstCompositeMode mode)
{
  gint port, encode;

  if (srv->composite) {
    return TRUE;
  }

  port = gst_switch_server_alloc_port (srv);
  encode = gst_switch_server_alloc_port (srv);

  INFO ("Compose sink to %d, %d", port, encode);

  g_assert (srv->composite == NULL);
  srv->composite = GST_COMPOSITE (g_object_new (GST_TYPE_COMPOSITE,
          "name", "composite", "port",
          port, "encode", encode, "mode", mode, NULL));

  g_signal_connect (srv->composite, "start-worker",
      G_CALLBACK (gst_switch_server_worker_start), srv);
  g_signal_connect (srv->composite, "worker-null",
      G_CALLBACK (gst_switch_server_worker_null), srv);

  /*
     g_signal_connect (srv->composite, "start-output",
     G_CALLBACK (gst_switch_server_start_output), srv);
     g_signal_connect (srv->composite, "start-recorder",
     G_CALLBACK (gst_switch_server_start_recorder), srv);
   */
  g_signal_connect (srv->composite, "end-transition",
      G_CALLBACK (gst_switch_server_end_transition), srv);

  GST_SWITCH_SERVER_LOCK_PIP (srv);
  srv->pip_x = srv->composite->b_x;
  srv->pip_y = srv->composite->b_y;
  srv->pip_w = srv->composite->b_width;
  srv->pip_h = srv->composite->b_height;
  GST_SWITCH_SERVER_UNLOCK_PIP (srv);

  if (!gst_worker_start (GST_WORKER (srv->composite)))
    goto error_start_composite;

  return TRUE;

error_start_composite:
  {
    g_object_unref (srv->composite);
    srv->composite = NULL;
    return FALSE;
  }
}