Added podcast support, only from subsonic API for now, ref #726
This commit is contained in:
@@ -23,7 +23,6 @@
|
||||
#include "core/ILogger.hpp"
|
||||
#include "database/IDb.hpp"
|
||||
#include "database/Session.hpp"
|
||||
#include "database/objects/Track.hpp"
|
||||
|
||||
#include "TranscodingResourceHandler.hpp"
|
||||
|
||||
@@ -64,20 +63,17 @@ namespace lms::transcoding
|
||||
{
|
||||
av::InputParameters avInputParams;
|
||||
std::optional<std::size_t> estimatedContentLength;
|
||||
|
||||
avInputParams.file = inputParameters.filePath;
|
||||
avInputParams.offset = inputParameters.offset;
|
||||
avInputParams.streamIndex = inputParameters.streamIndex;
|
||||
|
||||
if (estimateContentLength)
|
||||
{
|
||||
auto& session{ _db.getTLSSession() };
|
||||
auto transaction{ session.createReadTransaction() };
|
||||
|
||||
db::Track::pointer track{ db::Track::find(session, inputParameters.trackId) };
|
||||
if (!track)
|
||||
return nullptr;
|
||||
|
||||
avInputParams.file = track->getAbsoluteFilePath();
|
||||
avInputParams.offset = inputParameters.offset;
|
||||
avInputParams.streamIndex = inputParameters.streamIndex;
|
||||
|
||||
if (estimateContentLength)
|
||||
estimatedContentLength = doEstimateContentLength(outputParameters.bitrate, track->getDuration());
|
||||
if (inputParameters.offset < inputParameters.duration)
|
||||
estimatedContentLength = doEstimateContentLength(outputParameters.bitrate, inputParameters.duration - inputParameters.offset);
|
||||
else
|
||||
LMS_LOG(TRANSCODING, WARNING, "Offset " << inputParameters.offset << " is greater than audio file duration " << inputParameters.duration << ": not estimating content length");
|
||||
}
|
||||
|
||||
return std::make_unique<TranscodingResourceHandler>(avInputParams, toAv(outputParameters), estimatedContentLength);
|
||||
|
||||
@@ -19,12 +19,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
#include "database/objects/TrackId.hpp"
|
||||
|
||||
namespace lms
|
||||
{
|
||||
namespace core
|
||||
@@ -43,9 +42,10 @@ namespace lms::transcoding
|
||||
{
|
||||
struct InputParameters
|
||||
{
|
||||
db::TrackId trackId;
|
||||
std::chrono::milliseconds offset{}; // Offset in the track file to start transcoding from
|
||||
std::optional<std::size_t> streamIndex; // Index of the stream to be transcoded (select "best" audio stream if not set)
|
||||
std::filesystem::path filePath;
|
||||
std::chrono::milliseconds duration{}; // Duration of the audio file
|
||||
std::chrono::milliseconds offset{}; // Offset in the audio file to start transcoding from
|
||||
std::optional<std::size_t> streamIndex; // Index of the stream to be transcoded (select the "best" audio stream if not set)
|
||||
};
|
||||
|
||||
enum class OutputFormat
|
||||
|
||||
Reference in New Issue
Block a user