using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.MediaInfo;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.IO;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
namespace MediaBrowser.Api.Playback.Hls
{
///
/// Class BaseHlsService
///
public abstract class BaseHlsService : BaseStreamingService
{
protected override string GetOutputFilePath(StreamState state)
{
var folder = ApplicationPaths.EncodedMediaCachePath;
var outputFileExtension = GetOutputFileExtension(state);
return Path.Combine(folder, GetCommandLineArguments("dummy\\dummy", state, false).GetMD5() + (outputFileExtension ?? string.Empty).ToLower());
}
///
/// Initializes a new instance of the class.
///
/// The app paths.
/// The user manager.
/// The library manager.
/// The iso manager.
/// The media encoder.
protected BaseHlsService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService, IFileSystem fileSystem)
: base(appPaths, userManager, libraryManager, isoManager, mediaEncoder, dtoService, fileSystem)
{
}
///
/// Gets the audio arguments.
///
/// The state.
/// System.String.
protected abstract string GetAudioArguments(StreamState state);
///
/// Gets the video arguments.
///
/// The state.
/// if set to true [perform subtitle conversion].
/// System.String.
protected abstract string GetVideoArguments(StreamState state, bool performSubtitleConversion);
///
/// Gets the segment file extension.
///
/// The state.
/// System.String.
protected abstract string GetSegmentFileExtension(StreamState state);
///
/// Gets the type of the transcoding job.
///
/// The type of the transcoding job.
protected override TranscodingJobType TranscodingJobType
{
get { return TranscodingJobType.Hls; }
}
///
/// Processes the request.
///
/// The request.
/// System.Object.
protected object ProcessRequest(StreamRequest request)
{
var state = GetState(request);
return ProcessRequestAsync(state).Result;
}
///
/// Processes the request async.
///
/// The state.
/// Task{System.Object}.
public async Task