1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
3 * Copyright (C) 2006 James Livingston <jrl@ids.org.au>
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 2 of the License, or
8 * (at your option) any later version.
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.
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 St, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "rb-encoder.h"
24 #include "rb-encoder-gst.h"
34 static guint signals
[LAST_SIGNAL
] = { 0 };
37 rb_encoder_interface_init (RBEncoderIface
*iface
)
40 g_signal_new ("progress",
41 G_TYPE_FROM_INTERFACE (iface
),
43 G_STRUCT_OFFSET (RBEncoderIface
, progress
),
45 g_cclosure_marshal_VOID__DOUBLE
,
49 g_signal_new ("completed",
50 G_TYPE_FROM_INTERFACE (iface
),
52 G_STRUCT_OFFSET (RBEncoderIface
, completed
),
54 g_cclosure_marshal_VOID__VOID
,
58 g_signal_new ("error",
59 G_TYPE_FROM_INTERFACE (iface
),
61 G_STRUCT_OFFSET (RBEncoderIface
, error
),
63 g_cclosure_marshal_VOID__POINTER
,
70 rb_encoder_get_type (void)
72 static GType our_type
= 0;
75 static const GTypeInfo our_info
= {
76 sizeof (RBEncoderIface
),
78 NULL
, /* base_finalize */
79 (GClassInitFunc
)rb_encoder_interface_init
,
80 NULL
, /* class_finalize */
81 NULL
, /* class_data */
87 our_type
= g_type_register_static (G_TYPE_INTERFACE
, "RBEncoder", &our_info
, 0);
94 rb_encoder_encode (RBEncoder
*encoder
,
97 const char *mime_type
)
99 RBEncoderIface
*iface
= RB_ENCODER_GET_IFACE (encoder
);
101 return iface
->encode (encoder
, entry
, dest
, mime_type
);
105 rb_encoder_cancel (RBEncoder
*encoder
)
107 RBEncoderIface
*iface
= RB_ENCODER_GET_IFACE (encoder
);
109 iface
->cancel (encoder
);
113 rb_encoder_new (void)
115 return rb_encoder_gst_new ();
119 _rb_encoder_emit_progress (RBEncoder
*encoder
, double fraction
)
121 g_signal_emit (encoder
, signals
[PROGRESS
], 0, fraction
);
125 _rb_encoder_emit_completed (RBEncoder
*encoder
)
127 g_signal_emit (encoder
, signals
[COMPLETED
], 0);
131 _rb_encoder_emit_error (RBEncoder
*encoder
, GError
*error
)
133 g_signal_emit (encoder
, signals
[ERROR
], 0, error
);
137 rb_encoder_error_quark (void)
139 static GQuark quark
= 0;
141 quark
= g_quark_from_static_string ("rb_encoder_error");