+ stringstream d;
+
+ string fixed_name = to_upper_copy (name());
+ for (size_t i = 0; i < fixed_name.length(); ++i) {
+ if (fixed_name[i] == ' ') {
+ fixed_name[i] = '-';
+ }
+ }
+
+ /* Spec is that the name part should be maximum 14 characters, as I understand it */
+ if (fixed_name.length() > 14) {
+ fixed_name = fixed_name.substr (0, 14);
+ }
+
+ d << fixed_name;
+
+ if (dcp_content_type()) {
+ d << "_" << dcp_content_type()->dci_name();
+ }
+
+ if (three_d ()) {
+ d << "-3D";
+ }
+
+ if (video_frame_rate() != 24) {
+ d << "-" << video_frame_rate();
+ }
+
+ if (container()) {
+ d << "_" << container()->dci_name();
+ }
+
+ DCIMetadata const dm = dci_metadata ();
+
+ if (!dm.audio_language.empty ()) {
+ d << "_" << dm.audio_language;
+ if (!dm.subtitle_language.empty() && with_subtitles()) {
+ d << "-" << dm.subtitle_language;
+ } else {
+ d << "-XX";
+ }
+ }
+
+ if (!dm.territory.empty ()) {
+ d << "_" << dm.territory;
+ if (!dm.rating.empty ()) {
+ d << "-" << dm.rating;
+ }
+ }
+
+ switch (audio_channels ()) {
+ case 1:
+ d << "_10";
+ break;
+ case 2:
+ d << "_20";
+ break;
+ case 3:
+ d << "_30";
+ break;
+ case 4:
+ d << "_40";
+ break;
+ case 5:
+ d << "_50";
+ break;
+ case 6:
+ d << "_51";
+ break;
+ }
+
+ d << "_" << resolution_to_string (_resolution);
+
+ if (!dm.studio.empty ()) {
+ d << "_" << dm.studio;
+ }
+
+ if (if_created_now) {
+ d << "_" << boost::gregorian::to_iso_string (boost::gregorian::day_clock::local_day ());
+ } else {
+ d << "_" << boost::gregorian::to_iso_string (_dci_date);
+ }
+
+ if (!dm.facility.empty ()) {
+ d << "_" << dm.facility;
+ }
+
+ if (!dm.package_type.empty ()) {
+ d << "_" << dm.package_type;
+ }
+
+ return d.str ();