[byzanz] rename: ByzanzRecorder => ByzanzSession
- From: Benjamin Otte <otte src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [byzanz] rename: ByzanzRecorder => ByzanzSession
- Date: Wed, 26 Aug 2009 10:21:32 +0000 (UTC)
commit c39ebf46e1eb5a3aceef4d1baf04ece7a8962a19
Author: Benjamin Otte <otte gnome org>
Date: Wed Aug 19 15:17:21 2009 +0200
rename: ByzanzRecorder => ByzanzSession
The object maintains a full recording session. The recorder should be
the object that takes screenshots and allows you to encode them.
src/Makefile.am | 4 +-
src/byzanzapplet.c | 30 ++--
src/byzanzselect.c | 2 +-
src/{byzanzrecorder.c => byzanzsession.c} | 248 ++++++++++++++--------------
src/{byzanzrecorder.h => byzanzsession.h} | 22 ++--
src/record.c | 26 ++--
6 files changed, 166 insertions(+), 166 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index d1ddf30..44a02e9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,14 +4,14 @@ libexec_PROGRAMS = byzanz-applet
man_MANS = byzanz-record.1
noinst_HEADERS = \
- byzanzrecorder.h \
+ byzanzsession.h \
byzanzselect.h \
paneldropdown.h \
paneltogglebutton.h \
screenshot-utils.h
libbyzanz_la_SOURCES = \
- byzanzrecorder.c \
+ byzanzsession.c \
byzanzselect.c
libbyzanz_la_CFLAGS = $(BYZANZ_CFLAGS) -I$(top_srcdir)/gifenc
diff --git a/src/byzanzapplet.c b/src/byzanzapplet.c
index 0501e55..37c2768 100644
--- a/src/byzanzapplet.c
+++ b/src/byzanzapplet.c
@@ -1,4 +1,4 @@
-/* desktop recorder
+/* desktop session
* Copyright (C) 2005,2009 Benjamin Otte <otte gnome org>
*
* This library is free software; you can redistribute it and/or
@@ -27,7 +27,7 @@
#include <gio/gio.h>
#include <glib/gstdio.h>
#include <panel-applet-gconf.h>
-#include "byzanzrecorder.h"
+#include "byzanzsession.h"
#include "byzanzselect.h"
#include "paneltogglebutton.h"
#include "paneldropdown.h"
@@ -45,7 +45,7 @@ typedef struct {
GtkWidget * record_cursor; /* checkmenuitem for cursor recording */
GtkTooltips * tooltips; /* our tooltips */
- ByzanzRecorder * rec; /* the recorder (if recording) */
+ ByzanzSession * rec; /* the session (if recording) */
char * tmp_file; /* filename that's recorded to */
GTimeVal start; /* time the recording started */
@@ -58,7 +58,7 @@ typedef struct {
typedef struct {
AppletPrivate * priv;
- ByzanzRecorder * rec;
+ ByzanzSession * rec;
GFile * source;
GFile * destination;
GCancellable * cancellable;
@@ -120,9 +120,9 @@ check_done_saving_cb (gpointer data)
{
PendingRecording *pending = data;
- if (byzanz_recorder_is_active (pending->rec))
+ if (byzanz_session_is_active (pending->rec))
return TRUE;
- byzanz_recorder_destroy (pending->rec);
+ byzanz_session_destroy (pending->rec);
pending->rec = NULL;
if (pending->destination == NULL) {
@@ -153,7 +153,7 @@ pending_recording_response (GtkWidget *dialog, int response, PendingRecording *p
}
static void
-pending_recording_launch (AppletPrivate *priv, ByzanzRecorder *rec, const char *tmp_file)
+pending_recording_launch (AppletPrivate *priv, ByzanzSession *rec, const char *tmp_file)
{
PendingRecording *pending;
GtkWidget *dialog;
@@ -232,9 +232,9 @@ byzanz_applet_start_recording (AppletPrivate *priv)
if (byzanz_applet_is_recording (priv))
goto out;
if (priv->rec) {
- if (byzanz_recorder_is_active (priv->rec))
+ if (byzanz_session_is_active (priv->rec))
goto out;
- byzanz_recorder_destroy (priv->rec);
+ byzanz_session_destroy (priv->rec);
priv->rec = NULL;
}
/* check for correct bpp */
@@ -247,7 +247,7 @@ byzanz_applet_start_recording (AppletPrivate *priv)
if (window) {
int fd = g_file_open_tmp ("byzanzXXXXXX", &priv->tmp_file, NULL);
if (fd > 0)
- priv->rec = byzanz_recorder_new_fd (fd, window, &area, TRUE,
+ priv->rec = byzanz_session_new_fd (fd, window, &area, TRUE,
gtk_check_menu_item_get_active (
GTK_CHECK_MENU_ITEM (priv->record_cursor)));
if (!priv->rec) {
@@ -259,8 +259,8 @@ byzanz_applet_start_recording (AppletPrivate *priv)
g_object_unref (window);
}
if (priv->rec) {
- byzanz_recorder_prepare (priv->rec);
- byzanz_recorder_start (priv->rec);
+ byzanz_session_prepare (priv->rec);
+ byzanz_session_start (priv->rec);
g_get_current_time (&priv->start);
}
@@ -272,11 +272,11 @@ static void
byzanz_applet_stop_recording (AppletPrivate *priv)
{
char *tmp_file;
- ByzanzRecorder *rec;
+ ByzanzSession *rec;
g_assert (byzanz_applet_is_recording (priv));
- byzanz_recorder_stop (priv->rec);
+ byzanz_session_stop (priv->rec);
tmp_file = priv->tmp_file;
priv->tmp_file = NULL;
rec = priv->rec;
@@ -346,7 +346,7 @@ byzanz_about_cb (BonoboUIComponent *uic, AppletPrivate *priv, const char *verb)
};
gtk_show_about_dialog( NULL,
- "name", _("Desktop Recorder"),
+ "name", _("Desktop Session"),
"version", VERSION,
"copyright", "\xC2\xA9 2005-2006 Benjamin Otte",
"comments", _("Record what's happening on your desktop"),
diff --git a/src/byzanzselect.c b/src/byzanzselect.c
index 5411581..f4840c5 100644
--- a/src/byzanzselect.c
+++ b/src/byzanzselect.c
@@ -226,7 +226,7 @@ byzanz_select_area (GdkRectangle *rect)
rect->width = MAX (data->x1, data->x0) - rect->x;
rect->height = MAX (data->y1, data->y0) - rect->y;
ret = gdk_get_default_root_window ();
- /* stupid hack to get around a recorder recording the selection screen */
+ /* stupid hack to get around a session recording the selection screen */
gdk_display_sync (gdk_display_get_default ());
g_timeout_add (1000, quit_cb, data);
g_main_loop_run (data->loop);
diff --git a/src/byzanzrecorder.c b/src/byzanzsession.c
similarity index 81%
rename from src/byzanzrecorder.c
rename to src/byzanzsession.c
index df70e47..c4bbbf2 100644
--- a/src/byzanzrecorder.c
+++ b/src/byzanzsession.c
@@ -21,7 +21,7 @@
# include "config.h"
#endif
-#include "byzanzrecorder.h"
+#include "byzanzsession.h"
#include <string.h>
#include <sys/types.h>
@@ -52,7 +52,7 @@ typedef enum {
RECORDER_STATE_PREPARED,
RECORDER_STATE_RECORDING,
RECORDER_STATE_STOPPED
-} RecorderState;
+} SessionState;
typedef enum {
RECORDER_JOB_QUIT,
@@ -60,18 +60,18 @@ typedef enum {
RECORDER_JOB_QUANTIZE,
RECORDER_JOB_ENCODE,
RECORDER_JOB_USE_FILE_CACHE,
-} RecorderJobType;
+} SessionJobType;
-typedef gboolean (* DitherRegionGetDataFunc) (ByzanzRecorder *rec,
+typedef gboolean (* DitherRegionGetDataFunc) (ByzanzSession *rec,
gpointer data, GdkRectangle *rect,
gpointer *data_out, guint *bpl_out);
typedef struct {
- RecorderJobType type; /* type of job */
+ SessionJobType type; /* type of job */
GTimeVal tv; /* time this job was enqueued */
cairo_surface_t * image; /* image to process */
GdkRegion * region; /* relevant region of image */
-} RecorderJob;
+} SessionJob;
typedef struct {
GdkRegion * region; /* the region this image represents */
@@ -81,7 +81,7 @@ typedef struct {
off_t offset; /* offset at which the data starts */
} StoredImage;
-struct _ByzanzRecorder {
+struct _ByzanzSession {
/*< private >*/
/* set by user - accessed ALSO by thread */
GdkRectangle area; /* area of the screen we record */
@@ -92,7 +92,7 @@ struct _ByzanzRecorder {
gint max_file_cache; /* maximum allowed size of all cache files together - ATOMIC */
/* state */
guint cache_size; /* current cache size */
- RecorderState state; /* state the recorder is in */
+ SessionState state; /* state the session is in */
guint timeout; /* signal id for timeout */
GdkWindow * window; /* root window we record */
Damage damage; /* the Damage object */
@@ -152,7 +152,7 @@ compute_image_size (cairo_surface_t *image)
}
static void
-recorder_job_free (ByzanzRecorder *rec, RecorderJob *job)
+session_job_free (ByzanzSession *rec, SessionJob *job)
{
if (job->image) {
rec->cache_size -= compute_image_size (job->image);
@@ -165,11 +165,11 @@ recorder_job_free (ByzanzRecorder *rec, RecorderJob *job)
}
/* UGH: This function takes ownership of region, but only if a job could be created */
-static RecorderJob *
-recorder_job_new (ByzanzRecorder *rec, RecorderJobType type,
+static SessionJob *
+session_job_new (ByzanzSession *rec, SessionJobType type,
const GTimeVal *tv, GdkRegion *region)
{
- RecorderJob *job;
+ SessionJob *job;
for (;;) {
job = g_async_queue_try_pop (rec->finished);
@@ -177,10 +177,10 @@ recorder_job_new (ByzanzRecorder *rec, RecorderJobType type,
break;
if (rec->cache_size - compute_image_size (job->image) <= rec->max_cache_size)
break;
- recorder_job_free (rec, job);
+ session_job_free (rec, job);
}
if (!job)
- job = g_new0 (RecorderJob, 1);
+ job = g_new0 (SessionJob, 1);
g_assert (job->region == NULL);
@@ -197,10 +197,10 @@ recorder_job_new (ByzanzRecorder *rec, RecorderJobType type,
rec->cache_size += compute_image_size (job->image);
if (!rec->use_file_cache &&
rec->cache_size >= rec->max_cache_size / 2) {
- RecorderJob *tmp;
+ SessionJob *tmp;
guint count;
rec->use_file_cache = TRUE;
- tmp = recorder_job_new (rec, RECORDER_JOB_USE_FILE_CACHE, NULL, NULL);
+ tmp = session_job_new (rec, RECORDER_JOB_USE_FILE_CACHE, NULL, NULL);
/* push job to the front */
g_async_queue_lock (rec->jobs);
count = g_async_queue_length_unlocked (rec->jobs);
@@ -237,7 +237,7 @@ recorder_job_new (ByzanzRecorder *rec, RecorderJobType type,
/*** THREAD FUNCTIONS ***/
static gboolean
-byzanz_recorder_dither_region (ByzanzRecorder *rec, GdkRegion *region,
+byzanz_session_dither_region (ByzanzSession *rec, GdkRegion *region,
DitherRegionGetDataFunc func, gpointer data)
{
GdkRectangle *rects;
@@ -287,7 +287,7 @@ byzanz_recorder_dither_region (ByzanzRecorder *rec, GdkRegion *region,
}
static void
-byzanz_recorder_add_image (ByzanzRecorder *rec, const GTimeVal *tv)
+byzanz_session_add_image (ByzanzSession *rec, const GTimeVal *tv)
{
glong msecs;
if (rec->data == NULL) {
@@ -315,7 +315,7 @@ byzanz_recorder_add_image (ByzanzRecorder *rec, const GTimeVal *tv)
}
static void
-stored_image_remove_file (ByzanzRecorder *rec, int fd, char *filename)
+stored_image_remove_file (ByzanzSession *rec, int fd, char *filename)
{
guint size;
@@ -328,7 +328,7 @@ stored_image_remove_file (ByzanzRecorder *rec, int fd, char *filename)
/* returns FALSE if no more images can be cached */
static gboolean
-stored_image_store (ByzanzRecorder *rec, cairo_surface_t *image, GdkRegion *region, const GTimeVal *tv)
+stored_image_store (ByzanzSession *rec, cairo_surface_t *image, GdkRegion *region, const GTimeVal *tv)
{
off_t offset;
StoredImage *store;
@@ -404,7 +404,7 @@ out_err:
}
static gboolean
-stored_image_dither_get_data (ByzanzRecorder *rec, gpointer data, GdkRectangle *rect,
+stored_image_dither_get_data (ByzanzSession *rec, gpointer data, GdkRectangle *rect,
gpointer *data_out, guint *bpl_out)
{
StoredImage *store = data;
@@ -430,7 +430,7 @@ stored_image_dither_get_data (ByzanzRecorder *rec, gpointer data, GdkRectangle *
}
static gboolean
-stored_image_process (ByzanzRecorder *rec)
+stored_image_process (ByzanzSession *rec)
{
StoredImage *store;
gboolean ret;
@@ -444,9 +444,9 @@ stored_image_process (ByzanzRecorder *rec)
g_printerr ("Couldn't seek to %d\n", (int) store->offset);
g_assert_not_reached ();
}
- byzanz_recorder_add_image (rec, &store->tv);
+ byzanz_session_add_image (rec, &store->tv);
lseek (store->fd, store->offset, SEEK_SET);
- ret = byzanz_recorder_dither_region (rec, store->region, stored_image_dither_get_data, store);
+ ret = byzanz_session_dither_region (rec, store->region, stored_image_dither_get_data, store);
if (store->filename)
stored_image_remove_file (rec, store->fd, store->filename);
@@ -456,7 +456,7 @@ stored_image_process (ByzanzRecorder *rec)
}
static void
-byzanz_recorder_quantize (ByzanzRecorder *rec, cairo_surface_t *image)
+byzanz_session_quantize (ByzanzSession *rec, cairo_surface_t *image)
{
GifencPalette *palette;
@@ -467,7 +467,7 @@ byzanz_recorder_quantize (ByzanzRecorder *rec, cairo_surface_t *image)
}
static gboolean
-byzanz_recorder_encode_get_data (ByzanzRecorder *rec, gpointer data, GdkRectangle *rect,
+byzanz_session_encode_get_data (ByzanzSession *rec, gpointer data, GdkRectangle *rect,
gpointer *data_out, guint *bpl_out)
{
cairo_surface_t *image = data;
@@ -480,19 +480,19 @@ byzanz_recorder_encode_get_data (ByzanzRecorder *rec, gpointer data, GdkRectangl
}
static void
-byzanz_recorder_encode (ByzanzRecorder *rec, cairo_surface_t *image, GdkRegion *region)
+byzanz_session_encode (ByzanzSession *rec, cairo_surface_t *image, GdkRegion *region)
{
g_assert (!gdk_region_empty (region));
- byzanz_recorder_dither_region (rec, region, byzanz_recorder_encode_get_data,
+ byzanz_session_dither_region (rec, region, byzanz_session_encode_get_data,
image);
}
static gpointer
-byzanz_recorder_run_encoder (gpointer data)
+byzanz_session_run_encoder (gpointer data)
{
- ByzanzRecorder *rec = data;
- RecorderJob *job;
+ ByzanzSession *rec = data;
+ SessionJob *job;
GTimeVal quit_tv;
gboolean quit = FALSE;
#define USING_FILE_CACHE(rec) ((rec)->file_cache_data_size > 0)
@@ -521,7 +521,7 @@ loop:
}
switch (job->type) {
case RECORDER_JOB_QUANTIZE:
- byzanz_recorder_quantize (rec, job->image);
+ byzanz_session_quantize (rec, job->image);
break;
case RECORDER_JOB_ENCODE:
if (USING_FILE_CACHE (rec)) {
@@ -532,8 +532,8 @@ loop:
}
job->region = NULL;
} else {
- byzanz_recorder_add_image (rec, &job->tv);
- byzanz_recorder_encode (rec, job->image, job->region);
+ byzanz_session_add_image (rec, &job->tv);
+ byzanz_session_encode (rec, job->image, job->region);
}
break;
case RECORDER_JOB_USE_FILE_CACHE:
@@ -561,7 +561,7 @@ loop:
g_async_queue_push (rec->finished, job);
}
- byzanz_recorder_add_image (rec, &quit_tv);
+ byzanz_session_add_image (rec, &quit_tv);
gifenc_close (rec->gifenc, NULL);
g_free (rec->data);
@@ -618,11 +618,11 @@ cursor_equal (gconstpointer c1, gconstpointer c2)
((const XFixesCursorImage *) c2)->cursor_serial;
}
-static gboolean byzanz_recorder_timeout_cb (gpointer recorder);
+static gboolean byzanz_session_timeout_cb (gpointer session);
static void
-byzanz_recorder_queue_image (ByzanzRecorder *rec)
+byzanz_session_queue_image (ByzanzSession *rec)
{
- RecorderJob *job;
+ SessionJob *job;
GTimeVal tv;
gboolean render_cursor = FALSE;
@@ -641,7 +641,7 @@ byzanz_recorder_queue_image (ByzanzRecorder *rec)
}
if (!gdk_region_empty (rec->region)) {
- job = recorder_job_new (rec, RECORDER_JOB_ENCODE, &tv, rec->region);
+ job = session_job_new (rec, RECORDER_JOB_ENCODE, &tv, rec->region);
if (job) {
if (render_cursor)
render_cursor_to_image (job->image, rec->cursor,
@@ -654,14 +654,14 @@ byzanz_recorder_queue_image (ByzanzRecorder *rec)
if (rec->timeout == 0) {
rec->timeout = g_timeout_add (rec->frame_duration,
- byzanz_recorder_timeout_cb, rec);
+ byzanz_session_timeout_cb, rec);
}
}
static gboolean
-byzanz_recorder_timeout_cb (gpointer recorder)
+byzanz_session_timeout_cb (gpointer session)
{
- ByzanzRecorder *rec = recorder;
+ ByzanzSession *rec = session;
if (IS_RECORDING_CURSOR (rec)) {
gint x, y;
@@ -676,26 +676,26 @@ byzanz_recorder_timeout_cb (gpointer recorder)
return FALSE;
}
}
- byzanz_recorder_queue_image (rec);
+ byzanz_session_queue_image (rec);
return TRUE;
}
static gboolean
-byzanz_recorder_idle_cb (gpointer recorder)
+byzanz_session_idle_cb (gpointer session)
{
- ByzanzRecorder *rec = recorder;
+ ByzanzSession *rec = session;
g_assert (!gdk_region_empty (rec->region));
rec->timeout = 0;
- byzanz_recorder_queue_image (rec);
+ byzanz_session_queue_image (rec);
return FALSE;
}
static GdkFilterReturn
-byzanz_recorder_filter_events (GdkXEvent *xevent, GdkEvent *event, gpointer data)
+byzanz_session_filter_events (GdkXEvent *xevent, GdkEvent *event, gpointer data)
{
- ByzanzRecorder *rec = data;
+ ByzanzSession *rec = data;
XDamageNotifyEvent *dev = (XDamageNotifyEvent *) xevent;
Display *dpy;
@@ -721,7 +721,7 @@ byzanz_recorder_filter_events (GdkXEvent *xevent, GdkEvent *event, gpointer data
gdk_region_union_with_rect (rec->region, &rect);
if (rec->timeout == 0)
rec->timeout = g_idle_add_full (G_PRIORITY_DEFAULT,
- byzanz_recorder_idle_cb, rec, NULL);
+ byzanz_session_idle_cb, rec, NULL);
}
return GDK_FILTER_REMOVE;
} else if (dev->type == fixes_event_base + XFixesCursorNotify) {
@@ -742,17 +742,17 @@ byzanz_recorder_filter_events (GdkXEvent *xevent, GdkEvent *event, gpointer data
}
static void
-byzanz_recorder_state_advance (ByzanzRecorder *recorder)
+byzanz_session_state_advance (ByzanzSession *session)
{
- switch (recorder->state) {
+ switch (session->state) {
case RECORDER_STATE_CREATED:
- byzanz_recorder_prepare (recorder);
+ byzanz_session_prepare (session);
break;
case RECORDER_STATE_PREPARED:
- byzanz_recorder_start (recorder);
+ byzanz_session_start (session);
break;
case RECORDER_STATE_RECORDING:
- byzanz_recorder_stop (recorder);
+ byzanz_session_stop (session);
break;
case RECORDER_STATE_STOPPED:
case RECORDER_STATE_ERROR:
@@ -762,22 +762,22 @@ byzanz_recorder_state_advance (ByzanzRecorder *recorder)
}
/**
- * byzanz_recorder_new:
+ * byzanz_session_new:
* @filename: filename to record to
* @window: window to record
* @area: area of window that should be recorded
* @loop: if the resulting animation should loop
* @record_cursor: if the cursor image should be recorded
*
- * Creates a new #ByzanzRecorder and initializes all basic variables.
+ * Creates a new #ByzanzSession and initializes all basic variables.
* gtk_init() and g_thread_init() must have been called before.
*
- * Returns: a new #ByzanzRecorder or NULL if an error occured. Most likely
+ * Returns: a new #ByzanzSession or NULL if an error occured. Most likely
* the XDamage extension is not available on the current X server
* then. Another reason would be a thread creation failure.
**/
-ByzanzRecorder *
-byzanz_recorder_new (const gchar *filename, GdkWindow *window, GdkRectangle *area,
+ByzanzSession *
+byzanz_session_new (const gchar *filename, GdkWindow *window, GdkRectangle *area,
gboolean loop, gboolean record_cursor)
{
gint fd;
@@ -792,11 +792,11 @@ byzanz_recorder_new (const gchar *filename, GdkWindow *window, GdkRectangle *are
if (fd < 0)
return NULL;
- return byzanz_recorder_new_fd (fd, window, area, loop, record_cursor);
+ return byzanz_session_new_fd (fd, window, area, loop, record_cursor);
}
static gboolean
-recorder_gifenc_write (gpointer closure, const guchar *data, gsize len, GError **error)
+session_gifenc_write (gpointer closure, const guchar *data, gsize len, GError **error)
{
gssize written;
int fd = GPOINTER_TO_INT (closure);
@@ -822,16 +822,16 @@ recorder_gifenc_write (gpointer closure, const guchar *data, gsize len, GError *
}
static void
-recorder_gifenc_close (gpointer closure)
+session_gifenc_close (gpointer closure)
{
close (GPOINTER_TO_INT (closure));
}
-ByzanzRecorder *
-byzanz_recorder_new_fd (gint fd, GdkWindow *window, GdkRectangle *area,
+ByzanzSession *
+byzanz_session_new_fd (gint fd, GdkWindow *window, GdkRectangle *area,
gboolean loop, gboolean record_cursor)
{
- ByzanzRecorder *recorder;
+ ByzanzSession *session;
Display *dpy;
GdkRectangle root_rect;
@@ -851,56 +851,56 @@ byzanz_recorder_new_fd (gint fd, GdkWindow *window, GdkRectangle *area,
fixes_event_base + XFixesCursorNotify, 1);
}
- recorder = g_new0 (ByzanzRecorder, 1);
+ session = g_new0 (ByzanzSession, 1);
/* set user properties */
- recorder->area = *area;
- recorder->loop = loop;
- recorder->frame_duration = 1000 / 25;
- recorder->max_cache_size = BYZANZ_RECORDER_MAX_CACHE;
- recorder->max_file_size = BYZANZ_RECORDER_MAX_FILE_SIZE;
- recorder->max_file_cache = BYZANZ_RECORDER_MAX_FILE_CACHE;
+ session->area = *area;
+ session->loop = loop;
+ session->frame_duration = 1000 / 25;
+ session->max_cache_size = BYZANZ_RECORDER_MAX_CACHE;
+ session->max_file_size = BYZANZ_RECORDER_MAX_FILE_SIZE;
+ session->max_file_cache = BYZANZ_RECORDER_MAX_FILE_CACHE;
/* prepare thread first, so we can easily error out on failure */
- recorder->window = window;
+ session->window = window;
g_object_ref (window);
root_rect.x = root_rect.y = 0;
- gdk_drawable_get_size (recorder->window,
+ gdk_drawable_get_size (session->window,
&root_rect.width, &root_rect.height);
- gdk_rectangle_intersect (&recorder->area, &root_rect, &recorder->area);
- recorder->gifenc = gifenc_new (recorder->area.width, recorder->area.height,
- recorder_gifenc_write, GINT_TO_POINTER (fd), recorder_gifenc_close);
- if (!recorder->gifenc) {
- g_free (recorder);
+ gdk_rectangle_intersect (&session->area, &root_rect, &session->area);
+ session->gifenc = gifenc_new (session->area.width, session->area.height,
+ session_gifenc_write, GINT_TO_POINTER (fd), session_gifenc_close);
+ if (!session->gifenc) {
+ g_free (session);
return NULL;
}
- recorder->jobs = g_async_queue_new ();
- recorder->finished = g_async_queue_new ();
- recorder->encoder_running = 1;
- recorder->encoder = g_thread_create (byzanz_recorder_run_encoder, recorder,
+ session->jobs = g_async_queue_new ();
+ session->finished = g_async_queue_new ();
+ session->encoder_running = 1;
+ session->encoder = g_thread_create (byzanz_session_run_encoder, session,
TRUE, NULL);
- if (!recorder->encoder) {
- gifenc_free (recorder->gifenc);
- g_async_queue_unref (recorder->jobs);
- g_free (recorder);
+ if (!session->encoder) {
+ gifenc_free (session->gifenc);
+ g_async_queue_unref (session->jobs);
+ g_free (session);
return NULL;
}
/* do setup work */
- recorder->damaged = XFixesCreateRegion (dpy, 0, 0);
- recorder->tmp_region = XFixesCreateRegion (dpy, 0, 0);
+ session->damaged = XFixesCreateRegion (dpy, 0, 0);
+ session->tmp_region = XFixesCreateRegion (dpy, 0, 0);
if (record_cursor)
- recorder->cursors = g_hash_table_new_full (cursor_hash, cursor_equal,
+ session->cursors = g_hash_table_new_full (cursor_hash, cursor_equal,
NULL, (GDestroyNotify) XFree);
- recorder->state = RECORDER_STATE_CREATED;
- return recorder;
+ session->state = RECORDER_STATE_CREATED;
+ return session;
}
void
-byzanz_recorder_prepare (ByzanzRecorder *rec)
+byzanz_session_prepare (ByzanzSession *rec)
{
- RecorderJob *job;
+ SessionJob *job;
GdkRegion *region;
GTimeVal tv;
@@ -909,14 +909,14 @@ byzanz_recorder_prepare (ByzanzRecorder *rec)
region = gdk_region_rectangle (&rec->area);
g_get_current_time (&tv);
- job = recorder_job_new (rec, RECORDER_JOB_QUANTIZE, &tv, region);
+ job = session_job_new (rec, RECORDER_JOB_QUANTIZE, &tv, region);
g_async_queue_push (rec->jobs, job);
//g_print ("pushing QUANTIZE\n");
rec->state = RECORDER_STATE_PREPARED;
}
void
-byzanz_recorder_start (ByzanzRecorder *rec)
+byzanz_session_start (ByzanzSession *rec)
{
Display *dpy;
@@ -928,7 +928,7 @@ byzanz_recorder_start (ByzanzRecorder *rec)
dpy = gdk_x11_display_get_xdisplay (gdk_display_get_default ());
rec->region = gdk_region_rectangle (&rec->area);
gdk_window_add_filter (rec->window,
- byzanz_recorder_filter_events, rec);
+ byzanz_session_filter_events, rec);
rec->damage = XDamageCreate (dpy, GDK_DRAWABLE_XID (rec->window),
XDamageReportDeltaRectangles);
if (rec->cursors) {
@@ -939,28 +939,28 @@ byzanz_recorder_start (ByzanzRecorder *rec)
g_hash_table_insert (rec->cursors, rec->cursor, rec->cursor);
gdk_window_get_pointer (rec->window, &rec->cursor_x, &rec->cursor_y, NULL);
}
- /* byzanz_recorder_queue_image (rec); - we'll get a damage event anyway */
+ /* byzanz_session_queue_image (rec); - we'll get a damage event anyway */
rec->state = RECORDER_STATE_RECORDING;
}
void
-byzanz_recorder_stop (ByzanzRecorder *rec)
+byzanz_session_stop (ByzanzSession *rec)
{
GTimeVal tv;
- RecorderJob *job;
+ SessionJob *job;
Display *dpy;
g_return_if_fail (BYZANZ_IS_RECORDER (rec));
g_return_if_fail (rec->state == RECORDER_STATE_RECORDING);
- /* byzanz_recorder_queue_image (rec); - useless because last image would have a 0 time */
+ /* byzanz_session_queue_image (rec); - useless because last image would have a 0 time */
g_get_current_time (&tv);
- job = recorder_job_new (rec, RECORDER_JOB_QUIT, &tv, NULL);
+ job = session_job_new (rec, RECORDER_JOB_QUIT, &tv, NULL);
g_async_queue_push (rec->jobs, job);
//g_print ("pushing QUIT\n");
gdk_window_remove_filter (rec->window,
- byzanz_recorder_filter_events, rec);
+ byzanz_session_filter_events, rec);
if (rec->timeout != 0) {
if (!g_source_remove (rec->timeout))
g_assert_not_reached ();
@@ -976,22 +976,22 @@ byzanz_recorder_stop (ByzanzRecorder *rec)
}
void
-byzanz_recorder_destroy (ByzanzRecorder *rec)
+byzanz_session_destroy (ByzanzSession *rec)
{
Display *dpy;
- RecorderJob *job;
+ SessionJob *job;
g_return_if_fail (BYZANZ_IS_RECORDER (rec));
while (rec->state != RECORDER_STATE_ERROR &&
rec->state != RECORDER_STATE_STOPPED)
- byzanz_recorder_state_advance (rec);
+ byzanz_session_state_advance (rec);
if (g_thread_join (rec->encoder) != rec)
g_assert_not_reached ();
while ((job = g_async_queue_try_pop (rec->finished)) != NULL)
- recorder_job_free (rec, job);
+ session_job_free (rec, job);
dpy = gdk_x11_display_get_xdisplay (gdk_display_get_default ());
XFixesDestroyRegion (dpy, rec->damaged);
XFixesDestroyRegion (dpy, rec->tmp_region);
@@ -1009,11 +1009,11 @@ byzanz_recorder_destroy (ByzanzRecorder *rec)
}
/**
- * byzanz_recorder_set_max_cache:
+ * byzanz_session_set_max_cache:
* @rec: a recording session
* @max_cache_bytes: maximum allowed cache size in bytes
*
- * Sets the maximum allowed cache size. Since the recorder uses two threads -
+ * Sets the maximum allowed cache size. Since the session uses two threads -
* one for taking screenshots and one for encoding these screenshots into the
* final file, on heavy screen changes a big number of screenshot images can
* build up waiting to be encoded. This value is used to determine the maximum
@@ -1021,7 +1021,7 @@ byzanz_recorder_destroy (ByzanzRecorder *rec)
* during a recording session.
**/
void
-byzanz_recorder_set_max_cache (ByzanzRecorder *rec,
+byzanz_session_set_max_cache (ByzanzSession *rec,
guint max_cache_bytes)
{
g_return_if_fail (BYZANZ_IS_RECORDER (rec));
@@ -1029,24 +1029,24 @@ byzanz_recorder_set_max_cache (ByzanzRecorder *rec,
rec->max_cache_size = max_cache_bytes;
while (rec->cache_size > max_cache_bytes) {
- RecorderJob *job = g_async_queue_try_pop (rec->finished);
+ SessionJob *job = g_async_queue_try_pop (rec->finished);
if (!job)
break;
- recorder_job_free (rec, job);
+ session_job_free (rec, job);
}
}
/**
- * byzanz_recorder_get_max_cache:
+ * byzanz_session_get_max_cache:
* @rec: a recording session
*
- * Gets the maximum allowed cache size. See byzanz_recorder_set_max_cache()
+ * Gets the maximum allowed cache size. See byzanz_session_set_max_cache()
* for details.
*
* Returns: the maximum allowed cache size in bytes
**/
guint
-byzanz_recorder_get_max_cache (ByzanzRecorder *rec)
+byzanz_session_get_max_cache (ByzanzSession *rec)
{
g_return_val_if_fail (BYZANZ_IS_RECORDER (rec), 0);
@@ -1054,7 +1054,7 @@ byzanz_recorder_get_max_cache (ByzanzRecorder *rec)
}
/**
- * byzanz_recorder_get_cache:
+ * byzanz_session_get_cache:
* @rec: a recording session
*
* Determines the current amount of image cache used.
@@ -1062,7 +1062,7 @@ byzanz_recorder_get_max_cache (ByzanzRecorder *rec)
* Returns: current cache used in bytes
**/
guint
-byzanz_recorder_get_cache (ByzanzRecorder *rec)
+byzanz_session_get_cache (ByzanzSession *rec)
{
g_return_val_if_fail (BYZANZ_IS_RECORDER (rec), 0);
@@ -1070,20 +1070,20 @@ byzanz_recorder_get_cache (ByzanzRecorder *rec)
}
/**
- * byzanz_recorder_is_active:
- * @recorder: ia recording session
+ * byzanz_session_is_active:
+ * @session: ia recording session
*
- * Checks if the recorder is currently running or - after being stopped - if
+ * Checks if the session is currently running or - after being stopped - if
* the encoder is still actively processing cached data.
- * Note that byzanz_recorder_destroy() will block until all cached data has been
+ * Note that byzanz_session_destroy() will block until all cached data has been
* processed, so it might take a long time.
*
* Returns: TRUE if the recording session is still active.
**/
gboolean
-byzanz_recorder_is_active (ByzanzRecorder *recorder)
+byzanz_session_is_active (ByzanzSession *session)
{
- g_return_val_if_fail (BYZANZ_IS_RECORDER (recorder), 0);
+ g_return_val_if_fail (BYZANZ_IS_RECORDER (session), 0);
- return g_atomic_int_get (&recorder->encoder_running) > 0;
+ return g_atomic_int_get (&session->encoder_running) > 0;
}
diff --git a/src/byzanzrecorder.h b/src/byzanzsession.h
similarity index 66%
rename from src/byzanzrecorder.h
rename to src/byzanzsession.h
index 0464157..722c1ea 100644
--- a/src/byzanzrecorder.h
+++ b/src/byzanzsession.h
@@ -23,29 +23,29 @@
#ifndef __HAVE_BYZANZ_RECORDER_H__
#define __HAVE_BYZANZ_RECORDER_H__
-typedef struct _ByzanzRecorder ByzanzRecorder;
+typedef struct _ByzanzSession ByzanzSession;
#define BYZANZ_IS_RECORDER(obj) ((obj) != NULL)
-ByzanzRecorder * byzanz_recorder_new (const gchar * filename,
+ByzanzSession * byzanz_session_new (const gchar * filename,
GdkWindow * window,
GdkRectangle * area,
gboolean loop,
gboolean record_cursor);
-ByzanzRecorder * byzanz_recorder_new_fd (gint fd,
+ByzanzSession * byzanz_session_new_fd (gint fd,
GdkWindow * window,
GdkRectangle * area,
gboolean loop,
gboolean record_cursor);
-void byzanz_recorder_prepare (ByzanzRecorder * recorder);
-void byzanz_recorder_start (ByzanzRecorder * recorder);
-void byzanz_recorder_stop (ByzanzRecorder * recorder);
-void byzanz_recorder_destroy (ByzanzRecorder * recorder);
-gboolean byzanz_recorder_is_active (ByzanzRecorder * recorder);
+void byzanz_session_prepare (ByzanzSession * session);
+void byzanz_session_start (ByzanzSession * session);
+void byzanz_session_stop (ByzanzSession * session);
+void byzanz_session_destroy (ByzanzSession * session);
+gboolean byzanz_session_is_active (ByzanzSession * session);
/* property functions */
-void byzanz_recorder_set_max_cache (ByzanzRecorder * recorder,
+void byzanz_session_set_max_cache (ByzanzSession * session,
guint max_cache_bytes);
-guint byzanz_recorder_get_max_cache (ByzanzRecorder * recorder);
-guint byzanz_recorder_get_cache (ByzanzRecorder * recorder);
+guint byzanz_session_get_max_cache (ByzanzSession * session);
+guint byzanz_session_get_cache (ByzanzSession * session);
#endif /* __HAVE_BYZANZ_RECORDER_H__ */
diff --git a/src/record.c b/src/record.c
index 7e6b15b..d7afa43 100644
--- a/src/record.c
+++ b/src/record.c
@@ -1,4 +1,4 @@
-/* desktop recorder
+/* desktop session
* Copyright (C) 2005 Benjamin Otte <otte gnome org
*
* This library is free software; you can redistribute it and/or
@@ -21,7 +21,7 @@
# include "config.h"
#endif
-#include "byzanzrecorder.h"
+#include "byzanzsession.h"
#include "i18n.h"
static int duration = 10;
@@ -68,31 +68,31 @@ usage (void)
}
static gboolean
-stop_recording (gpointer recorder)
+stop_recording (gpointer session)
{
verbose_print (_("Recording done. Cleaning up...\n"));
- byzanz_recorder_stop (recorder);
+ byzanz_session_stop (session);
gtk_main_quit ();
return FALSE;
}
static gboolean
-start_recording (gpointer recorder)
+start_recording (gpointer session)
{
verbose_print (_("Recording starts. Will record %d seconds...\n"), duration / 1000);
- byzanz_recorder_start (recorder);
- g_timeout_add (duration, stop_recording, recorder);
+ byzanz_session_start (session);
+ g_timeout_add (duration, stop_recording, session);
return FALSE;
}
static gboolean
-prepare_recording (gpointer recorder)
+prepare_recording (gpointer session)
{
verbose_print (_("Preparing recording. Will start in 1 second...\n"));
- byzanz_recorder_prepare (recorder);
- g_timeout_add (1000, start_recording, recorder);
+ byzanz_session_prepare (session);
+ g_timeout_add (1000, start_recording, session);
return FALSE;
}
@@ -100,7 +100,7 @@ prepare_recording (gpointer recorder)
int
main (int argc, char **argv)
{
- ByzanzRecorder *rec;
+ ByzanzSession *rec;
GOptionContext* context;
GError *error = NULL;
@@ -128,7 +128,7 @@ main (int argc, char **argv)
usage ();
return 0;
}
- rec = byzanz_recorder_new (argv[1], gdk_get_default_root_window (),
+ rec = byzanz_session_new (argv[1], gdk_get_default_root_window (),
&area, loop, cursor);
if (rec == NULL) {
g_print (_("Could not prepare recording.\n"
@@ -145,6 +145,6 @@ main (int argc, char **argv)
gtk_main ();
- byzanz_recorder_destroy (rec);
+ byzanz_session_destroy (rec);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]