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/TracksView.cpp \
|
||||
$(srcdir)/ui/resource/ImageResource.cpp \
|
||||
$(srcdir)/ui/resource/TranscodeResource.cpp \
|
||||
$(srcdir)/ui/resource/AudioResource.cpp \
|
||||
$(srcdir)/utils/Config.cpp \
|
||||
$(srcdir)/utils/Logger.cpp \
|
||||
$(srcdir)/utils/Path.cpp \
|
||||
|
||||
@@ -42,8 +42,6 @@ enum class Encoding
|
||||
};
|
||||
|
||||
std::string encodingToMimetype(Encoding encoding);
|
||||
int encodingToInt(Encoding encoding);
|
||||
Encoding encodingFromInt(int encoding);
|
||||
|
||||
struct TranscodeParameters
|
||||
{
|
||||
|
||||
@@ -28,6 +28,7 @@ const std::vector<std::size_t>
|
||||
User::audioBitrates =
|
||||
{
|
||||
64000,
|
||||
96000,
|
||||
128000,
|
||||
192000,
|
||||
320000,
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#include "admin/UsersView.hpp"
|
||||
|
||||
#include "resource/ImageResource.hpp"
|
||||
#include "resource/TranscodeResource.hpp"
|
||||
#include "resource/AudioResource.hpp"
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
@@ -78,7 +78,7 @@ LmsApplication::LmsApplication(const Wt::WEnvironment& env, Wt::Dbo::SqlConnecti
|
||||
_appGroups(appGroups),
|
||||
_scanner(scanner),
|
||||
_imageResource(nullptr),
|
||||
_transcodeResource(nullptr)
|
||||
_audioResource(nullptr)
|
||||
{
|
||||
auto bootstrapTheme = std::make_unique<Wt::WBootstrapTheme>();
|
||||
bootstrapTheme->setVersion(Wt::BootstrapVersion::v3);
|
||||
@@ -329,7 +329,7 @@ LmsApplication::createHome()
|
||||
}
|
||||
|
||||
_imageResource = std::make_shared<ImageResource>();
|
||||
_transcodeResource = std::make_shared<TranscodeResource>();
|
||||
_audioResource = std::make_shared<AudioResource>();
|
||||
|
||||
setConfirmCloseMessage(Wt::WString::tr("Lms.quit-confirm"));
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
class TranscodeResource;
|
||||
class AudioResource;
|
||||
class ImageResource;
|
||||
|
||||
// Events that can be listen to anywhere in the application
|
||||
@@ -75,7 +75,7 @@ class LmsApplication : public Wt::WApplication
|
||||
|
||||
// Session application data
|
||||
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;}
|
||||
Wt::Dbo::Session& getDboSession() { return _db.getSession();}
|
||||
|
||||
@@ -122,7 +122,7 @@ class LmsApplication : public Wt::WApplication
|
||||
Auth* _auth;
|
||||
Scanner::MediaScanner& _scanner;
|
||||
std::shared_ptr<ImageResource> _imageResource;
|
||||
std::shared_ptr<TranscodeResource> _transcodeResource;
|
||||
std::shared_ptr<AudioResource> _audioResource;
|
||||
bool _isAdmin = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
|
||||
#include "resource/ImageResource.hpp"
|
||||
#include "resource/TranscodeResource.hpp"
|
||||
#include "resource/AudioResource.hpp"
|
||||
|
||||
#include "LmsApplication.hpp"
|
||||
|
||||
@@ -65,7 +65,7 @@ MediaPlayer::loadTrack(Database::IdType trackId, bool play)
|
||||
{
|
||||
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);
|
||||
|
||||
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
|
||||
|
||||
LMS_LOG(UI, DEBUG) << "Runing js = '" << oss.str() << "'";
|
||||
LMS_LOG(UI, DEBUG) << "Running js = '" << oss.str() << "'";
|
||||
|
||||
_title->setText(Wt::WString::fromUTF8(track->getName()));
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "TranscodeResource.hpp"
|
||||
#include "AudioResource.hpp"
|
||||
|
||||
#include <Wt/Http/Response.h>
|
||||
|
||||
@@ -30,21 +30,21 @@
|
||||
namespace UserInterface {
|
||||
|
||||
|
||||
TranscodeResource:: ~TranscodeResource()
|
||||
AudioResource:: ~AudioResource()
|
||||
{
|
||||
beingDeleted();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void
|
||||
TranscodeResource::handleRequest(const Wt::Http::Request& request,
|
||||
AudioResource::handleRequest(const Wt::Http::Request& request,
|
||||
Wt::Http::Response& response)
|
||||
{
|
||||
std::shared_ptr<Av::Transcoder> transcoder;
|
||||
@@ -77,14 +77,6 @@ TranscodeResource::handleRequest(const Wt::Http::Request& request,
|
||||
auto offsetStr = request.getParameter("offset");
|
||||
if (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)
|
||||
{
|
||||
@@ -107,6 +99,22 @@ TranscodeResource::handleRequest(const Wt::Http::Request& request,
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include <Wt/WResource.h>
|
||||
|
||||
#include "av/AvTranscoder.hpp"
|
||||
@@ -31,12 +29,12 @@
|
||||
|
||||
namespace UserInterface {
|
||||
|
||||
class TranscodeResource : public Wt::WResource
|
||||
class AudioResource : public Wt::WResource
|
||||
{
|
||||
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,
|
||||
Wt::Http::Response& response);
|
||||
Reference in New Issue
Block a user