aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/MediaInfo/MediaEncoderHelpers.cs
blob: 4485c40726d15e774b9112217ebde222cedeb9d3 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using MediaBrowser.Common.IO;
using MediaBrowser.Common.MediaInfo;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.IO;

namespace MediaBrowser.Controller.MediaInfo
{
    /// <summary>
    /// Class MediaEncoderHelpers
    /// </summary>
    public static class MediaEncoderHelpers
    {
        /// <summary>
        /// Gets the input argument.
        /// </summary>
        /// <param name="video">The video.</param>
        /// <param name="isoMount">The iso mount.</param>
        /// <param name="type">The type.</param>
        /// <returns>System.String[][].</returns>
        public static string[] GetInputArgument(Video video, IIsoMount isoMount, out InputType type)
        {
            var inputPath = isoMount == null ? new[] { video.Path } : new[] { isoMount.MountedPath };

            type = InputType.VideoFile;

            switch (video.VideoType)
            {
                case VideoType.BluRay:
                    type = InputType.Bluray;
                    break;
                case VideoType.Dvd:
                    type = InputType.Dvd;
                    inputPath = video.GetPlayableStreamFiles(inputPath[0]).ToArray();
                    break;
                case VideoType.Iso:
                    if (video.IsoType.HasValue)
                    {
                        switch (video.IsoType.Value)
                        {
                            case IsoType.BluRay:
                                type = InputType.Bluray;
                                break;
                            case IsoType.Dvd:
                                type = InputType.Dvd;
                                inputPath = video.GetPlayableStreamFiles(inputPath[0]).ToArray();
                                break;
                        }
                    }
                    break;
                case VideoType.VideoFile:
                    {
                        if (video.LocationType == LocationType.Remote)
                        {
                            type = InputType.Url;
                        }
                        break;
                    }
            }

            return inputPath;
        }

        /// <summary>
        /// Gets the type of the input.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>InputType.</returns>
        public static InputType GetInputType(BaseItem item)
        {
            var type = InputType.AudioFile;

            var video = item as Video;

            if (video != null)
            {
                switch (video.VideoType)
                {
                    case VideoType.BluRay:
                        type = InputType.Bluray;
                        break;
                    case VideoType.Dvd:
                        type = InputType.Dvd;
                        break;
                    case VideoType.Iso:
                        if (video.IsoType.HasValue)
                        {
                            switch (video.IsoType.Value)
                            {
                                case IsoType.BluRay:
                                    type = InputType.Bluray;
                                    break;
                                case IsoType.Dvd:
                                    type = InputType.Dvd;
                                    break;
                            }
                        }
                        break;
                }
            }

            return type;
        }
    }
}