Example #1
0
static void
byzanz_session_constructed (GObject *object)
{
  ByzanzSession *session = BYZANZ_SESSION (object);
  GOutputStream *stream;

  session->recorder = byzanz_recorder_new (session->window, &session->area);
  g_signal_connect (session->recorder, "notify::recording", 
      G_CALLBACK (byzanz_session_recorder_notify_cb), session);
  g_signal_connect (session->recorder, "image", 
      G_CALLBACK (byzanz_session_recorder_image_cb), session);

  /* FIXME: make async */
  stream = G_OUTPUT_STREAM (g_file_replace (session->file, NULL, 
        FALSE, G_FILE_CREATE_REPLACE_DESTINATION, session->cancellable, &session->error));
  if (stream != NULL) {
    session->encoder = byzanz_encoder_new (session->encoder_type, 
        byzanz_queue_get_input_stream (session->queue),
        stream, session->record_audio, session->cancellable);
    g_signal_connect (session->encoder, "notify", 
        G_CALLBACK (byzanz_session_encoder_notify_cb), session);
    g_object_unref (stream);
    if (byzanz_encoder_get_error (session->encoder))
      byzanz_session_set_error (session, byzanz_encoder_get_error (session->encoder));
  }
  byzanz_serialize_header (byzanz_queue_get_output_stream (session->queue),
      session->area.width, session->area.height, session->cancellable, &session->error);

  if (G_OBJECT_CLASS (byzanz_session_parent_class)->constructed)
    G_OBJECT_CLASS (byzanz_session_parent_class)->constructed (object);
}
Example #2
0
static void
encoder_notify (ByzanzEncoder *encoder, GParamSpec *pspec, GMainLoop *loop)
{
  const GError *error;

  error = byzanz_encoder_get_error (encoder);
  if (error) {
    g_print ("%s\n", error->message);
    g_main_loop_quit (loop);
  } else if (!byzanz_encoder_is_running (encoder)) {
    g_main_loop_quit (loop);
  }
}
Example #3
0
static void
byzanz_session_encoder_notify_cb (ByzanzEncoder * encoder,
                                  GParamSpec *    pspec,
                                  ByzanzSession * session)
{
  if (g_str_equal (pspec->name, "running")) {
    g_object_notify (G_OBJECT (session), "encoding");
  } else if (g_str_equal (pspec->name, "error")) {
    const GError *error = byzanz_encoder_get_error (encoder);

    /* Delete the file, it's broken after all. Don't throw errors if it fails though. */
    g_file_delete (session->file, NULL, NULL);

    /* Cancellation is not an error, it's been requested via _abort() */
    if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
      byzanz_session_set_error (session, error);
  }
}