33
34
#include <glib/gi18n.h>
34
35
#include <libgnomevfs/gnome-vfs-utils.h>
35
#include <nautilus-burn-recorder.h>
36
36
#include <gst/gst.h>
37
37
#ifdef HAVE_GSTREAMER_0_8
38
38
#include <gst/gconf/gconf.h>
39
39
#include <gst/play/play.h>
42
#include <nautilus-burn-drive.h>
43
#include <nautilus-burn-recorder.h>
44
#ifndef NAUTILUS_BURN_CHECK_VERSION
45
#define NAUTILUS_BURN_CHECK_VERSION(a,b,c) FALSE
48
#if NAUTILUS_BURN_CHECK_VERSION(2,15,3)
49
#include <nautilus-burn.h>
42
52
#include "rb-recorder.h"
43
#include "rb-recorder-marshal.h"
45
54
#include "rb-debug.h"
55
#include "rb-marshal.h"
47
57
#ifdef HAVE_GSTREAMER_0_8
48
58
#define gst_caps_unref gst_caps_free
607
633
g_signal_connect_object (G_OBJECT (recorder->priv->pipeline), "eos",
608
634
G_CALLBACK (eos_cb), recorder, 0);
609
635
#elif HAVE_GSTREAMER_0_10
610
g_object_set (recorder->priv->capsfilter, "filter-caps", filtercaps, NULL);
636
g_object_set (recorder->priv->capsfilter, "caps", filtercaps, NULL);
612
638
gst_element_link_many (recorder->priv->src,
613
639
recorder->priv->typefind,
706
tick_timeout_cb (RBRecorder *recorder)
708
gint64 position, total;
713
GstFormat format = GST_FORMAT_BYTES;
714
#ifdef HAVE_GSTREAMER_0_10
734
#ifdef HAVE_GSTREAMER_0_8
736
tick_timeout_cb (RBRecorder *recorder)
738
gint64 position, total;
743
GstFormat format = GST_FORMAT_BYTES;
745
g_return_val_if_fail (recorder != NULL, FALSE);
746
g_return_val_if_fail (RB_IS_RECORDER (recorder), FALSE);
747
g_return_val_if_fail (recorder->priv != NULL, FALSE);
748
g_return_val_if_fail (recorder->priv->pipeline != NULL, FALSE);
750
if (gst_element_get_state (recorder->priv->pipeline) != GST_STATE_PLAYING) {
751
recorder->priv->tick_timeout_id = 0;
752
if (recorder->priv->start_timer) {
753
g_timer_destroy (recorder->priv->start_timer);
754
recorder->priv->start_timer = NULL;
759
if (!gst_pad_query (recorder->priv->src_pad, GST_QUERY_POSITION, &format, &position)) {
760
g_warning (_("Could not get current track position"));
764
if (!gst_pad_query (recorder->priv->src_pad, GST_QUERY_TOTAL, &format, &total)) {
765
g_warning (_("Could not get current track position"));
769
if (! recorder->priv->start_timer) {
770
recorder->priv->start_timer = g_timer_new ();
771
recorder->priv->start_pos = position;
774
fraction = (float)position / (float)total;
776
elapsed = g_timer_elapsed (recorder->priv->start_timer, NULL);
778
rate = (double)(position - recorder->priv->start_pos) / elapsed;
781
secs = ceil ((total - position) / rate);
786
if (fraction != recorder->priv->progress) {
787
recorder->priv->progress = fraction;
788
g_signal_emit (G_OBJECT (recorder),
789
rb_recorder_signals [TRACK_PROGRESS_CHANGED],
791
fraction, (long)secs);
794
/* Extra kick in the pants to keep things moving on a busy system */
795
gst_bin_iterate (GST_BIN (recorder->priv->pipeline));
799
#elif HAVE_GSTREAMER_0_10
801
tick_timeout_cb (RBRecorder *recorder)
803
gint64 position, total;
808
GstFormat format = GST_FORMAT_BYTES;
718
811
g_return_val_if_fail (recorder != NULL, FALSE);
719
812
g_return_val_if_fail (RB_IS_RECORDER (recorder), FALSE);
720
813
g_return_val_if_fail (recorder->priv != NULL, FALSE);
721
814
g_return_val_if_fail (recorder->priv->pipeline != NULL, FALSE);
723
#ifdef HAVE_GSTREAMER_0_8
724
if (gst_element_get_state (recorder->priv->pipeline) != GST_STATE_PLAYING) {
725
#elif HAVE_GSTREAMER_0_10
726
816
if (!gst_element_get_state (recorder->priv->pipeline, &state, NULL, 3 * GST_SECOND)) {
727
817
g_warning (_("Could not retrieve state from processing pipeline"));
730
821
if (state != GST_STATE_PLAYING) {
732
822
recorder->priv->tick_timeout_id = 0;
733
823
if (recorder->priv->start_timer) {
734
824
g_timer_destroy (recorder->priv->start_timer);
740
#ifdef HAVE_GSTREAMER_0_8
741
if (!gst_pad_query (recorder->priv->src_pad, GST_QUERY_POSITION, &format, &position)) {
742
g_warning (_("Could not get current track position"));
746
if (!gst_pad_query (recorder->priv->src_pad, GST_QUERY_TOTAL, &format, &total)) {
747
#elif HAVE_GSTREAMER_0_10
748
if (!gst_element_query_position (recorder->priv->src, &format, &position) || !gst_element_query_duration (recorder->priv->src, &format, &total)) {
830
if (!gst_element_query_position (recorder->priv->src, &format, &position) || !gst_element_query_duration (recorder->priv->src, &format, &total)) {
750
831
g_warning (_("Could not get current track position"));
795
875
rb_debug ("Syncing pipeline");
796
876
if (recorder->priv->playing) {
797
877
rb_debug ("Playing pipeline");
798
#ifdef HAVE_GSTREAMER_0_8
799
878
if (gst_element_set_state (recorder->priv->pipeline, GST_STATE_PLAYING) == GST_STATE_FAILURE) {
800
#elif HAVE_GSTREAMER_0_10
801
if (gst_element_set_state (recorder->priv->pipeline, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
803
879
g_set_error (error,
804
880
RB_RECORDER_ERROR,
805
881
RB_RECORDER_ERROR_GENERAL,
806
882
_("Could not start pipeline playing"));
809
#ifdef HAVE_GSTREAMER_0_8
810
886
recorder->priv->idle_id = g_idle_add ((GSourceFunc)gst_bin_iterate,
811
887
GST_BIN (recorder->priv->pipeline));
812
888
recorder->priv->tick_timeout_id = g_timeout_add (200,
813
889
(GSourceFunc)tick_timeout_cb,
815
#elif HAVE_GSTREAMER_0_10
816
recorder->priv->tick_timeout_id =
817
g_timeout_add (200, (GSourceFunc)tick_timeout_cb, recorder);
820
892
rb_debug ("Pausing pipeline");
821
#ifdef HAVE_GSTREAMER_0_8
822
893
if (gst_element_set_state (recorder->priv->pipeline, GST_STATE_PAUSED) == GST_STATE_FAILURE) {
823
#elif HAVE_GSTREAMER_0_10
824
if (gst_element_set_state (recorder->priv->pipeline, GST_STATE_PAUSED) == GST_STATE_CHANGE_FAILURE) {
826
894
g_set_error (error,
827
895
RB_RECORDER_ERROR,
828
896
RB_RECORDER_ERROR_GENERAL,
829
897
_("Could not pause playback"));
832
#ifdef HAVE_GSTREAMER_0_8
833
900
if (recorder->priv->idle_id > 0) {
834
901
g_source_remove (recorder->priv->idle_id);
835
902
recorder->priv->idle_id = 0;
904
if (recorder->priv->tick_timeout_id > 0) {
905
g_source_remove (recorder->priv->tick_timeout_id);
906
recorder->priv->tick_timeout_id = 0;
907
if (recorder->priv->start_timer) {
908
g_timer_destroy (recorder->priv->start_timer);
909
recorder->priv->start_timer = NULL;
916
#elif HAVE_GSTREAMER_0_10
919
rb_recorder_sync_pipeline (RBRecorder *recorder,
922
g_return_val_if_fail (recorder != NULL, FALSE);
923
g_return_val_if_fail (RB_IS_RECORDER (recorder), FALSE);
924
g_return_val_if_fail (recorder->priv != NULL, FALSE);
925
g_return_val_if_fail (recorder->priv->pipeline != NULL, FALSE);
927
rb_debug ("Syncing pipeline");
928
if (recorder->priv->playing) {
929
rb_debug ("Playing pipeline");
930
if (gst_element_set_state (recorder->priv->pipeline, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
933
RB_RECORDER_ERROR_GENERAL,
934
_("Could not start pipeline playing"));
938
recorder->priv->tick_timeout_id = g_timeout_add (200, (GSourceFunc)tick_timeout_cb, recorder);
940
rb_debug ("Pausing pipeline");
941
if (gst_element_set_state (recorder->priv->pipeline, GST_STATE_PAUSED) == GST_STATE_CHANGE_FAILURE) {
944
RB_RECORDER_ERROR_GENERAL,
945
_("Could not pause playback"));
948
if (recorder->priv->tick_timeout_id > 0) {
949
g_source_remove (recorder->priv->tick_timeout_id);
950
recorder->priv->tick_timeout_id = 0;
951
if (recorder->priv->start_timer) {
952
g_timer_destroy (recorder->priv->start_timer);
953
recorder->priv->start_timer = NULL;
838
if (recorder->priv->tick_timeout_id > 0) {
839
g_source_remove (recorder->priv->tick_timeout_id);
840
recorder->priv->tick_timeout_id = 0;
841
if (recorder->priv->start_timer) {
842
g_timer_destroy (recorder->priv->start_timer);
843
recorder->priv->start_timer = NULL;
851
962
rb_recorder_close (RBRecorder *recorder,
1036
1161
const char *device,
1037
1162
GError **error)
1164
#if NAUTILUS_BURN_CHECK_VERSION(2,15,3)
1165
NautilusBurnDriveMonitor *monitor;
1042
1172
g_return_val_if_fail (recorder != NULL, FALSE);
1043
1173
g_return_val_if_fail (RB_IS_RECORDER (recorder), FALSE);
1044
1174
g_return_val_if_fail (device != NULL, FALSE);
1049
if (recorder->priv->drive) {
1180
if (recorder->priv->drive != NULL) {
1050
1181
nautilus_burn_drive_unref (recorder->priv->drive);
1051
1182
recorder->priv->drive = NULL;
1187
#if NAUTILUS_BURN_CHECK_VERSION(2,15,3)
1188
monitor = nautilus_burn_get_drive_monitor ();
1189
recorder->priv->drive = nautilus_burn_drive_monitor_get_drive_for_device (monitor, device);
1190
if (recorder->priv->drive != NULL) {
1191
type = nautilus_burn_drive_get_drive_type (recorder->priv->drive);
1054
1194
drives = nautilus_burn_drive_get_list (TRUE, FALSE);
1056
1196
for (tmp = drives; tmp != NULL; tmp = tmp->next) {