2021-12-29 15:44:16 +00:00
|
|
|
// Copyright (C) 2021 Guillaume Desmottes <guillaume@desmottes.be>
|
|
|
|
//
|
2021-12-30 13:40:15 +00:00
|
|
|
// This Source Code Form is subject to the terms of the Mozilla Public License, v2.0.
|
|
|
|
// If a copy of the MPL was not distributed with this file, You can obtain one at
|
|
|
|
// <https://mozilla.org/MPL/2.0/>.
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
2021-12-29 15:44:16 +00:00
|
|
|
|
|
|
|
use gst::glib;
|
|
|
|
use gst::prelude::*;
|
|
|
|
|
|
|
|
mod imp;
|
|
|
|
|
2023-02-02 11:05:59 +00:00
|
|
|
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::Enum)]
|
|
|
|
#[repr(u32)]
|
|
|
|
#[enum_type(name = "GstRsSpotifyBitrate")]
|
|
|
|
enum Bitrate {
|
|
|
|
#[enum_value(name = "96 kbit/s", nick = "96")]
|
|
|
|
B96,
|
|
|
|
#[enum_value(name = "160 kbit/s", nick = "160")]
|
|
|
|
B160,
|
|
|
|
#[enum_value(name = "320 kbit/s", nick = "320")]
|
|
|
|
B320,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Bitrate {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self::B160
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<Bitrate> for librespot::playback::config::Bitrate {
|
|
|
|
fn from(value: Bitrate) -> Self {
|
|
|
|
match value {
|
|
|
|
Bitrate::B96 => Self::Bitrate96,
|
|
|
|
Bitrate::B160 => Self::Bitrate160,
|
|
|
|
Bitrate::B320 => Self::Bitrate320,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-29 15:44:16 +00:00
|
|
|
glib::wrapper! {
|
2022-09-10 21:33:48 +00:00
|
|
|
pub struct SpotifyAudioSrc(ObjectSubclass<imp::SpotifyAudioSrc>) @extends gst_base::PushSrc, gst_base::BaseSrc, gst::Element, gst::Object, @implements gst::URIHandler;
|
2021-12-29 15:44:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
|
2023-02-02 11:05:59 +00:00
|
|
|
#[cfg(feature = "doc")]
|
|
|
|
Bitrate::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty());
|
|
|
|
|
2021-12-29 15:44:16 +00:00
|
|
|
gst::Element::register(
|
|
|
|
Some(plugin),
|
|
|
|
"spotifyaudiosrc",
|
2023-11-02 12:10:59 +00:00
|
|
|
gst::Rank::PRIMARY,
|
2021-12-29 15:44:16 +00:00
|
|
|
SpotifyAudioSrc::static_type(),
|
|
|
|
)
|
|
|
|
}
|