Rename original_url to media_url
This commit is contained in:
parent
3bedfb6ac8
commit
bee6b7f946
@ -235,8 +235,8 @@ void Player::SaveVolume() {
|
||||
|
||||
void Player::HandleLoadResult(const UrlHandler::LoadResult &result) {
|
||||
|
||||
if (loading_async_.contains(result.original_url_)) {
|
||||
loading_async_.removeAll(result.original_url_);
|
||||
if (loading_async_.contains(result.media_url_)) {
|
||||
loading_async_.removeAll(result.media_url_);
|
||||
}
|
||||
|
||||
// Might've been an async load, so check we're still on the same item
|
||||
@ -254,10 +254,10 @@ void Player::HandleLoadResult(const UrlHandler::LoadResult &result) {
|
||||
bool is_current(false);
|
||||
bool is_next(false);
|
||||
|
||||
if (result.original_url_ == item->Url()) {
|
||||
if (result.media_url_ == item->Url()) {
|
||||
is_current = true;
|
||||
}
|
||||
else if (has_next_row && next_item->Url() == result.original_url_) {
|
||||
else if (has_next_row && next_item->Url() == result.media_url_) {
|
||||
is_next = true;
|
||||
}
|
||||
else {
|
||||
@ -267,19 +267,19 @@ void Player::HandleLoadResult(const UrlHandler::LoadResult &result) {
|
||||
switch (result.type_) {
|
||||
case UrlHandler::LoadResult::Type::Error:
|
||||
if (is_current) {
|
||||
InvalidSongRequested(result.original_url_);
|
||||
InvalidSongRequested(result.media_url_);
|
||||
}
|
||||
emit Error(result.error_);
|
||||
break;
|
||||
|
||||
case UrlHandler::LoadResult::Type::NoMoreTracks:
|
||||
qLog(Debug) << "URL handler for" << result.original_url_ << "said no more tracks" << is_current;
|
||||
qLog(Debug) << "URL handler for" << result.media_url_ << "said no more tracks" << is_current;
|
||||
if (is_current) NextItem(stream_change_type_, autoscroll_);
|
||||
break;
|
||||
|
||||
case UrlHandler::LoadResult::Type::TrackAvailable: {
|
||||
|
||||
qLog(Debug) << "URL handler for" << result.original_url_ << "returned" << result.stream_url_;
|
||||
qLog(Debug) << "URL handler for" << result.media_url_ << "returned" << result.stream_url_;
|
||||
|
||||
Song song;
|
||||
if (is_current) song = item->Metadata();
|
||||
@ -341,23 +341,23 @@ void Player::HandleLoadResult(const UrlHandler::LoadResult &result) {
|
||||
|
||||
if (is_current) {
|
||||
qLog(Debug) << "Playing song" << item->Metadata().title() << result.stream_url_ << "position" << play_offset_nanosec_;
|
||||
engine_->Play(result.stream_url_, result.original_url_, stream_change_type_, song.has_cue(), song.beginning_nanosec(), song.end_nanosec(), play_offset_nanosec_);
|
||||
engine_->Play(result.media_url_, result.stream_url_, stream_change_type_, song.has_cue(), song.beginning_nanosec(), song.end_nanosec(), play_offset_nanosec_);
|
||||
current_item_ = item;
|
||||
play_offset_nanosec_ = 0;
|
||||
}
|
||||
else if (is_next && !item->Metadata().is_module_music()) {
|
||||
qLog(Debug) << "Preloading next song" << next_item->Metadata().title() << result.stream_url_;
|
||||
engine_->StartPreloading(result.stream_url_, next_item->Url(), song.has_cue(), song.beginning_nanosec(), song.end_nanosec());
|
||||
engine_->StartPreloading(next_item->Url(), result.stream_url_, song.has_cue(), song.beginning_nanosec(), song.end_nanosec());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case UrlHandler::LoadResult::Type::WillLoadAsynchronously:
|
||||
qLog(Debug) << "URL handler for" << result.original_url_ << "is loading asynchronously";
|
||||
qLog(Debug) << "URL handler for" << result.media_url_ << "is loading asynchronously";
|
||||
|
||||
// We'll get called again later with either NoMoreTracks or TrackAvailable
|
||||
loading_async_ << result.original_url_;
|
||||
loading_async_ << result.media_url_;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -731,7 +731,7 @@ void Player::PlayAt(const int index, const quint64 offset_nanosec, Engine::Track
|
||||
}
|
||||
else {
|
||||
qLog(Debug) << "Playing song" << current_item_->Metadata().title() << url << "position" << offset_nanosec;
|
||||
engine_->Play(url, current_item_->Url(), change, current_item_->Metadata().has_cue(), current_item_->effective_beginning_nanosec(), current_item_->effective_end_nanosec(), offset_nanosec);
|
||||
engine_->Play(current_item_->Url(), url, change, current_item_->Metadata().has_cue(), current_item_->effective_beginning_nanosec(), current_item_->effective_end_nanosec(), offset_nanosec);
|
||||
}
|
||||
|
||||
}
|
||||
@ -778,7 +778,7 @@ void Player::EngineMetadataReceived(const Engine::SimpleMetaBundle &bundle) {
|
||||
|
||||
if (bundle.type == Engine::SimpleMetaBundle::Type::Any || bundle.type == Engine::SimpleMetaBundle::Type::Current) {
|
||||
PlaylistItemPtr item = app_->playlist_manager()->active()->current_item();
|
||||
if (item && bundle.url == item->Url()) {
|
||||
if (item && bundle.media_url == item->Url()) {
|
||||
Song song = item->Metadata();
|
||||
bool minor = song.MergeFromSimpleMetaBundle(bundle);
|
||||
app_->playlist_manager()->active()->SetStreamMetadata(item->Url(), song, minor);
|
||||
@ -790,7 +790,7 @@ void Player::EngineMetadataReceived(const Engine::SimpleMetaBundle &bundle) {
|
||||
int next_row = app_->playlist_manager()->active()->next_row();
|
||||
if (next_row != -1) {
|
||||
PlaylistItemPtr next_item = app_->playlist_manager()->active()->item_at(next_row);
|
||||
if (bundle.url == next_item->Url()) {
|
||||
if (bundle.media_url == next_item->Url()) {
|
||||
Song song = next_item->Metadata();
|
||||
song.MergeFromSimpleMetaBundle(bundle);
|
||||
next_item->SetTemporaryMetadata(song);
|
||||
@ -892,7 +892,7 @@ void Player::TrackAboutToEnd() {
|
||||
loading_async_ << url;
|
||||
return;
|
||||
case UrlHandler::LoadResult::Type::TrackAvailable:
|
||||
qLog(Debug) << "URL handler for" << result.original_url_ << "returned" << result.stream_url_;
|
||||
qLog(Debug) << "URL handler for" << result.media_url_ << "returned" << result.stream_url_;
|
||||
url = result.stream_url_;
|
||||
Song song = next_item->Metadata();
|
||||
song.set_stream_url(url);
|
||||
@ -907,7 +907,7 @@ void Player::TrackAboutToEnd() {
|
||||
return;
|
||||
}
|
||||
|
||||
engine_->StartPreloading(url, next_item->Url(), next_item->Metadata().has_cue(), next_item->effective_beginning_nanosec(), next_item->effective_end_nanosec());
|
||||
engine_->StartPreloading(next_item->Url(), url, next_item->Metadata().has_cue(), next_item->effective_beginning_nanosec(), next_item->effective_end_nanosec());
|
||||
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,7 @@
|
||||
|
||||
UrlHandler::UrlHandler(QObject *parent) : QObject(parent) {}
|
||||
|
||||
UrlHandler::LoadResult::LoadResult(const QUrl &original_url, const Type type, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 length_nanosec, const QString &error) :
|
||||
original_url_(original_url),
|
||||
UrlHandler::LoadResult::LoadResult(const QUrl &media_url, const Type type, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 length_nanosec, const QString &error) : media_url_(media_url),
|
||||
type_(type),
|
||||
stream_url_(stream_url),
|
||||
filetype_(filetype),
|
||||
@ -41,8 +40,7 @@ UrlHandler::LoadResult::LoadResult(const QUrl &original_url, const Type type, co
|
||||
error_(error)
|
||||
{}
|
||||
|
||||
UrlHandler::LoadResult::LoadResult(const QUrl &original_url, const Type type, const QString &error) :
|
||||
original_url_(original_url),
|
||||
UrlHandler::LoadResult::LoadResult(const QUrl &media_url, const Type type, const QString &error) : media_url_(media_url),
|
||||
type_(type),
|
||||
filetype_(Song::FileType::Stream),
|
||||
samplerate_(-1),
|
||||
|
@ -47,7 +47,7 @@ class UrlHandler : public QObject {
|
||||
NoMoreTracks,
|
||||
|
||||
// There might be another track available but the handler needs to do some work (eg. fetching a remote playlist) to find out.
|
||||
// AsyncLoadComplete will be emitted later with the same original_url.
|
||||
// AsyncLoadComplete will be emitted later with the same media_url.
|
||||
WillLoadAsynchronously,
|
||||
|
||||
// There was a track available. Its url is in stream_url.
|
||||
@ -57,18 +57,18 @@ class UrlHandler : public QObject {
|
||||
Error,
|
||||
};
|
||||
|
||||
explicit LoadResult(const QUrl &original_url = QUrl(), const Type type = Type::NoMoreTracks, const QUrl &stream_url = QUrl(), const Song::FileType filetype = Song::FileType::Stream, const int samplerate = -1, const int bit_depth = -1, const qint64 length_nanosec = -1, const QString &error = QString());
|
||||
explicit LoadResult(const QUrl &media_url = QUrl(), const Type type = Type::NoMoreTracks, const QUrl &stream_url = QUrl(), const Song::FileType filetype = Song::FileType::Stream, const int samplerate = -1, const int bit_depth = -1, const qint64 length_nanosec = -1, const QString &error = QString());
|
||||
|
||||
explicit LoadResult(const QUrl &original_url, const Type type, const QString &error);
|
||||
explicit LoadResult(const QUrl &media_url, const Type type, const QString &error);
|
||||
|
||||
// The url that the playlist item has in Url().
|
||||
// Might be something unplayable like lastfm://...
|
||||
QUrl original_url_;
|
||||
QUrl media_url_;
|
||||
|
||||
// Result type
|
||||
Type type_;
|
||||
|
||||
// The actual url to something that gstreamer can play.
|
||||
// The actual URL to something that gstreamer can play.
|
||||
QUrl stream_url_;
|
||||
|
||||
// The type of the stream
|
||||
|
@ -75,12 +75,12 @@ Engine::Base::Base(const EngineType type, QObject *parent)
|
||||
|
||||
Engine::Base::~Base() = default;
|
||||
|
||||
bool Engine::Base::Load(const QUrl &stream_url, const QUrl &original_url, const TrackChangeFlags, const bool force_stop_at_end, const quint64 beginning_nanosec, const qint64 end_nanosec) {
|
||||
bool Engine::Base::Load(const QUrl &media_url, const QUrl &stream_url, const TrackChangeFlags, const bool force_stop_at_end, const quint64 beginning_nanosec, const qint64 end_nanosec) {
|
||||
|
||||
Q_UNUSED(force_stop_at_end);
|
||||
|
||||
media_url_ = media_url;
|
||||
stream_url_ = stream_url;
|
||||
original_url_ = original_url;
|
||||
beginning_nanosec_ = beginning_nanosec;
|
||||
end_nanosec_ = end_nanosec;
|
||||
|
||||
@ -90,9 +90,9 @@ bool Engine::Base::Load(const QUrl &stream_url, const QUrl &original_url, const
|
||||
|
||||
}
|
||||
|
||||
bool Engine::Base::Play(const QUrl &stream_url, const QUrl &original_url, const TrackChangeFlags flags, const bool force_stop_at_end, const quint64 beginning_nanosec, const qint64 end_nanosec, const quint64 offset_nanosec) {
|
||||
bool Engine::Base::Play(const QUrl &media_url, const QUrl &stream_url, const TrackChangeFlags flags, const bool force_stop_at_end, const quint64 beginning_nanosec, const qint64 end_nanosec, const quint64 offset_nanosec) {
|
||||
|
||||
if (!Load(stream_url, original_url, flags, force_stop_at_end, beginning_nanosec, end_nanosec)) {
|
||||
if (!Load(media_url, stream_url, flags, force_stop_at_end, beginning_nanosec, end_nanosec)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ class Base : public QObject {
|
||||
virtual bool Init() = 0;
|
||||
virtual State state() const = 0;
|
||||
virtual void StartPreloading(const QUrl&, const QUrl&, const bool, const qint64, const qint64) {}
|
||||
virtual bool Load(const QUrl &stream_url, const QUrl &original_url, const TrackChangeFlags change, const bool force_stop_at_end, const quint64 beginning_nanosec, const qint64 end_nanosec);
|
||||
virtual bool Load(const QUrl &media_url, const QUrl &stream_url, const TrackChangeFlags change, const bool force_stop_at_end, const quint64 beginning_nanosec, const qint64 end_nanosec);
|
||||
virtual bool Play(const quint64 offset_nanosec) = 0;
|
||||
virtual void Stop(const bool stop_after = false) = 0;
|
||||
virtual void Pause() = 0;
|
||||
@ -96,7 +96,7 @@ class Base : public QObject {
|
||||
|
||||
// Plays a media stream represented with the URL 'u' from the given 'beginning' to the given 'end' (usually from 0 to a song's length).
|
||||
// Both markers should be passed in nanoseconds. 'end' can be negative, indicating that the real length of 'u' stream is unknown.
|
||||
bool Play(const QUrl &stream_url, const QUrl &original_url, const TrackChangeFlags flags, const bool force_stop_at_end, const quint64 beginning_nanosec, const qint64 end_nanosec, const quint64 offset_nanosec);
|
||||
bool Play(const QUrl &media_url, const QUrl &stream_url, const TrackChangeFlags flags, const bool force_stop_at_end, const quint64 beginning_nanosec, const qint64 end_nanosec, const quint64 offset_nanosec);
|
||||
void SetVolume(const uint volume);
|
||||
|
||||
public slots:
|
||||
@ -169,8 +169,8 @@ class Base : public QObject {
|
||||
uint volume_;
|
||||
quint64 beginning_nanosec_;
|
||||
qint64 end_nanosec_;
|
||||
QUrl media_url_;
|
||||
QUrl stream_url_;
|
||||
QUrl original_url_;
|
||||
Scope scope_;
|
||||
bool buffering_;
|
||||
bool equalizer_enabled_;
|
||||
@ -231,7 +231,7 @@ struct SimpleMetaBundle {
|
||||
Next
|
||||
};
|
||||
Type type;
|
||||
QUrl url;
|
||||
QUrl media_url;
|
||||
QUrl stream_url;
|
||||
QString title;
|
||||
QString artist;
|
||||
|
@ -154,15 +154,15 @@ Engine::State GstEngine::state() const {
|
||||
|
||||
}
|
||||
|
||||
void GstEngine::StartPreloading(const QUrl &stream_url, const QUrl &original_url, const bool force_stop_at_end, const qint64 beginning_nanosec, const qint64 end_nanosec) {
|
||||
void GstEngine::StartPreloading(const QUrl &media_url, const QUrl &stream_url, const bool force_stop_at_end, const qint64 beginning_nanosec, const qint64 end_nanosec) {
|
||||
|
||||
EnsureInitialized();
|
||||
|
||||
QByteArray gst_url = FixupUrl(stream_url);
|
||||
const QByteArray gst_url = FixupUrl(stream_url);
|
||||
|
||||
// No crossfading, so we can just queue the new URL in the existing pipeline and get gapless playback (hopefully)
|
||||
if (current_pipeline_) {
|
||||
current_pipeline_->SetNextUrl(gst_url, original_url, beginning_nanosec, force_stop_at_end ? end_nanosec : 0);
|
||||
current_pipeline_->SetNextUrl(media_url, stream_url, gst_url, beginning_nanosec, force_stop_at_end ? end_nanosec : 0);
|
||||
// Add request to discover the stream
|
||||
if (discoverer_) {
|
||||
if (!gst_discoverer_discover_uri_async(discoverer_, gst_url.constData())) {
|
||||
@ -173,13 +173,13 @@ void GstEngine::StartPreloading(const QUrl &stream_url, const QUrl &original_url
|
||||
|
||||
}
|
||||
|
||||
bool GstEngine::Load(const QUrl &stream_url, const QUrl &original_url, Engine::TrackChangeFlags change, const bool force_stop_at_end, const quint64 beginning_nanosec, const qint64 end_nanosec) {
|
||||
bool GstEngine::Load(const QUrl &media_url, const QUrl &stream_url, const Engine::TrackChangeFlags change, const bool force_stop_at_end, const quint64 beginning_nanosec, const qint64 end_nanosec) {
|
||||
|
||||
EnsureInitialized();
|
||||
|
||||
Engine::Base::Load(stream_url, original_url, change, force_stop_at_end, beginning_nanosec, end_nanosec);
|
||||
Engine::Base::Load(stream_url, media_url, change, force_stop_at_end, beginning_nanosec, end_nanosec);
|
||||
|
||||
QByteArray gst_url = FixupUrl(stream_url);
|
||||
const QByteArray gst_url = FixupUrl(stream_url);
|
||||
|
||||
bool crossfade = current_pipeline_ && ((crossfade_enabled_ && change & Engine::TrackChangeType::Manual) || (autocrossfade_enabled_ && change & Engine::TrackChangeType::Auto) || ((crossfade_enabled_ || autocrossfade_enabled_) && change & Engine::TrackChangeType::Intro));
|
||||
|
||||
@ -187,12 +187,12 @@ bool GstEngine::Load(const QUrl &stream_url, const QUrl &original_url, Engine::T
|
||||
crossfade = false;
|
||||
}
|
||||
|
||||
if (!crossfade && current_pipeline_ && current_pipeline_->stream_url() == gst_url && change & Engine::TrackChangeType::Auto) {
|
||||
if (!crossfade && current_pipeline_ && current_pipeline_->stream_url() == stream_url && change & Engine::TrackChangeType::Auto) {
|
||||
// We're not crossfading, and the pipeline is already playing the URI we want, so just do nothing.
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<GstEnginePipeline> pipeline = CreatePipeline(gst_url, original_url, force_stop_at_end ? end_nanosec : 0);
|
||||
std::shared_ptr<GstEnginePipeline> pipeline = CreatePipeline(media_url, stream_url, gst_url, force_stop_at_end ? end_nanosec : 0);
|
||||
if (!pipeline) return false;
|
||||
|
||||
if (crossfade) StartFadeout();
|
||||
@ -258,8 +258,8 @@ void GstEngine::Stop(const bool stop_after) {
|
||||
|
||||
StopTimers();
|
||||
|
||||
media_url_.clear();
|
||||
stream_url_.clear(); // To ensure we return Empty from state()
|
||||
original_url_.clear();
|
||||
beginning_nanosec_ = end_nanosec_ = 0;
|
||||
|
||||
// Check if we started a fade out. If it isn't finished yet and the user pressed stop, we cancel the fader and just stop the playback.
|
||||
@ -634,10 +634,10 @@ void GstEngine::PlayDone(const GstStateChangeReturn ret, const quint64 offset_na
|
||||
|
||||
if (ret == GST_STATE_CHANGE_FAILURE) {
|
||||
// Failure, but we got a redirection URL - try loading that instead
|
||||
QByteArray redirect_url = current_pipeline_->redirect_url();
|
||||
if (!redirect_url.isEmpty() && redirect_url != current_pipeline_->stream_url()) {
|
||||
const QByteArray redirect_url = current_pipeline_->redirect_url();
|
||||
if (!redirect_url.isEmpty() && redirect_url != current_pipeline_->gst_url()) {
|
||||
qLog(Info) << "Redirecting to" << redirect_url;
|
||||
current_pipeline_ = CreatePipeline(redirect_url, current_pipeline_->original_url(), end_nanosec_);
|
||||
current_pipeline_ = CreatePipeline(current_pipeline_->media_url(), current_pipeline_->stream_url(), redirect_url, end_nanosec_);
|
||||
Play(offset_nanosec);
|
||||
return;
|
||||
}
|
||||
@ -829,11 +829,11 @@ std::shared_ptr<GstEnginePipeline> GstEngine::CreatePipeline() {
|
||||
|
||||
}
|
||||
|
||||
std::shared_ptr<GstEnginePipeline> GstEngine::CreatePipeline(const QByteArray &gst_url, const QUrl &original_url, const qint64 end_nanosec) {
|
||||
std::shared_ptr<GstEnginePipeline> GstEngine::CreatePipeline(const QUrl &media_url, const QUrl &stream_url, const QByteArray &gst_url, const qint64 end_nanosec) {
|
||||
|
||||
std::shared_ptr<GstEnginePipeline> ret = CreatePipeline();
|
||||
QString error;
|
||||
if (!ret->InitFromUrl(gst_url, original_url, end_nanosec, error)) {
|
||||
if (!ret->InitFromUrl(media_url, stream_url, gst_url, end_nanosec, error)) {
|
||||
ret.reset();
|
||||
emit Error(error);
|
||||
emit StateChanged(Engine::State::Error);
|
||||
@ -911,7 +911,7 @@ void GstEngine::StreamDiscovered(GstDiscoverer*, GstDiscovererInfo *info, GError
|
||||
GstEngine *instance = reinterpret_cast<GstEngine*>(self);
|
||||
if (!instance->current_pipeline_) return;
|
||||
|
||||
QString discovered_url(gst_discoverer_info_get_uri(info));
|
||||
const QByteArray discovered_url = gst_discoverer_info_get_uri(info);
|
||||
|
||||
GstDiscovererResult result = gst_discoverer_info_get_result(info);
|
||||
if (result != GST_DISCOVERER_OK) {
|
||||
@ -926,15 +926,16 @@ void GstEngine::StreamDiscovered(GstDiscoverer*, GstDiscovererInfo *info, GError
|
||||
GstDiscovererStreamInfo *stream_info = reinterpret_cast<GstDiscovererStreamInfo*>(g_list_first(audio_streams)->data);
|
||||
|
||||
Engine::SimpleMetaBundle bundle;
|
||||
if (discovered_url == instance->current_pipeline_->stream_url()) {
|
||||
if (discovered_url == instance->current_pipeline_->gst_url()) {
|
||||
bundle.type = Engine::SimpleMetaBundle::Type::Current;
|
||||
bundle.url = instance->current_pipeline_->original_url();
|
||||
bundle.media_url = instance->current_pipeline_->media_url();
|
||||
bundle.stream_url = instance->current_pipeline_->stream_url();
|
||||
}
|
||||
else if (discovered_url == instance->current_pipeline_->next_stream_url()) {
|
||||
else if (discovered_url == instance->current_pipeline_->next_gst_url()) {
|
||||
bundle.type = Engine::SimpleMetaBundle::Type::Next;
|
||||
bundle.url = instance->current_pipeline_->next_original_url();
|
||||
bundle.media_url = instance->current_pipeline_->next_media_url();
|
||||
bundle.stream_url = instance->current_pipeline_->next_stream_url();
|
||||
}
|
||||
bundle.stream_url = QUrl(discovered_url);
|
||||
bundle.samplerate = static_cast<int>(gst_discoverer_audio_info_get_sample_rate(GST_DISCOVERER_AUDIO_INFO(stream_info)));
|
||||
bundle.bitdepth = static_cast<int>(gst_discoverer_audio_info_get_depth(GST_DISCOVERER_AUDIO_INFO(stream_info)));
|
||||
bundle.bitrate = static_cast<int>(gst_discoverer_audio_info_get_bitrate(GST_DISCOVERER_AUDIO_INFO(stream_info)) / 1000);
|
||||
|
@ -65,8 +65,8 @@ class GstEngine : public Engine::Base, public GstBufferConsumer {
|
||||
|
||||
bool Init() override;
|
||||
Engine::State state() const override;
|
||||
void StartPreloading(const QUrl &stream_url, const QUrl &original_url, const bool force_stop_at_end, const qint64 beginning_nanosec, const qint64 end_nanosec) override;
|
||||
bool Load(const QUrl &stream_url, const QUrl &original_url, const Engine::TrackChangeFlags change, const bool force_stop_at_end, const quint64 beginning_nanosec, const qint64 end_nanosec) override;
|
||||
void StartPreloading(const QUrl &media_url, const QUrl &stream_url, const bool force_stop_at_end, const qint64 beginning_nanosec, const qint64 end_nanosec) override;
|
||||
bool Load(const QUrl &media_url, const QUrl &stream_url, const Engine::TrackChangeFlags change, const bool force_stop_at_end, const quint64 beginning_nanosec, const qint64 end_nanosec) override;
|
||||
bool Play(const quint64 offset_nanosec) override;
|
||||
void Stop(const bool stop_after = false) override;
|
||||
void Pause() override;
|
||||
@ -138,7 +138,7 @@ class GstEngine : public Engine::Base, public GstBufferConsumer {
|
||||
void StopTimers();
|
||||
|
||||
std::shared_ptr<GstEnginePipeline> CreatePipeline();
|
||||
std::shared_ptr<GstEnginePipeline> CreatePipeline(const QByteArray &gst_url, const QUrl &original_url, const qint64 end_nanosec);
|
||||
std::shared_ptr<GstEnginePipeline> CreatePipeline(const QUrl &media_url, const QUrl &stream_url, const QByteArray &gst_url, const qint64 end_nanosec);
|
||||
|
||||
void UpdateScope(int chunk_length);
|
||||
|
||||
|
@ -288,10 +288,11 @@ GstElement *GstEnginePipeline::CreateElement(const QString &factory_name, const
|
||||
|
||||
}
|
||||
|
||||
bool GstEnginePipeline::InitFromUrl(const QByteArray &stream_url, const QUrl &original_url, const qint64 end_nanosec, QString &error) {
|
||||
bool GstEnginePipeline::InitFromUrl(const QUrl &media_url, const QUrl &stream_url, const QByteArray &gst_url, const qint64 end_nanosec, QString &error) {
|
||||
|
||||
media_url_ = media_url;
|
||||
stream_url_ = stream_url;
|
||||
original_url_ = original_url;
|
||||
gst_url_ = gst_url;
|
||||
end_offset_nanosec_ = end_nanosec;
|
||||
|
||||
guint version_major = 0, version_minor = 0, version_micro = 0, version_nano = 0;
|
||||
@ -331,7 +332,7 @@ bool GstEnginePipeline::InitFromUrl(const QByteArray &stream_url, const QUrl &or
|
||||
flags &= ~0x00000010;
|
||||
g_object_set(G_OBJECT(pipeline_), "flags", flags, nullptr);
|
||||
|
||||
g_object_set(G_OBJECT(pipeline_), "uri", stream_url.constData(), nullptr);
|
||||
g_object_set(G_OBJECT(pipeline_), "uri", gst_url.constData(), nullptr);
|
||||
|
||||
pipeline_is_connected_ = true;
|
||||
|
||||
@ -1075,8 +1076,9 @@ GstPadProbeReturn GstEnginePipeline::BufferProbeCallback(GstPad *pad, GstPadProb
|
||||
if (instance->has_next_valid_url() && instance->next_stream_url_ == instance->stream_url_ && instance->next_beginning_offset_nanosec_ == instance->end_offset_nanosec_) {
|
||||
// The "next" song is actually the next segment of this file - so cheat and keep on playing, but just tell the Engine we've moved on.
|
||||
instance->end_offset_nanosec_ = instance->next_end_offset_nanosec_;
|
||||
instance->next_media_url_.clear();
|
||||
instance->next_stream_url_.clear();
|
||||
instance->next_original_url_.clear();
|
||||
instance->next_gst_url_.clear();
|
||||
instance->next_beginning_offset_nanosec_ = 0;
|
||||
instance->next_end_offset_nanosec_ = 0;
|
||||
|
||||
@ -1104,7 +1106,7 @@ void GstEnginePipeline::AboutToFinishCallback(GstPlayBin *playbin, gpointer self
|
||||
// Set the next uri. When the current song ends it will be played automatically and a STREAM_START message is send to the bus.
|
||||
// When the next uri is not playable an error message is send when the pipeline goes to PLAY (or PAUSE) state or immediately if it is currently in PLAY state.
|
||||
instance->next_uri_set_ = true;
|
||||
g_object_set(G_OBJECT(instance->pipeline_), "uri", instance->next_stream_url_.constData(), nullptr);
|
||||
g_object_set(G_OBJECT(instance->pipeline_), "uri", instance->next_gst_url_.constData(), nullptr);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1204,11 +1206,13 @@ void GstEnginePipeline::StreamStartMessageReceived() {
|
||||
if (next_uri_set_) {
|
||||
next_uri_set_ = false;
|
||||
|
||||
media_url_ = next_media_url_;
|
||||
stream_url_ = next_stream_url_;
|
||||
original_url_ = next_original_url_;
|
||||
gst_url_ = next_gst_url_;
|
||||
end_offset_nanosec_ = next_end_offset_nanosec_;
|
||||
next_stream_url_.clear();
|
||||
next_original_url_.clear();
|
||||
next_media_url_.clear();
|
||||
next_gst_url_.clear();
|
||||
next_beginning_offset_nanosec_ = 0;
|
||||
next_end_offset_nanosec_ = 0;
|
||||
|
||||
@ -1300,7 +1304,8 @@ void GstEnginePipeline::TagMessageReceived(GstMessage *msg) {
|
||||
|
||||
Engine::SimpleMetaBundle bundle;
|
||||
bundle.type = Engine::SimpleMetaBundle::Type::Current;
|
||||
bundle.url = original_url_;
|
||||
bundle.media_url = media_url_;
|
||||
bundle.stream_url = stream_url_;
|
||||
bundle.title = ParseStrTag(taglist, GST_TAG_TITLE);
|
||||
bundle.artist = ParseStrTag(taglist, GST_TAG_ARTIST);
|
||||
bundle.comment = ParseStrTag(taglist, GST_TAG_COMMENT);
|
||||
@ -1396,7 +1401,7 @@ void GstEnginePipeline::StateChangedMessageReceived(GstMessage *msg) {
|
||||
if (next_uri_set_ && new_state == GST_STATE_READY) {
|
||||
// Revert uri and go back to PLAY state again
|
||||
next_uri_set_ = false;
|
||||
g_object_set(G_OBJECT(pipeline_), "uri", stream_url_.constData(), nullptr);
|
||||
g_object_set(G_OBJECT(pipeline_), "uri", gst_url_.constData(), nullptr);
|
||||
SetState(GST_STATE_PLAYING);
|
||||
}
|
||||
}
|
||||
@ -1649,10 +1654,11 @@ void GstEnginePipeline::RemoveAllBufferConsumers() {
|
||||
buffer_consumers_.clear();
|
||||
}
|
||||
|
||||
void GstEnginePipeline::SetNextUrl(const QByteArray &stream_url, const QUrl &original_url, const qint64 beginning_nanosec, const qint64 end_nanosec) {
|
||||
void GstEnginePipeline::SetNextUrl(const QUrl &media_url, const QUrl &stream_url, const QByteArray &gst_url, const qint64 beginning_nanosec, const qint64 end_nanosec) {
|
||||
|
||||
next_media_url_ = media_url;
|
||||
next_stream_url_ = stream_url;
|
||||
next_original_url_ = original_url;
|
||||
next_gst_url_ = gst_url;
|
||||
next_beginning_offset_nanosec_ = beginning_nanosec;
|
||||
next_end_offset_nanosec_ = end_nanosec;
|
||||
|
||||
|
@ -78,7 +78,7 @@ class GstEnginePipeline : public QObject {
|
||||
void set_fading_enabled(const bool enabled);
|
||||
|
||||
// Creates the pipeline, returns false on error
|
||||
bool InitFromUrl(const QByteArray &stream_url, const QUrl &original_url, const qint64 end_nanosec, QString &error);
|
||||
bool InitFromUrl(const QUrl &media_url, const QUrl &stream_url, const QByteArray &gst_url, const qint64 end_nanosec, QString &error);
|
||||
|
||||
// GstBufferConsumers get fed audio data. Thread-safe.
|
||||
void AddBufferConsumer(GstBufferConsumer *consumer);
|
||||
@ -95,16 +95,18 @@ class GstEnginePipeline : public QObject {
|
||||
void StartFader(const qint64 duration_nanosec, const QTimeLine::Direction direction = QTimeLine::Forward, const QEasingCurve::Type shape = QEasingCurve::Linear, const bool use_fudge_timer = true);
|
||||
|
||||
// If this is set then it will be loaded automatically when playback finishes for gapless playback
|
||||
void SetNextUrl(const QByteArray &stream_url, const QUrl &original_url, qint64 beginning_nanosec, qint64 end_nanosec);
|
||||
bool has_next_valid_url() const { return !next_stream_url_.isEmpty(); }
|
||||
void SetNextUrl(const QUrl &media_url, const QUrl &stream_url, const QByteArray &gst_url, const qint64 beginning_nanosec, const qint64 end_nanosec);
|
||||
bool has_next_valid_url() const { return next_stream_url_.isValid(); }
|
||||
|
||||
void SetSourceDevice(const QString &device) { source_device_ = device; }
|
||||
|
||||
// Get information about the music playback
|
||||
QByteArray stream_url() const { return stream_url_; }
|
||||
QByteArray next_stream_url() const { return next_stream_url_; }
|
||||
QUrl original_url() const { return original_url_; }
|
||||
QUrl next_original_url() const { return next_original_url_; }
|
||||
QUrl media_url() const { return media_url_; }
|
||||
QUrl stream_url() const { return stream_url_; }
|
||||
QByteArray gst_url() const { return gst_url_; }
|
||||
QUrl next_media_url() const { return next_media_url_; }
|
||||
QUrl next_stream_url() const { return next_stream_url_; }
|
||||
QByteArray next_gst_url() const { return next_gst_url_; }
|
||||
bool is_valid() const { return valid_; }
|
||||
|
||||
// Please note that this method (unlike GstEngine's.position()) is multiple-section media unaware.
|
||||
@ -239,10 +241,12 @@ class GstEnginePipeline : public QObject {
|
||||
bool segment_start_received_;
|
||||
|
||||
// The URL that is currently playing, and the URL that is to be preloaded when the current track is close to finishing.
|
||||
QByteArray stream_url_;
|
||||
QUrl original_url_;
|
||||
QByteArray next_stream_url_;
|
||||
QUrl next_original_url_;
|
||||
QUrl media_url_;
|
||||
QUrl stream_url_;
|
||||
QByteArray gst_url_;
|
||||
QUrl next_media_url_;
|
||||
QUrl next_stream_url_;
|
||||
QByteArray next_gst_url_;
|
||||
|
||||
// If this is > 0 then the pipeline will be forced to stop when playback goes past this position.
|
||||
qint64 end_offset_nanosec_;
|
||||
|
@ -100,9 +100,9 @@ bool VLCEngine::Init() {
|
||||
|
||||
}
|
||||
|
||||
bool VLCEngine::Load(const QUrl &stream_url, const QUrl &original_url, const Engine::TrackChangeFlags change, const bool force_stop_at_end, const quint64 beginning_nanosec, const qint64 end_nanosec) {
|
||||
bool VLCEngine::Load(const QUrl &media_url, const QUrl &stream_url, const Engine::TrackChangeFlags change, const bool force_stop_at_end, const quint64 beginning_nanosec, const qint64 end_nanosec) {
|
||||
|
||||
Q_UNUSED(original_url);
|
||||
Q_UNUSED(media_url);
|
||||
Q_UNUSED(change);
|
||||
Q_UNUSED(force_stop_at_end);
|
||||
Q_UNUSED(beginning_nanosec);
|
||||
|
@ -47,7 +47,7 @@ class VLCEngine : public Engine::Base {
|
||||
|
||||
bool Init() override;
|
||||
Engine::State state() const override { return state_; }
|
||||
bool Load(const QUrl &stream_url, const QUrl &original_url, const Engine::TrackChangeFlags change, const bool force_stop_at_end, const quint64 beginning_nanosec, const qint64 end_nanosec) override;
|
||||
bool Load(const QUrl &media_url, const QUrl &stream_url, const Engine::TrackChangeFlags change, const bool force_stop_at_end, const quint64 beginning_nanosec, const qint64 end_nanosec) override;
|
||||
bool Play(const quint64 offset_nanosec) override;
|
||||
void Stop(const bool stop_after = false) override;
|
||||
void Pause() override;
|
||||
|
@ -129,8 +129,8 @@ class InternetService : public QObject {
|
||||
void RemoveSongsByList(const SongList &songs);
|
||||
void RemoveSongsByMap(const SongMap &songs);
|
||||
|
||||
void StreamURLFailure(const uint id, const QUrl &original_url, const QString &error);
|
||||
void StreamURLSuccess(const uint id, const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration);
|
||||
void StreamURLFailure(const uint id, const QUrl &media_url, const QString &error);
|
||||
void StreamURLSuccess(const uint id, const QUrl &media_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration);
|
||||
|
||||
protected:
|
||||
Application *app_;
|
||||
|
@ -103,7 +103,7 @@ class QobuzRequest : public QobuzBaseRequest {
|
||||
void Results(const int id, const SongMap &songs, const QString &error);
|
||||
void UpdateStatus(const int id, const QString &text);
|
||||
void UpdateProgress(const int id, const int max);
|
||||
void StreamURLFinished(const QUrl &original_url, const QUrl &url, const Song::FileType filetype, const QString &error = QString());
|
||||
void StreamURLFinished(const QUrl &media_url, const QUrl &url, const Song::FileType filetype, const QString &error = QString());
|
||||
|
||||
private slots:
|
||||
void ArtistsReplyReceived(QNetworkReply *reply, const int limit_requested, const int offset_requested);
|
||||
|
@ -756,21 +756,21 @@ uint QobuzService::GetStreamURL(const QUrl &url, QString &error) {
|
||||
|
||||
}
|
||||
|
||||
void QobuzService::HandleStreamURLFailure(const uint id, const QUrl &original_url, const QString &error) {
|
||||
void QobuzService::HandleStreamURLFailure(const uint id, const QUrl &media_url, const QString &error) {
|
||||
|
||||
if (!stream_url_requests_.contains(id)) return;
|
||||
stream_url_requests_.remove(id);
|
||||
|
||||
emit StreamURLFailure(id, original_url, error);
|
||||
emit StreamURLFailure(id, media_url, error);
|
||||
|
||||
}
|
||||
|
||||
void QobuzService::HandleStreamURLSuccess(const uint id, const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration) {
|
||||
void QobuzService::HandleStreamURLSuccess(const uint id, const QUrl &media_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration) {
|
||||
|
||||
if (!stream_url_requests_.contains(id)) return;
|
||||
stream_url_requests_.remove(id);
|
||||
|
||||
emit StreamURLSuccess(id, original_url, stream_url, filetype, samplerate, bit_depth, duration);
|
||||
emit StreamURLSuccess(id, media_url, stream_url, filetype, samplerate, bit_depth, duration);
|
||||
|
||||
}
|
||||
|
||||
|
@ -135,8 +135,8 @@ class QobuzService : public InternetService {
|
||||
void ArtistsUpdateProgressReceived(const int id, const int progress);
|
||||
void AlbumsUpdateProgressReceived(const int id, const int progress);
|
||||
void SongsUpdateProgressReceived(const int id, const int progress);
|
||||
void HandleStreamURLFailure(const uint id, const QUrl &original_url, const QString &error);
|
||||
void HandleStreamURLSuccess(const uint id, const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration);
|
||||
void HandleStreamURLFailure(const uint id, const QUrl &media_url, const QString &error);
|
||||
void HandleStreamURLSuccess(const uint id, const QUrl &media_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration);
|
||||
|
||||
private:
|
||||
using Param = QPair<QString, QString>;
|
||||
|
@ -41,13 +41,13 @@
|
||||
#include "qobuzbaserequest.h"
|
||||
#include "qobuzstreamurlrequest.h"
|
||||
|
||||
QobuzStreamURLRequest::QobuzStreamURLRequest(QobuzService *service, NetworkAccessManager *network, const QUrl &original_url, const uint id, QObject *parent)
|
||||
QobuzStreamURLRequest::QobuzStreamURLRequest(QobuzService *service, NetworkAccessManager *network, const QUrl &media_url, const uint id, QObject *parent)
|
||||
: QobuzBaseRequest(service, network, parent),
|
||||
service_(service),
|
||||
reply_(nullptr),
|
||||
original_url_(original_url),
|
||||
media_url_(media_url),
|
||||
id_(id),
|
||||
song_id_(original_url.path().toInt()),
|
||||
song_id_(media_url.path().toInt()),
|
||||
tries_(0),
|
||||
need_login_(false) {}
|
||||
|
||||
@ -67,7 +67,7 @@ void QobuzStreamURLRequest::LoginComplete(const bool success, const QString &err
|
||||
need_login_ = false;
|
||||
|
||||
if (!success) {
|
||||
emit StreamURLFailure(id_, original_url_, error);
|
||||
emit StreamURLFailure(id_, media_url_, error);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ void QobuzStreamURLRequest::LoginComplete(const bool success, const QString &err
|
||||
void QobuzStreamURLRequest::Process() {
|
||||
|
||||
if (app_id().isEmpty() || app_secret().isEmpty()) {
|
||||
emit StreamURLFailure(id_, original_url_, tr("Missing Qobuz app ID or secret."));
|
||||
emit StreamURLFailure(id_, media_url_, tr("Missing Qobuz app ID or secret."));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ void QobuzStreamURLRequest::Cancel() {
|
||||
reply_->abort();
|
||||
}
|
||||
else {
|
||||
emit StreamURLFailure(id_, original_url_, tr("Cancelled."));
|
||||
emit StreamURLFailure(id_, media_url_, tr("Cancelled."));
|
||||
}
|
||||
|
||||
}
|
||||
@ -157,32 +157,32 @@ void QobuzStreamURLRequest::StreamURLReceived() {
|
||||
need_login_ = true;
|
||||
return;
|
||||
}
|
||||
emit StreamURLFailure(id_, original_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject json_obj = ExtractJsonObj(data);
|
||||
if (json_obj.isEmpty()) {
|
||||
emit StreamURLFailure(id_, original_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains("track_id")) {
|
||||
Error("Invalid Json reply, stream url is missing track_id.", json_obj);
|
||||
emit StreamURLFailure(id_, original_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
return;
|
||||
}
|
||||
|
||||
int track_id = json_obj["track_id"].toInt();
|
||||
if (track_id != song_id_) {
|
||||
Error("Incorrect track ID returned.", json_obj);
|
||||
emit StreamURLFailure(id_, original_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains("mime_type") || !json_obj.contains("url")) {
|
||||
Error("Invalid Json reply, stream url is missing url or mime_type.", json_obj);
|
||||
emit StreamURLFailure(id_, original_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ void QobuzStreamURLRequest::StreamURLReceived() {
|
||||
|
||||
if (!url.isValid()) {
|
||||
Error("Returned stream url is invalid.", json_obj);
|
||||
emit StreamURLFailure(id_, original_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -220,7 +220,7 @@ void QobuzStreamURLRequest::StreamURLReceived() {
|
||||
bit_depth = static_cast<int>(json_obj["bit_depth"].toDouble());
|
||||
}
|
||||
|
||||
emit StreamURLSuccess(id_, original_url_, url, filetype, samplerate, bit_depth, duration);
|
||||
emit StreamURLSuccess(id_, media_url_, url, filetype, samplerate, bit_depth, duration);
|
||||
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ class QobuzStreamURLRequest : public QobuzBaseRequest {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QobuzStreamURLRequest(QobuzService *service, NetworkAccessManager *network, const QUrl &original_url, const uint id, QObject *parent = nullptr);
|
||||
explicit QobuzStreamURLRequest(QobuzService *service, NetworkAccessManager *network, const QUrl &media_url, const uint id, QObject *parent = nullptr);
|
||||
~QobuzStreamURLRequest();
|
||||
|
||||
void GetStreamURL();
|
||||
@ -48,14 +48,14 @@ class QobuzStreamURLRequest : public QobuzBaseRequest {
|
||||
void NeedLogin() { need_login_ = true; }
|
||||
void Cancel();
|
||||
|
||||
QUrl original_url() { return original_url_; }
|
||||
QUrl media_url() { return media_url_; }
|
||||
int song_id() { return song_id_; }
|
||||
bool need_login() { return need_login_; }
|
||||
|
||||
signals:
|
||||
void TryLogin();
|
||||
void StreamURLFailure(const uint id, const QUrl &original_url, const QString &error);
|
||||
void StreamURLSuccess(const uint id, const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration);
|
||||
void StreamURLFailure(const uint id, const QUrl &media_url, const QString &error);
|
||||
void StreamURLSuccess(const uint id, const QUrl &media_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration);
|
||||
|
||||
private slots:
|
||||
void StreamURLReceived();
|
||||
@ -68,7 +68,7 @@ class QobuzStreamURLRequest : public QobuzBaseRequest {
|
||||
|
||||
QobuzService *service_;
|
||||
QNetworkReply *reply_;
|
||||
QUrl original_url_;
|
||||
QUrl media_url_;
|
||||
uint id_;
|
||||
int song_id_;
|
||||
int tries_;
|
||||
|
@ -59,23 +59,23 @@ UrlHandler::LoadResult QobuzUrlHandler::StartLoading(const QUrl &url) {
|
||||
|
||||
}
|
||||
|
||||
void QobuzUrlHandler::GetStreamURLFailure(const uint id, const QUrl &original_url, const QString &error) {
|
||||
void QobuzUrlHandler::GetStreamURLFailure(const uint id, const QUrl &media_url, const QString &error) {
|
||||
|
||||
if (!requests_.contains(id)) return;
|
||||
Request req = requests_.take(id);
|
||||
CancelTask(req.task_id);
|
||||
|
||||
emit AsyncLoadComplete(LoadResult(original_url, LoadResult::Type::Error, error));
|
||||
emit AsyncLoadComplete(LoadResult(media_url, LoadResult::Type::Error, error));
|
||||
|
||||
}
|
||||
|
||||
void QobuzUrlHandler::GetStreamURLSuccess(const uint id, const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration) {
|
||||
void QobuzUrlHandler::GetStreamURLSuccess(const uint id, const QUrl &media_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration) {
|
||||
|
||||
if (!requests_.contains(id)) return;
|
||||
Request req = requests_.take(id);
|
||||
CancelTask(req.task_id);
|
||||
|
||||
emit AsyncLoadComplete(LoadResult(original_url, LoadResult::Type::TrackAvailable, stream_url, filetype, samplerate, bit_depth, duration));
|
||||
emit AsyncLoadComplete(LoadResult(media_url, LoadResult::Type::TrackAvailable, stream_url, filetype, samplerate, bit_depth, duration));
|
||||
|
||||
}
|
||||
|
||||
|
@ -45,8 +45,8 @@ class QobuzUrlHandler : public UrlHandler {
|
||||
void CancelTask(const int task_id);
|
||||
|
||||
private slots:
|
||||
void GetStreamURLFailure(const uint id, const QUrl &original_url, const QString &error);
|
||||
void GetStreamURLSuccess(const uint id, const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration);
|
||||
void GetStreamURLFailure(const uint id, const QUrl &media_url, const QString &error);
|
||||
void GetStreamURLSuccess(const uint id, const QUrl &media_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration);
|
||||
|
||||
private:
|
||||
struct Request {
|
||||
|
@ -103,7 +103,7 @@ class TidalRequest : public TidalBaseRequest {
|
||||
void Results(const int id, const SongMap &songs = SongMap(), const QString &error = QString());
|
||||
void UpdateStatus(const int id, const QString &text);
|
||||
void UpdateProgress(const int id, const int max);
|
||||
void StreamURLFinished(const QUrl &original_url, const QUrl &url, const Song::FileType filetype, const QString &error = QString());
|
||||
void StreamURLFinished(const QUrl &media_url, const QUrl &url, const Song::FileType filetype, const QString &error = QString());
|
||||
|
||||
private slots:
|
||||
void ArtistsReplyReceived(QNetworkReply *reply, const int limit_requested, const int offset_requested);
|
||||
|
@ -1003,21 +1003,21 @@ uint TidalService::GetStreamURL(const QUrl &url, QString &error) {
|
||||
|
||||
}
|
||||
|
||||
void TidalService::HandleStreamURLFailure(const uint id, const QUrl &original_url, const QString &error) {
|
||||
void TidalService::HandleStreamURLFailure(const uint id, const QUrl &media_url, const QString &error) {
|
||||
|
||||
if (!stream_url_requests_.contains(id)) return;
|
||||
stream_url_requests_.remove(id);
|
||||
|
||||
emit StreamURLFailure(id, original_url, error);
|
||||
emit StreamURLFailure(id, media_url, error);
|
||||
|
||||
}
|
||||
|
||||
void TidalService::HandleStreamURLSuccess(const uint id, const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration) {
|
||||
void TidalService::HandleStreamURLSuccess(const uint id, const QUrl &media_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration) {
|
||||
|
||||
if (!stream_url_requests_.contains(id)) return;
|
||||
stream_url_requests_.remove(id);
|
||||
|
||||
emit StreamURLSuccess(id, original_url, stream_url, filetype, samplerate, bit_depth, duration);
|
||||
emit StreamURLSuccess(id, media_url, stream_url, filetype, samplerate, bit_depth, duration);
|
||||
|
||||
}
|
||||
|
||||
|
@ -148,8 +148,8 @@ class TidalService : public InternetService {
|
||||
void ArtistsUpdateProgressReceived(const int id, const int progress);
|
||||
void AlbumsUpdateProgressReceived(const int id, const int progress);
|
||||
void SongsUpdateProgressReceived(const int id, const int progress);
|
||||
void HandleStreamURLFailure(const uint id, const QUrl &original_url, const QString &error);
|
||||
void HandleStreamURLSuccess(const uint id, const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration);
|
||||
void HandleStreamURLFailure(const uint id, const QUrl &media_url, const QString &error);
|
||||
void HandleStreamURLSuccess(const uint id, const QUrl &media_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration);
|
||||
|
||||
private:
|
||||
using Param = QPair<QString, QString>;
|
||||
|
@ -41,13 +41,13 @@
|
||||
#include "tidalbaserequest.h"
|
||||
#include "tidalstreamurlrequest.h"
|
||||
|
||||
TidalStreamURLRequest::TidalStreamURLRequest(TidalService *service, NetworkAccessManager *network, const QUrl &original_url, const uint id, QObject *parent)
|
||||
TidalStreamURLRequest::TidalStreamURLRequest(TidalService *service, NetworkAccessManager *network, const QUrl &media_url, const uint id, QObject *parent)
|
||||
: TidalBaseRequest(service, network, parent),
|
||||
service_(service),
|
||||
reply_(nullptr),
|
||||
original_url_(original_url),
|
||||
media_url_(media_url),
|
||||
id_(id),
|
||||
song_id_(original_url.path().toInt()),
|
||||
song_id_(media_url.path().toInt()),
|
||||
tries_(0),
|
||||
need_login_(false) {}
|
||||
|
||||
@ -67,7 +67,7 @@ void TidalStreamURLRequest::LoginComplete(const bool success, const QString &err
|
||||
need_login_ = false;
|
||||
|
||||
if (!success) {
|
||||
emit StreamURLFailure(id_, original_url_, error);
|
||||
emit StreamURLFailure(id_, media_url_, error);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -79,11 +79,11 @@ void TidalStreamURLRequest::Process() {
|
||||
|
||||
if (!authenticated()) {
|
||||
if (oauth()) {
|
||||
emit StreamURLFailure(id_, original_url_, tr("Not authenticated with Tidal."));
|
||||
emit StreamURLFailure(id_, media_url_, tr("Not authenticated with Tidal."));
|
||||
return;
|
||||
}
|
||||
else if (api_token().isEmpty() || username().isEmpty() || password().isEmpty()) {
|
||||
emit StreamURLFailure(id_, original_url_, tr("Missing Tidal API token, username or password."));
|
||||
emit StreamURLFailure(id_, media_url_, tr("Missing Tidal API token, username or password."));
|
||||
return;
|
||||
}
|
||||
need_login_ = true;
|
||||
@ -101,7 +101,7 @@ void TidalStreamURLRequest::Cancel() {
|
||||
reply_->abort();
|
||||
}
|
||||
else {
|
||||
emit StreamURLFailure(id_, original_url_, tr("Cancelled."));
|
||||
emit StreamURLFailure(id_, media_url_, tr("Cancelled."));
|
||||
}
|
||||
|
||||
}
|
||||
@ -158,25 +158,25 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
||||
need_login_ = true;
|
||||
return;
|
||||
}
|
||||
emit StreamURLFailure(id_, original_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject json_obj = ExtractJsonObj(data);
|
||||
if (json_obj.isEmpty()) {
|
||||
emit StreamURLFailure(id_, original_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains("trackId")) {
|
||||
Error("Invalid Json reply, stream missing trackId.", json_obj);
|
||||
emit StreamURLFailure(id_, original_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
return;
|
||||
}
|
||||
int track_id(json_obj["trackId"].toInt());
|
||||
if (track_id != song_id_) {
|
||||
Error("Incorrect track ID returned.", json_obj);
|
||||
emit StreamURLFailure(id_, original_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
||||
|
||||
json_obj = ExtractJsonObj(data_manifest);
|
||||
if (json_obj.isEmpty()) {
|
||||
emit StreamURLFailure(id_, original_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -221,14 +221,14 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
||||
QString key_id = json_obj["keyId"].toString();
|
||||
if (!encryption_type.isEmpty() && !key_id.isEmpty()) {
|
||||
Error(tr("Received URL with %1 encrypted stream from Tidal. Strawberry does not currently support encrypted streams.").arg(encryption_type));
|
||||
emit StreamURLFailure(id_, original_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!json_obj.contains("mimeType")) {
|
||||
Error("Invalid Json reply, stream url reply manifest is missing mimeType.", json_obj);
|
||||
emit StreamURLFailure(id_, original_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -251,7 +251,7 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
||||
QJsonValue json_urls = json_obj["urls"];
|
||||
if (!json_urls.isArray()) {
|
||||
Error("Invalid Json reply, urls is not an array.", json_urls);
|
||||
emit StreamURLFailure(id_, original_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
return;
|
||||
}
|
||||
QJsonArray json_array_urls = json_urls.toArray();
|
||||
@ -274,7 +274,7 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
||||
QString encryption_key = json_obj["encryptionKey"].toString();
|
||||
if (!encryption_key.isEmpty()) {
|
||||
Error(tr("Received URL with encrypted stream from Tidal. Strawberry does not currently support encrypted streams."));
|
||||
emit StreamURLFailure(id_, original_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -284,18 +284,18 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
||||
QString security_token = json_obj["securityToken"].toString();
|
||||
if (!security_type.isEmpty() && !security_token.isEmpty()) {
|
||||
Error(tr("Received URL with encrypted stream from Tidal. Strawberry does not currently support encrypted streams."));
|
||||
emit StreamURLFailure(id_, original_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (urls.isEmpty()) {
|
||||
Error("Missing stream urls.", json_obj);
|
||||
emit StreamURLFailure(id_, original_url_, errors_.first());
|
||||
emit StreamURLFailure(id_, media_url_, errors_.first());
|
||||
return;
|
||||
}
|
||||
|
||||
emit StreamURLSuccess(id_, original_url_, urls.first(), filetype);
|
||||
emit StreamURLSuccess(id_, media_url_, urls.first(), filetype);
|
||||
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ class TidalStreamURLRequest : public TidalBaseRequest {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TidalStreamURLRequest(TidalService *service, NetworkAccessManager *network, const QUrl &original_url, const uint id, QObject *parent = nullptr);
|
||||
explicit TidalStreamURLRequest(TidalService *service, NetworkAccessManager *network, const QUrl &media_url, const uint id, QObject *parent = nullptr);
|
||||
~TidalStreamURLRequest() override;
|
||||
|
||||
void GetStreamURL();
|
||||
@ -50,7 +50,7 @@ class TidalStreamURLRequest : public TidalBaseRequest {
|
||||
|
||||
bool oauth() { return service_->oauth(); }
|
||||
TidalSettingsPage::StreamUrlMethod stream_url_method() { return service_->stream_url_method(); }
|
||||
QUrl original_url() { return original_url_; }
|
||||
QUrl media_url() { return media_url_; }
|
||||
int song_id() { return song_id_; }
|
||||
|
||||
void set_need_login() override { need_login_ = true; }
|
||||
@ -58,8 +58,8 @@ class TidalStreamURLRequest : public TidalBaseRequest {
|
||||
|
||||
signals:
|
||||
void TryLogin();
|
||||
void StreamURLFailure(const uint id, const QUrl &original_url, const QString &error);
|
||||
void StreamURLSuccess(const uint id, const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate = -1, const int bit_depth = -1, const qint64 duration = -1);
|
||||
void StreamURLFailure(const uint id, const QUrl &media_url, const QString &error);
|
||||
void StreamURLSuccess(const uint id, const QUrl &media_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate = -1, const int bit_depth = -1, const qint64 duration = -1);
|
||||
|
||||
private slots:
|
||||
void StreamURLReceived();
|
||||
@ -72,7 +72,7 @@ class TidalStreamURLRequest : public TidalBaseRequest {
|
||||
|
||||
TidalService *service_;
|
||||
QNetworkReply *reply_;
|
||||
QUrl original_url_;
|
||||
QUrl media_url_;
|
||||
uint id_;
|
||||
int song_id_;
|
||||
int tries_;
|
||||
|
@ -59,23 +59,23 @@ UrlHandler::LoadResult TidalUrlHandler::StartLoading(const QUrl &url) {
|
||||
|
||||
}
|
||||
|
||||
void TidalUrlHandler::GetStreamURLFailure(const uint id, const QUrl &original_url, const QString &error) {
|
||||
void TidalUrlHandler::GetStreamURLFailure(const uint id, const QUrl &media_url, const QString &error) {
|
||||
|
||||
if (!requests_.contains(id)) return;
|
||||
Request req = requests_.take(id);
|
||||
CancelTask(req.task_id);
|
||||
|
||||
emit AsyncLoadComplete(LoadResult(original_url, LoadResult::Type::Error, error));
|
||||
emit AsyncLoadComplete(LoadResult(media_url, LoadResult::Type::Error, error));
|
||||
|
||||
}
|
||||
|
||||
void TidalUrlHandler::GetStreamURLSuccess(const uint id, const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration) {
|
||||
void TidalUrlHandler::GetStreamURLSuccess(const uint id, const QUrl &media_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration) {
|
||||
|
||||
if (!requests_.contains(id)) return;
|
||||
Request req = requests_.take(id);
|
||||
CancelTask(req.task_id);
|
||||
|
||||
emit AsyncLoadComplete(LoadResult(original_url, LoadResult::Type::TrackAvailable, stream_url, filetype, samplerate, bit_depth, duration));
|
||||
emit AsyncLoadComplete(LoadResult(media_url, LoadResult::Type::TrackAvailable, stream_url, filetype, samplerate, bit_depth, duration));
|
||||
|
||||
}
|
||||
|
||||
|
@ -47,8 +47,8 @@ class TidalUrlHandler : public UrlHandler {
|
||||
void CancelTask(const int task_id);
|
||||
|
||||
private slots:
|
||||
void GetStreamURLFailure(const uint id, const QUrl &original_url, const QString &error);
|
||||
void GetStreamURLSuccess(const uint id, const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration);
|
||||
void GetStreamURLFailure(const uint id, const QUrl &media_url, const QString &error);
|
||||
void GetStreamURLSuccess(const uint id, const QUrl &media_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration);
|
||||
|
||||
private:
|
||||
struct Request {
|
||||
|
Loading…
x
Reference in New Issue
Block a user