using namespace std;
using namespace boost;
-/** Write state to a stream.
- * @param f Stream to write to.
- */
+/** Write state to our `metadata' file */
void
FilmState::write_metadata () const
{
throw CreateFileError (m);
}
- /* XXX: reorder this */
-
/* User stuff */
f << "name " << _name << "\n";
f << "use_dci_name " << _use_dci_name << "\n";
if (_dcp_content_type) {
f << "dcp_content_type " << _dcp_content_type->pretty_name () << "\n";
}
- f << "frames_per_second " << _frames_per_second << "\n";
if (_format) {
f << "format " << _format->as_metadata () << "\n";
}
f << "audio_gain " << _audio_gain << "\n";
f << "audio_delay " << _audio_delay << "\n";
f << "still_duration " << _still_duration << "\n";
+ f << "selected_subtitle_stream " << _subtitle_stream << "\n";
f << "with_subtitles " << _with_subtitles << "\n";
f << "subtitle_offset " << _subtitle_offset << "\n";
f << "subtitle_scale " << _subtitle_scale << "\n";
f << "width " << _size.width << "\n";
f << "height " << _size.height << "\n";
f << "length " << _length << "\n";
- f << "audio_channels " << _audio_channels << "\n";
f << "audio_sample_rate " << _audio_sample_rate << "\n";
- f << "audio_sample_format " << audio_sample_format_to_string (_audio_sample_format) << "\n";
f << "content_digest " << _content_digest << "\n";
- f << "selected_subtitle_stream " << _subtitle_stream << "\n";
f << "has_subtitles " << _has_subtitles << "\n";
- for (vector<Stream>::const_iterator i = _audio_streams.begin(); i != _audio_streams.end(); ++i) {
+ for (vector<AudioStream>::const_iterator i = _audio_streams.begin(); i != _audio_streams.end(); ++i) {
f << "audio_stream " << i->to_string () << "\n";
}
- for (vector<Stream>::const_iterator i = _subtitle_streams.begin(); i != _subtitle_streams.end(); ++i) {
+ for (vector<SubtitleStream>::const_iterator i = _subtitle_streams.begin(); i != _subtitle_streams.end(); ++i) {
f << "subtitle_stream " << i->to_string () << "\n";
}
+ f << "frames_per_second " << _frames_per_second << "\n";
+
_dirty = false;
}
-/** Read state from a key / value pair.
- * @param k Key.
- * @param v Value.
- */
+/** Read state from our metadata file */
void
FilmState::read_metadata ()
{
_content = v;
} else if (k == "dcp_content_type") {
_dcp_content_type = DCPContentType::from_pretty_name (v);
- } else if (k == "frames_per_second") {
- _frames_per_second = atof (v.c_str ());
} else if (k == "format") {
_format = Format::from_metadata (v);
} else if (k == "left_crop") {
_audio_delay = atoi (v.c_str ());
} else if (k == "still_duration") {
_still_duration = atoi (v.c_str ());
+ } else if (k == "selected_subtitle_stream") {
+ _subtitle_stream = atoi (v.c_str ());
} else if (k == "with_subtitles") {
_with_subtitles = (v == "1");
} else if (k == "subtitle_offset") {
_subtitle_offset = atoi (v.c_str ());
} else if (k == "subtitle_scale") {
_subtitle_scale = atof (v.c_str ());
- } else if (k == "selected_subtitle_stream") {
- _subtitle_stream = atoi (v.c_str ());
} else if (k == "audio_language") {
_audio_language = v;
} else if (k == "subtitle_language") {
_size.height = atoi (v.c_str ());
} else if (k == "length") {
_length = atof (v.c_str ());
- } else if (k == "audio_channels") {
- _audio_channels = atoi (v.c_str ());
} else if (k == "audio_sample_rate") {
_audio_sample_rate = atoi (v.c_str ());
- } else if (k == "audio_sample_format") {
- _audio_sample_format = audio_sample_format_from_string (v);
} else if (k == "content_digest") {
_content_digest = v;
} else if (k == "has_subtitles") {
_has_subtitles = (v == "1");
} else if (k == "audio_stream") {
- _audio_streams.push_back (Stream (v));
+ _audio_streams.push_back (AudioStream (v));
} else if (k == "subtitle_stream") {
- _subtitle_streams.push_back (Stream (v));
+ _subtitle_streams.push_back (SubtitleStream (v));
+ } else if (k == "frames_per_second") {
+ _frames_per_second = atof (v.c_str ());
}
}
return VIDEO;
}
-/** @return Number of bytes per sample of a single channel */
+/** @return The sampling rate that we will resample the audio to */
int
-FilmState::bytes_per_sample () const
-{
- switch (_audio_sample_format) {
- case AV_SAMPLE_FMT_S16:
- return 2;
- default:
- return 0;
- }
-
- return 0;
-}
-
-int
-FilmState::target_sample_rate () const
+FilmState::target_audio_sample_rate () const
{
/* Resample to a DCI-approved sample rate */
double t = dcp_audio_sample_rate (_audio_sample_rate);
d << "_";
}
- switch (_audio_channels) {
+ switch (_audio_streams[_audio_stream].channels()) {
case 1:
d << "10_";
break;
case 6:
d << "51_";
break;
+ case 8:
+ d << "71_";
+ break;
}
d << "2K_";
shared_ptr<Decoder> d = decoder_factory (s, o, 0, 0);
set_size (d->native_size ());
- set_length (d->length_in_frames ());
set_frames_per_second (d->frames_per_second ());
- set_audio_channels (d->audio_channels ());
set_audio_sample_rate (d->audio_sample_rate ());
- set_audio_sample_format (d->audio_sample_format ());
set_has_subtitles (d->has_subtitles ());
set_audio_streams (d->audio_streams ());
set_subtitle_streams (d->subtitle_streams ());
- set_audio_stream (audio_streams().empty() ? -1 : audio_streams().front().id);
- set_subtitle_stream (subtitle_streams().empty() ? -1 : subtitle_streams().front().id);
- set_content_digest (md5_digest (content_path ()));
+ set_audio_stream (audio_streams().empty() ? -1 : 0);
+ set_subtitle_stream (subtitle_streams().empty() ? -1 : 0);
_content = c;
signal_changed (CONTENT);
+
+ set_content_digest (md5_digest (content_path ()));
}
void
signal_changed (LENGTH);
}
-void
-FilmState::set_audio_channels (int c)
-{
- _audio_channels = c;
- signal_changed (AUDIO_CHANNELS);
-}
-
void
FilmState::set_audio_sample_rate (int r)
{
signal_changed (AUDIO_SAMPLE_RATE);
}
-void
-FilmState::set_audio_sample_format (AVSampleFormat f)
-{
- _audio_sample_format = f;
- _dirty = true;
-}
-
void
FilmState::set_content_digest (string d)
{
}
void
-FilmState::set_audio_streams (vector<Stream> s)
+FilmState::set_audio_streams (vector<AudioStream> s)
{
_audio_streams = s;
_dirty = true;
}
void
-FilmState::set_subtitle_streams (vector<Stream> s)
+FilmState::set_subtitle_streams (vector<SubtitleStream> s)
{
_subtitle_streams = s;
_dirty = true;
{
return shared_ptr<FilmState> (new FilmState (*this));
}
+
+int
+FilmState::audio_channels () const
+{
+ if (_audio_stream == -1) {
+ return 0;
+ }
+
+ return _audio_streams[_audio_stream].channels ();
+}