summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Helpers/MP4Helper.cs
blob: 78e3b5ee2be9059c3adb9170f662cb0f60889339 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="MP4Helper.cs" company="HandBrake Project (http://handbrake.fr)">
//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
//   Defines the MP4Helper type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace HandBrakeWPF.Helpers
{
    using System.Linq;

    using HandBrakeWPF.Services.Encode.Model;
    using HandBrakeWPF.Services.Encode.Model.Models;

    /// <summary>
    /// The MP4 Format helper class
    /// </summary>
    public class MP4Helper
    {
        /// <summary>
        /// Gets a value indicating whether M4v extension is required.
        /// </summary>
        /// <param name="task">
        /// The task.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/> to indicate if this task requires m4v extension
        /// </returns>
        public static bool RequiresM4v(EncodeTask task)
        {
            if (task.OutputFormat == OutputFormat.Mp4)
            {
                bool audio =
                    task.AudioTracks.Any(
                        item =>
                        item.Encoder == AudioEncoder.Ac3Passthrough || item.Encoder == AudioEncoder.Ac3
                        || item.Encoder == AudioEncoder.DtsPassthrough || item.Encoder == AudioEncoder.Passthrough);

                bool subtitles = task.SubtitleTracks.Any(track => track.SubtitleType != SubtitleType.VobSub);

                return audio || subtitles;
            }

            return false;
        }
    }
}