[mistelix] Detects if a project uses MP3 but the user has no MP3 decodec
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mistelix] Detects if a project uses MP3 but the user has no MP3 decodec
- Date: Tue, 2 Nov 2010 20:28:45 +0000 (UTC)
commit a6022276061451f6a23309c239b8c28e85bd830d
Author: Jordi Mas <jmas softcatala org>
Date: Tue Nov 2 21:30:40 2010 +0100
Detects if a project uses MP3 but the user has no MP3 decodec
libmistelix/mistelix.h | 4 +-
po/POTFILES.in | 1 +
src/Backends/GStreamer/DetectMedia.cs | 56 +++++++++++++++++++++++++++++++++
src/Backends/GStreamer/Video.cs | 2 +-
src/Core/Dependencies.cs | 11 ++++++-
src/Core/SlideShow.cs | 25 ++++++++++++++
src/DataModel/Project.cs | 19 +++++++++++
src/Makefile.am | 1 +
src/mistelix.cs | 18 ++++++++++
9 files changed, 133 insertions(+), 4 deletions(-)
---
diff --git a/libmistelix/mistelix.h b/libmistelix/mistelix.h
index 40fbad2..2170287 100644
--- a/libmistelix/mistelix.h
+++ b/libmistelix/mistelix.h
@@ -57,14 +57,14 @@ unsigned int mistelix_get_plugins_count ();
void mistelix_get_plugins (char *plugins[]);
+void mistelix_detect_media (const char* file, char* media);
+
/* Private (not exposed) but shared within the library */
void mistelix_check_init ();
void mistelix_check_started ();
-void mistelix_detect_media (const char* file, char* media);
-
#endif /* __MISTELIX_H__ */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index e52cf2e..1873be9 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -15,6 +15,7 @@ src/Core/Dependencies.cs
src/Core/DvdProjectBuilder.cs
src/Core/NoneTransition.cs
src/Core/ResolutionManager.cs
+src/Core/SlideShow.cs
src/Core/SlideShowsProjectBuilder.cs
src/Core/ThumbnailSizeManager.cs
src/DataModel/AspectRatio.cs
diff --git a/src/Backends/GStreamer/DetectMedia.cs b/src/Backends/GStreamer/DetectMedia.cs
new file mode 100644
index 0000000..7ece48f
--- /dev/null
+++ b/src/Backends/GStreamer/DetectMedia.cs
@@ -0,0 +1,56 @@
+//
+// Copyright (C) 2010 Jordi Mas i Hernandez, jmas softcatala org
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Text;
+using System.Runtime.InteropServices;
+using Mono.Unix;
+
+using Mistelix.Core;
+
+namespace Mistelix.Backends.GStreamer
+{
+ //
+ // GStreamer detect media functions
+ //
+ public static class DetectMedia
+ {
+ [DllImport ("libmistelix")]
+ static extern void mistelix_detect_media (string file, StringBuilder media);
+
+ static string [] extensions;
+
+ static DetectMedia ()
+ {
+
+ }
+
+ static public string GetType (string file)
+ {
+ StringBuilder media = new StringBuilder (2048);
+ mistelix_detect_media (file, media);
+
+ return media.ToString ();
+ }
+ }
+}
diff --git a/src/Backends/GStreamer/Video.cs b/src/Backends/GStreamer/Video.cs
index 4d33f04..c7db06d 100644
--- a/src/Backends/GStreamer/Video.cs
+++ b/src/Backends/GStreamer/Video.cs
@@ -105,7 +105,7 @@ namespace Mistelix.Backends.GStreamer
msg = String.Format (Catalog.GetString ("The file '{0}' is encoded in a recognised format. However, you are missing the GStreamer plug-in '{1}' to decode it."), file, rslt);
return false;
default:
- throw new Exception ("Unexpected result");
+ throw new InvalidOperationException ("Unexpected result");
}
}
diff --git a/src/Core/Dependencies.cs b/src/Core/Dependencies.cs
index 0e7c1d7..33da7a2 100644
--- a/src/Core/Dependencies.cs
+++ b/src/Core/Dependencies.cs
@@ -78,7 +78,7 @@ namespace Mistelix.Core
List <Dependency> DependencyList;
bool status_checked;
- bool dvd_support, theora_support;
+ bool dvd_support, theora_support, mp3_support;
public Dependencies ()
{
@@ -116,6 +116,13 @@ namespace Mistelix.Core
}
}
+ public bool MP3Support {
+ get {
+ Check ();
+ return mp3_support;
+ }
+ }
+
public List <Dependency> Status {
get {
Check ();
@@ -186,6 +193,8 @@ namespace Mistelix.Core
{
theora_support = true;
}
+
+ mp3_support = founds [(int) Codecs.FLUMP3DEC];
}
void CheckFmpeg (string [] used, bool [] founds)
diff --git a/src/Core/SlideShow.cs b/src/Core/SlideShow.cs
index 4314595..767342c 100644
--- a/src/Core/SlideShow.cs
+++ b/src/Core/SlideShow.cs
@@ -23,6 +23,7 @@
using System;
using Gdk;
+using Mono.Unix;
using Mistelix.Transitions;
using Mistelix.Core;
@@ -150,6 +151,30 @@ namespace Mistelix.Core
}
return collection;
}
+
+ // Check if the audio uses a supported format
+ public bool AudioSupportedFormat (out string msg)
+ {
+ Dependencies dependencies;
+ string format;
+
+ format = Backends.GStreamer.DetectMedia.GetType (AudioFile);
+ Logger.Debug ("SlideShow.SupportedFormat. Filename {0} is {1}", AudioFile, format);
+
+ dependencies = new Dependencies ();
+
+ if (String.Compare (format, "application/x-id3", StringComparison.OrdinalIgnoreCase) == 0)
+ {
+ if (dependencies.MP3Support == false)
+ {
+ msg = String.Format (Catalog.GetString ("The file '{0}' is encoded in MP3 but you do not have the right codec installed."), AudioFile);
+ return false;
+ }
+ }
+
+ msg = string.Empty;
+ return true;
+ }
}
}
diff --git a/src/DataModel/Project.cs b/src/DataModel/Project.cs
index e52fd3c..d83e5bd 100644
--- a/src/DataModel/Project.cs
+++ b/src/DataModel/Project.cs
@@ -60,6 +60,25 @@ namespace Mistelix.DataModel
get { return buttons;}
}
+ public bool AudioSupportedFormat (out string msg)
+ {
+ SlideShow slide;
+
+ foreach (ProjectElement element in Elements)
+ {
+ slide = element as SlideShow;
+
+ if (slide == null)
+ continue;
+
+ if (slide.AudioSupportedFormat (out msg) == false)
+ return false;
+ }
+
+ msg = string.Empty;
+ return true;
+ }
+
public string FileToFullPath (string file)
{
return Path.Combine (details.OutputDir, file);
diff --git a/src/Makefile.am b/src/Makefile.am
index f009ef1..a3349d2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -71,6 +71,7 @@ MISTELIX_CSDISTFILES = \
$(srcdir)/Widgets/WelcomeView.cs \
$(srcdir)/DataModel/RecentFile.cs \
$(srcdir)/Core/RecentFilesStorage.cs \
+ $(srcdir)/Backends/GStreamer/DetectMedia.cs \
$(srcdir)/Backends/GStreamer/Video.cs \
$(srcdir)/Backends/GStreamer/Thumbnail.cs \
$(srcdir)/Backends/GStreamer/SlideShow.cs \
diff --git a/src/mistelix.cs b/src/mistelix.cs
index a8b5db2..444adc6 100644
--- a/src/mistelix.cs
+++ b/src/mistelix.cs
@@ -322,8 +322,26 @@ namespace Mistelix
{
Dependencies dependencies;
bool support;
+ string msg_audio;
dependencies = new Dependencies ();
+
+ if (project.AudioSupportedFormat (out msg_audio) == false)
+ {
+ string msg;
+
+ msg = String.Format (Catalog.GetString (
+ // Translators: {0} is the error message
+ "{0}\n\nGo to 'Check Mistelix's Dependencies Requirements' dialog and make sure that you have the right audio codecs installed.\n\nIf you continue, your project will have no audio."),
+ msg_audio);
+
+ MessageDialog md = new MessageDialog (app_window,
+ DialogFlags.Modal, MessageType.Warning,
+ ButtonsType.Ok, false, msg);
+
+ md.Run ();
+ md.Destroy ();
+ }
if (project.Details.Type == ProjectType.DVD)
support = dependencies.DvdSupport;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]