- /* XXX: this should look at c to decide which of video/audio/subtitle
- get created.
- */
- video.reset (new VideoContent (this, c));
- audio.reset (new AudioContent (this, c));
- subtitle.reset (new SubtitleContent (this, c));
+ vector<shared_ptr<Content> >::const_iterator i = c.begin ();
+
+ bool need_video = false;
+ bool need_audio = false;
+ bool need_subtitle = false;
+
+ if (i != c.end ()) {
+ need_video = static_cast<bool> ((*i)->video);
+ need_audio = static_cast<bool> ((*i)->audio);
+ need_subtitle = static_cast<bool> ((*i)->subtitle);
+ }
+
+ while (i != c.end ()) {
+ if (need_video != static_cast<bool> ((*i)->video)) {
+ throw JoinError (_("Content to be joined must all have or not have video"));
+ }
+ if (need_audio != static_cast<bool> ((*i)->audio)) {
+ throw JoinError (_("Content to be joined must all have or not have audio"));
+ }
+ if (need_subtitle != static_cast<bool> ((*i)->subtitle)) {
+ throw JoinError (_("Content to be joined must all have or not have subtitles"));
+ }
+ ++i;
+ }
+
+ if (need_video) {
+ video.reset (new VideoContent (this, c));
+ }
+ if (need_audio) {
+ audio.reset (new AudioContent (this, c));
+ }
+ if (need_subtitle) {
+ subtitle.reset (new SubtitleContent (this, c));
+ }