using boost::dynamic_pointer_cast;
int const AudioContentProperty::AUDIO_CHANNELS = 200;
-int const AudioContentProperty::AUDIO_LENGTH = 201;
-int const AudioContentProperty::AUDIO_FRAME_RATE = 202;
-int const AudioContentProperty::AUDIO_GAIN = 203;
-int const AudioContentProperty::AUDIO_DELAY = 204;
-int const AudioContentProperty::AUDIO_MAPPING = 205;
-int const AudioContentProperty::AUDIO_PROCESSOR = 206;
+int const AudioContentProperty::AUDIO_FRAME_RATE = 201;
+int const AudioContentProperty::AUDIO_GAIN = 202;
+int const AudioContentProperty::AUDIO_DELAY = 203;
+int const AudioContentProperty::AUDIO_MAPPING = 204;
+int const AudioContentProperty::AUDIO_PROCESSOR = 205;
AudioContent::AudioContent (shared_ptr<const Film> f)
: Content (f)
AudioContent::technical_summary () const
{
return String::compose (
- "audio: channels %1, length %2 frames, content rate %3, resampled rate %4",
+ "audio: channels %1, content rate %2, resampled rate %3",
audio_channels(),
- audio_length(),
audio_frame_rate(),
resampled_audio_frame_rate()
);
{
public:
static int const AUDIO_CHANNELS;
- static int const AUDIO_LENGTH;
static int const AUDIO_FRAME_RATE;
static int const AUDIO_GAIN;
static int const AUDIO_DELAY;
/** @return number of audio channels in the content */
virtual int audio_channels () const = 0;
- /** @return the length of the audio in the content */
- virtual Frame audio_length () const = 0;
/** @return the frame rate of the content */
virtual int audio_frame_rate () const = 0;
virtual AudioMapping audio_mapping () const = 0;
signal_changed (FFmpegContentProperty::AUDIO_STREAM);
}
-Frame
-FFmpegContent::audio_length () const
-{
- if (!audio_stream ()) {
- return 0;
- }
-
- /* We're talking about the content's audio length here, at the content's frame
- rate. We assume it's the same as the video's length, and we can just convert
- using the content's rates.
- */
- return (video_length () / video_frame_rate ()) * audio_frame_rate ();
-}
-
int
FFmpegContent::audio_channels () const
{
/* AudioContent */
int audio_channels () const;
- Frame audio_length () const;
int audio_frame_rate () const;
AudioMapping audio_mapping () const;
void set_audio_mapping (AudioMapping);
}
signal_changed (AudioContentProperty::AUDIO_CHANNELS);
- signal_changed (AudioContentProperty::AUDIO_LENGTH);
signal_changed (AudioContentProperty::AUDIO_FRAME_RATE);
int const p = processed_audio_channels ();
boost::mutex::scoped_lock lm (_mutex);
return _audio_channels;
}
-
+
Frame audio_length () const {
boost::mutex::scoped_lock lm (_mutex);
return _audio_length;
#include "lib/content.h"
#include "lib/video_content.h"
#include "lib/audio_content.h"
+#include "lib/single_stream_audio_content.h"
#include <boost/algorithm/string.hpp>
using std::string;
_("Audio channels"),
std_to_wx (raw_convert<string> (audio->audio_channels ()))
);
+ }
+
+ shared_ptr<SingleStreamAudioContent> single = dynamic_pointer_cast<SingleStreamAudioContent> (content);
+ if (single) {
add_property (
_("Audio length"),
- std_to_wx (raw_convert<string> (audio->audio_length())) + " " + _("audio frames")
+ std_to_wx (raw_convert<string> (single->audio_length())) + " " + _("audio frames")
);
}
using std::min;
using boost::shared_ptr;
-class TestAudioDecoder : public AudioDecoder
-{
-public:
- TestAudioDecoder (shared_ptr<AudioContent> content)
- : AudioDecoder (content)
- , _position (0)
- {}
-
- bool pass (PassReason)
- {
- Frame const N = min (
- Frame (2000),
- _audio_content->audio_length() - _position
- );
-
- shared_ptr<AudioBuffers> buffers (new AudioBuffers (_audio_content->audio_channels(), N));
- for (int i = 0; i < _audio_content->audio_channels(); ++i) {
- for (int j = 0; j < N; ++j) {
- buffers->data(i)[j] = j + _position;
- }
- }
-
- audio (buffers, ContentTime::from_frames (_position, _audio_content->resampled_audio_frame_rate ()));
- _position += N;
-
- return N < 2000;
- }
-
- void seek (ContentTime t, bool accurate)
- {
- AudioDecoder::seek (t, accurate);
- _position = t.frames (_audio_content->resampled_audio_frame_rate ());
- }
-
-private:
- Frame _position;
-};
-
class TestAudioContent : public AudioContent
{
public:
void set_audio_mapping (AudioMapping) {}
};
+class TestAudioDecoder : public AudioDecoder
+{
+public:
+ TestAudioDecoder (shared_ptr<TestAudioContent> content)
+ : AudioDecoder (content)
+ , _test_audio_content (content)
+ , _position (0)
+ {}
+
+ bool pass (PassReason)
+ {
+ Frame const N = min (
+ Frame (2000),
+ _test_audio_content->audio_length() - _position
+ );
+
+ shared_ptr<AudioBuffers> buffers (new AudioBuffers (_audio_content->audio_channels(), N));
+ for (int i = 0; i < _audio_content->audio_channels(); ++i) {
+ for (int j = 0; j < N; ++j) {
+ buffers->data(i)[j] = j + _position;
+ }
+ }
+
+ audio (buffers, ContentTime::from_frames (_position, _audio_content->resampled_audio_frame_rate ()));
+ _position += N;
+
+ return N < 2000;
+ }
+
+ void seek (ContentTime t, bool accurate)
+ {
+ AudioDecoder::seek (t, accurate);
+ _position = t.frames (_audio_content->resampled_audio_frame_rate ());
+ }
+
+private:
+ boost::shared_ptr<TestAudioContent> _test_audio_content;
+ Frame _position;
+};
+
shared_ptr<TestAudioContent> content;
shared_ptr<TestAudioDecoder> decoder;