summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-03-31 15:24:38 +0100
committerCarl Hetherington <cth@carlh.net>2013-03-31 15:24:38 +0100
commit5920000d247ab3ef7fb9ba29c6ba238b323cf909 (patch)
treeb4ca56096992df06dc2daad9e859165542f9443d /src/lib
parent127672223cca569986e35c91265e269ed5a6561c (diff)
Allow adding of content.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/imagemagick_content.cc25
-rw-r--r--src/lib/imagemagick_content.h4
-rw-r--r--src/lib/sndfile_content.cc16
-rw-r--r--src/lib/sndfile_content.h6
-rw-r--r--src/lib/util.cc13
-rw-r--r--src/lib/util.h6
6 files changed, 50 insertions, 20 deletions
diff --git a/src/lib/imagemagick_content.cc b/src/lib/imagemagick_content.cc
index d0887c0aa..806c8ac5d 100644
--- a/src/lib/imagemagick_content.cc
+++ b/src/lib/imagemagick_content.cc
@@ -1,2 +1,27 @@
#include "imagemagick_content.h"
+#include "compose.hpp"
+#include "i18n.h"
+
+using std::string;
+
+ImageMagickContent::ImageMagickContent (boost::filesystem::path f)
+ : Content (f)
+ , VideoContent (f)
+{
+
+}
+
+string
+ImageMagickContent::summary () const
+{
+ return String::compose (_("Image: %1"), file().filename ());
+}
+
+bool
+ImageMagickContent::valid_file (boost::filesystem::path f)
+{
+ string ext = f.extension().string();
+ transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
+ return (ext == ".tif" || ext == ".tiff" || ext == ".jpg" || ext == ".jpeg" || ext == ".png" || ext == ".bmp");
+}
diff --git a/src/lib/imagemagick_content.h b/src/lib/imagemagick_content.h
index 985aa0e8d..0dd5baba8 100644
--- a/src/lib/imagemagick_content.h
+++ b/src/lib/imagemagick_content.h
@@ -4,4 +4,8 @@ class ImageMagickContent : public VideoContent
{
public:
ImageMagickContent (boost::filesystem::path);
+
+ std::string summary () const;
+
+ static bool valid_file (boost::filesystem::path);
};
diff --git a/src/lib/sndfile_content.cc b/src/lib/sndfile_content.cc
index 8f5b28901..53df4deea 100644
--- a/src/lib/sndfile_content.cc
+++ b/src/lib/sndfile_content.cc
@@ -5,6 +5,13 @@
using namespace std;
+SndfileContent::SndfileContent (boost::filesystem::path f)
+ : Content (f)
+ , AudioContent (f)
+{
+
+}
+
string
SndfileContent::summary () const
{
@@ -39,3 +46,12 @@ SndfileContent::audio_channel_layout () const
return 0;
}
+
+bool
+SndfileContent::valid_file (boost::filesystem::path f)
+{
+ /* XXX: more extensions */
+ string ext = f.extension().string();
+ transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
+ return (ext == ".wav" || ext == ".aif" || ext == ".aiff");
+}
diff --git a/src/lib/sndfile_content.h b/src/lib/sndfile_content.h
index e84617ed3..10cb428a1 100644
--- a/src/lib/sndfile_content.h
+++ b/src/lib/sndfile_content.h
@@ -3,11 +3,15 @@
class SndfileContent : public AudioContent
{
public:
+ SndfileContent (boost::filesystem::path);
+
std::string summary () const;
- /* AudioDecoder */
+ /* AudioContent */
int audio_channels () const;
ContentAudioFrame audio_length () const;
int audio_frame_rate () const;
int64_t audio_channel_layout () const;
+
+ static bool valid_file (boost::filesystem::path);
};
diff --git a/src/lib/util.cc b/src/lib/util.cc
index 024740867..1c020875a 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -878,19 +878,6 @@ video_frames_to_audio_frames (SourceFrame v, float audio_sample_rate, float fram
return ((int64_t) v * audio_sample_rate / frames_per_second);
}
-/** @param f Filename.
- * @return true if this file is a still image, false if it is something else.
- */
-bool
-still_image_file (string f)
-{
- string ext = boost::filesystem::path(f).extension().string();
-
- transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
-
- return (ext == N_(".tif") || ext == N_(".tiff") || ext == N_(".jpg") || ext == N_(".jpeg") || ext == N_(".png") || ext == N_(".bmp"));
-}
-
/** @return A pair containing CPU model name and the number of processors */
pair<string, int>
cpu_info ()
diff --git a/src/lib/util.h b/src/lib/util.h
index 87274cfff..b8c1e3116 100644
--- a/src/lib/util.h
+++ b/src/lib/util.h
@@ -106,11 +106,6 @@ struct FrameRateConversion
int best_dcp_frame_rate (float);
-enum ContentType {
- STILL, ///< content is still images
- VIDEO ///< content is a video
-};
-
/** @struct Crop
* @brief A description of the crop of an image or video.
*/
@@ -292,7 +287,6 @@ private:
};
extern int64_t video_frames_to_audio_frames (SourceFrame v, float audio_sample_rate, float frames_per_second);
-extern bool still_image_file (std::string);
extern std::pair<std::string, int> cpu_info ();
#endif