Various minor cleanup
This commit is contained in:
@@ -25,9 +25,10 @@
|
||||
#include "core/IChildProcessManager.hpp"
|
||||
#include "core/IConfig.hpp"
|
||||
#include "core/ILogger.hpp"
|
||||
#include "core/Path.hpp"
|
||||
#include "core/Service.hpp"
|
||||
|
||||
#include "av/Types.hpp"
|
||||
|
||||
namespace lms::av::transcoding
|
||||
{
|
||||
|
||||
@@ -81,7 +82,7 @@ namespace lms::av::transcoding
|
||||
{
|
||||
if (!std::filesystem::exists(_inputParameters.trackPath))
|
||||
throw Exception{ "File '" + _inputParameters.trackPath.string() + "' does not exist!" };
|
||||
else if (!std::filesystem::is_regular_file(_inputParameters.trackPath))
|
||||
if (!std::filesystem::is_regular_file(_inputParameters.trackPath))
|
||||
throw Exception{ "File '" + _inputParameters.trackPath.string() + "' is not regular!" };
|
||||
}
|
||||
catch (const std::filesystem::filesystem_error& e)
|
||||
@@ -108,7 +109,7 @@ namespace lms::av::transcoding
|
||||
args.emplace_back("-ss");
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << std::fixed << std::showpoint << std::setprecision(3) << (_outputParameters.offset.count() / float{ 1000 });
|
||||
oss << std::fixed << std::showpoint << std::setprecision(3) << (_outputParameters.offset.count() / float{ 1'000 });
|
||||
args.emplace_back(oss.str());
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
|
||||
#include "av/TranscodingParameters.hpp"
|
||||
#include "av/Types.hpp"
|
||||
|
||||
namespace lms::core
|
||||
{
|
||||
@@ -37,7 +35,6 @@ namespace lms::av::transcoding
|
||||
public:
|
||||
Transcoder(const InputParameters& inputParameters, const OutputParameters& outputParameters);
|
||||
~Transcoder();
|
||||
|
||||
Transcoder(const Transcoder&) = delete;
|
||||
Transcoder& operator=(const Transcoder&) = delete;
|
||||
Transcoder(Transcoder&&) = delete;
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace lms::av::transcoding
|
||||
{
|
||||
LMS_LOG(TRANSCODING, DEBUG, "Writing " << _bytesReadyCount << " bytes back to client");
|
||||
|
||||
response.out().write(reinterpret_cast<const char*>(&_buffer[0]), _bytesReadyCount);
|
||||
response.out().write(reinterpret_cast<const char*>(_buffer.data()), _bytesReadyCount);
|
||||
_totalServedByteCount += _bytesReadyCount;
|
||||
_bytesReadyCount = 0;
|
||||
}
|
||||
@@ -78,24 +78,22 @@ namespace lms::av::transcoding
|
||||
|
||||
return continuation;
|
||||
}
|
||||
else
|
||||
|
||||
// pad with 0 if necessary as duration may not be accurate
|
||||
if (_estimatedContentLength && *_estimatedContentLength > _totalServedByteCount)
|
||||
{
|
||||
// pad with 0 if necessary as duration may not be accurate
|
||||
if (_estimatedContentLength && *_estimatedContentLength > _totalServedByteCount)
|
||||
{
|
||||
const std::size_t padSize{ *_estimatedContentLength - _totalServedByteCount };
|
||||
const std::size_t padSize{ *_estimatedContentLength - _totalServedByteCount };
|
||||
|
||||
LMS_LOG(TRANSCODING, DEBUG, "Adding " << padSize << " padding bytes");
|
||||
LMS_LOG(TRANSCODING, DEBUG, "Adding " << padSize << " padding bytes");
|
||||
|
||||
for (std::size_t i{}; i < padSize; ++i)
|
||||
response.out().put(0);
|
||||
for (std::size_t i{}; i < padSize; ++i)
|
||||
response.out().put(0);
|
||||
|
||||
_totalServedByteCount += padSize;
|
||||
}
|
||||
|
||||
LMS_LOG(TRANSCODING, DEBUG, "Transcoding finished. Total served byte count = " << _totalServedByteCount);
|
||||
_totalServedByteCount += padSize;
|
||||
}
|
||||
|
||||
LMS_LOG(TRANSCODING, DEBUG, "Transcoding finished. Total served byte count = " << _totalServedByteCount);
|
||||
|
||||
return {};
|
||||
}
|
||||
} // namespace lms::av::transcoding
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
|
||||
#include "av/TranscodingParameters.hpp"
|
||||
@@ -34,9 +33,13 @@ namespace lms::av::transcoding
|
||||
{
|
||||
public:
|
||||
TranscodingResourceHandler(const InputParameters& inputParameters, const OutputParameters& outputParameters, bool estimateContentLength);
|
||||
~TranscodingResourceHandler() override = default;
|
||||
|
||||
TranscodingResourceHandler(const TranscodingResourceHandler&) = delete;
|
||||
TranscodingResourceHandler& operator=(const TranscodingResourceHandler&) = delete;
|
||||
|
||||
private:
|
||||
Wt::Http::ResponseContinuation* processRequest(const Wt::Http::Request& request, Wt::Http::Response& reponse) override;
|
||||
Wt::Http::ResponseContinuation* processRequest(const Wt::Http::Request& request, Wt::Http::Response& response) override;
|
||||
void abort() override{};
|
||||
|
||||
static constexpr std::size_t _chunkSize{ 262'144 };
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
|
||||
#include "Types.hpp"
|
||||
|
||||
namespace lms::av::transcoding
|
||||
{
|
||||
struct InputParameters
|
||||
@@ -47,7 +45,7 @@ namespace lms::av::transcoding
|
||||
struct OutputParameters
|
||||
{
|
||||
OutputFormat format;
|
||||
std::size_t bitrate{ 128000 };
|
||||
std::size_t bitrate{ 128'000 };
|
||||
std::optional<std::size_t> stream; // Id of the stream to be transcoded (auto detect by default)
|
||||
std::chrono::milliseconds offset{ 0 };
|
||||
bool stripMetadata{ true };
|
||||
|
||||
Reference in New Issue
Block a user