1 From 862e7756ca714ad873afcab9b603e5ca8e59b862 Mon Sep 17 00:00:00 2001
2 From: Christophe Fergeau <cfergeau@redhat.com>
3 Date: Sat, 6 Aug 2011 22:13:12 +0200
4 Subject: [PATCH] Replace GnomeMediaProfile with GstEncodingProfile
9 data/rhythmbox.gep | 46 ++++++
10 data/sound-juicer.schemas.in | 21 ++-
11 data/sound-juicer.ui | 1 +
12 libjuicer/Makefile.am | 5 +-
13 libjuicer/rb-gst-media-types.c | 336 +++++++++++++++++++++++++++++++++++++++++
14 libjuicer/rb-gst-media-types.h | 76 ++++++++++
15 libjuicer/sj-extractor.c | 88 ++++-------
16 libjuicer/sj-extractor.h | 4 +-
18 src/sj-extracting.c | 10 +-
19 src/sj-main.c | 21 +--
20 src/sj-prefs.c | 117 ++++++++++----
21 src/sound-juicer.h | 1 +
22 tests/Makefile.am | 1 -
23 16 files changed, 629 insertions(+), 111 deletions(-)
24 create mode 100644 data/rhythmbox.gep
25 create mode 100644 libjuicer/rb-gst-media-types.c
26 create mode 100644 libjuicer/rb-gst-media-types.h
28 diff --git a/configure.in b/configure.in
29 index 37a85df..f84d346 100644
34 LIBBRASERO_MEDIA_PC="libbrasero-media >= 2.26"
35 LIBCANBERRA_GTK_PC=libcanberra-gtk
36 - GNOME_MEDIA_PROFILES_PC="gnome-media-profiles >= 2.11.91"
38 3.0) GTK_API_VERSION=3.0
40 LIBBRASERO_MEDIA_PC=libbrasero-media3
41 LIBCANBERRA_GTK_PC=libcanberra-gtk3
42 - GNOME_MEDIA_PROFILES_PC=gnome-media-profiles-3.0
50 -PKG_CHECK_MODULES(GSTREAMER, gstreamer-0.10 >= 0.10.15 gstreamer-plugins-base-0.10)
51 +PKG_CHECK_MODULES(GSTREAMER, gstreamer-0.10 >= 0.10.32 gstreamer-plugins-base-0.10 gstreamer-pbutils-0.10)
52 AC_SUBST(GSTREAMER_CFLAGS)
53 AC_SUBST(GSTREAMER_LIBS)
56 AM_GST_ELEMENT_CHECK(wavenc,,AC_MSG_WARN([The 'wavenc' element was not found. This will cause encoding to Wave to fail.]))
57 AM_GST_ELEMENT_CHECK(giosink,,AC_MSG_WARN([The 'giosink' element was not found. This will cause Sound Juicer to fail at runtime.]))
59 -# Find GNOME Media Profiles
60 -PKG_CHECK_MODULES(MEDIA_PROFILES, $GNOME_MEDIA_PROFILES_PC)
61 -AC_SUBST(MEDIA_PROFILES_CFLAGS)
62 -AC_SUBST(MEDIA_PROFILES_LIBS)
64 # Find optional MusicBrainz3 and required Musicbrainz2
65 PKG_CHECK_MODULES(MUSICBRAINZ3, libmusicbrainz3 >= 3.0.2, [have_mb3=yes], [have_mb3=no])
66 AC_SUBST(MUSICBRAINZ3_CFLAGS)
67 --- a/data/Makefile.am
68 +++ b/data/Makefile.am
69 @@ -11,6 +11,9 @@ schema_in_files = sound-juicer.schemas.in
70 schema_DATA = $(schema_in_files:.schemas.in=.schemas)
71 @INTLTOOL_SCHEMAS_RULE@
73 +profilesdir = $(datadir)/sound-juicer
74 +profiles_DATA = rhythmbox.gep
76 man1_MANS = sound-juicer.1
78 gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
79 diff --git a/data/rhythmbox.gep b/data/rhythmbox.gep
81 index 0000000..6383d96
83 +++ b/data/rhythmbox.gep
85 +[GStreamer Encoding Target]
88 +description = Common encoding profiles for Rhythmbox
92 +description = MPEG Layer 3 Audio
93 +format = application/x-id3
96 +[streamprofile-mp3-1]
99 +format = audio/mpeg, mpegversion=1, layer=3
104 +description = Ogg Vorbis
105 +format = application/ogg
108 +[streamprofile-oggvorbis-1]
111 +format = audio/x-vorbis
117 +format = audio/x-flac
122 +description = MPEG 4 Audio
123 +format = video/quicktime, variant=iso
126 +[streamprofile-m4a-1]
129 +format = audio/mpeg, mpegversion=4, stream-format=raw
131 diff --git a/data/sound-juicer.schemas.in b/data/sound-juicer.schemas.in
132 index 145bbb2..ed502e6 100644
133 --- a/data/sound-juicer.schemas.in
134 +++ b/data/sound-juicer.schemas.in
135 @@ -165,14 +165,31 @@
136 <owner>sound-juicer</owner>
137 <default>cdlossy</default>
139 - <short>Audio Profile with which to encode</short>
140 + <short>(obsolete) Audio Profile with which to encode</short>
142 - The GNOME Audio Profile with which to encode.
143 + This key used to store the GNOME Audio Profile with which to encode.
144 + This has been superseded by GStreamer encoding profiles, which are
145 + configured using the audio_profile_media_type key.
151 + <key>/schemas/apps/sound-juicer/audio_profile_media_type</key>
152 + <applyto>/apps/sound-juicer/audio_profile_media_type</applyto>
153 + <type>string</type>
154 + <owner>sound-juicer</owner>
155 + <default>audio/x-vorbis</default>
157 + <short>Media type to encode to</short>
159 + The GStreamer media type to encode to.
166 <key>/schemas/apps/sound-juicer/volume</key>
167 <applyto>/apps/sound-juicer/volume</applyto>
169 diff --git a/data/sound-juicer.ui b/data/sound-juicer.ui
170 index 2625f97..d2ddf28 100644
171 --- a/data/sound-juicer.ui
172 +++ b/data/sound-juicer.ui
173 @@ -1125,6 +1125,7 @@ audio-volume-medium</property>
176 <object class="GtkButton" id="prefs_edit_profile">
177 + <property name="sensitive">False</property>
178 <property name="can_focus">True</property>
179 <property name="receives_default">False</property>
180 <signal name="clicked" handler="prefs_edit_profile_clicked"/>
181 diff --git a/libjuicer/Makefile.am b/libjuicer/Makefile.am
182 index 9844ad6..d87e755 100644
183 --- a/libjuicer/Makefile.am
184 +++ b/libjuicer/Makefile.am
185 @@ -2,6 +2,8 @@ noinst_LTLIBRARIES = libjuicer.la
187 libjuicer_la_SOURCES = \
189 + rb-gst-media-types.h \
190 + rb-gst-media-types.c \
193 sj-error.h sj-error.c \
194 @@ -16,6 +18,7 @@ libjuicer_la_SOURCES = \
197 libjuicer_la_CPPFLAGS = \
198 + -DDATADIR=\""$(datadir)"\" \
199 $(DISABLE_DEPRECATED_CFLAGS) \
202 @@ -23,7 +26,6 @@ libjuicer_la_CFLAGS = \
204 $(MUSICBRAINZ3_CFLAGS) \
205 $(GSTREAMER_CFLAGS) \
206 - $(MEDIA_PROFILES_CFLAGS) \
210 @@ -31,7 +33,6 @@ libjuicer_la_CFLAGS = \
212 libjuicer_la_LIBADD = \
213 $(MUSICBRAINZ3_LIBS) \
214 - $(MEDIA_PROFILES_LIBS) \
218 diff --git a/libjuicer/rb-gst-media-types.c b/libjuicer/rb-gst-media-types.c
220 index 0000000..e87b013
222 +++ b/libjuicer/rb-gst-media-types.c
225 + * Copyright (C) 2010 Jonathan Matthew <jonathan@d14n.org>
227 + * This program is free software; you can redistribute it and/or modify
228 + * it under the terms of the GNU General Public License as published by
229 + * the Free Software Foundation; either version 2, or (at your option)
230 + * any later version.
232 + * The Rhythmbox authors hereby grant permission for non-GPL compatible
233 + * GStreamer plugins to be used and distributed together with GStreamer
234 + * and Rhythmbox. This permission is above and beyond the permissions granted
235 + * by the GPL license by which Rhythmbox is covered. If you modify this code
236 + * you may extend this exception to your version of the code, but you are not
237 + * obligated to do so. If you do not wish to do so, delete this exception
238 + * statement from your version.
240 + * This program is distributed in the hope that it will be useful,
241 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
242 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
243 + * GNU General Public License for more details.
245 + * You should have received a copy of the GNU General Public License
246 + * along with this program; if not, write to the Free Software
247 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
255 +#include <gst/pbutils/encoding-target.h>
256 +#include <gst/pbutils/missing-plugins.h>
258 +#include "rb-gst-media-types.h"
260 +#define SOURCE_ENCODING_TARGET_FILE "../data/rhythmbox.gep"
261 +#define INSTALLED_ENCODING_TARGET_FILE DATADIR"/sound-juicer/rhythmbox.gep"
262 +static GstEncodingTarget *default_target = NULL;
265 +rb_gst_caps_to_media_type (const GstCaps *caps)
268 + const char *media_type;
270 + /* the aim here is to reduce the caps to a single mimetype-like
271 + * string, describing the audio encoding (for audio files) or the
272 + * file type (for everything else). raw media types are ignored.
274 + * there are only a couple of special cases.
277 + if (gst_caps_get_size (caps) == 0)
280 + s = gst_caps_get_structure (caps, 0);
281 + media_type = gst_structure_get_name (s);
282 + if (media_type == NULL) {
284 + } else if (g_str_has_prefix (media_type, "audio/x-raw-") ||
285 + g_str_has_prefix (media_type, "video/x-raw-")) {
286 + /* ignore raw types */
288 + } else if (g_str_equal (media_type, "audio/mpeg")) {
289 + /* need to distinguish between mpeg 1 layer 3 and
290 + * mpeg 2 or 4 here.
292 + int mpegversion = 0;
293 + gst_structure_get_int (s, "mpegversion", &mpegversion);
294 + switch (mpegversion) {
297 + return g_strdup ("audio/x-aac"); /* hmm. */
301 + return g_strdup ("audio/mpeg");
304 + /* everything else is fine as-is */
305 + return g_strdup (media_type);
310 +rb_gst_media_type_to_caps (const char *media_type)
312 + /* special cases: */
313 + if (strcmp (media_type, "audio/mpeg") == 0) {
314 + return gst_caps_from_string ("audio/mpeg, mpegversion=(int)1");
315 + } else if (strcmp (media_type, "audio/x-aac") == 0) {
316 + return gst_caps_from_string ("audio/mpeg, mpegversion=(int){ 2, 4 }");
318 + /* otherwise, the media type is enough */
319 + return gst_caps_from_string (media_type);
324 +rb_gst_media_type_to_extension (const char *media_type)
326 + if (media_type == NULL) {
328 + } else if (!strcmp (media_type, "audio/mpeg")) {
330 + } else if (!strcmp (media_type, "audio/x-vorbis") || !strcmp (media_type, "application/ogg")) {
332 + } else if (!strcmp (media_type, "audio/x-flac") || !strcmp (media_type, "audio/flac")) {
334 + } else if (!strcmp (media_type, "audio/x-aac") || !strcmp (media_type, "audio/aac") || !strcmp (media_type, "audio/x-alac")) {
336 + } else if (!strcmp (media_type, "audio/x-wavpack")) {
344 +rb_gst_mime_type_to_media_type (const char *mime_type)
346 + if (!strcmp (mime_type, "application/x-id3") || !strcmp (mime_type, "audio/mpeg")) {
347 + return "audio/mpeg";
348 + } else if (!strcmp (mime_type, "application/ogg") || !strcmp (mime_type, "audio/x-vorbis")) {
349 + return "audio/x-vorbis";
350 + } else if (!strcmp (mime_type, "audio/flac")) {
351 + return "audio/x-flac";
352 + } else if (!strcmp (mime_type, "audio/aac") || !strcmp (mime_type, "audio/mp4") || !strcmp (mime_type, "audio/m4a")) {
353 + return "audio/x-aac";
359 +rb_gst_media_type_to_mime_type (const char *media_type)
361 + if (!strcmp (media_type, "audio/x-vorbis")) {
362 + return "application/ogg";
363 + } else if (!strcmp (media_type, "audio/x-flac")) {
364 + return "audio/flac";
365 + } else if (!strcmp (media_type, "audio/x-aac")) {
366 + return "audio/mp4"; /* probably */
373 +rb_gst_media_type_matches_profile (GstEncodingProfile *profile, const char *media_type)
375 + const GstCaps *pcaps;
378 + gboolean matches = FALSE;
380 + caps = rb_gst_media_type_to_caps (media_type);
381 + if (caps == NULL) {
385 + pcaps = gst_encoding_profile_get_format (profile);
386 + if (gst_caps_can_intersect (caps, pcaps)) {
390 + if (matches == FALSE && GST_IS_ENCODING_CONTAINER_PROFILE (profile)) {
391 + for (cl = gst_encoding_container_profile_get_profiles (GST_ENCODING_CONTAINER_PROFILE (profile)); cl != NULL; cl = cl->next) {
392 + GstEncodingProfile *cp = cl->data;
393 + pcaps = gst_encoding_profile_get_format (cp);
394 + if (gst_caps_can_intersect (caps, pcaps)) {
404 +rb_gst_encoding_profile_get_media_type (GstEncodingProfile *profile)
406 + if (GST_IS_ENCODING_CONTAINER_PROFILE (profile)) {
407 + const GList *cl = gst_encoding_container_profile_get_profiles (GST_ENCODING_CONTAINER_PROFILE (profile));
408 + for (; cl != NULL; cl = cl->next) {
409 + GstEncodingProfile *p = cl->data;
410 + if (GST_IS_ENCODING_AUDIO_PROFILE (p)) {
411 + return rb_gst_caps_to_media_type (gst_encoding_profile_get_format (p));
419 + return rb_gst_caps_to_media_type (gst_encoding_profile_get_format (profile));
424 +rb_gst_get_default_encoding_target ()
426 + if (default_target == NULL) {
428 + GError *error = NULL;
430 + if (g_file_test (SOURCE_ENCODING_TARGET_FILE,
431 + G_FILE_TEST_EXISTS) != FALSE) {
432 + target_file = SOURCE_ENCODING_TARGET_FILE;
434 + target_file = INSTALLED_ENCODING_TARGET_FILE;
437 + default_target = gst_encoding_target_load_from_file (target_file, &error);
438 + if (default_target == NULL) {
439 + g_warning ("Unable to load encoding profiles from %s: %s", target_file, error ? error->message : "no error");
440 + g_clear_error (&error);
445 + return default_target;
448 +GstEncodingProfile *
449 +rb_gst_get_encoding_profile (const char *media_type)
452 + GstEncodingTarget *target;
453 + target = rb_gst_get_default_encoding_target ();
455 + for (l = gst_encoding_target_get_profiles (target); l != NULL; l = l->next) {
456 + GstEncodingProfile *profile = l->data;
457 + if (rb_gst_media_type_matches_profile (profile, media_type)) {
458 + gst_encoding_profile_ref (profile);
467 +rb_gst_media_type_is_lossless (const char *media_type)
470 + const char *lossless_types[] = {
474 + "audio/x-wavpack" /* not completely sure */
477 + for (i = 0; i < G_N_ELEMENTS (lossless_types); i++) {
478 + if (strcmp (media_type, lossless_types[i]) == 0) {
486 +rb_gst_check_missing_plugins (GstEncodingProfile *profile,
488 + char ***descriptions)
490 + GstElement *encodebin;
497 + encodebin = gst_element_factory_make ("encodebin", NULL);
498 + if (encodebin == NULL) {
499 + g_warning ("Unable to create encodebin");
503 + bus = gst_bus_new ();
504 + gst_element_set_bus (encodebin, bus);
505 + gst_bus_set_flushing (bus, FALSE); /* necessary? */
507 + g_object_set (encodebin, "profile", profile, NULL);
508 + pad = gst_element_get_static_pad (encodebin, "audio_0");
510 + GstMessage *message;
511 + GList *messages = NULL;
515 + message = gst_bus_pop (bus);
516 + while (message != NULL) {
517 + if (gst_is_missing_plugin_message (message)) {
518 + messages = g_list_append (messages, message);
520 + gst_message_unref (message);
522 + message = gst_bus_pop (bus);
525 + if (messages != NULL) {
526 + if (details != NULL) {
527 + *details = g_new0(char *, g_list_length (messages)+1);
529 + if (descriptions != NULL) {
530 + *descriptions = g_new0(char *, g_list_length (messages)+1);
533 + for (m = messages; m != NULL; m = m->next) {
535 + if (details != NULL) {
536 + str = gst_missing_plugin_message_get_installer_detail (m->data);
537 + (*details)[i] = str;
539 + if (descriptions != NULL) {
540 + str = gst_missing_plugin_message_get_description (m->data);
541 + (*descriptions)[i] = str;
547 + g_list_foreach (messages, (GFunc)gst_message_unref, NULL);
548 + g_list_free (messages);
552 + gst_element_release_request_pad (encodebin, pad);
553 + gst_object_unref (pad);
556 + gst_object_unref (encodebin);
557 + gst_object_unref (bus);
560 diff --git a/libjuicer/rb-gst-media-types.h b/libjuicer/rb-gst-media-types.h
562 index 0000000..9211361
564 +++ b/libjuicer/rb-gst-media-types.h
567 + * Copyright (C) 2010 Jonathan Matthew <jonathan@d14n.org>
569 + * This program is free software; you can redistribute it and/or modify
570 + * it under the terms of the GNU General Public License as published by
571 + * the Free Software Foundation; either version 2, or (at your option)
572 + * any later version.
574 + * The Rhythmbox authors hereby grant permission for non-GPL compatible
575 + * GStreamer plugins to be used and distributed together with GStreamer
576 + * and Rhythmbox. This permission is above and beyond the permissions granted
577 + * by the GPL license by which Rhythmbox is covered. If you modify this code
578 + * you may extend this exception to your version of the code, but you are not
579 + * obligated to do so. If you do not wish to do so, delete this exception
580 + * statement from your version.
582 + * This program is distributed in the hope that it will be useful,
583 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
584 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
585 + * GNU General Public License for more details.
587 + * You should have received a copy of the GNU General Public License
588 + * along with this program; if not, write to the Free Software
589 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
593 +#ifndef __RB_GST_MEDIA_TYPES_H
594 +#define __RB_GST_MEDIA_TYPES_H
596 +#include <gst/gst.h>
597 +#include <gst/pbutils/encoding-target.h>
598 +#include <gst/pbutils/encoding-profile.h>
602 +/* some common media types */
603 +#define RB_GST_MEDIA_TYPE_MP3 "audio/mpeg"
604 +#define RB_GST_MEDIA_TYPE_OGG_VORBIS "audio/x-vorbis"
605 +#define RB_GST_MEDIA_TYPE_FLAC "audio/x-flac"
606 +#define RB_GST_MEDIA_TYPE_AAC "audio/x-aac"
608 +/* media type categories */
610 + MEDIA_TYPE_NONE = 0,
611 + MEDIA_TYPE_CONTAINER,
617 +char * rb_gst_caps_to_media_type (const GstCaps *caps);
618 +GstCaps * rb_gst_media_type_to_caps (const char *media_type);
620 +const char * rb_gst_media_type_to_extension (const char *media_type);
622 +const char * rb_gst_mime_type_to_media_type (const char *mime_type);
624 +const char * rb_gst_media_type_to_mime_type (const char *media_type);
626 +GstEncodingTarget *rb_gst_get_default_encoding_target (void);
628 +GstEncodingProfile *rb_gst_get_encoding_profile (const char *media_type);
630 +gboolean rb_gst_media_type_matches_profile (GstEncodingProfile *profile, const char *media_type);
632 +char * rb_gst_encoding_profile_get_media_type (GstEncodingProfile *profile);
634 +gboolean rb_gst_media_type_is_lossless (const char *media_type);
635 +gboolean rb_gst_check_missing_plugins (GstEncodingProfile *profile,
637 + char ***descriptions);
641 +#endif /* __RB_GST_MEDIA_TYPES_H */
642 diff --git a/libjuicer/sj-extractor.c b/libjuicer/sj-extractor.c
643 index 52f80d2..10523d4 100644
644 --- a/libjuicer/sj-extractor.c
645 +++ b/libjuicer/sj-extractor.c
646 --- sound-juicer-2.32.0/libjuicer/sj-extractor.c.~1~ 2010-02-09 16:33:28.000000000 +0300
647 +++ sound-juicer-2.32.0/libjuicer/sj-extractor.c 2017-04-04 19:47:01.533926108 +0300
649 #include <glib-object.h>
651 #include <gst/tag/tag.h>
652 -#include <profiles/gnome-media-profiles.h>
653 #include "sj-extractor.h"
654 #include "sj-structures.h"
655 #include "sj-error.h"
657 static guint signals[LAST_SIGNAL] = { 0 };
659 /* Default profile name */
660 -#define DEFAULT_AUDIO_PROFILE_NAME "cdlossy"
661 +#define DEFAULT_MEDIA_TYPE "audio/x-vorbis"
664 #define FILE_SINK "giosink"
666 struct SjExtractorPrivate {
667 /** The current audio profile */
668 - GMAudioProfile *profile;
669 + GstEncodingProfile *profile;
670 /** If the pipeline needs to be re-created */
671 gboolean rebuild_pipeline;
672 /* The gstreamer pipeline elements */
673 - GstElement *pipeline, *cdsrc, *queue, *thread, *encoder, *filesink;
674 + GstElement *pipeline, *cdsrc, *encodebin, *filesink;
675 GstFormat track_format;
679 sj_extractor_set_property (GObject *object, guint property_id,
680 const GValue *value, GParamSpec *pspec)
682 + GstEncodingProfile *profile;
683 SjExtractorPrivate *priv = SJ_EXTRACTOR (object)->priv;
684 switch (property_id) {
687 - g_object_unref (priv->profile);
688 - priv->profile = GM_AUDIO_PROFILE (g_value_dup_object (value));
689 + gst_encoding_profile_unref (priv->profile);
690 + profile = GST_ENCODING_PROFILE (g_value_get_pointer (value));
691 + priv->profile = GST_ENCODING_PROFILE(gst_encoding_profile_ref (profile));
692 priv->rebuild_pipeline = TRUE;
693 g_object_notify (object, "profile");
696 SjExtractorPrivate *priv = SJ_EXTRACTOR (object)->priv;
697 switch (property_id) {
699 - g_value_set_object (value, priv->profile);
700 + g_value_set_pointer (value, gst_encoding_profile_ref (priv->profile));
703 g_value_set_string (value, priv->device_path);
705 SjExtractorPrivate *priv = SJ_EXTRACTOR (object)->priv;
708 - g_object_unref (priv->profile);
709 + gst_encoding_profile_unref (priv->profile);
710 priv->profile = NULL;
713 @@ -188,11 +189,10 @@
715 /* TODO: make these constructors */
716 g_object_class_install_property (object_class, PROP_PROFILE,
717 - g_param_spec_object ("profile",
718 - _("Audio Profile"),
719 - _("The GNOME Audio Profile used for encoding audio"),
720 - GM_AUDIO_TYPE_PROFILE,
721 - G_PARAM_READWRITE));
722 + g_param_spec_pointer ("profile",
723 + _("Audio Profile"),
724 + _("The GStreamer Encoding Profile used for encoding audio"),
725 + G_PARAM_READWRITE));
727 g_object_class_install_property (object_class, PROP_PARANOIA,
728 g_param_spec_int ("paranoia",
730 sj_extractor_init (SjExtractor *extractor)
732 extractor->priv = EXTRACTOR_PRIVATE (extractor);
733 - extractor->priv->profile =
734 - g_object_ref (gm_audio_profile_lookup (DEFAULT_AUDIO_PROFILE_NAME));
735 + extractor->priv->profile = rb_gst_get_encoding_profile (DEFAULT_MEDIA_TYPE);
736 extractor->priv->rebuild_pipeline = TRUE;
737 extractor->priv->paranoia_mode = 8; /* TODO: replace with construct params */
739 @@ -272,18 +271,20 @@
740 build_encoder (SjExtractor *extractor)
742 SjExtractorPrivate *priv;
743 - GstElement *element = NULL;
745 + GstElement *encodebin;
747 g_return_val_if_fail (SJ_IS_EXTRACTOR (extractor), NULL);
748 priv = (SjExtractorPrivate*)extractor->priv;
749 g_return_val_if_fail (priv->profile != NULL, NULL);
751 - pipeline = g_strdup_printf ("audioresample ! audioconvert ! %s",
752 - gm_audio_profile_get_pipeline (priv->profile));
753 - element = gst_parse_bin_from_description (pipeline, TRUE, NULL); /* TODO: return error */
757 + encodebin = gst_element_factory_make ("encodebin", NULL);
758 + if (encodebin == NULL)
760 + g_object_set (encodebin, "profile", priv->profile, NULL);
761 + /* Nice big buffers... */
762 + g_object_set (encodebin, "queue-time-max", 120 * GST_SECOND, NULL);
768 @@ -357,16 +358,13 @@
769 priv->track_format = gst_format_get_by_nick ("track");
770 g_assert (priv->track_format != 0);
772 - priv->queue = gst_element_factory_make ("queue", "queue");
773 - /* Nice big buffers... */
774 - g_object_set (priv->queue, "max-size-time", 120 * GST_SECOND, NULL);
777 - priv->encoder = build_encoder (extractor);
778 - if (priv->encoder == NULL) {
779 + priv->encodebin = build_encoder (extractor);
780 + if (priv->encodebin == NULL) {
781 g_set_error (&priv->construct_error,
782 SJ_ERROR, SJ_ERROR_INTERNAL_ERROR,
783 - _("Could not create GStreamer encoders for %s"), gm_audio_profile_get_name (priv->profile));
784 + _("Could not create GStreamer encoders for %s"),
785 + gst_encoding_profile_get_name (priv->profile));
788 /* Connect to the eos so we know when its finished */
789 @@ -385,10 +383,10 @@
792 /* Add the elements to the pipeline */
793 - gst_bin_add_many (GST_BIN (priv->pipeline), priv->cdsrc, priv->queue, priv->encoder, priv->filesink, NULL);
794 + gst_bin_add_many (GST_BIN (priv->pipeline), priv->cdsrc, priv->encodebin, priv->filesink, NULL);
796 /* Link it all together */
797 - if (!gst_element_link_many (priv->cdsrc, priv->queue, priv->encoder, priv->filesink, NULL)) {
798 + if (!gst_element_link_many (priv->cdsrc, priv->encodebin, priv->filesink, NULL)) {
799 g_set_error (&priv->construct_error,
800 SJ_ERROR, SJ_ERROR_INTERNAL_ERROR,
801 _("Could not link pipeline"));
806 -sj_extractor_supports_profile (GMAudioProfile *profile)
807 +sj_extractor_supports_profile (GstEncodingProfile *profile)
809 /* TODO: take a GError to return a message if the profile isn't supported */
810 - GstElement *element;
811 - GError *error = NULL;
814 - pipeline = g_strdup_printf ("fakesrc ! %s", gm_audio_profile_get_pipeline (profile));
815 - element = gst_parse_launch (pipeline, &error);
818 - /* It is possible for both element and error to be non NULL, so check both */
820 - gst_object_unref (GST_OBJECT (element));
822 - g_warning ("Profile warning: %s", error->message);
823 - g_error_free (error);
828 - g_warning ("Profile error: %s", error->message);
829 - g_error_free (error);
833 + return !rb_gst_check_missing_plugins(profile, NULL, NULL);
835 diff --git a/libjuicer/sj-extractor.h b/libjuicer/sj-extractor.h
836 index bbe23fc..7e71803 100644
837 --- a/libjuicer/sj-extractor.h
838 +++ b/libjuicer/sj-extractor.h
841 #include <glib-object.h>
843 -#include <profiles/audio-profile.h>
844 +#include "rb-gst-media-types.h"
845 #include "sj-structures.h"
848 @@ -71,7 +71,7 @@ void sj_extractor_extract_track (SjExtractor *extractor, const TrackDetails *tra
850 void sj_extractor_cancel_extract (SjExtractor *extractor);
852 -gboolean sj_extractor_supports_profile (GMAudioProfile *profile);
853 +gboolean sj_extractor_supports_profile (GstEncodingProfile *profile);
855 gboolean sj_extractor_supports_encoding (GError **error);
857 diff --git a/src/Makefile.am b/src/Makefile.am
858 index 716ac6c..c1996eb 100644
859 --- a/src/Makefile.am
860 +++ b/src/Makefile.am
861 @@ -36,7 +36,6 @@ sound_juicer_CPPFLAGS = \
863 sound_juicer_CFLAGS = \
864 $(GSTREAMER_CFLAGS) \
865 - $(MEDIA_PROFILES_CFLAGS) \
869 @@ -44,7 +43,6 @@ sound_juicer_CFLAGS = \
871 sound_juicer_CFLAGS = \
872 $(GSTREAMER_CFLAGS) \
873 - $(MEDIA_PROFILES_CFLAGS) \
877 @@ -52,7 +50,6 @@ sound_juicer_CFLAGS = \
879 sound_juicer_LDADD = \
880 $(top_builddir)/libjuicer/libjuicer.la \
881 - $(MEDIA_PROFILES_LIBS) \
885 diff --git a/src/sj-extracting.c b/src/sj-extracting.c
886 index dab3dbd..0622a0e 100644
887 --- a/src/sj-extracting.c
888 +++ b/src/sj-extracting.c
889 @@ -134,12 +134,12 @@ static guint cookie;
891 build_filename (const TrackDetails *track, gboolean temp_filename, GError **error)
895 gchar *realfile, *realpath, *filename, *scheme;
896 const gchar *extension;
897 size_t len_extension;
898 int max_realfile = INT_MAX;
899 - GMAudioProfile *profile;
900 + GstEncodingProfile *profile;
902 g_object_get (extractor, "profile", &profile, NULL);
904 @@ -152,7 +152,11 @@ build_filename (const TrackDetails *track, gboolean temp_filename, GError **erro
905 g_set_error (error, 0, 0, _("Failed to get output format"));
908 - extension = gm_audio_profile_get_extension (profile);
910 + media_type = rb_gst_encoding_profile_get_media_type (profile);
911 + extension = rb_gst_media_type_to_extension (media_type);
912 + g_free (media_type);
913 + gst_encoding_profile_unref (profile);
916 len_extension = 1 + strlen (extension);
917 diff --git a/src/sj-main.c b/src/sj-main.c
918 index 0133c77..ded7300 100644
922 #include <gconf/gconf-client.h>
923 #include <brasero-medium-selection.h>
924 #include <brasero-volume.h>
925 -#include <profiles/gnome-media-profiles.h>
927 +#include <gst/pbutils/encoding-profile.h>
929 #include "bacon-message-connection.h"
930 #include "gconf-bridge.h"
931 +#include "rb-gst-media-types.h"
932 #include "sj-about.h"
933 #include "sj-metadata-getter.h"
934 #include "sj-extractor.h"
935 @@ -1132,11 +1133,13 @@ static void device_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *e
937 static void profile_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
939 - GMAudioProfile *profile;
940 + GstEncodingProfile *profile;
941 + const char *media_type;
943 - g_assert (strcmp (entry->key, GCONF_AUDIO_PROFILE) == 0);
944 + g_assert (strcmp (entry->key, GCONF_AUDIO_PROFILE_MEDIA_TYPE) == 0);
945 if (!entry->value) return;
946 - profile = gm_audio_profile_lookup (gconf_value_get_string (entry->value));
947 + media_type = gconf_value_get_string (entry->value);
948 + profile = rb_gst_get_encoding_profile (media_type);
950 g_object_set (extractor, "profile", profile, NULL);
952 @@ -1160,6 +1163,9 @@ static void profile_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *
957 + if (profile != NULL)
958 + gst_encoding_profile_unref (profile);
962 @@ -1684,7 +1690,7 @@ int main (int argc, char **argv)
963 gconf_client_notify_add (gconf_client, GCONF_OPEN, open_changed_cb, NULL, NULL, NULL);
964 gconf_client_notify_add (gconf_client, GCONF_BASEURI, baseuri_changed_cb, NULL, NULL, NULL);
965 gconf_client_notify_add (gconf_client, GCONF_STRIP, strip_changed_cb, NULL, NULL, NULL);
966 - gconf_client_notify_add (gconf_client, GCONF_AUDIO_PROFILE, profile_changed_cb, NULL, NULL, NULL);
967 + gconf_client_notify_add (gconf_client, GCONF_AUDIO_PROFILE_MEDIA_TYPE, profile_changed_cb, NULL, NULL, NULL);
968 gconf_client_notify_add (gconf_client, GCONF_PARANOIA, paranoia_changed_cb, NULL, NULL, NULL);
969 gconf_client_notify_add (gconf_client, GCONF_PATH_PATTERN, path_pattern_changed_cb, NULL, NULL, NULL);
970 gconf_client_notify_add (gconf_client, GCONF_FILE_PATTERN, file_pattern_changed_cb, NULL, NULL, NULL);
971 @@ -1694,9 +1700,6 @@ int main (int argc, char **argv)
972 gconf_client_notify_add (gconf_client, GCONF_HTTP_PROXY, http_proxy_changed_cb, NULL, NULL, NULL);
973 gconf_client_notify_add (gconf_client, GCONF_HTTP_PROXY_PORT, http_proxy_port_changed_cb, NULL, NULL, NULL);
975 - /* init gnome-media-profiles */
976 - gnome_media_profiles_init (gconf_client);
978 builder = gtk_builder_new ();
979 if (g_file_test (SOURCE_BUILDER, G_FILE_TEST_EXISTS) != FALSE) {
980 gtk_builder_add_from_file (builder, SOURCE_BUILDER, &error);
981 @@ -1834,7 +1837,7 @@ int main (int argc, char **argv)
982 baseuri_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_BASEURI, NULL, TRUE, NULL), NULL);
983 path_pattern_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_PATH_PATTERN, NULL, TRUE, NULL), NULL);
984 file_pattern_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_FILE_PATTERN, NULL, TRUE, NULL), NULL);
985 - profile_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_AUDIO_PROFILE, NULL, TRUE, NULL), NULL);
986 + profile_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_AUDIO_PROFILE_MEDIA_TYPE, NULL, TRUE, NULL), NULL);
987 paranoia_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_PARANOIA, NULL, TRUE, NULL), NULL);
988 strip_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_STRIP, NULL, TRUE, NULL), NULL);
989 eject_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_EJECT, NULL, TRUE, NULL), NULL);
990 diff --git a/src/sj-prefs.c b/src/sj-prefs.c
991 index 10dd220..f698d16 100644
995 #include "sound-juicer.h"
998 +#include <gst/pbutils/encoding-profile.h>
1000 #include <gconf/gconf-client.h>
1001 -#include <profiles/gnome-media-profiles.h>
1002 #include <brasero-drive-selection.h>
1004 +#include "rb-gst-media-types.h"
1005 #include "sj-util.h"
1006 #include "gconf-bridge.h"
1007 #include "sj-extracting.h"
1008 @@ -44,8 +45,6 @@ static GtkWidget *audio_profile;
1009 static GtkWidget *cd_option, *path_option, *file_option, *basepath_fcb, *check_strip, *check_eject, *check_open;
1010 static GtkWidget *path_example_label;
1012 -#define DEFAULT_AUDIO_PROFILE_NAME "cdlossy"
1017 @@ -79,12 +78,18 @@ static const FilePattern file_patterns[] = {
1019 void prefs_profile_changed (GtkWidget *widget, gpointer user_data)
1021 - GMAudioProfile *profile;
1023 + GtkTreeModel *model;
1025 + model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
1026 /* Handle the change being to unselect a profile */
1027 - if (gtk_combo_box_get_active (GTK_COMBO_BOX (widget)) != -1) {
1028 - profile = gm_audio_profile_choose_get_active (widget);
1029 - gconf_client_set_string (gconf_client, GCONF_AUDIO_PROFILE,
1030 - gm_audio_profile_get_id (profile), NULL);
1031 + if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter)) {
1033 + gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
1034 + 0, &media_type, -1);
1035 + gconf_client_set_string (gconf_client, GCONF_AUDIO_PROFILE_MEDIA_TYPE,
1036 + media_type, NULL);
1037 + g_free (media_type);
1041 @@ -165,25 +170,44 @@ G_MODULE_EXPORT void prefs_file_option_changed (GtkComboBox *combo, gpointer use
1043 G_MODULE_EXPORT void prefs_edit_profile_clicked (GtkButton *button, gpointer user_data)
1045 - GtkWidget *dialog;
1046 - dialog = gm_audio_profiles_edit_new (gconf_client, GTK_WINDOW (main_window));
1047 - gtk_widget_show_all (dialog);
1048 - gtk_dialog_run (GTK_DIALOG (dialog));
1049 + /* Not implemented */
1053 +sj_audio_profile_chooser_set_active (GtkWidget *chooser, const char *profile)
1056 + GtkTreeModel *model;
1060 + model = gtk_combo_box_get_model(GTK_COMBO_BOX(chooser));
1061 + if (gtk_tree_model_get_iter_first (model, &iter)) {
1065 + gtk_tree_model_get (model, &iter, 0, &media_type, -1);
1066 + if (g_strcmp0 (media_type, profile) == 0) {
1067 + gtk_combo_box_set_active_iter (GTK_COMBO_BOX (chooser), &iter);
1070 + g_free (media_type);
1071 + } while (done == FALSE && gtk_tree_model_iter_next (model, &iter));
1074 + if (done == FALSE) {
1075 + gtk_combo_box_set_active_iter (GTK_COMBO_BOX (chooser), NULL);
1079 static void audio_profile_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
1082 - g_return_if_fail (strcmp (entry->key, GCONF_AUDIO_PROFILE) == 0);
1083 + g_return_if_fail (strcmp (entry->key, GCONF_AUDIO_PROFILE_MEDIA_TYPE) == 0);
1084 if (!entry->value) return;
1085 value = gconf_value_get_string (entry->value);
1087 - /* If the value is empty, unset the combo. Otherwise try and set it. */
1088 - if (strcmp (value, "") == 0) {
1089 - gtk_combo_box_set_active (GTK_COMBO_BOX (audio_profile), -1);
1091 - gm_audio_profile_choose_set_active (audio_profile, value);
1094 + sj_audio_profile_chooser_set_active (audio_profile, value);
1097 static void baseuri_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
1098 @@ -224,7 +248,8 @@ static void pattern_label_update (void)
1100 char *file_pattern, *path_pattern;
1101 char *file_value, *path_value, *example, *format;
1102 - GMAudioProfile *profile;
1104 + GstEncodingProfile *profile;
1106 static const AlbumDetails sample_album = {
1107 "Help!", /* title */
1108 @@ -254,6 +279,8 @@ static void pattern_label_update (void)
1112 + media_type = rb_gst_encoding_profile_get_media_type (profile);
1113 + gst_encoding_profile_unref (profile);
1115 /* TODO: sucky. Replace with get-gconf-key-with-default mojo */
1116 file_pattern = gconf_client_get_string (gconf_client, GCONF_FILE_PATTERN, NULL);
1117 @@ -279,9 +306,10 @@ static void pattern_label_update (void)
1121 - gm_audio_profile_get_extension (profile),
1122 + rb_gst_media_type_to_extension (media_type),
1123 "</i></small>", NULL);
1125 + g_free (media_type);
1127 gtk_label_set_markup (GTK_LABEL (path_example_label), format);
1129 @@ -403,6 +431,41 @@ on_response (GtkDialog *dialog, gint response, gpointer user_data)
1133 +static GtkWidget *sj_audio_profile_chooser_new(void)
1135 + GstEncodingTarget *target;
1137 + GtkWidget *combo_box;
1138 + GtkCellRenderer *renderer;
1139 + GtkTreeModel *model;
1141 + model = GTK_TREE_MODEL (gtk_tree_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER));
1143 + target = rb_gst_get_default_encoding_target ();
1144 + for (p = gst_encoding_target_get_profiles (target); p != NULL; p = p->next) {
1145 + GstEncodingProfile *profile = GST_ENCODING_PROFILE (p->data);
1148 + media_type = rb_gst_encoding_profile_get_media_type (profile);
1149 + if (media_type == NULL) {
1152 + gtk_tree_store_insert_with_values (GTK_TREE_STORE (model),
1155 + 1, gst_encoding_profile_get_description (profile),
1157 + g_free (media_type);
1160 + combo_box = gtk_combo_box_new_with_model (model);
1161 + renderer = gtk_cell_renderer_text_new ();
1162 + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE);
1163 + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer, "text", 1, NULL);
1165 + return GTK_WIDGET (combo_box);
1169 * Clicked on Preferences in the UI
1171 @@ -449,11 +512,11 @@ G_MODULE_EXPORT void on_edit_preferences_cb (GtkMenuItem *item, gpointer user_da
1172 * using GtkBuilder. */
1173 audio_profile = GET_WIDGET ("audio_profile");
1175 - audio_profile = gm_audio_profile_choose_new();
1176 + audio_profile = sj_audio_profile_chooser_new();
1177 g_signal_connect (G_OBJECT (audio_profile), "changed",
1178 G_CALLBACK (prefs_profile_changed), NULL);
1179 - gtk_box_pack_start (GTK_BOX (box), audio_profile, TRUE, TRUE, 0);
1180 - gtk_widget_show (audio_profile);
1181 + gtk_box_pack_start (GTK_BOX (box), audio_profile, TRUE, TRUE, 0);
1182 + gtk_widget_show (audio_profile);
1184 check_strip = GET_WIDGET ("check_strip");
1185 check_eject = GET_WIDGET ("check_eject");
1186 @@ -474,7 +537,7 @@ G_MODULE_EXPORT void on_edit_preferences_cb (GtkMenuItem *item, gpointer user_da
1187 gconf_bridge_bind_property (bridge, GCONF_STRIP, G_OBJECT (check_strip), "active");
1188 gconf_client_notify_add (gconf_client, GCONF_DEVICE, device_changed_cb, NULL, NULL, NULL);
1189 gconf_client_notify_add (gconf_client, GCONF_BASEURI, baseuri_changed_cb, NULL, NULL, NULL);
1190 - gconf_client_notify_add (gconf_client, GCONF_AUDIO_PROFILE, audio_profile_changed_cb, NULL, NULL, NULL);
1191 + gconf_client_notify_add (gconf_client, GCONF_AUDIO_PROFILE_MEDIA_TYPE, audio_profile_changed_cb, NULL, NULL, NULL);
1192 gconf_client_notify_add (gconf_client, GCONF_PATH_PATTERN, path_pattern_changed_cb, NULL, NULL, NULL);
1193 gconf_client_notify_add (gconf_client, GCONF_FILE_PATTERN, file_pattern_changed_cb, NULL, NULL, NULL);
1194 gconf_client_notify_add (gconf_client, GCONF_STRIP, strip_changed_cb, NULL, NULL, NULL);
1195 @@ -482,7 +545,7 @@ G_MODULE_EXPORT void on_edit_preferences_cb (GtkMenuItem *item, gpointer user_da
1196 g_signal_connect (extractor, "notify::profile", pattern_label_update, NULL);
1198 baseuri_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_BASEURI, NULL, TRUE, NULL), NULL);
1199 - audio_profile_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_AUDIO_PROFILE, NULL, TRUE, NULL), NULL);
1200 + audio_profile_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_AUDIO_PROFILE_MEDIA_TYPE, NULL, TRUE, NULL), NULL);
1201 file_pattern_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_FILE_PATTERN, NULL, TRUE, NULL), NULL);
1202 path_pattern_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_PATH_PATTERN, NULL, TRUE, NULL), NULL);
1203 device_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_DEVICE, NULL, TRUE, NULL), NULL);
1204 diff --git a/src/sound-juicer.h b/src/sound-juicer.h
1205 index 2200fd0..3568de7 100644
1206 --- a/src/sound-juicer.h
1207 +++ b/src/sound-juicer.h
1208 @@ -151,6 +151,7 @@ void sj_debug (SjDebugDomain domain, const gchar* format, ...);
1209 #define GCONF_FILE_PATTERN GCONF_ROOT "/file_pattern"
1210 #define GCONF_PATH_PATTERN GCONF_ROOT "/path_pattern"
1211 #define GCONF_AUDIO_PROFILE GCONF_ROOT "/audio_profile"
1212 +#define GCONF_AUDIO_PROFILE_MEDIA_TYPE GCONF_ROOT "/audio_profile_media_type"
1213 #define GCONF_PARANOIA GCONF_ROOT "/paranoia"
1214 #define GCONF_STRIP GCONF_ROOT "/strip-special"
1215 #define GCONF_WINDOW GCONF_ROOT "/window"
1216 diff --git a/tests/Makefile.am b/tests/Makefile.am
1217 index 27906b2..0321975 100644
1218 --- a/tests/Makefile.am
1219 +++ b/tests/Makefile.am
1220 @@ -13,7 +13,6 @@ mb_test_CPPFLAGS = \
1223 $(GSTREAMER_CFLAGS) \
1224 - $(MEDIA_PROFILES_CFLAGS) \