add 96kbps + handle the encoding settings from user
This commit is contained in:
+1
-1
@@ -41,7 +41,7 @@ lms_SOURCES = \
|
|||||||
$(srcdir)/ui/explore/TracksInfoView.cpp \
|
$(srcdir)/ui/explore/TracksInfoView.cpp \
|
||||||
$(srcdir)/ui/explore/TracksView.cpp \
|
$(srcdir)/ui/explore/TracksView.cpp \
|
||||||
$(srcdir)/ui/resource/ImageResource.cpp \
|
$(srcdir)/ui/resource/ImageResource.cpp \
|
||||||
$(srcdir)/ui/resource/TranscodeResource.cpp \
|
$(srcdir)/ui/resource/AudioResource.cpp \
|
||||||
$(srcdir)/utils/Config.cpp \
|
$(srcdir)/utils/Config.cpp \
|
||||||
$(srcdir)/utils/Logger.cpp \
|
$(srcdir)/utils/Logger.cpp \
|
||||||
$(srcdir)/utils/Path.cpp \
|
$(srcdir)/utils/Path.cpp \
|
||||||
|
|||||||
@@ -42,8 +42,6 @@ enum class Encoding
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::string encodingToMimetype(Encoding encoding);
|
std::string encodingToMimetype(Encoding encoding);
|
||||||
int encodingToInt(Encoding encoding);
|
|
||||||
Encoding encodingFromInt(int encoding);
|
|
||||||
|
|
||||||
struct TranscodeParameters
|
struct TranscodeParameters
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ const std::vector<std::size_t>
|
|||||||
User::audioBitrates =
|
User::audioBitrates =
|
||||||
{
|
{
|
||||||
64000,
|
64000,
|
||||||
|
96000,
|
||||||
128000,
|
128000,
|
||||||
192000,
|
192000,
|
||||||
320000,
|
320000,
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
#include "admin/UsersView.hpp"
|
#include "admin/UsersView.hpp"
|
||||||
|
|
||||||
#include "resource/ImageResource.hpp"
|
#include "resource/ImageResource.hpp"
|
||||||
#include "resource/TranscodeResource.hpp"
|
#include "resource/AudioResource.hpp"
|
||||||
|
|
||||||
namespace UserInterface {
|
namespace UserInterface {
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ LmsApplication::LmsApplication(const Wt::WEnvironment& env, Wt::Dbo::SqlConnecti
|
|||||||
_appGroups(appGroups),
|
_appGroups(appGroups),
|
||||||
_scanner(scanner),
|
_scanner(scanner),
|
||||||
_imageResource(nullptr),
|
_imageResource(nullptr),
|
||||||
_transcodeResource(nullptr)
|
_audioResource(nullptr)
|
||||||
{
|
{
|
||||||
auto bootstrapTheme = std::make_unique<Wt::WBootstrapTheme>();
|
auto bootstrapTheme = std::make_unique<Wt::WBootstrapTheme>();
|
||||||
bootstrapTheme->setVersion(Wt::BootstrapVersion::v3);
|
bootstrapTheme->setVersion(Wt::BootstrapVersion::v3);
|
||||||
@@ -329,7 +329,7 @@ LmsApplication::createHome()
|
|||||||
}
|
}
|
||||||
|
|
||||||
_imageResource = std::make_shared<ImageResource>();
|
_imageResource = std::make_shared<ImageResource>();
|
||||||
_transcodeResource = std::make_shared<TranscodeResource>();
|
_audioResource = std::make_shared<AudioResource>();
|
||||||
|
|
||||||
setConfirmCloseMessage(Wt::WString::tr("Lms.quit-confirm"));
|
setConfirmCloseMessage(Wt::WString::tr("Lms.quit-confirm"));
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
namespace UserInterface {
|
namespace UserInterface {
|
||||||
|
|
||||||
class TranscodeResource;
|
class AudioResource;
|
||||||
class ImageResource;
|
class ImageResource;
|
||||||
|
|
||||||
// Events that can be listen to anywhere in the application
|
// Events that can be listen to anywhere in the application
|
||||||
@@ -75,7 +75,7 @@ class LmsApplication : public Wt::WApplication
|
|||||||
|
|
||||||
// Session application data
|
// Session application data
|
||||||
std::shared_ptr<ImageResource> getImageResource() { return _imageResource; }
|
std::shared_ptr<ImageResource> getImageResource() { return _imageResource; }
|
||||||
std::shared_ptr<TranscodeResource> getTranscodeResource() { return _transcodeResource; }
|
std::shared_ptr<AudioResource> getAudioResource() { return _audioResource; }
|
||||||
Database::Handler& getDb() { return _db;}
|
Database::Handler& getDb() { return _db;}
|
||||||
Wt::Dbo::Session& getDboSession() { return _db.getSession();}
|
Wt::Dbo::Session& getDboSession() { return _db.getSession();}
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ class LmsApplication : public Wt::WApplication
|
|||||||
Auth* _auth;
|
Auth* _auth;
|
||||||
Scanner::MediaScanner& _scanner;
|
Scanner::MediaScanner& _scanner;
|
||||||
std::shared_ptr<ImageResource> _imageResource;
|
std::shared_ptr<ImageResource> _imageResource;
|
||||||
std::shared_ptr<TranscodeResource> _transcodeResource;
|
std::shared_ptr<AudioResource> _audioResource;
|
||||||
bool _isAdmin = false;
|
bool _isAdmin = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "resource/ImageResource.hpp"
|
#include "resource/ImageResource.hpp"
|
||||||
#include "resource/TranscodeResource.hpp"
|
#include "resource/AudioResource.hpp"
|
||||||
|
|
||||||
#include "LmsApplication.hpp"
|
#include "LmsApplication.hpp"
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ MediaPlayer::loadTrack(Database::IdType trackId, bool play)
|
|||||||
{
|
{
|
||||||
Av::MediaFile mediaFile(track->getPath());
|
Av::MediaFile mediaFile(track->getPath());
|
||||||
|
|
||||||
auto resource = LmsApp->getTranscodeResource()->getUrl(trackId, Av::Encoding::MP3);
|
auto resource = LmsApp->getAudioResource()->getUrl(trackId);
|
||||||
auto imgResource = LmsApp->getImageResource()->getTrackUrl(trackId, 64);
|
auto imgResource = LmsApp->getImageResource()->getTrackUrl(trackId, 64);
|
||||||
|
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@@ -77,7 +77,7 @@ MediaPlayer::loadTrack(Database::IdType trackId, bool play)
|
|||||||
<< "};";
|
<< "};";
|
||||||
oss << "LMS.mediaplayer.loadTrack(params, " << (play ? "true" : "false") << ")"; // true to autoplay
|
oss << "LMS.mediaplayer.loadTrack(params, " << (play ? "true" : "false") << ")"; // true to autoplay
|
||||||
|
|
||||||
LMS_LOG(UI, DEBUG) << "Runing js = '" << oss.str() << "'";
|
LMS_LOG(UI, DEBUG) << "Running js = '" << oss.str() << "'";
|
||||||
|
|
||||||
_title->setText(Wt::WString::fromUTF8(track->getName()));
|
_title->setText(Wt::WString::fromUTF8(track->getName()));
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "TranscodeResource.hpp"
|
#include "AudioResource.hpp"
|
||||||
|
|
||||||
#include <Wt/Http/Response.h>
|
#include <Wt/Http/Response.h>
|
||||||
|
|
||||||
@@ -30,21 +30,21 @@
|
|||||||
namespace UserInterface {
|
namespace UserInterface {
|
||||||
|
|
||||||
|
|
||||||
TranscodeResource:: ~TranscodeResource()
|
AudioResource:: ~AudioResource()
|
||||||
{
|
{
|
||||||
beingDeleted();
|
beingDeleted();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
TranscodeResource::getUrl(Database::IdType trackId, Av::Encoding encoding) const
|
AudioResource::getUrl(Database::IdType trackId) const
|
||||||
{
|
{
|
||||||
std::string res = url()+ "&trackid=" + std::to_string(trackId) + "&encoding=" + std::to_string(Av::encodingToInt(encoding));
|
std::string res = url()+ "&trackid=" + std::to_string(trackId);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TranscodeResource::handleRequest(const Wt::Http::Request& request,
|
AudioResource::handleRequest(const Wt::Http::Request& request,
|
||||||
Wt::Http::Response& response)
|
Wt::Http::Response& response)
|
||||||
{
|
{
|
||||||
std::shared_ptr<Av::Transcoder> transcoder;
|
std::shared_ptr<Av::Transcoder> transcoder;
|
||||||
@@ -77,14 +77,6 @@ TranscodeResource::handleRequest(const Wt::Http::Request& request,
|
|||||||
auto offsetStr = request.getParameter("offset");
|
auto offsetStr = request.getParameter("offset");
|
||||||
if (offsetStr)
|
if (offsetStr)
|
||||||
parameters.offset = std::chrono::seconds(std::stol(*offsetStr));
|
parameters.offset = std::chrono::seconds(std::stol(*offsetStr));
|
||||||
|
|
||||||
auto encodingStr = request.getParameter("encoding");
|
|
||||||
if (encodingStr)
|
|
||||||
parameters.encoding = Av::encodingFromInt(std::stol(*encodingStr));
|
|
||||||
|
|
||||||
auto streamStr = request.getParameter("stream");
|
|
||||||
if (streamStr)
|
|
||||||
parameters.stream = std::stol(*streamStr);
|
|
||||||
}
|
}
|
||||||
catch (std::exception &e)
|
catch (std::exception &e)
|
||||||
{
|
{
|
||||||
@@ -107,6 +99,22 @@ TranscodeResource::handleRequest(const Wt::Http::Request& request,
|
|||||||
}
|
}
|
||||||
|
|
||||||
parameters.bitrate = LmsApp->getUser()->getAudioBitrate();
|
parameters.bitrate = LmsApp->getUser()->getAudioBitrate();
|
||||||
|
|
||||||
|
switch (LmsApp->getUser()->getAudioEncoding())
|
||||||
|
{
|
||||||
|
case Database::AudioEncoding::OGA:
|
||||||
|
parameters.encoding = Av::Encoding::OGA;
|
||||||
|
break;
|
||||||
|
case Database::AudioEncoding::WEBMA:
|
||||||
|
parameters.encoding = Av::Encoding::WEBMA;
|
||||||
|
break;
|
||||||
|
case Database::AudioEncoding::MP3:
|
||||||
|
parameters.encoding = Av::Encoding::MP3;
|
||||||
|
break;
|
||||||
|
case Database::AudioEncoding::AUTO:
|
||||||
|
default:
|
||||||
|
parameters.encoding = Av::Encoding::MP3;
|
||||||
|
}
|
||||||
transcoder = std::make_shared<Av::Transcoder>(track->getPath(), parameters);
|
transcoder = std::make_shared<Av::Transcoder>(track->getPath(), parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
#include <Wt/WResource.h>
|
#include <Wt/WResource.h>
|
||||||
|
|
||||||
#include "av/AvTranscoder.hpp"
|
#include "av/AvTranscoder.hpp"
|
||||||
@@ -31,12 +29,12 @@
|
|||||||
|
|
||||||
namespace UserInterface {
|
namespace UserInterface {
|
||||||
|
|
||||||
class TranscodeResource : public Wt::WResource
|
class AudioResource : public Wt::WResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~TranscodeResource();
|
~AudioResource();
|
||||||
|
|
||||||
std::string getUrl(Database::IdType trackId, Av::Encoding encoding) const;
|
std::string getUrl(Database::IdType trackId) const;
|
||||||
|
|
||||||
void handleRequest(const Wt::Http::Request& request,
|
void handleRequest(const Wt::Http::Request& request,
|
||||||
Wt::Http::Response& response);
|
Wt::Http::Response& response);
|
||||||
Reference in New Issue
Block a user