Merge branch 'marcus/sender-sdk' into 'master'
Sender SDK See merge request videostreaming/fcast!16
2
.cargo/config.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[alias]
|
||||||
|
xtask = "run -p xtask --"
|
5
.gitignore
vendored
|
@ -6,3 +6,8 @@
|
||||||
node_modules/
|
node_modules/
|
||||||
.wrangler/
|
.wrangler/
|
||||||
.secure_files/
|
.secure_files/
|
||||||
|
|
||||||
|
/target
|
||||||
|
/flake*
|
||||||
|
/ios-bindings
|
||||||
|
/ios-build
|
|
@ -4,6 +4,8 @@ stages:
|
||||||
- buildAndDeployElectron
|
- buildAndDeployElectron
|
||||||
- buildWebOSReceiver
|
- buildWebOSReceiver
|
||||||
- buildTizenOSReceiver
|
- buildTizenOSReceiver
|
||||||
|
- buildSenderSDKForAndroid
|
||||||
|
- testSDK
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
ANDROID_VERSION_NAME:
|
ANDROID_VERSION_NAME:
|
||||||
|
@ -18,3 +20,4 @@ include:
|
||||||
- local: 'receivers/electron/.gitlab-ci.yml'
|
- local: 'receivers/electron/.gitlab-ci.yml'
|
||||||
- local: 'receivers/webos/.gitlab-ci.yml'
|
- local: 'receivers/webos/.gitlab-ci.yml'
|
||||||
- local: 'receivers/tizen/.gitlab-ci.yml'
|
- local: 'receivers/tizen/.gitlab-ci.yml'
|
||||||
|
- local: 'sdk/sender/.gitlab-ci.yml'
|
||||||
|
|
6998
Cargo.lock
generated
Normal file
21
Cargo.toml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
[workspace]
|
||||||
|
members = [ "sdk/sender/chromecast-protocol", "sdk/sender/fcast-sender-sdk", "sdk/sender/examples/terminal", "sdk/sender/xtask", "senders/terminal", "sdk/sender/fuzz", "sdk/sender/parsers-common", "sdk/sender/http", "sdk/sender/examples/desktop", "sdk/common/fcast-protocol"]
|
||||||
|
resolver = "2"
|
||||||
|
|
||||||
|
[workspace.package]
|
||||||
|
license = "MIT"
|
||||||
|
|
||||||
|
[workspace.dependencies]
|
||||||
|
tokio = { version = "1.46.1", features = [ "rt", "rt-multi-thread", "sync", "macros", "net", "time", "io-util", "fs" ] }
|
||||||
|
serde = { version = "1.0.219", features = [ "derive" ] }
|
||||||
|
serde_json = "1.0.140"
|
||||||
|
thiserror = "2.0.12"
|
||||||
|
log = "0.4.27"
|
||||||
|
env_logger = "0.11.8"
|
||||||
|
mdns-sd = "0.14.0"
|
||||||
|
anyhow = "1.0.98"
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
lto = true
|
||||||
|
codegen-units = 1
|
||||||
|
strip = "debuginfo"
|
10
sdk/README.md
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
# FCast SDK
|
||||||
|
|
||||||
|
## [`sender/`](./sender)
|
||||||
|
|
||||||
|
The sender SDK can be used to easily add casting capabilities to applications. The SDK works out of the box
|
||||||
|
with Kotlin, Swift and Rust. Support for more languages are comming in the future.
|
||||||
|
|
||||||
|
## [`common/`](./common)
|
||||||
|
|
||||||
|
Common components that can be used by both senders and receivers.
|
11
sdk/common/fcast-protocol/Cargo.toml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "fcast-protocol"
|
||||||
|
version = "0.1.0"
|
||||||
|
license.workspace = true
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
serde.workspace = true
|
||||||
|
serde_json.workspace = true
|
||||||
|
serde_repr = "0.1.20"
|
||||||
|
thiserror.workspace = true
|
125
sdk/common/fcast-protocol/src/lib.rs
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
//! # FCast Protocol
|
||||||
|
//!
|
||||||
|
//! Implementation of the data models documented [here](https://gitlab.futo.org/videostreaming/fcast/-/wikis/Protocol-version-3).
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
pub mod v2;
|
||||||
|
pub mod v3;
|
||||||
|
|
||||||
|
#[derive(Debug, thiserror::Error)]
|
||||||
|
pub enum TryFromByteError {
|
||||||
|
#[error("Unknown opcode: {0}")]
|
||||||
|
UnknownOpcode(u8),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Copy, Clone)]
|
||||||
|
pub enum Opcode {
|
||||||
|
/// Not used
|
||||||
|
None = 0,
|
||||||
|
/// Sender message to play media content, body is [`v3::PlayMessage`]
|
||||||
|
Play = 1,
|
||||||
|
/// Sender message to pause media content, no body
|
||||||
|
Pause = 2,
|
||||||
|
/// Sender message to resume media content, no body
|
||||||
|
Resume = 3,
|
||||||
|
/// Sender message to stop media content, no body
|
||||||
|
Stop = 4,
|
||||||
|
/// Sender message to seek, body is [`SeekMessage`]
|
||||||
|
Seek = 5,
|
||||||
|
/// Receiver message to notify an updated playback state, body is [`v3::PlaybackUpdateMessage`]
|
||||||
|
PlaybackUpdate = 6,
|
||||||
|
/// Receiver message to notify when the volume has changed, body is [`VolumeUpdateMessage`]
|
||||||
|
VolumeUpdate = 7,
|
||||||
|
/// Sender message to change volume, body is [`SetVolumeMessage`]
|
||||||
|
SetVolume = 8,
|
||||||
|
/// Server message to notify the sender a playback error happened, body is [`PlaybackErrorMessage`]
|
||||||
|
PlaybackError = 9,
|
||||||
|
/// Sender message to change playback speed, body is [`SetSpeedMessage`]
|
||||||
|
SetSpeed = 10,
|
||||||
|
/// Message to notify the other of the current version, body is [`VersionMessage`]
|
||||||
|
Version = 11,
|
||||||
|
/// Message to get the other party to pong, no body
|
||||||
|
Ping = 12,
|
||||||
|
/// Message to respond to a ping from the other party, no body
|
||||||
|
Pong = 13,
|
||||||
|
/// Message to notify the other party of device information and state, body is InitialSenderMessage
|
||||||
|
/// if receiver or [`v3::InitialReceiverMessage`] if sender
|
||||||
|
Initial = 14,
|
||||||
|
/// Receiver message to notify all senders when any device has sent a [`v3::PlayMessage`], body is
|
||||||
|
/// [`v3::PlayUpdateMessage`]
|
||||||
|
PlayUpdate = 15,
|
||||||
|
/// Sender message to set the item index in a playlist to play content from, body is
|
||||||
|
/// [`v3::SetPlaylistItemMessage`]
|
||||||
|
SetPlaylistItem = 16,
|
||||||
|
/// Sender message to subscribe to a receiver event, body is [`v3::SubscribeEventMessage`]
|
||||||
|
SubscribeEvent = 17,
|
||||||
|
/// Sender message to unsubscribe to a receiver event, body is [`v3::UnsubscribeEventMessage`]
|
||||||
|
UnsubscribeEvent = 18,
|
||||||
|
/// Receiver message to notify when a sender subscribed event has occurred, body is [`v3::EventMessage`]
|
||||||
|
Event = 19,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TryFrom<u8> for Opcode {
|
||||||
|
type Error = TryFromByteError;
|
||||||
|
|
||||||
|
fn try_from(value: u8) -> Result<Self, Self::Error> {
|
||||||
|
Ok(match value {
|
||||||
|
0 => Opcode::None,
|
||||||
|
1 => Opcode::Play,
|
||||||
|
2 => Opcode::Pause,
|
||||||
|
3 => Opcode::Resume,
|
||||||
|
4 => Opcode::Stop,
|
||||||
|
5 => Opcode::Seek,
|
||||||
|
6 => Opcode::PlaybackUpdate,
|
||||||
|
7 => Opcode::VolumeUpdate,
|
||||||
|
8 => Opcode::SetVolume,
|
||||||
|
9 => Opcode::PlaybackError,
|
||||||
|
10 => Opcode::SetSpeed,
|
||||||
|
11 => Opcode::Version,
|
||||||
|
12 => Opcode::Ping,
|
||||||
|
13 => Opcode::Pong,
|
||||||
|
14 => Opcode::Initial,
|
||||||
|
15 => Opcode::PlayUpdate,
|
||||||
|
16 => Opcode::SetPlaylistItem,
|
||||||
|
17 => Opcode::SubscribeEvent,
|
||||||
|
18 => Opcode::UnsubscribeEvent,
|
||||||
|
19 => Opcode::Event,
|
||||||
|
_ => return Err(TryFromByteError::UnknownOpcode(value)),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[derive(Deserialize, Debug)]
|
||||||
|
pub struct PlaybackErrorMessage {
|
||||||
|
pub message: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize, Debug)]
|
||||||
|
pub struct VersionMessage {
|
||||||
|
pub version: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Debug)]
|
||||||
|
pub struct SetSpeedMessage {
|
||||||
|
pub speed: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[derive(Deserialize, Debug)]
|
||||||
|
pub struct VolumeUpdateMessage {
|
||||||
|
#[serde(rename = "generationTime")]
|
||||||
|
pub generation_time: u64,
|
||||||
|
pub volume: f64, //(0-1)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Debug)]
|
||||||
|
pub struct SetVolumeMessage {
|
||||||
|
pub volume: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Debug)]
|
||||||
|
pub struct SeekMessage {
|
||||||
|
pub time: f64,
|
||||||
|
}
|
|
@ -12,26 +12,7 @@ pub struct PlayMessage {
|
||||||
pub headers: Option<HashMap<String, String>>,
|
pub headers: Option<HashMap<String, String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PlayMessage {
|
#[allow(dead_code)]
|
||||||
pub fn new(
|
|
||||||
container: String,
|
|
||||||
url: Option<String>,
|
|
||||||
content: Option<String>,
|
|
||||||
time: Option<f64>,
|
|
||||||
speed: Option<f64>,
|
|
||||||
headers: Option<HashMap<String, String>>,
|
|
||||||
) -> Self {
|
|
||||||
Self {
|
|
||||||
container,
|
|
||||||
url,
|
|
||||||
content,
|
|
||||||
time,
|
|
||||||
speed,
|
|
||||||
headers,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct PlaybackUpdateMessage {
|
pub struct PlaybackUpdateMessage {
|
||||||
#[serde(rename = "generationTime")]
|
#[serde(rename = "generationTime")]
|
|
@ -90,9 +90,7 @@ impl<'de> Deserialize<'de> for MetadataObject {
|
||||||
Ok(Self::Generic {
|
Ok(Self::Generic {
|
||||||
title,
|
title,
|
||||||
thumbnail_url,
|
thumbnail_url,
|
||||||
custom: rest
|
custom: rest.get("custom").cloned(),
|
||||||
.get("custom")
|
|
||||||
.cloned(),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
_ => Err(de::Error::custom(format!("Unknown metadata type {type_}"))),
|
_ => Err(de::Error::custom(format!("Unknown metadata type {type_}"))),
|
||||||
|
@ -102,7 +100,7 @@ impl<'de> Deserialize<'de> for MetadataObject {
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct PlayMessage {
|
pub struct PlayMessage {
|
||||||
/// The MIME type (video/mp4)
|
/// The MIME type (video/mp4)
|
||||||
pub container: String,
|
pub container: String,
|
||||||
// The URL to load (optional)
|
// The URL to load (optional)
|
||||||
pub url: Option<String>,
|
pub url: Option<String>,
|
||||||
|
@ -119,13 +117,14 @@ pub struct PlayMessage {
|
||||||
pub metadata: Option<MetadataObject>,
|
pub metadata: Option<MetadataObject>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize_repr, Serialize_repr, Debug)]
|
#[derive(Deserialize_repr, Serialize_repr, Debug, Default)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum ContentType {
|
pub enum ContentType {
|
||||||
|
#[default]
|
||||||
Playlist = 0,
|
Playlist = 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone, Default)]
|
||||||
pub struct MediaItem {
|
pub struct MediaItem {
|
||||||
/// The MIME type (video/mp4)
|
/// The MIME type (video/mp4)
|
||||||
pub container: String,
|
pub container: String,
|
||||||
|
@ -149,10 +148,10 @@ pub struct MediaItem {
|
||||||
pub metadata: Option<MetadataObject>,
|
pub metadata: Option<MetadataObject>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug)]
|
#[derive(Serialize, Debug, Default)]
|
||||||
pub struct PlaylistContent {
|
pub struct PlaylistContent {
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "contentType")]
|
||||||
variant: ContentType,
|
pub variant: ContentType,
|
||||||
pub items: Vec<MediaItem>,
|
pub items: Vec<MediaItem>,
|
||||||
/// Start position of the first item to play from the playlist
|
/// Start position of the first item to play from the playlist
|
||||||
pub offset: Option<u64>, // int or float?
|
pub offset: Option<u64>, // int or float?
|
||||||
|
@ -205,6 +204,7 @@ pub struct InitialSenderMessage {
|
||||||
pub app_version: Option<String>,
|
pub app_version: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct InitialReceiverMessage {
|
pub struct InitialReceiverMessage {
|
||||||
#[serde(rename = "displayName")]
|
#[serde(rename = "displayName")]
|
||||||
|
@ -217,6 +217,7 @@ pub struct InitialReceiverMessage {
|
||||||
pub play_data: Option<PlayMessage>,
|
pub play_data: Option<PlayMessage>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct PlayUpdateMessage {
|
pub struct PlayUpdateMessage {
|
||||||
#[serde(rename = "generationTime")]
|
#[serde(rename = "generationTime")]
|
||||||
|
@ -240,6 +241,7 @@ pub enum KeyNames {
|
||||||
Enter,
|
Enter,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
impl KeyNames {
|
impl KeyNames {
|
||||||
pub fn all() -> Vec<String> {
|
pub fn all() -> Vec<String> {
|
||||||
vec![
|
vec![
|
||||||
|
@ -458,7 +460,7 @@ impl<'de> Deserialize<'de> for EventObject {
|
||||||
pub struct EventMessage {
|
pub struct EventMessage {
|
||||||
#[serde(rename = "generationTime")]
|
#[serde(rename = "generationTime")]
|
||||||
pub generation_time: u64,
|
pub generation_time: u64,
|
||||||
event: EventObject,
|
pub event: EventObject,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -738,4 +740,47 @@ mod tests {
|
||||||
);
|
);
|
||||||
assert!(serde_json::from_str::<EventObject>(r#"{"type":5}"#).is_err());
|
assert!(serde_json::from_str::<EventObject>(r#"{"type":5}"#).is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn serialize_playlist_content() {
|
||||||
|
assert_eq!(
|
||||||
|
serde_json::to_string(&PlaylistContent {
|
||||||
|
variant: ContentType::Playlist,
|
||||||
|
items: Vec::new(),
|
||||||
|
offset: None,
|
||||||
|
volume: None,
|
||||||
|
speed: None,
|
||||||
|
forward_cache: None,
|
||||||
|
backward_cache: None,
|
||||||
|
metadata: None
|
||||||
|
})
|
||||||
|
.unwrap(),
|
||||||
|
r#"{"contentType":0,"items":[],"offset":null,"volume":null,"speed":null,"forwardCache":null,"backwardCache":null,"metadata":null}"#,
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
serde_json::to_string(&PlaylistContent {
|
||||||
|
variant: ContentType::Playlist,
|
||||||
|
items: vec![MediaItem {
|
||||||
|
container: "video/mp4".to_string(),
|
||||||
|
url: Some("abc".to_string()),
|
||||||
|
content: None,
|
||||||
|
time: None,
|
||||||
|
volume: None,
|
||||||
|
speed: None,
|
||||||
|
cache: None,
|
||||||
|
show_duration: None,
|
||||||
|
headers: None,
|
||||||
|
metadata: None
|
||||||
|
}],
|
||||||
|
offset: None,
|
||||||
|
volume: None,
|
||||||
|
speed: None,
|
||||||
|
forward_cache: None,
|
||||||
|
backward_cache: None,
|
||||||
|
metadata: None
|
||||||
|
})
|
||||||
|
.unwrap(),
|
||||||
|
r#"{"contentType":0,"items":[{"container":"video/mp4","url":"abc","content":null,"time":null,"volume":null,"speed":null,"cache":null,"showDuration":null,"headers":null,"metadata":null}],"offset":null,"volume":null,"speed":null,"forwardCache":null,"backwardCache":null,"metadata":null}"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
49
sdk/sender/.gitlab-ci.yml
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
buildSenderSDKDockerContainer:
|
||||||
|
stage: buildDockerContainers
|
||||||
|
image: docker:20.10.16
|
||||||
|
services:
|
||||||
|
- docker:20.10.16-dind
|
||||||
|
tags:
|
||||||
|
- fcast-instance-runner
|
||||||
|
before_script:
|
||||||
|
- cd sdk/sender
|
||||||
|
script:
|
||||||
|
- echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin
|
||||||
|
- docker build -t $CI_REGISTRY/videostreaming/fcast/sender-sdk-dev:latest .
|
||||||
|
- docker push $CI_REGISTRY/videostreaming/fcast/sender-sdk-dev:latest
|
||||||
|
when: manual
|
||||||
|
|
||||||
|
buildAndroid:
|
||||||
|
stage: buildSenderSDKForAndroid
|
||||||
|
image: gitlab.futo.org:5050/videostreaming/fcast/sender-sdk-dev:latest
|
||||||
|
script:
|
||||||
|
- cargo xtask kotlin build-android-library --release --src-dir sdk/sender/out
|
||||||
|
- cp -rf sdk/sender/out/* /artifacts/
|
||||||
|
tags:
|
||||||
|
- fcast-instance-runner
|
||||||
|
artifacts:
|
||||||
|
untracked: false
|
||||||
|
when: on_success
|
||||||
|
access: all
|
||||||
|
expire_in: "3 days"
|
||||||
|
paths:
|
||||||
|
- sdk/sender/out/*
|
||||||
|
when: manual
|
||||||
|
|
||||||
|
cargoHackSenderSDK:
|
||||||
|
stage: testSDK
|
||||||
|
image: gitlab.futo.org:5050/videostreaming/fcast/sender-sdk-dev:latest
|
||||||
|
script:
|
||||||
|
- cargo hack check -p fcast-sender-sdk --each-feature
|
||||||
|
tags:
|
||||||
|
- fcast-instance-runner
|
||||||
|
when: manual
|
||||||
|
|
||||||
|
cargoTestSenderSDK:
|
||||||
|
stage: testSDK
|
||||||
|
image: gitlab.futo.org:5050/videostreaming/fcast/sender-sdk-dev:latest
|
||||||
|
script:
|
||||||
|
- cargo test --verbose
|
||||||
|
tags:
|
||||||
|
- fcast-instance-runner
|
||||||
|
when: manual
|
19
sdk/sender/Dockerfile
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# docker build --no-cache -t fcast/sender-sdk-dev:latest .
|
||||||
|
# docker run --rm -it -w /app/sdk/sender --entrypoint='sh' --network host -v ..:/app fcast/sender-sdk-dev:latest
|
||||||
|
|
||||||
|
FROM rust:1-alpine
|
||||||
|
|
||||||
|
RUN apk add --update alpine-sdk protobuf wget2 gcompat
|
||||||
|
|
||||||
|
RUN cargo install cargo-ndk
|
||||||
|
RUN cargo install cargo-hack --locked
|
||||||
|
|
||||||
|
RUN rustup target add aarch64-linux-android \
|
||||||
|
armv7-linux-androideabi \
|
||||||
|
x86_64-linux-android \
|
||||||
|
i686-linux-android
|
||||||
|
|
||||||
|
RUN mkdir -p ndk
|
||||||
|
RUN wget2 https://dl.google.com/android/repository/android-ndk-r27d-linux.zip -O ndk/android-ndk-r27d-linux.zip
|
||||||
|
RUN unzip ndk/android-ndk-r27d-linux.zip -d ndk
|
||||||
|
ENV ANDROID_NDK_HOME="/ndk/android-ndk-r27d"
|
49
sdk/sender/README.md
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
# FCast Sender SDK
|
||||||
|
|
||||||
|
## Required tools
|
||||||
|
|
||||||
|
* [Rust](https://www.rust-lang.org/)
|
||||||
|
* [Cargo](https://doc.rust-lang.org/cargo/)
|
||||||
|
* [protoc](https://protobuf.dev/installation/)
|
||||||
|
|
||||||
|
## Android
|
||||||
|
|
||||||
|
### Additional required tools
|
||||||
|
|
||||||
|
* [cargo-ndk](https://github.com/bbqsrc/cargo-ndk)
|
||||||
|
* The `aarch64-linux-android`, `i686-linux-android`, `armv7-linux-androideabi` and `x86_64-linux-android` rustc targets
|
||||||
|
(can be installed with [rustup](https://rustup.rs/): `rustup target add x86_64-linux-android i686-linux-android armv7-linux-androideabi aarch64-linux-android`)
|
||||||
|
* `JAVA_HOME` must point to a java implementation
|
||||||
|
|
||||||
|
### Building
|
||||||
|
|
||||||
|
To build the android library locally you first need to clone [fcast-sdk-jitpack](https://gitlab.futo.org/videostreaming/fcast-sdk-jitpack) locally, build the rust binaries and generate the UniFFI kotlin module:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ cargo xtask kotlin build-android-library --release --src-dir <path-to-fcast-sdk-jitpack>/src
|
||||||
|
```
|
||||||
|
|
||||||
|
Then follow the `Local testing` section [here](https://gitlab.futo.org/videostreaming/fcast-sdk-jitpack/-/blob/main/README.md?ref_type=heads).
|
||||||
|
|
||||||
|
## IOS
|
||||||
|
|
||||||
|
If `iphonesimulator SDK` is not found when running the build commands, execute the following:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ # xcode-select --switch /Applications/Xcode.app/Contents/Developer/
|
||||||
|
```
|
||||||
|
|
||||||
|
### Additional required tools
|
||||||
|
|
||||||
|
* The `aarch64-apple-ios-sim` and `aarch64-apple-ios` rustc targets
|
||||||
|
(can be installed with [rustup](https://rustup.rs/): `rustup target add aarch64-apple-ios-sim aarch64-apple-ios`)
|
||||||
|
|
||||||
|
### Building
|
||||||
|
|
||||||
|
Execute:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ cargo xtask generate-ios
|
||||||
|
```
|
||||||
|
|
||||||
|
You can now import the SDK in your project by drag and dropping `ios-bindings/uniffi/{fcast_sender_sdk.swift, fcast_sender_sdkFFI.h}` and `ios-bindings/fcast_sender_sdk.xcframework` into Xcode.
|
13
sdk/sender/chromecast-protocol/Cargo.toml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
[package]
|
||||||
|
name = "chromecast-protocol"
|
||||||
|
version = "0.1.0"
|
||||||
|
license.workspace = true
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
serde.workspace = true
|
||||||
|
serde_json.workspace = true
|
||||||
|
prost = "0.14.1"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
prost-build = "0.14.1"
|
7
sdk/sender/chromecast-protocol/build.rs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
use std::io::Result;
|
||||||
|
|
||||||
|
fn main() -> Result<()> {
|
||||||
|
prost_build::compile_protos(&["src/chromecast.proto"], &["src"])?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
18
sdk/sender/chromecast-protocol/src/chromecast.proto
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
syntax = "proto2";
|
||||||
|
option optimize_for = LITE_RUNTIME;
|
||||||
|
package protos;
|
||||||
|
|
||||||
|
message CastMessage {
|
||||||
|
enum ProtocolVersion { CASTV2_1_0 = 0; }
|
||||||
|
required ProtocolVersion protocol_version = 1;
|
||||||
|
required string source_id = 2;
|
||||||
|
required string destination_id = 3;
|
||||||
|
required string namespace = 4;
|
||||||
|
enum PayloadType {
|
||||||
|
STRING = 0;
|
||||||
|
BINARY = 1;
|
||||||
|
}
|
||||||
|
required PayloadType payload_type = 5;
|
||||||
|
optional string payload_utf8 = 6;
|
||||||
|
optional bytes payload_binary = 7;
|
||||||
|
}
|
679
sdk/sender/chromecast-protocol/src/lib.rs
Normal file
|
@ -0,0 +1,679 @@
|
||||||
|
use serde::{de, ser, Deserialize, Serialize};
|
||||||
|
|
||||||
|
pub use prost;
|
||||||
|
use serde_json::{json, Value};
|
||||||
|
|
||||||
|
pub mod protos {
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/protos.rs"));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const HEARTBEAT_NAMESPACE: &str = "urn:x-cast:com.google.cast.tp.heartbeat";
|
||||||
|
pub const RECEIVER_NAMESPACE: &str = "urn:x-cast:com.google.cast.receiver";
|
||||||
|
pub const MEDIA_NAMESPACE: &str = "urn:x-cast:com.google.cast.media";
|
||||||
|
pub const CONNECTION_NAMESPACE: &str = "urn:x-cast:com.google.cast.tp.connection";
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct Volume {
|
||||||
|
/// Current stream volume level as a value between 0.0 and 1.0 where 1.0 is the maximum volume.
|
||||||
|
pub level: Option<f64>,
|
||||||
|
/// Whether the Cast device is muted, independent of the volume level
|
||||||
|
pub muted: Option<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub enum StreamType {
|
||||||
|
#[serde(rename = "NONE")]
|
||||||
|
None,
|
||||||
|
#[serde(rename = "BUFFERED")]
|
||||||
|
Buffered,
|
||||||
|
#[serde(rename = "LIVE")]
|
||||||
|
Live,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||||
|
pub struct Image {
|
||||||
|
pub url: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub enum Metadata {
|
||||||
|
Generic {
|
||||||
|
title: Option<String>,
|
||||||
|
subtitle: Option<String>,
|
||||||
|
images: Option<Vec<Image>>,
|
||||||
|
release_date: Option<String>,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Serialize for Metadata {
|
||||||
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: serde::Serializer,
|
||||||
|
{
|
||||||
|
match self {
|
||||||
|
Metadata::Generic {
|
||||||
|
title,
|
||||||
|
subtitle,
|
||||||
|
images,
|
||||||
|
release_date,
|
||||||
|
} => {
|
||||||
|
let mut map = serde_json::Map::new();
|
||||||
|
map.insert("metadataType".to_owned(), json!(0u64));
|
||||||
|
map.insert(
|
||||||
|
"title".to_owned(),
|
||||||
|
match title {
|
||||||
|
Some(t) => Value::String(t.to_owned()),
|
||||||
|
None => Value::Null,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
map.insert(
|
||||||
|
"subtitle".to_owned(),
|
||||||
|
match subtitle {
|
||||||
|
Some(s) => Value::String(s.to_owned()),
|
||||||
|
None => Value::Null,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
map.insert(
|
||||||
|
"images".to_owned(),
|
||||||
|
match images {
|
||||||
|
Some(i) => serde_json::to_value(i)
|
||||||
|
.map_err(|_| ser::Error::custom("failed to serialize `images`"))?,
|
||||||
|
None => Value::Null,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
map.insert(
|
||||||
|
"releaseDate".to_owned(),
|
||||||
|
match release_date {
|
||||||
|
Some(r) => Value::String(r.to_owned()),
|
||||||
|
None => Value::Null,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
map.serialize(serializer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'de> Deserialize<'de> for Metadata {
|
||||||
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
|
where
|
||||||
|
D: serde::Deserializer<'de>,
|
||||||
|
{
|
||||||
|
let mut map = serde_json::Map::deserialize(deserializer)?;
|
||||||
|
|
||||||
|
let type_ = map
|
||||||
|
.remove("metadataType")
|
||||||
|
.ok_or(de::Error::missing_field("metadataType"))?
|
||||||
|
.as_u64()
|
||||||
|
.ok_or(de::Error::custom("`metadataType` is not an integer"))?;
|
||||||
|
let rest = Value::Object(map);
|
||||||
|
|
||||||
|
match type_ {
|
||||||
|
0 => {
|
||||||
|
let title = match rest.get("title") {
|
||||||
|
Some(t) => t.as_str().map(|s| s.to_string()),
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
let subtitle = match rest.get("subtitle") {
|
||||||
|
Some(s) => s.as_str().map(|s| s.to_string()),
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
let images = match rest.get("images") {
|
||||||
|
Some(i) => match i.as_array() {
|
||||||
|
Some(images) => Some(
|
||||||
|
images
|
||||||
|
.iter()
|
||||||
|
.map(|maybe_image| {
|
||||||
|
serde_json::from_value::<Image>(maybe_image.clone())
|
||||||
|
})
|
||||||
|
.collect::<Result<Vec<Image>, serde_json::Error>>()
|
||||||
|
.map_err(|_| {
|
||||||
|
de::Error::custom("`images` is not an array of images")
|
||||||
|
})?,
|
||||||
|
),
|
||||||
|
None => None,
|
||||||
|
},
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
let release_date = match rest.get("releaseDate") {
|
||||||
|
Some(r) => r.as_str().map(|s| s.to_string()),
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(Self::Generic {
|
||||||
|
title,
|
||||||
|
subtitle,
|
||||||
|
images,
|
||||||
|
release_date,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
_ => Err(de::Error::custom(format!("Unknown metadata type {type_}"))),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <https://developers.google.com/cast/docs/media/messages#MediaInformation>
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct MediaInformation {
|
||||||
|
/// Service-specific identifier of the content currently loaded by the media player. This is a
|
||||||
|
/// free form string and is specific to the application. In most cases, this will be the URL to
|
||||||
|
/// the media, but the sender can choose to pass a string that the receiver can interpret
|
||||||
|
/// properly. Max length: 1k
|
||||||
|
#[serde(rename = "contentId")]
|
||||||
|
pub content_id: String,
|
||||||
|
#[serde(rename = "streamType")]
|
||||||
|
pub stream_type: StreamType,
|
||||||
|
/// MIME content type of the media being played
|
||||||
|
#[serde(rename = "contentType")]
|
||||||
|
pub content_type: String,
|
||||||
|
pub metadata: Option<Metadata>,
|
||||||
|
/// Duration of the currently playing stream in seconds
|
||||||
|
pub duration: Option<f64>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub enum IdleReason {
|
||||||
|
/// A sender requested to stop playback using the STOP command
|
||||||
|
#[serde(rename = "CANCELLED")]
|
||||||
|
Cancelled,
|
||||||
|
/// A sender requested playing a different media using the LOAD command
|
||||||
|
#[serde(rename = "INTERRUPTED")]
|
||||||
|
Interrupted,
|
||||||
|
/// The media playback completed
|
||||||
|
#[serde(rename = "FINISHED")]
|
||||||
|
Finished,
|
||||||
|
/// The media was interrupted due to an error; for example, if the player could not download the
|
||||||
|
/// media due to network issues
|
||||||
|
#[serde(rename = "ERROR")]
|
||||||
|
Error,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
|
||||||
|
pub enum PlayerState {
|
||||||
|
/// Player has not been loaded yet
|
||||||
|
#[serde(rename = "IDLE")]
|
||||||
|
Idle,
|
||||||
|
/// Player is actively playing content
|
||||||
|
#[serde(rename = "PLAYING")]
|
||||||
|
Playing,
|
||||||
|
/// Player is in PLAY mode but not actively playing content (currentTime is not changing)
|
||||||
|
#[serde(rename = "BUFFERING")]
|
||||||
|
Buffering,
|
||||||
|
/// Player is paused
|
||||||
|
#[serde(rename = "PAUSED")]
|
||||||
|
Paused,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Describes the current status of the media artifact with respect to the session.
|
||||||
|
///
|
||||||
|
/// <https://developers.google.com/cast/docs/media/messages#MediaStatus>
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct MediaStatus {
|
||||||
|
/// Unique ID for the playback of this specific session. This ID is set by the receiver at LOAD
|
||||||
|
/// and can be used to identify a specific instance of a playback. For example, two playbacks
|
||||||
|
/// of "Wish you were here" within the same session would each have a unique mediaSessionId.
|
||||||
|
#[serde(rename = "mediaSessionId")]
|
||||||
|
pub media_session_id: u64,
|
||||||
|
/// optional (for status messages) Full description of the content that is being played back.
|
||||||
|
/// Only be returned in a status messages if the MediaInformation has changed.
|
||||||
|
pub media: Option<MediaInformation>,
|
||||||
|
/// Indicates whether the media time is progressing, and at what rate. This is independent of the
|
||||||
|
/// player state since the media time can stop in any state.
|
||||||
|
/// 1.0 is regular time, 0.5 is slow motion
|
||||||
|
#[serde(rename = "playbackRate")]
|
||||||
|
pub playback_rate: f64,
|
||||||
|
#[serde(rename = "playerState")]
|
||||||
|
pub player_state: PlayerState,
|
||||||
|
/// optional If the playerState is IDLE and the reason it became IDLE is known, this property is
|
||||||
|
/// provided. If the player is IDLE because it just started, this property will not be provided;
|
||||||
|
/// if the player is in any other state this property should not be provided.
|
||||||
|
#[serde(rename = "idleReason")]
|
||||||
|
pub idle_reason: Option<IdleReason>,
|
||||||
|
/// The current position of the media player since the beginning of the content, in seconds.
|
||||||
|
/// If this a live stream content, then this field represents the time in seconds from the
|
||||||
|
/// beginning of the event that should be known to the player.
|
||||||
|
#[serde(rename = "currentTime")]
|
||||||
|
pub current_time: f64,
|
||||||
|
/// Flags describing which media commands the media player supports:
|
||||||
|
///
|
||||||
|
/// * 1 Pause
|
||||||
|
/// * 2 Seek
|
||||||
|
/// * 4 Stream volume
|
||||||
|
/// * 8 Stream mute
|
||||||
|
/// * 16 Skip forward
|
||||||
|
/// * 32 Skip backward
|
||||||
|
///
|
||||||
|
/// Combinations are described as summations; for example, Pause+Seek+StreamVolume+Mute == 15.
|
||||||
|
#[serde(rename = "supportedMediaCommands")]
|
||||||
|
pub supported_media_commands: u64,
|
||||||
|
/// Stream volume
|
||||||
|
pub volume: Volume,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.media.QueueItem>
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct QueueItem {
|
||||||
|
/// Whether the media will automatically play.
|
||||||
|
pub autoplay: bool,
|
||||||
|
pub media: MediaInformation,
|
||||||
|
/// Playback duration of the item in seconds. If it is larger than the actual duration - startTime it will be
|
||||||
|
/// limited to the actual duration - startTime. It can be negative, in such case the duration will be the actual
|
||||||
|
/// item duration minus the duration provided. A duration of value zero effectively means that the item will not be
|
||||||
|
/// played.
|
||||||
|
#[serde(rename = "playbackDuration")]
|
||||||
|
pub playback_duration: i32,
|
||||||
|
// This parameter is a hint for the receiver to preload this media item before it is played. It allows for a smooth
|
||||||
|
// transition between items played from the queue.
|
||||||
|
//
|
||||||
|
// The time is expressed in seconds, relative to the beginning of this item playback (usually the end of the
|
||||||
|
// previous item playback). Only positive values are valid. For example, if the value is 10 seconds, this item will
|
||||||
|
// be preloaded 10 seconds before the previous item has finished. The receiver will try to honor this value but
|
||||||
|
// will not guarantee it, for example if the value is larger than the previous item duration the receiver may just
|
||||||
|
// preload this item shortly after the previous item has started playing (there will never be two items being
|
||||||
|
// preloaded in parallel). Also, if an item is inserted in the queue just after the currentItem and the time to
|
||||||
|
// preload is higher than the time left on the currentItem, the preload will just happen as soon as possible.
|
||||||
|
// #[serde(rename = "preloadTime")]
|
||||||
|
// pub preload_time: f64,
|
||||||
|
/// Seconds from the beginning of the media to start playback.
|
||||||
|
#[serde(rename = "startTime")]
|
||||||
|
pub start_time: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct NamespaceMap {
|
||||||
|
pub name: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct Application {
|
||||||
|
#[serde(rename = "appId")]
|
||||||
|
pub app_id: String,
|
||||||
|
#[serde(rename = "appType")]
|
||||||
|
pub app_type: String,
|
||||||
|
#[serde(rename = "displayName")]
|
||||||
|
pub display_name: String,
|
||||||
|
#[serde(rename = "iconUrl")]
|
||||||
|
pub icon_url: String,
|
||||||
|
#[serde(rename = "isIdleScreen")]
|
||||||
|
pub is_idle_screen: bool,
|
||||||
|
#[serde(rename = "launchedFromCloud")]
|
||||||
|
pub launched_from_cloud: bool,
|
||||||
|
pub namespaces: Vec<NamespaceMap>,
|
||||||
|
#[serde(rename = "sessionId")]
|
||||||
|
pub session_id: String,
|
||||||
|
#[serde(rename = "statusText")]
|
||||||
|
pub status_text: String,
|
||||||
|
#[serde(rename = "transportId")]
|
||||||
|
pub transport_id: String,
|
||||||
|
#[serde(rename = "universalAppId")]
|
||||||
|
pub universal_app_id: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub enum QueueRepeatMode {
|
||||||
|
/// Items are played in order, and when the queue is completed (the last item has ended) the media session is
|
||||||
|
/// terminated.
|
||||||
|
#[serde(rename = "REPEAT_OFF")]
|
||||||
|
Off,
|
||||||
|
/// The items in the queue will be played indefinitely. When the last item has ended, the first item will be played
|
||||||
|
/// again.
|
||||||
|
#[serde(rename = "REPEAT_ALL")]
|
||||||
|
All,
|
||||||
|
/// The current item will be repeated indefinitely.
|
||||||
|
#[serde(rename = "REPEAT_SINGLE")]
|
||||||
|
Single,
|
||||||
|
/// The items in the queue will be played indefinitely. When the last item has ended, the list of items will be
|
||||||
|
/// randomly shuffled by the receiver, and the queue will continue to play starting from the first item of the
|
||||||
|
/// shuffled items.
|
||||||
|
#[serde(rename = "REPEAT_ALL_AND_SHUFFLE")]
|
||||||
|
AllAndShuffle,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct VolumeStatus {
|
||||||
|
#[serde(rename = "controlType")]
|
||||||
|
pub control_type: String,
|
||||||
|
pub level: f64,
|
||||||
|
pub muted: bool,
|
||||||
|
#[serde(rename = "stepInterval")]
|
||||||
|
pub step_interval: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct Status {
|
||||||
|
pub applications: Option<Vec<Application>>,
|
||||||
|
// TODO: `userEq`
|
||||||
|
pub volume: VolumeStatus,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub enum InvalidRequestReason {
|
||||||
|
#[serde(rename = "INVALID_COMMAND")]
|
||||||
|
InvalidCommand,
|
||||||
|
#[serde(rename = "DUPLICATE_REQUESTID")]
|
||||||
|
DuplicateRequestId,
|
||||||
|
#[serde(rename = "INVALID_MEDIA_SESSION_ID")]
|
||||||
|
InvalidMediaSessionId,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod namespaces {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
pub trait Namespace {
|
||||||
|
fn name(&self) -> &'static str;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
#[serde(tag = "type")]
|
||||||
|
pub enum Connection {
|
||||||
|
#[serde(rename = "CONNECT")]
|
||||||
|
Connect {
|
||||||
|
#[serde(rename = "connType")]
|
||||||
|
conn_type: u64,
|
||||||
|
},
|
||||||
|
#[serde(rename = "CLOSE")]
|
||||||
|
Close,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Namespace for Connection {
|
||||||
|
fn name(&self) -> &'static str {
|
||||||
|
CONNECTION_NAMESPACE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
#[serde(tag = "type")]
|
||||||
|
pub enum Heartbeat {
|
||||||
|
#[serde(rename = "PING")]
|
||||||
|
Ping,
|
||||||
|
#[serde(rename = "PONG")]
|
||||||
|
Pong,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Namespace for Heartbeat {
|
||||||
|
fn name(&self) -> &'static str {
|
||||||
|
HEARTBEAT_NAMESPACE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
#[serde(tag = "type")]
|
||||||
|
pub enum Receiver {
|
||||||
|
#[serde(rename = "SET_VOLUME")]
|
||||||
|
SetVolume {
|
||||||
|
volume: Volume,
|
||||||
|
#[serde(rename = "requestId")]
|
||||||
|
request_id: u64,
|
||||||
|
},
|
||||||
|
#[serde(rename = "STOP")]
|
||||||
|
StopSession {
|
||||||
|
#[serde(rename = "requestId")]
|
||||||
|
request_id: u64,
|
||||||
|
#[serde(rename = "sessionId")]
|
||||||
|
session_id: String,
|
||||||
|
},
|
||||||
|
#[serde(rename = "LAUNCH")]
|
||||||
|
Launch {
|
||||||
|
#[serde(rename = "appId")]
|
||||||
|
app_id: String,
|
||||||
|
#[serde(rename = "requestId")]
|
||||||
|
request_id: u64,
|
||||||
|
},
|
||||||
|
#[serde(rename = "GET_STATUS")]
|
||||||
|
GetStatus {
|
||||||
|
#[serde(rename = "requestId")]
|
||||||
|
request_id: u64,
|
||||||
|
},
|
||||||
|
#[serde(rename = "RECEIVER_STATUS")]
|
||||||
|
Status {
|
||||||
|
#[serde(rename = "requestId")]
|
||||||
|
request_id: u64,
|
||||||
|
status: Status,
|
||||||
|
},
|
||||||
|
#[serde(rename = "LAUNCH_STATUS")]
|
||||||
|
LaunchStatus {
|
||||||
|
#[serde(rename = "launchRequestId")]
|
||||||
|
request_id: u64,
|
||||||
|
status: String,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Namespace for Receiver {
|
||||||
|
fn name(&self) -> &'static str {
|
||||||
|
RECEIVER_NAMESPACE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: can media_session_id be a u64?
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
#[serde(tag = "type")]
|
||||||
|
pub enum Media {
|
||||||
|
/// Loads new content into the media player.
|
||||||
|
///
|
||||||
|
/// <https://developers.google.com/cast/docs/media/messages#Load>
|
||||||
|
#[serde(rename = "LOAD")]
|
||||||
|
Load {
|
||||||
|
/// ID of the request, to correlate request and response
|
||||||
|
#[serde(rename = "requestId")]
|
||||||
|
request_id: u64,
|
||||||
|
/// Metadata (including contentId) of the media to load
|
||||||
|
media: MediaInformation,
|
||||||
|
/// If the autoplay parameter is specified, the media player will begin playing the
|
||||||
|
/// content when it is loaded. Even if autoplay is not specified, media player
|
||||||
|
/// implementation may choose to begin playback immediately. If playback is started,
|
||||||
|
/// the player state in the response should be set to BUFFERING, otherwise it should
|
||||||
|
/// be set to PAUSED. default is true
|
||||||
|
#[serde(rename = "autoPlay")]
|
||||||
|
auto_play: Option<bool>,
|
||||||
|
/// Seconds since beginning of content. If the content is live content, and position is
|
||||||
|
/// not specified, the stream will start at the live position
|
||||||
|
#[serde(rename = "currentTime")]
|
||||||
|
current_time: Option<f64>,
|
||||||
|
/// The media playback rate.
|
||||||
|
#[serde(rename = "playbackRate", skip_serializing_if = "Option::is_none")]
|
||||||
|
playback_rate: Option<f64>,
|
||||||
|
},
|
||||||
|
/// Sets the current position in the stream. Triggers a STATUS event notification to all
|
||||||
|
/// sender applications. If the position provided is outside the range of valid positions
|
||||||
|
/// for the current content, then the player should pick a valid position as close to the
|
||||||
|
/// requested position as possible.
|
||||||
|
///
|
||||||
|
/// <https://developers.google.com/cast/docs/media/messages#Seek>
|
||||||
|
#[serde(rename = "SEEK")]
|
||||||
|
Seek {
|
||||||
|
/// ID of the media session where the position of the stream is set
|
||||||
|
#[serde(rename = "mediaSessionId")]
|
||||||
|
media_session_id: String,
|
||||||
|
/// ID of the request, to correlate request and response
|
||||||
|
#[serde(rename = "requestId")]
|
||||||
|
request_id: u64,
|
||||||
|
// TODO: `resumeState`
|
||||||
|
#[serde(rename = "currentTime")]
|
||||||
|
current_time: Option<f64>,
|
||||||
|
},
|
||||||
|
/// Begins playback of the content that was loaded with the load call, playback is continued
|
||||||
|
/// from the current time position.
|
||||||
|
///
|
||||||
|
/// <https://developers.google.com/cast/docs/media/messages#Play>
|
||||||
|
#[serde(rename = "PLAY")]
|
||||||
|
Resume {
|
||||||
|
#[serde(rename = "mediaSessionId")]
|
||||||
|
media_session_id: String,
|
||||||
|
#[serde(rename = "requestId")]
|
||||||
|
request_id: u64,
|
||||||
|
},
|
||||||
|
/// Pauses playback of the current content. Triggers a STATUS event notification to all sender
|
||||||
|
/// applications.
|
||||||
|
///
|
||||||
|
/// <https://developers.google.com/cast/docs/media/messages#Pause>
|
||||||
|
#[serde(rename = "PAUSE")]
|
||||||
|
Pause {
|
||||||
|
/// ID of the media session to be paused
|
||||||
|
#[serde(rename = "mediaSessionId")]
|
||||||
|
media_session_id: String,
|
||||||
|
/// ID of the request, to use to correlate request/response
|
||||||
|
#[serde(rename = "requestId")]
|
||||||
|
request_id: u64,
|
||||||
|
},
|
||||||
|
/// Stops playback of the current content. Triggers a STATUS event notification to all sender
|
||||||
|
/// applications. After this command the content will no longer be loaded and the
|
||||||
|
/// mediaSessionId is invalidated.
|
||||||
|
///
|
||||||
|
/// <https://developers.google.com/cast/docs/media/messages#Stop>
|
||||||
|
#[serde(rename = "STOP")]
|
||||||
|
Stop {
|
||||||
|
/// ID of the media session for the content to be stopped
|
||||||
|
#[serde(rename = "mediaSessionId")]
|
||||||
|
media_session_id: String,
|
||||||
|
/// ID of the request, to correlate request and response
|
||||||
|
#[serde(rename = "requestId")]
|
||||||
|
request_id: u64,
|
||||||
|
},
|
||||||
|
/// Retrieves the media status.
|
||||||
|
///
|
||||||
|
/// <https://developers.google.com/cast/docs/media/messages#GetStatus>
|
||||||
|
#[serde(rename = "GET_STATUS")]
|
||||||
|
GetStatus {
|
||||||
|
/// Media session ID of the media for which the media status should be returned. If none
|
||||||
|
/// is provided, then the status for all media session IDs will be provided.
|
||||||
|
#[serde(rename = "mediaSessionId")]
|
||||||
|
media_session_id: Option<u64>,
|
||||||
|
/// ID of the request, to correlate request and response
|
||||||
|
#[serde(rename = "requestId")]
|
||||||
|
request_id: u64,
|
||||||
|
},
|
||||||
|
/// Sent after a state change or after a media status request. Only the MediaStatus objects
|
||||||
|
/// that changed or were requested will be sent.
|
||||||
|
///
|
||||||
|
/// <https://developers.google.com/cast/docs/media/messages#MediaStatusMess>
|
||||||
|
#[serde(rename = "MEDIA_STATUS")]
|
||||||
|
Status {
|
||||||
|
/// ID used to correlate this status response with the request that originated it or 0
|
||||||
|
/// if the status message is spontaneous (not triggered by a sender request). Sender
|
||||||
|
/// applications will generate unique request IDs by selecting a random number and
|
||||||
|
/// continuously increasing it (they will not use 0).
|
||||||
|
#[serde(rename = "requestId")]
|
||||||
|
request_id: u64,
|
||||||
|
/// Array of Media Status objects. NOTE: the media element in MediaStatus will only be
|
||||||
|
/// returned if it has changed.
|
||||||
|
status: Vec<MediaStatus>,
|
||||||
|
},
|
||||||
|
#[serde(rename = "SET_PLAYBACK_RATE")]
|
||||||
|
SetPlaybackRate {
|
||||||
|
#[serde(rename = "mediaSessionId")]
|
||||||
|
media_session_id: u64,
|
||||||
|
#[serde(rename = "requestId")]
|
||||||
|
request_id: u64,
|
||||||
|
#[serde(rename = "playbackRate")]
|
||||||
|
playback_rate: f64,
|
||||||
|
},
|
||||||
|
#[serde(rename = "QUEUE_LOAD")]
|
||||||
|
QueueLoad {
|
||||||
|
#[serde(rename = "requestId")]
|
||||||
|
request_id: u64,
|
||||||
|
/// Array of items to load. It is sorted (first element will be played first). Must not be null or empty.
|
||||||
|
items: Vec<QueueItem>,
|
||||||
|
#[serde(rename = "repeatMode")]
|
||||||
|
repeat_mode: QueueRepeatMode,
|
||||||
|
/// The index of the item in the items array that must be the first currentItem (the item that will be
|
||||||
|
/// played first). Note this is the index of the array (starts at 0) and not the itemId (as it is not known
|
||||||
|
/// until the queue is created). If repeatMode is chrome.cast.media.RepeatMode.OFF playback will end when
|
||||||
|
/// the last item in the array is played (elements before the startIndex will not be played). This may be
|
||||||
|
/// useful for continuation scenarios where the user was already using the sender app and in the middle
|
||||||
|
/// decides to cast. In this way the sender app does not need to map between the local and remote queue
|
||||||
|
/// positions or saves one extra request to update the queue.
|
||||||
|
#[serde(rename = "startIndex")]
|
||||||
|
start_index: u32,
|
||||||
|
#[serde(rename = "queueType")]
|
||||||
|
queue_type: Option<String>,
|
||||||
|
},
|
||||||
|
#[serde(rename = "QUEUE_UPDATE")]
|
||||||
|
QueueUpdate {
|
||||||
|
#[serde(rename = "requestId")]
|
||||||
|
request_id: u64,
|
||||||
|
#[serde(rename = "mediaSessionId")]
|
||||||
|
media_session_id: String,
|
||||||
|
jump: Option<i32>,
|
||||||
|
},
|
||||||
|
/// https://developers.google.com/cast/docs/media/messages#InvalidPlayerState
|
||||||
|
///
|
||||||
|
/// <https://developers.google.com/cast/docs/media/messages#InvalidPlayerState>
|
||||||
|
#[serde(rename = "INVALID_PLAYER_STATE")]
|
||||||
|
InvalidPlayerState {
|
||||||
|
#[serde(rename = "requestId")]
|
||||||
|
request_id: u64,
|
||||||
|
},
|
||||||
|
/// Sent when the load request failed. The player state will be IDLE.
|
||||||
|
///
|
||||||
|
/// <https://developers.google.com/cast/docs/media/messages#LoadFailed>
|
||||||
|
#[serde(rename = "LOAD_FAILED")]
|
||||||
|
LoadFailed {
|
||||||
|
#[serde(rename = "requestId")]
|
||||||
|
request_id: u64,
|
||||||
|
},
|
||||||
|
#[serde(rename = "ERROR")]
|
||||||
|
Error {
|
||||||
|
#[serde(rename = "requestId")]
|
||||||
|
request_id: u64,
|
||||||
|
#[serde(rename = "detailedErrorCode")]
|
||||||
|
detailed_error_code: Option<u64>,
|
||||||
|
reason: Option<String>,
|
||||||
|
#[serde(rename = "itemId")]
|
||||||
|
item_id: u64,
|
||||||
|
},
|
||||||
|
/// Sent when the load request was cancelled (a second load request was received).
|
||||||
|
///
|
||||||
|
/// <https://developers.google.com/cast/docs/media/messages#LoadCancelled>
|
||||||
|
#[serde(rename = "LOAD_CANCELLED")]
|
||||||
|
LoadCancelled {
|
||||||
|
#[serde(rename = "requestId")]
|
||||||
|
request_id: u64,
|
||||||
|
},
|
||||||
|
/// Sent when the request is invalid (an unknown request type, for example).
|
||||||
|
///
|
||||||
|
/// <https://developers.google.com/cast/docs/media/messages#InvalidRequest>
|
||||||
|
#[serde(rename = "INVALID_REQUEST")]
|
||||||
|
InvalidRequest {
|
||||||
|
#[serde(rename = "requestId")]
|
||||||
|
request_id: u64,
|
||||||
|
reason: InvalidRequestReason,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Namespace for Media {
|
||||||
|
fn name(&self) -> &'static str {
|
||||||
|
MEDIA_NAMESPACE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn serde_generic_metadata() {
|
||||||
|
let meta = Metadata::Generic {
|
||||||
|
title: None,
|
||||||
|
subtitle: None,
|
||||||
|
images: None,
|
||||||
|
release_date: None,
|
||||||
|
};
|
||||||
|
assert_eq!(
|
||||||
|
serde_json::from_str::<Metadata>(&serde_json::to_string(&meta).unwrap()).unwrap(),
|
||||||
|
meta,
|
||||||
|
);
|
||||||
|
let meta = Metadata::Generic {
|
||||||
|
title: Some("title".to_owned()),
|
||||||
|
subtitle: Some("subtitle".to_owned()),
|
||||||
|
images: Some(vec![Image {
|
||||||
|
url: "url".to_owned(),
|
||||||
|
}]),
|
||||||
|
release_date: None,
|
||||||
|
};
|
||||||
|
assert_eq!(
|
||||||
|
serde_json::from_str::<Metadata>(&serde_json::to_string(&meta).unwrap()).unwrap(),
|
||||||
|
meta,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
10
sdk/sender/examples/android-views/.gitignore
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
*.iml
|
||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea
|
||||||
|
.DS_Store
|
||||||
|
/build
|
||||||
|
/captures
|
||||||
|
.externalNativeBuild
|
||||||
|
.cxx
|
||||||
|
local.properties
|
1
sdk/sender/examples/android-views/app/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/build
|
52
sdk/sender/examples/android-views/app/build.gradle.kts
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
plugins {
|
||||||
|
alias(libs.plugins.android.application)
|
||||||
|
alias(libs.plugins.kotlin.android)
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace = "org.fcast.sdk.example.views"
|
||||||
|
compileSdk = 35
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId = "org.fcast.sdk.example.views"
|
||||||
|
minSdk = 26
|
||||||
|
targetSdk = 35
|
||||||
|
versionCode = 1
|
||||||
|
versionName = "1.0"
|
||||||
|
|
||||||
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
isMinifyEnabled = false
|
||||||
|
proguardFiles(
|
||||||
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||||
|
"proguard-rules.pro"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
|
targetCompatibility = JavaVersion.VERSION_11
|
||||||
|
}
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = "11"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(libs.androidx.core.ktx)
|
||||||
|
implementation(libs.androidx.appcompat)
|
||||||
|
implementation(libs.material)
|
||||||
|
implementation(libs.androidx.activity)
|
||||||
|
implementation(libs.androidx.constraintlayout)
|
||||||
|
testImplementation(libs.junit)
|
||||||
|
androidTestImplementation(libs.androidx.junit)
|
||||||
|
androidTestImplementation(libs.androidx.espresso.core)
|
||||||
|
implementation("com.journeyapps:zxing-android-embedded:4.3.0")
|
||||||
|
implementation("org.futo.gitlab.videostreaming.fcast-sdk-jitpack:sender-sdk-full:0.2.1") {
|
||||||
|
exclude(group = "net.java.dev.jna")
|
||||||
|
}
|
||||||
|
implementation("net.java.dev.jna:jna:5.13.0@aar")
|
||||||
|
}
|
21
sdk/sender/examples/android-views/app/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
|
@ -0,0 +1,24 @@
|
||||||
|
package org.fcast.sdk.example.views
|
||||||
|
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
import org.junit.Assert.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instrumented test, which will execute on an Android device.
|
||||||
|
*
|
||||||
|
* See [testing documentation](http://d.android.com/tools/testing).
|
||||||
|
*/
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class ExampleInstrumentedTest {
|
||||||
|
@Test
|
||||||
|
fun useAppContext() {
|
||||||
|
// Context of the app under test.
|
||||||
|
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||||
|
assertEquals("org.fcast.sdk.example.views", appContext.packageName)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
||||||
|
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
|
||||||
|
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
|
android:fullBackupContent="@xml/backup_rules"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/Theme.AndroidViewsExample"
|
||||||
|
tools:targetApi="31">
|
||||||
|
<activity
|
||||||
|
android:name="com.journeyapps.barcodescanner.CaptureActivity"
|
||||||
|
android:screenOrientation="fullSensor"
|
||||||
|
tools:replace="screenOrientation" />
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
|
@ -0,0 +1,706 @@
|
||||||
|
package org.fcast.sdk.example.views
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuItem
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.view.WindowManager
|
||||||
|
import android.widget.AdapterView
|
||||||
|
import android.widget.ArrayAdapter
|
||||||
|
import android.widget.Button
|
||||||
|
import android.widget.EditText
|
||||||
|
import android.widget.ImageButton
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import android.widget.ProgressBar
|
||||||
|
import android.widget.Spinner
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
||||||
|
import com.google.android.material.slider.Slider
|
||||||
|
import com.journeyapps.barcodescanner.ScanContract
|
||||||
|
import com.journeyapps.barcodescanner.ScanOptions
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import org.fcast.sender_sdk.DeviceConnectionState
|
||||||
|
import org.fcast.sender_sdk.ProtocolType
|
||||||
|
import org.fcast.sender_sdk.CastingDevice
|
||||||
|
import org.fcast.sender_sdk.DeviceEventHandler
|
||||||
|
import org.fcast.sender_sdk.IpAddr
|
||||||
|
import org.fcast.sender_sdk.PlaybackState
|
||||||
|
import org.fcast.sender_sdk.Source
|
||||||
|
import org.fcast.sender_sdk.GenericKeyEvent
|
||||||
|
import org.fcast.sender_sdk.GenericMediaEvent
|
||||||
|
import org.fcast.sender_sdk.initLogger
|
||||||
|
import org.fcast.sender_sdk.DeviceInfo
|
||||||
|
import org.fcast.sender_sdk.DeviceDiscovererEventHandler
|
||||||
|
import org.fcast.sender_sdk.CastContext
|
||||||
|
import org.fcast.sender_sdk.LoadRequest
|
||||||
|
import org.fcast.sender_sdk.deviceInfoFromUrl
|
||||||
|
import org.fcast.sender_sdk.urlFormatIpAddr
|
||||||
|
import org.fcast.sender_sdk.LogLevelFilter
|
||||||
|
import org.fcast.sender_sdk.NsdDeviceDiscoverer
|
||||||
|
import org.fcast.sender_sdk.tryIpAddrFromStr
|
||||||
|
|
||||||
|
data class CastingState(
|
||||||
|
var activeDevice: CastingDevice? = null,
|
||||||
|
var volume: Double = 1.0,
|
||||||
|
var playbackState: PlaybackState = PlaybackState.IDLE,
|
||||||
|
var time: Double = 0.0,
|
||||||
|
var duration: Double = 0.0,
|
||||||
|
var speed: Double = 1.0,
|
||||||
|
var contentType: String = "",
|
||||||
|
var localAddress: IpAddr? = null,
|
||||||
|
) {
|
||||||
|
fun reset() {
|
||||||
|
volume = 1.0
|
||||||
|
playbackState = PlaybackState.IDLE
|
||||||
|
time = 0.0
|
||||||
|
duration = 0.0
|
||||||
|
speed = 1.0
|
||||||
|
contentType = ""
|
||||||
|
localAddress = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class EventHandler(
|
||||||
|
private val castingState: CastingState,
|
||||||
|
private val onConnected: () -> Unit,
|
||||||
|
private val onVolumeChanged: (Double) -> Unit,
|
||||||
|
private val onDurationChanged: (Double) -> Unit,
|
||||||
|
private val onPositionChanged: (Double) -> Unit,
|
||||||
|
) :
|
||||||
|
DeviceEventHandler {
|
||||||
|
override fun connectionStateChanged(state: DeviceConnectionState) {
|
||||||
|
println("Connection state changed: $state")
|
||||||
|
when (state) {
|
||||||
|
is DeviceConnectionState.Connected -> {
|
||||||
|
castingState.localAddress = state.localAddr
|
||||||
|
onConnected()
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun volumeChanged(volume: Double) {
|
||||||
|
println("Volume changed: $volume")
|
||||||
|
castingState.volume = volume
|
||||||
|
onVolumeChanged(volume)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun timeChanged(time: Double) {
|
||||||
|
println("Time changed: $time")
|
||||||
|
castingState.time = time
|
||||||
|
onPositionChanged(time)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun playbackStateChanged(state: PlaybackState) {
|
||||||
|
println("Playback state changed: $state")
|
||||||
|
castingState.playbackState = state
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun durationChanged(duration: Double) {
|
||||||
|
println("Duration changed: $duration")
|
||||||
|
castingState.duration = duration
|
||||||
|
onDurationChanged(duration)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun speedChanged(speed: Double) {
|
||||||
|
println("Speed changed: $speed")
|
||||||
|
castingState.speed = speed
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun sourceChanged(source: Source) {
|
||||||
|
println("Source changed: $source")
|
||||||
|
when (source) {
|
||||||
|
is Source.Url -> {
|
||||||
|
castingState.contentType = source.contentType
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
castingState.contentType = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun keyEvent(event: GenericKeyEvent) {
|
||||||
|
// Unreachable
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mediaEvent(event: GenericMediaEvent) {
|
||||||
|
// Unreachable
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun playbackError(message: String) {
|
||||||
|
println("Playback error: $message")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DiscoveryEventHandler(
|
||||||
|
private val onDeviceAdded: (DeviceInfo) -> Unit,
|
||||||
|
private val onDeviceRemoved: (String) -> Unit,
|
||||||
|
private val onDeviceUpdated: (DeviceInfo) -> Unit,
|
||||||
|
) : DeviceDiscovererEventHandler {
|
||||||
|
override fun deviceAvailable(deviceInfo: DeviceInfo) {
|
||||||
|
onDeviceAdded(deviceInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun deviceChanged(deviceInfo: DeviceInfo) {
|
||||||
|
onDeviceUpdated(deviceInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun deviceRemoved(deviceName: String) {
|
||||||
|
onDeviceRemoved(deviceName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DeviceViewHolder(view: View, private val onConnect: (CastingDevice) -> Unit) :
|
||||||
|
ViewHolder(view) {
|
||||||
|
private val root: ConstraintLayout = view.findViewById(org.fcast.sender_sdk.R.id.layout_root)
|
||||||
|
private val textName: TextView = view.findViewById(org.fcast.sender_sdk.R.id.text_name)
|
||||||
|
private val imageDevice: ImageView = view.findViewById(org.fcast.sender_sdk.R.id.image_device)
|
||||||
|
private val progressBar: ProgressBar = view.findViewById(org.fcast.sender_sdk.R.id.image_loader)
|
||||||
|
private val textType: TextView = view.findViewById(org.fcast.sender_sdk.R.id.text_type)
|
||||||
|
private var device: CastingDevice? = null
|
||||||
|
|
||||||
|
init {
|
||||||
|
root.setOnClickListener {
|
||||||
|
device?.let {
|
||||||
|
if (it.isReady()) {
|
||||||
|
onConnect(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
|
fun bind(d: CastingDevice) {
|
||||||
|
when (d.castingProtocol()) {
|
||||||
|
ProtocolType.CHROMECAST -> {
|
||||||
|
imageDevice.setImageResource(org.fcast.sender_sdk.R.drawable.ic_chromecast)
|
||||||
|
textType.text = "Chromecast"
|
||||||
|
}
|
||||||
|
|
||||||
|
ProtocolType.F_CAST -> {
|
||||||
|
imageDevice.setImageResource(org.fcast.sender_sdk.R.drawable.ic_fc)
|
||||||
|
textType.text = "FCast"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
textName.text = d.name()
|
||||||
|
|
||||||
|
if (d.isReady()) {
|
||||||
|
progressBar.visibility = View.GONE
|
||||||
|
} else {
|
||||||
|
progressBar.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
|
device = d
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DeviceAdapter(
|
||||||
|
private val devices: List<CastingDevice>,
|
||||||
|
private val onConnect: (CastingDevice) -> Unit
|
||||||
|
) : RecyclerView.Adapter<DeviceViewHolder>() {
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DeviceViewHolder {
|
||||||
|
val view = LayoutInflater.from(parent.context)
|
||||||
|
.inflate(org.fcast.sender_sdk.R.layout.list_device, parent, false)
|
||||||
|
return DeviceViewHolder(view, onConnect)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount(): Int {
|
||||||
|
return devices.size
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: DeviceViewHolder, position: Int) {
|
||||||
|
holder.bind(devices[position])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConnectCastingDialog(
|
||||||
|
context: Context,
|
||||||
|
private val onBarcode: () -> Unit,
|
||||||
|
private val onConnect: (CastingDevice) -> Unit,
|
||||||
|
private val onAddManually: () -> Unit,
|
||||||
|
) : AlertDialog(context) {
|
||||||
|
val devices: MutableList<CastingDevice> = mutableListOf()
|
||||||
|
private lateinit var adapter: DeviceAdapter
|
||||||
|
private lateinit var recyclerDevices: RecyclerView
|
||||||
|
private lateinit var textNoDevicesFound: TextView
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(
|
||||||
|
LayoutInflater.from(context)
|
||||||
|
.inflate(org.fcast.sender_sdk.R.layout.dialog_casting_connect, null)
|
||||||
|
)
|
||||||
|
|
||||||
|
recyclerDevices = findViewById(org.fcast.sender_sdk.R.id.recycler_devices)!!
|
||||||
|
textNoDevicesFound = findViewById(org.fcast.sender_sdk.R.id.text_no_devices_found)!!
|
||||||
|
|
||||||
|
adapter = DeviceAdapter(devices, onConnect)
|
||||||
|
recyclerDevices.adapter = adapter
|
||||||
|
recyclerDevices.layoutManager = LinearLayoutManager(context)
|
||||||
|
|
||||||
|
val buttonScanQr = findViewById<LinearLayout>(org.fcast.sender_sdk.R.id.button_qr)
|
||||||
|
buttonScanQr?.setOnClickListener {
|
||||||
|
onBarcode()
|
||||||
|
}
|
||||||
|
|
||||||
|
findViewById<Button>(org.fcast.sender_sdk.R.id.button_close)
|
||||||
|
?.setOnClickListener {
|
||||||
|
this.hide()
|
||||||
|
}
|
||||||
|
findViewById<LinearLayout>(org.fcast.sender_sdk.R.id.button_add)
|
||||||
|
?.setOnClickListener {
|
||||||
|
onAddManually()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun show() {
|
||||||
|
super.show()
|
||||||
|
textNoDevicesFound.visibility = if (devices.isEmpty()) View.VISIBLE else View.GONE
|
||||||
|
recyclerDevices.visibility = if (devices.isNotEmpty()) View.VISIBLE else View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
fun update() {
|
||||||
|
try {
|
||||||
|
adapter.notifyDataSetChanged()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("ConnectCastingDialog update failed: $e")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DeviceConnectingDialog(context: Context) : AlertDialog(context) {
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(
|
||||||
|
LayoutInflater.from(context)
|
||||||
|
.inflate(org.fcast.sender_sdk.R.layout.dialog_connecting_to_device, null)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DeviceConnectedDialog(
|
||||||
|
context: Context,
|
||||||
|
private val castingState: CastingState,
|
||||||
|
private val onDisconnected: () -> Unit,
|
||||||
|
) : AlertDialog(context) {
|
||||||
|
private lateinit var imageDevice: ImageView
|
||||||
|
private lateinit var textName: TextView
|
||||||
|
private lateinit var textType: TextView
|
||||||
|
lateinit var volumeSlider: Slider
|
||||||
|
lateinit var positionSlider: Slider
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(
|
||||||
|
LayoutInflater.from(context)
|
||||||
|
.inflate(org.fcast.sender_sdk.R.layout.dialog_casting_connected, null)
|
||||||
|
)
|
||||||
|
|
||||||
|
imageDevice = findViewById(org.fcast.sender_sdk.R.id.image_device)!!
|
||||||
|
textName = findViewById(org.fcast.sender_sdk.R.id.text_name)!!
|
||||||
|
textType = findViewById(org.fcast.sender_sdk.R.id.text_type)!!
|
||||||
|
findViewById<Button>(org.fcast.sender_sdk.R.id.button_close)
|
||||||
|
?.setOnClickListener {
|
||||||
|
this.hide()
|
||||||
|
}
|
||||||
|
findViewById<Button>(org.fcast.sender_sdk.R.id.button_disconnect)
|
||||||
|
?.setOnClickListener {
|
||||||
|
try {
|
||||||
|
castingState.activeDevice?.disconnect()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println(e)
|
||||||
|
}
|
||||||
|
castingState.activeDevice = null
|
||||||
|
castingState.reset()
|
||||||
|
this.hide()
|
||||||
|
onDisconnected()
|
||||||
|
}
|
||||||
|
findViewById<ImageButton>(org.fcast.sender_sdk.R.id.button_play)
|
||||||
|
?.setOnClickListener {
|
||||||
|
castingState.activeDevice?.resumePlayback()
|
||||||
|
}
|
||||||
|
findViewById<ImageButton>(org.fcast.sender_sdk.R.id.button_pause)
|
||||||
|
?.setOnClickListener {
|
||||||
|
castingState.activeDevice?.pausePlayback()
|
||||||
|
}
|
||||||
|
findViewById<ImageButton>(org.fcast.sender_sdk.R.id.button_stop)
|
||||||
|
?.setOnClickListener {
|
||||||
|
castingState.activeDevice?.stopPlayback()
|
||||||
|
}
|
||||||
|
volumeSlider = findViewById(org.fcast.sender_sdk.R.id.slider_volume)!!
|
||||||
|
volumeSlider.addOnChangeListener(Slider.OnChangeListener { _, value, fromUser ->
|
||||||
|
if (fromUser) {
|
||||||
|
castingState.activeDevice?.changeVolume(value.toDouble())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
positionSlider = findViewById(org.fcast.sender_sdk.R.id.slider_position)!!
|
||||||
|
positionSlider.addOnChangeListener(Slider.OnChangeListener { _, value, fromUser ->
|
||||||
|
if (fromUser) {
|
||||||
|
castingState.activeDevice?.seek(value.toDouble())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun update() {
|
||||||
|
val device = castingState.activeDevice ?: return
|
||||||
|
when (device.castingProtocol()) {
|
||||||
|
ProtocolType.CHROMECAST -> {
|
||||||
|
imageDevice.setImageResource(org.fcast.sender_sdk.R.drawable.ic_chromecast)
|
||||||
|
textType.text = "Chromecast"
|
||||||
|
}
|
||||||
|
|
||||||
|
ProtocolType.F_CAST -> {
|
||||||
|
imageDevice.setImageResource(org.fcast.sender_sdk.R.drawable.ic_fc)
|
||||||
|
textType.text = "FCast"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
textName.text = device.name()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class CastingAddDialog(context: Context, val onAdded: (DeviceInfo) -> Unit) : AlertDialog(context) {
|
||||||
|
private lateinit var textError: TextView
|
||||||
|
private lateinit var editName: EditText
|
||||||
|
private lateinit var editIP: EditText
|
||||||
|
private lateinit var editPort: EditText
|
||||||
|
private lateinit var spinnerType: Spinner
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(
|
||||||
|
LayoutInflater.from(context)
|
||||||
|
.inflate(org.fcast.sender_sdk.R.layout.dialog_casting_add, null)
|
||||||
|
)
|
||||||
|
|
||||||
|
findViewById<Button>(org.fcast.sender_sdk.R.id.button_cancel)
|
||||||
|
?.setOnClickListener {
|
||||||
|
this.hide()
|
||||||
|
}
|
||||||
|
|
||||||
|
textError = findViewById(org.fcast.sender_sdk.R.id.text_error)!!
|
||||||
|
textError.visibility = View.GONE
|
||||||
|
editName = findViewById(org.fcast.sender_sdk.R.id.edit_name)!!
|
||||||
|
editIP = findViewById(org.fcast.sender_sdk.R.id.edit_ip)!!
|
||||||
|
editPort = findViewById(org.fcast.sender_sdk.R.id.edit_port)!!
|
||||||
|
spinnerType = findViewById(org.fcast.sender_sdk.R.id.spinner_type)!!
|
||||||
|
|
||||||
|
ArrayAdapter.createFromResource(
|
||||||
|
context,
|
||||||
|
org.fcast.sender_sdk.R.array.casting_device_type_array,
|
||||||
|
org.fcast.sender_sdk.R.layout.spinner_item_simple
|
||||||
|
).also { adapter ->
|
||||||
|
adapter.setDropDownViewResource(org.fcast.sender_sdk.R.layout.spinner_dropdownitem_simple)
|
||||||
|
spinnerType.adapter = adapter
|
||||||
|
}
|
||||||
|
|
||||||
|
spinnerType.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
|
override fun onItemSelected(p0: AdapterView<*>?, p1: View?, p2: Int, p3: Long) {
|
||||||
|
editPort.text?.clear()
|
||||||
|
editPort.text?.append(
|
||||||
|
when (spinnerType.selectedItemPosition) {
|
||||||
|
0 -> "46899" // FCast
|
||||||
|
1 -> "8009" // Chromecast
|
||||||
|
else -> ""
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNothingSelected(p0: AdapterView<*>?) = Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
findViewById<Button>(org.fcast.sender_sdk.R.id.button_confirm)
|
||||||
|
?.setOnClickListener {
|
||||||
|
val castProtocolType = when (spinnerType.selectedItemPosition) {
|
||||||
|
0 -> ProtocolType.F_CAST
|
||||||
|
1 -> ProtocolType.CHROMECAST
|
||||||
|
else -> {
|
||||||
|
textError.text =
|
||||||
|
"Device type is invalid expected values like FastCast or ChromeCast."
|
||||||
|
textError.visibility = View.VISIBLE
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val name = editName.text.toString().trim()
|
||||||
|
if (name.isBlank()) {
|
||||||
|
textError.text = "Name can not be empty."
|
||||||
|
textError.visibility = View.VISIBLE
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
|
||||||
|
val ip = editIP.text.toString().trim()
|
||||||
|
if (ip.isBlank()) {
|
||||||
|
textError.text = "IP can not be empty."
|
||||||
|
textError.visibility = View.VISIBLE
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
|
||||||
|
val address = try {
|
||||||
|
tryIpAddrFromStr(ip)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("Invalid IP address ($ip): $e")
|
||||||
|
textError.text = "IP address is invalid"
|
||||||
|
textError.visibility = View.VISIBLE
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
val port: UShort? = editPort.text.toString().trim().toUShortOrNull();
|
||||||
|
if (port == null) {
|
||||||
|
textError.text = "Port number is invalid, expected a number between 0 and 65535.";
|
||||||
|
textError.visibility = View.VISIBLE;
|
||||||
|
return@setOnClickListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
textError.visibility = View.GONE;
|
||||||
|
val deviceInfo = DeviceInfo(name, castProtocolType, listOf(address), port);
|
||||||
|
onAdded(deviceInfo)
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun show() {
|
||||||
|
super.show()
|
||||||
|
|
||||||
|
editName.text.clear()
|
||||||
|
editIP.text.clear()
|
||||||
|
editPort.text.clear()
|
||||||
|
editPort.text.append("46899")
|
||||||
|
textError.visibility = View.GONE
|
||||||
|
spinnerType.setSelection(0)
|
||||||
|
|
||||||
|
window?.apply {
|
||||||
|
clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)
|
||||||
|
clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM)
|
||||||
|
setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MainActivity : AppCompatActivity() {
|
||||||
|
private val castingState = CastingState()
|
||||||
|
private val eventHandler = EventHandler(
|
||||||
|
castingState,
|
||||||
|
{
|
||||||
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
|
connectingToDeviceDialog.hide()
|
||||||
|
castingConnectedDialog.show()
|
||||||
|
castingConnectedDialog.update()
|
||||||
|
castLocalFileBtn.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ newVolume ->
|
||||||
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
|
try {
|
||||||
|
castingConnectedDialog.volumeSlider.value = newVolume.toFloat()
|
||||||
|
.coerceAtMost(castingConnectedDialog.volumeSlider.valueTo)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("$e")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ newDuration ->
|
||||||
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
|
try {
|
||||||
|
val newDurationF = newDuration.toFloat()
|
||||||
|
castingConnectedDialog.positionSlider.value =
|
||||||
|
castingConnectedDialog.positionSlider.value.coerceAtMost(newDurationF)
|
||||||
|
castingConnectedDialog.positionSlider.valueTo = newDurationF
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("$e")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ newPosition ->
|
||||||
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
|
try {
|
||||||
|
val newPositionF = newPosition.toFloat()
|
||||||
|
castingConnectedDialog.positionSlider.value = newPositionF
|
||||||
|
castingConnectedDialog.positionSlider.value =
|
||||||
|
castingConnectedDialog.positionSlider.valueTo.coerceAtMost(newPositionF)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("$e")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
private val castContext = CastContext()
|
||||||
|
private val fileServer = castContext.startFileServer()
|
||||||
|
private lateinit var connectCastingDialog: ConnectCastingDialog
|
||||||
|
private lateinit var castingConnectedDialog: DeviceConnectedDialog
|
||||||
|
private lateinit var castingAddDialog: CastingAddDialog
|
||||||
|
private lateinit var connectingToDeviceDialog: DeviceConnectingDialog
|
||||||
|
private val barcodeLauncher = registerForActivityResult(ScanContract()) { result ->
|
||||||
|
result.contents?.let {
|
||||||
|
deviceInfoFromUrl(it)?.let { deviceInfo ->
|
||||||
|
val device = castContext.createDeviceFromInfo(deviceInfo)
|
||||||
|
try {
|
||||||
|
castingState.reset()
|
||||||
|
device.connect(null, eventHandler)
|
||||||
|
castingState.activeDevice = device
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("Failed to start device: {e}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private val selectMediaIntent = registerForActivityResult(ActivityResultContracts.GetContent())
|
||||||
|
{ maybeUri ->
|
||||||
|
try {
|
||||||
|
val uri = maybeUri!!
|
||||||
|
val type = this.contentResolver.getType(uri)!!
|
||||||
|
val parcelFd = this.contentResolver.openFileDescriptor(uri, "r")
|
||||||
|
val fd = parcelFd?.detachFd() ?: throw Exception("asdf")
|
||||||
|
castingState.activeDevice?.let { device ->
|
||||||
|
val entry = fileServer.serveFile(fd)
|
||||||
|
val url =
|
||||||
|
"http://${urlFormatIpAddr(castingState.localAddress!!)}:${entry.port}/${entry.location}"
|
||||||
|
device.load(LoadRequest.Url(type, url))
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("Failed to read $maybeUri: $e")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private lateinit var deviceDiscoverer: NsdDeviceDiscoverer
|
||||||
|
private lateinit var castLocalFileBtn: Button
|
||||||
|
|
||||||
|
init {
|
||||||
|
initLogger(LogLevelFilter.DEBUG)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||||
|
super.onCreateOptionsMenu(menu)
|
||||||
|
menuInflater.inflate(R.menu.actions, menu)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
when (item.itemId) {
|
||||||
|
R.id.cast_button -> {
|
||||||
|
if (castingState.activeDevice != null) {
|
||||||
|
castingConnectedDialog.show()
|
||||||
|
castingConnectedDialog.update()
|
||||||
|
} else {
|
||||||
|
connectCastingDialog.show()
|
||||||
|
connectCastingDialog.update()
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
return super.onOptionsItemSelected(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
deviceDiscoverer = NsdDeviceDiscoverer(
|
||||||
|
this, DiscoveryEventHandler(
|
||||||
|
{ deviceInfo ->
|
||||||
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
|
try {
|
||||||
|
connectCastingDialog.devices.add(
|
||||||
|
castContext.createDeviceFromInfo(
|
||||||
|
deviceInfo
|
||||||
|
)
|
||||||
|
)
|
||||||
|
connectCastingDialog.update()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ deviceName ->
|
||||||
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
|
try {
|
||||||
|
connectCastingDialog.devices.removeIf { it.name() == deviceName }
|
||||||
|
connectCastingDialog.update()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ deviceInfo ->
|
||||||
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
|
try {
|
||||||
|
connectCastingDialog.devices.find { it.name() == deviceInfo.name }
|
||||||
|
?.let { device ->
|
||||||
|
device.setPort(deviceInfo.port)
|
||||||
|
device.setAddresses(deviceInfo.addresses)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
enableEdgeToEdge()
|
||||||
|
connectCastingDialog = ConnectCastingDialog(
|
||||||
|
this,
|
||||||
|
{
|
||||||
|
barcodeLauncher.launch(ScanOptions().setOrientationLocked(false))
|
||||||
|
},
|
||||||
|
{ device ->
|
||||||
|
connectCastingDialog.hide()
|
||||||
|
try {
|
||||||
|
device.connect(null, eventHandler)
|
||||||
|
castingState.activeDevice = device
|
||||||
|
connectingToDeviceDialog.show()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println(e)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
connectCastingDialog.hide()
|
||||||
|
castingAddDialog.show()
|
||||||
|
})
|
||||||
|
castingConnectedDialog = DeviceConnectedDialog(this, castingState) {
|
||||||
|
castLocalFileBtn.visibility = View.GONE
|
||||||
|
}
|
||||||
|
castingAddDialog = CastingAddDialog(this) { deviceInfo ->
|
||||||
|
try {
|
||||||
|
connectCastingDialog.devices.add(
|
||||||
|
castContext.createDeviceFromInfo(
|
||||||
|
deviceInfo
|
||||||
|
)
|
||||||
|
)
|
||||||
|
connectCastingDialog.update()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
connectingToDeviceDialog = DeviceConnectingDialog(this)
|
||||||
|
setContentView(R.layout.activity_main)
|
||||||
|
setSupportActionBar(findViewById(R.id.toolbar))
|
||||||
|
supportActionBar?.setDisplayShowTitleEnabled(false)
|
||||||
|
|
||||||
|
castLocalFileBtn = findViewById(R.id.cast_local_file)
|
||||||
|
castLocalFileBtn.visibility = View.GONE
|
||||||
|
castLocalFileBtn.setOnClickListener {
|
||||||
|
selectMediaIntent.launch("*/*")
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
|
||||||
|
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
||||||
|
insets
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,170 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path
|
||||||
|
android:fillColor="#3DDC84"
|
||||||
|
android:pathData="M0,0h108v108h-108z" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M9,0L9,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,0L19,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,0L29,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,0L39,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,0L49,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,0L59,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,0L69,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,0L79,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M89,0L89,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M99,0L99,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,9L108,9"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,19L108,19"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,29L108,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,39L108,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,49L108,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,59L108,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,69L108,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,79L108,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,89L108,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,99L108,99"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,29L89,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,39L89,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,49L89,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,59L89,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,69L89,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,79L89,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,19L29,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,19L39,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,19L49,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,19L59,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,19L69,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,19L79,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
</vector>
|
|
@ -0,0 +1,30 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:aapt="http://schemas.android.com/aapt"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||||
|
<aapt:attr name="android:fillColor">
|
||||||
|
<gradient
|
||||||
|
android:endX="85.84757"
|
||||||
|
android:endY="92.4963"
|
||||||
|
android:startX="42.9492"
|
||||||
|
android:startY="49.59793"
|
||||||
|
android:type="linear">
|
||||||
|
<item
|
||||||
|
android:color="#44000000"
|
||||||
|
android:offset="0.0" />
|
||||||
|
<item
|
||||||
|
android:color="#00000000"
|
||||||
|
android:offset="1.0" />
|
||||||
|
</gradient>
|
||||||
|
</aapt:attr>
|
||||||
|
</path>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:fillType="nonZero"
|
||||||
|
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:strokeColor="#00000000" />
|
||||||
|
</vector>
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/main"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
android:elevation="4dp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center">
|
||||||
|
<Button
|
||||||
|
android:id="@+id/cast_local_file"
|
||||||
|
android:text="@string/cast_local_file"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<item
|
||||||
|
android:id="@+id/cast_button"
|
||||||
|
android:icon="@drawable/ic_cast"
|
||||||
|
android:title="Cast"
|
||||||
|
app:tint="?attr/colorOnPrimary"
|
||||||
|
app:showAsAction="ifRoom"/>
|
||||||
|
</menu>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 982 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 7.6 KiB |
|
@ -0,0 +1,8 @@
|
||||||
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<!-- <style name="Base.Theme.AndroidViewsExample" parent="Theme.Material3.DayNight.NoActionBar"> -->
|
||||||
|
<style name="Base.Theme.AndroidViewsExample" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||||
|
<!-- Customize your dark theme here. -->
|
||||||
|
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
|
||||||
|
</style>
|
||||||
|
</resources>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="black">#FF000000</color>
|
||||||
|
<color name="white">#FFFFFFFF</color>
|
||||||
|
</resources>
|
|
@ -0,0 +1,4 @@
|
||||||
|
<resources>
|
||||||
|
<string name="app_name">FCast Sender SDK Views Demo</string>
|
||||||
|
<string name="cast_local_file">Cast local file</string>
|
||||||
|
</resources>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<!-- <style name="Base.Theme.AndroidViewsExample" parent="Theme.Material3.DayNight.NoActionBar"> -->
|
||||||
|
<style name="Base.Theme.AndroidViewsExample" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||||
|
<!-- Customize your light theme here. -->
|
||||||
|
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="Theme.AndroidViewsExample" parent="Base.Theme.AndroidViewsExample" />
|
||||||
|
</resources>
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
Sample backup rules file; uncomment and customize as necessary.
|
||||||
|
See https://developer.android.com/guide/topics/data/autobackup
|
||||||
|
for details.
|
||||||
|
Note: This file is ignored for devices older than API 31
|
||||||
|
See https://developer.android.com/about/versions/12/backup-restore
|
||||||
|
-->
|
||||||
|
<full-backup-content>
|
||||||
|
<!--
|
||||||
|
<include domain="sharedpref" path="."/>
|
||||||
|
<exclude domain="sharedpref" path="device.xml"/>
|
||||||
|
-->
|
||||||
|
</full-backup-content>
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
Sample data extraction rules file; uncomment and customize as necessary.
|
||||||
|
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||||
|
for details.
|
||||||
|
-->
|
||||||
|
<data-extraction-rules>
|
||||||
|
<cloud-backup>
|
||||||
|
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||||
|
<include .../>
|
||||||
|
<exclude .../>
|
||||||
|
-->
|
||||||
|
</cloud-backup>
|
||||||
|
<!--
|
||||||
|
<device-transfer>
|
||||||
|
<include .../>
|
||||||
|
<exclude .../>
|
||||||
|
</device-transfer>
|
||||||
|
-->
|
||||||
|
</data-extraction-rules>
|
|
@ -0,0 +1,17 @@
|
||||||
|
package org.fcast.sdk.example.views
|
||||||
|
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
import org.junit.Assert.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example local unit test, which will execute on the development machine (host).
|
||||||
|
*
|
||||||
|
* See [testing documentation](http://d.android.com/tools/testing).
|
||||||
|
*/
|
||||||
|
class ExampleUnitTest {
|
||||||
|
@Test
|
||||||
|
fun addition_isCorrect() {
|
||||||
|
assertEquals(4, 2 + 2)
|
||||||
|
}
|
||||||
|
}
|
5
sdk/sender/examples/android-views/build.gradle.kts
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
plugins {
|
||||||
|
alias(libs.plugins.android.application) apply false
|
||||||
|
alias(libs.plugins.kotlin.android) apply false
|
||||||
|
}
|
23
sdk/sender/examples/android-views/gradle.properties
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# Project-wide Gradle settings.
|
||||||
|
# IDE (e.g. Android Studio) users:
|
||||||
|
# Gradle settings configured through the IDE *will override*
|
||||||
|
# any settings specified in this file.
|
||||||
|
# For more details on how to configure your build environment visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
|
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||||
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
|
# This option should only be used with decoupled projects. For more details, visit
|
||||||
|
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
|
||||||
|
# org.gradle.parallel=true
|
||||||
|
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||||
|
# Android operating system, and which are packaged with your app's APK
|
||||||
|
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||||
|
android.useAndroidX=true
|
||||||
|
# Kotlin code style for this project: "official" or "obsolete":
|
||||||
|
kotlin.code.style=official
|
||||||
|
# Enables namespacing of each library's R class so that its R class includes only the
|
||||||
|
# resources declared in the library itself and none from the library's dependencies,
|
||||||
|
# thereby reducing the size of the R class for that library
|
||||||
|
android.nonTransitiveRClass=true
|
26
sdk/sender/examples/android-views/gradle/libs.versions.toml
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
[versions]
|
||||||
|
agp = "8.10.0"
|
||||||
|
kotlin = "2.0.21"
|
||||||
|
coreKtx = "1.16.0"
|
||||||
|
junit = "4.13.2"
|
||||||
|
junitVersion = "1.2.1"
|
||||||
|
espressoCore = "3.6.1"
|
||||||
|
appcompat = "1.7.1"
|
||||||
|
material = "1.12.0"
|
||||||
|
activity = "1.10.1"
|
||||||
|
constraintlayout = "2.2.1"
|
||||||
|
|
||||||
|
[libraries]
|
||||||
|
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||||
|
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||||
|
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
||||||
|
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
||||||
|
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
|
||||||
|
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
|
||||||
|
androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
|
||||||
|
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
|
||||||
|
|
||||||
|
[plugins]
|
||||||
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
|
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||||
|
|
BIN
sdk/sender/examples/android-views/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
sdk/sender/examples/android-views/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#Mon Jul 14 09:11:13 GMT 2025
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
185
sdk/sender/examples/android-views/gradlew
vendored
Executable file
|
@ -0,0 +1,185 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright 2015 the original author or authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=`expr $i + 1`
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
0) set -- ;;
|
||||||
|
1) set -- "$args0" ;;
|
||||||
|
2) set -- "$args0" "$args1" ;;
|
||||||
|
3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=`save "$@"`
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
89
sdk/sender/examples/android-views/gradlew.bat
vendored
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
25
sdk/sender/examples/android-views/settings.gradle.kts
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
google {
|
||||||
|
content {
|
||||||
|
includeGroupByRegex("com\\.android.*")
|
||||||
|
includeGroupByRegex("com\\.google.*")
|
||||||
|
includeGroupByRegex("androidx.*")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mavenCentral()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
mavenLocal()
|
||||||
|
maven("https://jitpack.io")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.name = "FCast Sender SDK Layouts Example"
|
||||||
|
include(":app")
|
10
sdk/sender/examples/android/.gitignore
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
*.iml
|
||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea
|
||||||
|
.DS_Store
|
||||||
|
/build
|
||||||
|
/captures
|
||||||
|
.externalNativeBuild
|
||||||
|
.cxx
|
||||||
|
local.properties
|
1
sdk/sender/examples/android/app/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/build
|
63
sdk/sender/examples/android/app/build.gradle.kts
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
plugins {
|
||||||
|
alias(libs.plugins.android.application)
|
||||||
|
alias(libs.plugins.kotlin.android)
|
||||||
|
alias(libs.plugins.kotlin.compose)
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace = "fcast.sender"
|
||||||
|
compileSdk = 35
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId = "org.fcast.sender.sdk.demo"
|
||||||
|
minSdk = 26
|
||||||
|
targetSdk = 35
|
||||||
|
versionCode = 1
|
||||||
|
versionName = "1.0"
|
||||||
|
|
||||||
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
isMinifyEnabled = false
|
||||||
|
proguardFiles(
|
||||||
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||||
|
"proguard-rules.pro"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
|
targetCompatibility = JavaVersion.VERSION_11
|
||||||
|
}
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = "11"
|
||||||
|
}
|
||||||
|
buildFeatures {
|
||||||
|
compose = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(libs.androidx.core.ktx)
|
||||||
|
implementation(libs.androidx.lifecycle.runtime.ktx)
|
||||||
|
implementation(libs.androidx.activity.compose)
|
||||||
|
implementation(platform(libs.androidx.compose.bom))
|
||||||
|
implementation(libs.androidx.ui)
|
||||||
|
implementation(libs.androidx.ui.graphics)
|
||||||
|
implementation(libs.androidx.ui.tooling.preview)
|
||||||
|
implementation(libs.androidx.material3)
|
||||||
|
implementation("com.journeyapps:zxing-android-embedded:4.3.0")
|
||||||
|
testImplementation(libs.junit)
|
||||||
|
androidTestImplementation(libs.androidx.junit)
|
||||||
|
androidTestImplementation(libs.androidx.espresso.core)
|
||||||
|
androidTestImplementation(platform(libs.androidx.compose.bom))
|
||||||
|
androidTestImplementation(libs.androidx.ui.test.junit4)
|
||||||
|
debugImplementation(libs.androidx.ui.tooling)
|
||||||
|
debugImplementation(libs.androidx.ui.test.manifest)
|
||||||
|
implementation("org.futo.gitlab.videostreaming.fcast-sdk-jitpack:sender-sdk-minimal:0.2.1") {
|
||||||
|
exclude(group = "net.java.dev.jna")
|
||||||
|
}
|
||||||
|
implementation("net.java.dev.jna:jna:5.13.0@aar")
|
||||||
|
}
|
21
sdk/sender/examples/android/app/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
|
@ -0,0 +1,24 @@
|
||||||
|
package fcast.sender
|
||||||
|
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
import org.junit.Assert.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instrumented test, which will execute on an Android device.
|
||||||
|
*
|
||||||
|
* See [testing documentation](http://d.android.com/tools/testing).
|
||||||
|
*/
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class ExampleInstrumentedTest {
|
||||||
|
@Test
|
||||||
|
fun useAppContext() {
|
||||||
|
// Context of the app under test.
|
||||||
|
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||||
|
assertEquals("fcast.sender", appContext.packageName)
|
||||||
|
}
|
||||||
|
}
|
1
sdk/sender/examples/android/app/src/main/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/jniLibs
|
36
sdk/sender/examples/android/app/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
|
android:fullBackupContent="@xml/backup_rules"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/Theme.FCastSender"
|
||||||
|
android:hardwareAccelerated="true"
|
||||||
|
tools:targetApi="31">
|
||||||
|
<activity
|
||||||
|
android:name="com.journeyapps.barcodescanner.CaptureActivity"
|
||||||
|
android:screenOrientation="fullSensor"
|
||||||
|
tools:replace="screenOrientation" />
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:exported="true"
|
||||||
|
android:theme="@style/Theme.FCastSender">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
|
@ -0,0 +1,493 @@
|
||||||
|
package fcast.sender
|
||||||
|
|
||||||
|
import android.icu.text.DecimalFormat
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.KeyEvent
|
||||||
|
import androidx.activity.ComponentActivity
|
||||||
|
import androidx.activity.compose.setContent
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material3.Button
|
||||||
|
import androidx.compose.material3.Card
|
||||||
|
import androidx.compose.material3.CircularProgressIndicator
|
||||||
|
import androidx.compose.material3.Scaffold
|
||||||
|
import androidx.compose.material3.Slider
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TextButton
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.MutableState
|
||||||
|
import androidx.compose.runtime.mutableDoubleStateOf
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.window.Dialog
|
||||||
|
import fcast.sender.ui.theme.FCastSenderTheme
|
||||||
|
import org.fcast.sender_sdk.DeviceConnectionState
|
||||||
|
import org.fcast.sender_sdk.CastingDevice
|
||||||
|
import org.fcast.sender_sdk.DeviceEventHandler
|
||||||
|
import org.fcast.sender_sdk.GenericKeyEvent
|
||||||
|
import org.fcast.sender_sdk.GenericMediaEvent
|
||||||
|
import org.fcast.sender_sdk.PlaybackState
|
||||||
|
import org.fcast.sender_sdk.Source
|
||||||
|
import org.fcast.sender_sdk.initLogger
|
||||||
|
import org.fcast.sender_sdk.IpAddr
|
||||||
|
import org.fcast.sender_sdk.urlFormatIpAddr
|
||||||
|
import org.fcast.sender_sdk.deviceInfoFromUrl
|
||||||
|
import org.fcast.sender_sdk.NsdDeviceDiscoverer
|
||||||
|
import org.fcast.sender_sdk.CastContext
|
||||||
|
import com.journeyapps.barcodescanner.ScanContract
|
||||||
|
import com.journeyapps.barcodescanner.ScanOptions
|
||||||
|
import org.fcast.sender_sdk.DeviceInfo
|
||||||
|
import org.fcast.sender_sdk.DeviceDiscovererEventHandler
|
||||||
|
import org.fcast.sender_sdk.LoadRequest
|
||||||
|
import org.fcast.sender_sdk.LogLevelFilter
|
||||||
|
|
||||||
|
data class CastingState(
|
||||||
|
var volume: MutableState<Double> = mutableDoubleStateOf(1.0),
|
||||||
|
var playbackState: MutableState<PlaybackState> = mutableStateOf(PlaybackState.IDLE),
|
||||||
|
var time: MutableState<Double> = mutableDoubleStateOf(0.0),
|
||||||
|
var duration: MutableState<Double> = mutableDoubleStateOf(0.0),
|
||||||
|
var speed: MutableState<Double> = mutableDoubleStateOf(1.0),
|
||||||
|
var contentType: MutableState<String> = mutableStateOf(""),
|
||||||
|
var localAddress: IpAddr? = null,
|
||||||
|
) {
|
||||||
|
fun reset() {
|
||||||
|
volume.value = 1.0
|
||||||
|
playbackState.value = PlaybackState.IDLE
|
||||||
|
time.value = 0.0
|
||||||
|
duration.value = 0.0
|
||||||
|
speed.value = 1.0
|
||||||
|
contentType.value = ""
|
||||||
|
localAddress = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class EventHandler : DeviceEventHandler {
|
||||||
|
var castingState = CastingState()
|
||||||
|
|
||||||
|
override fun connectionStateChanged(state: DeviceConnectionState) {
|
||||||
|
println("Connection state changed: $state")
|
||||||
|
when (state) {
|
||||||
|
is DeviceConnectionState.Connected -> {
|
||||||
|
castingState.localAddress = state.localAddr
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun volumeChanged(volume: Double) {
|
||||||
|
println("Volume changed: $volume")
|
||||||
|
castingState.volume.value = volume
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun timeChanged(time: Double) {
|
||||||
|
println("Time changed: $time")
|
||||||
|
castingState.time.value = time
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun playbackStateChanged(state: PlaybackState) {
|
||||||
|
println("Playback state changed: $state")
|
||||||
|
castingState.playbackState.value = state
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun durationChanged(duration: Double) {
|
||||||
|
println("Duration changed: $duration")
|
||||||
|
castingState.duration.value = duration
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun speedChanged(speed: Double) {
|
||||||
|
println("Speed changed: $speed")
|
||||||
|
castingState.speed.value = speed
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun sourceChanged(source: Source) {
|
||||||
|
println("Source changed: $source")
|
||||||
|
when (source) {
|
||||||
|
is Source.Url -> {
|
||||||
|
castingState.contentType.value = source.contentType
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
castingState.contentType.value = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun keyEvent(event: GenericKeyEvent) {
|
||||||
|
// Unreachable
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mediaEvent(event: GenericMediaEvent) {
|
||||||
|
// Unreachable
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun playbackError(message: String) {
|
||||||
|
println("Playback error: $message")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DiscoveryEventHandler(
|
||||||
|
private val devices: MutableState<List<CastingDevice>>,
|
||||||
|
private val ctx: CastContext
|
||||||
|
) : DeviceDiscovererEventHandler {
|
||||||
|
override fun deviceAvailable(deviceInfo: DeviceInfo) {
|
||||||
|
devices.value += ctx.createDeviceFromInfo(deviceInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun deviceChanged(deviceInfo: DeviceInfo) {
|
||||||
|
devices.value.find { it.name() == deviceInfo.name }?.let {
|
||||||
|
it.setAddresses(deviceInfo.addresses)
|
||||||
|
it.setPort(deviceInfo.port)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun deviceRemoved(deviceName: String) {
|
||||||
|
devices.value.filter { it.name() != deviceName }.let {
|
||||||
|
devices.value = it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MainActivity : ComponentActivity() {
|
||||||
|
private val eventHandler = EventHandler()
|
||||||
|
private val castContext = CastContext()
|
||||||
|
private val fileServer = castContext.startFileServer()
|
||||||
|
private var activeCastingDevice: MutableState<CastingDevice?> = mutableStateOf(null)
|
||||||
|
private val devices: MutableState<List<CastingDevice>> = mutableStateOf(listOf())
|
||||||
|
private val barcodeLauncher = registerForActivityResult(ScanContract()) { result ->
|
||||||
|
result.contents?.let {
|
||||||
|
deviceInfoFromUrl(it)?.let { deviceInfo ->
|
||||||
|
val device = castContext.createDeviceFromInfo(deviceInfo)
|
||||||
|
try {
|
||||||
|
device.connect(null, eventHandler)
|
||||||
|
activeCastingDevice.value = device
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("Failed to start device: {e}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private val selectMediaIntent = registerForActivityResult(ActivityResultContracts.GetContent())
|
||||||
|
{ maybeUri ->
|
||||||
|
try {
|
||||||
|
val uri = maybeUri!!
|
||||||
|
val type = this.contentResolver.getType(uri)!!
|
||||||
|
val parcelFd = this.contentResolver.openFileDescriptor(uri, "r")
|
||||||
|
val fd = parcelFd?.detachFd() ?: throw Exception("asdf")
|
||||||
|
activeCastingDevice.value?.let { device ->
|
||||||
|
val entry = fileServer.serveFile(fd)
|
||||||
|
val url =
|
||||||
|
"http://${urlFormatIpAddr(eventHandler.castingState.localAddress!!)}:${entry.port}/${entry.location}"
|
||||||
|
device.load(LoadRequest.Url(type, url))
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("Failed to read $maybeUri: $e")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private lateinit var deviceDiscoverer: NsdDeviceDiscoverer
|
||||||
|
|
||||||
|
init {
|
||||||
|
initLogger(LogLevelFilter.DEBUG)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
||||||
|
when (keyCode) {
|
||||||
|
KeyEvent.KEYCODE_VOLUME_UP -> {
|
||||||
|
eventHandler.castingState.volume.value =
|
||||||
|
(eventHandler.castingState.volume.value + 0.1).coerceAtMost(1.0)
|
||||||
|
activeCastingDevice.value?.changeVolume(eventHandler.castingState.volume.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyEvent.KEYCODE_VOLUME_DOWN -> {
|
||||||
|
eventHandler.castingState.volume.value =
|
||||||
|
(eventHandler.castingState.volume.value - 0.1).coerceAtLeast(0.0)
|
||||||
|
activeCastingDevice.value?.changeVolume(eventHandler.castingState.volume.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> return super.onKeyDown(keyCode, event)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
deviceDiscoverer = NsdDeviceDiscoverer(this, DiscoveryEventHandler(devices, castContext))
|
||||||
|
enableEdgeToEdge()
|
||||||
|
setContent {
|
||||||
|
FCastSenderTheme {
|
||||||
|
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
|
||||||
|
View(
|
||||||
|
Modifier.padding(innerPadding),
|
||||||
|
eventHandler.castingState,
|
||||||
|
activeCastingDevice,
|
||||||
|
devices,
|
||||||
|
connectDevice = { device ->
|
||||||
|
try {
|
||||||
|
device.connect(null, eventHandler)
|
||||||
|
activeCastingDevice.value = device
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("Failed to connect to device: $e")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
disconnectActiveDevice = {
|
||||||
|
try {
|
||||||
|
activeCastingDevice.value?.disconnect()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("Failed to stop device: $e")
|
||||||
|
}
|
||||||
|
activeCastingDevice.value = null
|
||||||
|
eventHandler.castingState.reset()
|
||||||
|
},
|
||||||
|
launchQrScanner = {
|
||||||
|
barcodeLauncher.launch(ScanOptions().setOrientationLocked(false))
|
||||||
|
},
|
||||||
|
selectMedia = {
|
||||||
|
// selectMediaIntent.launch("image/*,video/*,audio/*") // Doesn't show quick select for video and audio, only the first type in the list...
|
||||||
|
selectMediaIntent.launch("*/*")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun CastDialog(
|
||||||
|
onDismissRequest: () -> Unit,
|
||||||
|
connectDevice: (CastingDevice) -> Unit,
|
||||||
|
devices: MutableState<List<CastingDevice>>,
|
||||||
|
launchQrScanner: () -> Unit
|
||||||
|
) {
|
||||||
|
Dialog(onDismissRequest = { onDismissRequest() }) {
|
||||||
|
Card(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(8.dp),
|
||||||
|
shape = RoundedCornerShape(8.dp),
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
Text("Discovered Devices")
|
||||||
|
TextButton(onClick = onDismissRequest) {
|
||||||
|
Text("Close")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Column {
|
||||||
|
devices.value.forEach { device ->
|
||||||
|
TextButton(onClick = { connectDevice(device) }) {
|
||||||
|
Text(text = device.name())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Button(onClick = launchQrScanner) {
|
||||||
|
Text(text = "Scan QR code")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun DeviceDialog(
|
||||||
|
onDismissRequest: () -> Unit,
|
||||||
|
disconnectActiveDevice: () -> Unit,
|
||||||
|
device: CastingDevice,
|
||||||
|
state: CastingState
|
||||||
|
) {
|
||||||
|
Dialog(onDismissRequest = { onDismissRequest() }) {
|
||||||
|
Card(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(8.dp),
|
||||||
|
shape = RoundedCornerShape(8.dp),
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
Text("Connected to")
|
||||||
|
TextButton(onClick = onDismissRequest) {
|
||||||
|
Text("Close")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Column {
|
||||||
|
Text(text = device.name())
|
||||||
|
Text("Volume")
|
||||||
|
Slider(
|
||||||
|
value = state.volume.value.toFloat(),
|
||||||
|
onValueChange = {
|
||||||
|
state.volume.value = it.toDouble()
|
||||||
|
},
|
||||||
|
onValueChangeFinished = {
|
||||||
|
try {
|
||||||
|
device.changeVolume(state.volume.value)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("Failed to change volume: $e")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
Text("Playback speed: ${DecimalFormat("#.##").format(state.speed.value)}x")
|
||||||
|
Slider(
|
||||||
|
value = state.speed.value.toFloat(),
|
||||||
|
valueRange = 0.5f..2.0f,
|
||||||
|
onValueChange = {
|
||||||
|
state.speed.value = it.toDouble()
|
||||||
|
},
|
||||||
|
onValueChangeFinished = {
|
||||||
|
try {
|
||||||
|
device.changeSpeed(state.speed.value)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("Failed to change playback speed: $e")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
Button(onClick = { disconnectActiveDevice() }) {
|
||||||
|
Text("Disconnect")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun View(
|
||||||
|
modifier: Modifier,
|
||||||
|
state: CastingState,
|
||||||
|
activeDevice: MutableState<CastingDevice?>,
|
||||||
|
devices: MutableState<List<CastingDevice>>,
|
||||||
|
connectDevice: (CastingDevice) -> Unit,
|
||||||
|
disconnectActiveDevice: () -> Unit,
|
||||||
|
launchQrScanner: () -> Unit,
|
||||||
|
selectMedia: () -> Unit,
|
||||||
|
) {
|
||||||
|
val openCastDialog = remember { mutableStateOf(false) }
|
||||||
|
|
||||||
|
Column(
|
||||||
|
modifier = modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.fillMaxHeight(),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.Center
|
||||||
|
) {
|
||||||
|
Button(onClick = {
|
||||||
|
openCastDialog.value = true
|
||||||
|
}) {
|
||||||
|
Text("Devices")
|
||||||
|
}
|
||||||
|
when (val castingDevice = activeDevice.value) {
|
||||||
|
null -> {}
|
||||||
|
else -> {
|
||||||
|
Button(onClick = {
|
||||||
|
try {
|
||||||
|
castingDevice.load(LoadRequest.Video(
|
||||||
|
"video/mp4",
|
||||||
|
"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
|
||||||
|
))
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("Failed to load video: $e")
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
Text("Cast demo")
|
||||||
|
}
|
||||||
|
Button(onClick = selectMedia) {
|
||||||
|
Text("Cast local file")
|
||||||
|
}
|
||||||
|
if (state.playbackState.value == PlaybackState.PLAYING
|
||||||
|
|| state.playbackState.value == PlaybackState.PAUSED
|
||||||
|
) {
|
||||||
|
Button(onClick = {
|
||||||
|
castingDevice.stopPlayback()
|
||||||
|
}) {
|
||||||
|
Text("Stop casting")
|
||||||
|
}
|
||||||
|
if (state.contentType.value.startsWith("video/")) {
|
||||||
|
Text("Scrubber")
|
||||||
|
Slider(
|
||||||
|
value = state.time.value.toFloat(),
|
||||||
|
onValueChange = {
|
||||||
|
state.time.value = it.toDouble()
|
||||||
|
},
|
||||||
|
onValueChangeFinished = {
|
||||||
|
try {
|
||||||
|
castingDevice.seek(state.time.value)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("Failed to seek: $e")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
valueRange = 0.0f..state.duration.value.toFloat()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state.playbackState.value == PlaybackState.PLAYING && state.contentType.value.startsWith(
|
||||||
|
"video/"
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Button(onClick = {
|
||||||
|
try {
|
||||||
|
castingDevice.pausePlayback()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("Failed to pause playback: $e")
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
Text("Pause")
|
||||||
|
}
|
||||||
|
} else if (state.playbackState.value == PlaybackState.PAUSED && state.contentType.value.startsWith(
|
||||||
|
"video/"
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Button(onClick = {
|
||||||
|
try {
|
||||||
|
castingDevice.resumePlayback()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("Failed to resume playback: $e")
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
Text("Play")
|
||||||
|
}
|
||||||
|
} else if (state.playbackState.value == PlaybackState.BUFFERING) {
|
||||||
|
CircularProgressIndicator()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
when {
|
||||||
|
openCastDialog.value -> {
|
||||||
|
when (val castingDevice = activeDevice.value) {
|
||||||
|
null -> {
|
||||||
|
CastDialog(
|
||||||
|
onDismissRequest = { openCastDialog.value = false },
|
||||||
|
connectDevice,
|
||||||
|
devices,
|
||||||
|
launchQrScanner
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
DeviceDialog(
|
||||||
|
onDismissRequest = { openCastDialog.value = false },
|
||||||
|
disconnectActiveDevice,
|
||||||
|
castingDevice,
|
||||||
|
state
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package fcast.sender.ui.theme
|
||||||
|
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
|
||||||
|
val Purple80 = Color(0xFFD0BCFF)
|
||||||
|
val PurpleGrey80 = Color(0xFFCCC2DC)
|
||||||
|
val Pink80 = Color(0xFFEFB8C8)
|
||||||
|
|
||||||
|
val Purple40 = Color(0xFF6650a4)
|
||||||
|
val PurpleGrey40 = Color(0xFF625b71)
|
||||||
|
val Pink40 = Color(0xFF7D5260)
|
|
@ -0,0 +1,58 @@
|
||||||
|
package fcast.sender.ui.theme
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.os.Build
|
||||||
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.darkColorScheme
|
||||||
|
import androidx.compose.material3.dynamicDarkColorScheme
|
||||||
|
import androidx.compose.material3.dynamicLightColorScheme
|
||||||
|
import androidx.compose.material3.lightColorScheme
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
|
||||||
|
private val DarkColorScheme = darkColorScheme(
|
||||||
|
primary = Purple80,
|
||||||
|
secondary = PurpleGrey80,
|
||||||
|
tertiary = Pink80
|
||||||
|
)
|
||||||
|
|
||||||
|
private val LightColorScheme = lightColorScheme(
|
||||||
|
primary = Purple40,
|
||||||
|
secondary = PurpleGrey40,
|
||||||
|
tertiary = Pink40
|
||||||
|
|
||||||
|
/* Other default colors to override
|
||||||
|
background = Color(0xFFFFFBFE),
|
||||||
|
surface = Color(0xFFFFFBFE),
|
||||||
|
onPrimary = Color.White,
|
||||||
|
onSecondary = Color.White,
|
||||||
|
onTertiary = Color.White,
|
||||||
|
onBackground = Color(0xFF1C1B1F),
|
||||||
|
onSurface = Color(0xFF1C1B1F),
|
||||||
|
*/
|
||||||
|
)
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun FCastSenderTheme(
|
||||||
|
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||||
|
// Dynamic color is available on Android 12+
|
||||||
|
dynamicColor: Boolean = true,
|
||||||
|
content: @Composable () -> Unit
|
||||||
|
) {
|
||||||
|
val colorScheme = when {
|
||||||
|
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
|
||||||
|
val context = LocalContext.current
|
||||||
|
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
darkTheme -> DarkColorScheme
|
||||||
|
else -> LightColorScheme
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialTheme(
|
||||||
|
colorScheme = colorScheme,
|
||||||
|
typography = Typography,
|
||||||
|
content = content
|
||||||
|
)
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package fcast.sender.ui.theme
|
||||||
|
|
||||||
|
import androidx.compose.material3.Typography
|
||||||
|
import androidx.compose.ui.text.TextStyle
|
||||||
|
import androidx.compose.ui.text.font.FontFamily
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
|
||||||
|
// Set of Material typography styles to start with
|
||||||
|
val Typography = Typography(
|
||||||
|
bodyLarge = TextStyle(
|
||||||
|
fontFamily = FontFamily.Default,
|
||||||
|
fontWeight = FontWeight.Normal,
|
||||||
|
fontSize = 16.sp,
|
||||||
|
lineHeight = 24.sp,
|
||||||
|
letterSpacing = 0.5.sp
|
||||||
|
)
|
||||||
|
/* Other default text styles to override
|
||||||
|
titleLarge = TextStyle(
|
||||||
|
fontFamily = FontFamily.Default,
|
||||||
|
fontWeight = FontWeight.Normal,
|
||||||
|
fontSize = 22.sp,
|
||||||
|
lineHeight = 28.sp,
|
||||||
|
letterSpacing = 0.sp
|
||||||
|
),
|
||||||
|
labelSmall = TextStyle(
|
||||||
|
fontFamily = FontFamily.Default,
|
||||||
|
fontWeight = FontWeight.Medium,
|
||||||
|
fontSize = 11.sp,
|
||||||
|
lineHeight = 16.sp,
|
||||||
|
letterSpacing = 0.5.sp
|
||||||
|
)
|
||||||
|
*/
|
||||||
|
)
|
|
@ -0,0 +1,170 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path
|
||||||
|
android:fillColor="#3DDC84"
|
||||||
|
android:pathData="M0,0h108v108h-108z" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M9,0L9,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,0L19,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,0L29,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,0L39,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,0L49,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,0L59,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,0L69,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,0L79,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M89,0L89,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M99,0L99,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,9L108,9"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,19L108,19"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,29L108,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,39L108,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,49L108,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,59L108,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,69L108,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,79L108,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,89L108,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,99L108,99"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,29L89,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,39L89,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,49L89,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,59L89,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,69L89,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,79L89,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,19L29,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,19L39,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,19L49,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,19L59,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,19L69,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,19L79,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
</vector>
|
|
@ -0,0 +1,30 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:aapt="http://schemas.android.com/aapt"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||||
|
<aapt:attr name="android:fillColor">
|
||||||
|
<gradient
|
||||||
|
android:endX="85.84757"
|
||||||
|
android:endY="92.4963"
|
||||||
|
android:startX="42.9492"
|
||||||
|
android:startY="49.59793"
|
||||||
|
android:type="linear">
|
||||||
|
<item
|
||||||
|
android:color="#44000000"
|
||||||
|
android:offset="0.0" />
|
||||||
|
<item
|
||||||
|
android:color="#00000000"
|
||||||
|
android:offset="1.0" />
|
||||||
|
</gradient>
|
||||||
|
</aapt:attr>
|
||||||
|
</path>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:fillType="nonZero"
|
||||||
|
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:strokeColor="#00000000" />
|
||||||
|
</vector>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 982 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 7.6 KiB |
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="purple_200">#FFBB86FC</color>
|
||||||
|
<color name="purple_500">#FF6200EE</color>
|
||||||
|
<color name="purple_700">#FF3700B3</color>
|
||||||
|
<color name="teal_200">#FF03DAC5</color>
|
||||||
|
<color name="teal_700">#FF018786</color>
|
||||||
|
<color name="black">#FF000000</color>
|
||||||
|
<color name="white">#FFFFFFFF</color>
|
||||||
|
</resources>
|
|
@ -0,0 +1,3 @@
|
||||||
|
<resources>
|
||||||
|
<string name="app_name">FCast Sender SDK Demo</string>
|
||||||
|
</resources>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<style name="Theme.FCastSender" parent="android:Theme.Material.Light.NoActionBar" />
|
||||||
|
</resources>
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
Sample backup rules file; uncomment and customize as necessary.
|
||||||
|
See https://developer.android.com/guide/topics/data/autobackup
|
||||||
|
for details.
|
||||||
|
Note: This file is ignored for devices older than API 31
|
||||||
|
See https://developer.android.com/about/versions/12/backup-restore
|
||||||
|
-->
|
||||||
|
<full-backup-content>
|
||||||
|
<!--
|
||||||
|
<include domain="sharedpref" path="."/>
|
||||||
|
<exclude domain="sharedpref" path="device.xml"/>
|
||||||
|
-->
|
||||||
|
</full-backup-content>
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
Sample data extraction rules file; uncomment and customize as necessary.
|
||||||
|
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||||
|
for details.
|
||||||
|
-->
|
||||||
|
<data-extraction-rules>
|
||||||
|
<cloud-backup>
|
||||||
|
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||||
|
<include .../>
|
||||||
|
<exclude .../>
|
||||||
|
-->
|
||||||
|
</cloud-backup>
|
||||||
|
<!--
|
||||||
|
<device-transfer>
|
||||||
|
<include .../>
|
||||||
|
<exclude .../>
|
||||||
|
</device-transfer>
|
||||||
|
-->
|
||||||
|
</data-extraction-rules>
|
|
@ -0,0 +1,17 @@
|
||||||
|
package fcast.sender
|
||||||
|
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
import org.junit.Assert.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example local unit test, which will execute on the development machine (host).
|
||||||
|
*
|
||||||
|
* See [testing documentation](http://d.android.com/tools/testing).
|
||||||
|
*/
|
||||||
|
class ExampleUnitTest {
|
||||||
|
@Test
|
||||||
|
fun addition_isCorrect() {
|
||||||
|
assertEquals(4, 2 + 2)
|
||||||
|
}
|
||||||
|
}
|
5
sdk/sender/examples/android/build.gradle.kts
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
plugins {
|
||||||
|
alias(libs.plugins.android.application) apply false
|
||||||
|
alias(libs.plugins.kotlin.android) apply false
|
||||||
|
alias(libs.plugins.kotlin.compose) apply false
|
||||||
|
}
|
23
sdk/sender/examples/android/gradle.properties
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# Project-wide Gradle settings.
|
||||||
|
# IDE (e.g. Android Studio) users:
|
||||||
|
# Gradle settings configured through the IDE *will override*
|
||||||
|
# any settings specified in this file.
|
||||||
|
# For more details on how to configure your build environment visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
|
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||||
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
|
# This option should only be used with decoupled projects. For more details, visit
|
||||||
|
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
|
||||||
|
# org.gradle.parallel=true
|
||||||
|
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||||
|
# Android operating system, and which are packaged with your app's APK
|
||||||
|
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||||
|
android.useAndroidX=true
|
||||||
|
# Kotlin code style for this project: "official" or "obsolete":
|
||||||
|
kotlin.code.style=official
|
||||||
|
# Enables namespacing of each library's R class so that its R class includes only the
|
||||||
|
# resources declared in the library itself and none from the library's dependencies,
|
||||||
|
# thereby reducing the size of the R class for that library
|
||||||
|
android.nonTransitiveRClass=true
|
32
sdk/sender/examples/android/gradle/libs.versions.toml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
[versions]
|
||||||
|
agp = "8.10.1"
|
||||||
|
kotlin = "2.0.21"
|
||||||
|
coreKtx = "1.16.0"
|
||||||
|
junit = "4.13.2"
|
||||||
|
junitVersion = "1.2.1"
|
||||||
|
espressoCore = "3.6.1"
|
||||||
|
lifecycleRuntimeKtx = "2.9.1"
|
||||||
|
activityCompose = "1.10.1"
|
||||||
|
composeBom = "2024.09.00"
|
||||||
|
|
||||||
|
[libraries]
|
||||||
|
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||||
|
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||||
|
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
||||||
|
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
||||||
|
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
|
||||||
|
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
|
||||||
|
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
|
||||||
|
androidx-ui = { group = "androidx.compose.ui", name = "ui" }
|
||||||
|
androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
|
||||||
|
androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
|
||||||
|
androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
|
||||||
|
androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
|
||||||
|
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
|
||||||
|
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||||
|
|
||||||
|
[plugins]
|
||||||
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
|
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||||
|
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||||
|
|
BIN
sdk/sender/examples/android/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
sdk/sender/examples/android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#Thu Jun 05 11:16:30 GMT 2025
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
185
sdk/sender/examples/android/gradlew
vendored
Executable file
|
@ -0,0 +1,185 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright 2015 the original author or authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=`expr $i + 1`
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
0) set -- ;;
|
||||||
|
1) set -- "$args0" ;;
|
||||||
|
2) set -- "$args0" "$args1" ;;
|
||||||
|
3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=`save "$@"`
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
89
sdk/sender/examples/android/gradlew.bat
vendored
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
25
sdk/sender/examples/android/settings.gradle.kts
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
google {
|
||||||
|
content {
|
||||||
|
includeGroupByRegex("com\\.android.*")
|
||||||
|
includeGroupByRegex("com\\.google.*")
|
||||||
|
includeGroupByRegex("androidx.*")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mavenCentral()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
mavenLocal()
|
||||||
|
maven("https://jitpack.io")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.name = "FCast Sender SDK Demo"
|
||||||
|
include(":app")
|
18
sdk/sender/examples/desktop/Cargo.toml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
[package]
|
||||||
|
name = "desktop"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
license.workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
fcast-sender-sdk = { path = "../../fcast-sender-sdk", default-features = false, features = ["fcast", "chromecast", "http-file-server", "logging", "discovery"] }
|
||||||
|
tokio.workspace = true
|
||||||
|
env_logger.workspace = true
|
||||||
|
log.workspace = true
|
||||||
|
anyhow.workspace = true
|
||||||
|
slint = "1.12.1"
|
||||||
|
rfd = "0.15.4" # File dialog
|
||||||
|
infer = "0.19.0" # MIME type inference
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
slint-build = "1.12.1"
|
3
sdk/sender/examples/desktop/build.rs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
fn main() {
|
||||||
|
slint_build::compile("ui/main.slint").unwrap();
|
||||||
|
}
|
504
sdk/sender/examples/desktop/src/main.rs
Normal file
|
@ -0,0 +1,504 @@
|
||||||
|
use std::{rc::Rc, sync::Arc};
|
||||||
|
|
||||||
|
use fcast_sender_sdk::{
|
||||||
|
context::CastContext,
|
||||||
|
device::{
|
||||||
|
CastingDevice, DeviceConnectionState, DeviceEventHandler, DeviceInfo, GenericKeyEvent, GenericMediaEvent, LoadRequest, PlaybackState, ProtocolType, Source
|
||||||
|
},
|
||||||
|
file_server::FileServer,
|
||||||
|
url_format_ip_addr, DeviceDiscovererEventHandler, IpAddr,
|
||||||
|
};
|
||||||
|
use log::{debug, error};
|
||||||
|
use rfd::{AsyncFileDialog, FileHandle};
|
||||||
|
use slint::{Model, SharedString, VecModel};
|
||||||
|
use tokio::{
|
||||||
|
runtime::Runtime,
|
||||||
|
sync::mpsc::{channel, Receiver, Sender},
|
||||||
|
};
|
||||||
|
|
||||||
|
slint::include_modules!();
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
enum DeviceEvent {
|
||||||
|
ConnectionStateChanged(DeviceConnectionState),
|
||||||
|
VolumeChanged(f64),
|
||||||
|
TimeChanged(f64),
|
||||||
|
PlaybackStateChanged(PlaybackState),
|
||||||
|
DurationChanged(f64),
|
||||||
|
SpeedChanged(f64),
|
||||||
|
SourceChanged(Source),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
enum Event {
|
||||||
|
Quit,
|
||||||
|
DeviceAvailable(DeviceInfo),
|
||||||
|
DeviceRemoved(String),
|
||||||
|
DeviceChanged(DeviceInfo),
|
||||||
|
Connect(String),
|
||||||
|
Disconnect,
|
||||||
|
FromDevice {
|
||||||
|
id: usize,
|
||||||
|
event: DeviceEvent,
|
||||||
|
},
|
||||||
|
/// User requested that a local file should be casted
|
||||||
|
CastLocalRequested,
|
||||||
|
CastLocal {
|
||||||
|
media_type: infer::Type,
|
||||||
|
handle: FileHandle,
|
||||||
|
},
|
||||||
|
ChangeVolume(f64),
|
||||||
|
Seek(f64),
|
||||||
|
}
|
||||||
|
|
||||||
|
struct DiscoveryEventHandler {
|
||||||
|
event_tx: Sender<Event>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DiscoveryEventHandler {
|
||||||
|
pub fn new(event_tx: Sender<Event>) -> Self {
|
||||||
|
Self { event_tx }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DeviceDiscovererEventHandler for DiscoveryEventHandler {
|
||||||
|
fn device_available(&self, device_info: DeviceInfo) {
|
||||||
|
let event_tx = self.event_tx.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
event_tx
|
||||||
|
.send(Event::DeviceAvailable(device_info))
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn device_removed(&self, device_name: String) {
|
||||||
|
let event_tx = self.event_tx.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
event_tx
|
||||||
|
.send(Event::DeviceRemoved(device_name))
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn device_changed(&self, device_info: DeviceInfo) {
|
||||||
|
let event_tx = self.event_tx.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
event_tx
|
||||||
|
.send(Event::DeviceChanged(device_info))
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct DevEventHandler {
|
||||||
|
event_tx: Sender<Event>,
|
||||||
|
id: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DevEventHandler {
|
||||||
|
pub fn new(event_tx: Sender<Event>, id: usize) -> Self {
|
||||||
|
Self { event_tx, id }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn send_event(&self, event: DeviceEvent) {
|
||||||
|
let id = self.id;
|
||||||
|
let event_tx = self.event_tx.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
if let Err(err) = event_tx.send(Event::FromDevice { id, event }).await {
|
||||||
|
error!("Failed to send event: {err}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DeviceEventHandler for DevEventHandler {
|
||||||
|
fn connection_state_changed(&self, state: DeviceConnectionState) {
|
||||||
|
self.send_event(DeviceEvent::ConnectionStateChanged(state));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn volume_changed(&self, volume: f64) {
|
||||||
|
self.send_event(DeviceEvent::VolumeChanged(volume));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn time_changed(&self, time: f64) {
|
||||||
|
self.send_event(DeviceEvent::TimeChanged(time));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn playback_state_changed(&self, state: PlaybackState) {
|
||||||
|
self.send_event(DeviceEvent::PlaybackStateChanged(state));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn duration_changed(&self, duration: f64) {
|
||||||
|
self.send_event(DeviceEvent::DurationChanged(duration));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn speed_changed(&self, speed: f64) {
|
||||||
|
self.send_event(DeviceEvent::SpeedChanged(speed));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn source_changed(&self, source: Source) {
|
||||||
|
self.send_event(DeviceEvent::SourceChanged(source));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn key_event(&self, _event: GenericKeyEvent) {}
|
||||||
|
|
||||||
|
fn media_event(&self, _event: GenericMediaEvent) {}
|
||||||
|
|
||||||
|
fn playback_error(&self, message: String) {
|
||||||
|
error!("Playback error: {message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct App {
|
||||||
|
ui_weak: slint::Weak<MainWindow>,
|
||||||
|
cast_context: CastContext,
|
||||||
|
event_tx: Sender<Event>,
|
||||||
|
file_server: FileServer,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl App {
|
||||||
|
pub async fn new(
|
||||||
|
ui_weak: slint::Weak<MainWindow>,
|
||||||
|
event_tx: Sender<Event>,
|
||||||
|
) -> anyhow::Result<Self> {
|
||||||
|
let cast_context = CastContext::new()?;
|
||||||
|
|
||||||
|
let discovery_event_handler = DiscoveryEventHandler::new(event_tx.clone());
|
||||||
|
cast_context.start_discovery(Arc::new(discovery_event_handler));
|
||||||
|
|
||||||
|
let file_server = cast_context.start_file_server();
|
||||||
|
|
||||||
|
Ok(Self {
|
||||||
|
ui_weak,
|
||||||
|
cast_context,
|
||||||
|
event_tx,
|
||||||
|
file_server,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn init_models(&self) -> anyhow::Result<()> {
|
||||||
|
self.ui_weak.upgrade_in_event_loop(|ui| {
|
||||||
|
ui.global::<Bridge>()
|
||||||
|
.set_devices(Rc::new(VecModel::<Device>::default()).into());
|
||||||
|
})?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn add_device_to_list(&self, device_info: &DeviceInfo) -> anyhow::Result<()> {
|
||||||
|
let type_ = match device_info.protocol {
|
||||||
|
ProtocolType::Chromecast => DeviceType::Chromecast,
|
||||||
|
ProtocolType::FCast => DeviceType::FCast,
|
||||||
|
};
|
||||||
|
let name = SharedString::from(device_info.name.clone());
|
||||||
|
self.ui_weak.upgrade_in_event_loop(move |ui| {
|
||||||
|
let model = ui.global::<Bridge>().get_devices();
|
||||||
|
let model = model
|
||||||
|
.as_any()
|
||||||
|
.downcast_ref::<slint::VecModel<Device>>()
|
||||||
|
.unwrap();
|
||||||
|
model.push(Device {
|
||||||
|
name,
|
||||||
|
r#type: type_,
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn remove_device_from_list(&self, idx: usize) -> anyhow::Result<()> {
|
||||||
|
self.ui_weak.upgrade_in_event_loop(move |ui| {
|
||||||
|
let model = ui.global::<Bridge>().get_devices();
|
||||||
|
let model = model
|
||||||
|
.as_any()
|
||||||
|
.downcast_ref::<slint::VecModel<Device>>()
|
||||||
|
.unwrap();
|
||||||
|
model.remove(idx);
|
||||||
|
})?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn run(self, mut event_rx: Receiver<Event>) -> anyhow::Result<()> {
|
||||||
|
self.init_models()?;
|
||||||
|
|
||||||
|
let mut devices: Vec<DeviceInfo> = Vec::new();
|
||||||
|
let mut active_device: Option<Arc<dyn CastingDevice>> = None;
|
||||||
|
let mut current_device_id: usize = 0;
|
||||||
|
let mut local_adddress = IpAddr::v4(127, 0, 0, 1);
|
||||||
|
|
||||||
|
loop {
|
||||||
|
let Some(event) = event_rx.recv().await else {
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
|
||||||
|
debug!("Got event: {event:?}");
|
||||||
|
|
||||||
|
match event {
|
||||||
|
Event::Quit => break,
|
||||||
|
Event::DeviceAvailable(device_info) => {
|
||||||
|
self.add_device_to_list(&device_info)?;
|
||||||
|
devices.push(device_info);
|
||||||
|
}
|
||||||
|
Event::DeviceRemoved(name) => {
|
||||||
|
let mut idx = None;
|
||||||
|
for (i, device) in devices.iter().enumerate() {
|
||||||
|
if device.name == name {
|
||||||
|
idx = Some(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(idx) = idx {
|
||||||
|
devices.swap_remove(idx);
|
||||||
|
self.remove_device_from_list(idx)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Event::DeviceChanged(device_info) => {
|
||||||
|
if let Some(device) = devices
|
||||||
|
.iter_mut()
|
||||||
|
.find(|device| device.name == device_info.name)
|
||||||
|
{
|
||||||
|
device.addresses = device_info.addresses;
|
||||||
|
device.port = device_info.port;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Event::Connect(device_name) => {
|
||||||
|
if let Some(device_info) = devices
|
||||||
|
.iter()
|
||||||
|
.find(|device| device.name == device_name)
|
||||||
|
.cloned()
|
||||||
|
{
|
||||||
|
let device = self.cast_context.create_device_from_info(device_info);
|
||||||
|
device.connect(
|
||||||
|
None,
|
||||||
|
Arc::new(DevEventHandler::new(
|
||||||
|
self.event_tx.clone(),
|
||||||
|
current_device_id,
|
||||||
|
)),
|
||||||
|
)?;
|
||||||
|
active_device = Some(device);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Event::Disconnect => {
|
||||||
|
if let Some(active_device) = active_device.take() {
|
||||||
|
active_device.disconnect()?;
|
||||||
|
current_device_id += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Event::FromDevice { id, event } => {
|
||||||
|
if id != current_device_id {
|
||||||
|
debug!(
|
||||||
|
"Received event from old device ({id}, current is {current_device_id})"
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
match event {
|
||||||
|
DeviceEvent::ConnectionStateChanged(state) => match state {
|
||||||
|
DeviceConnectionState::Disconnected => (),
|
||||||
|
DeviceConnectionState::Connecting => (),
|
||||||
|
DeviceConnectionState::Connected { local_addr, .. } => {
|
||||||
|
local_adddress = local_addr;
|
||||||
|
self.ui_weak.upgrade_in_event_loop(|ui| {
|
||||||
|
ui.global::<Bridge>().invoke_connected();
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
DeviceEvent::VolumeChanged(volume) => {
|
||||||
|
self.ui_weak.upgrade_in_event_loop(move |ui| {
|
||||||
|
ui.global::<Bridge>().set_volume(volume as f32);
|
||||||
|
})?
|
||||||
|
}
|
||||||
|
DeviceEvent::TimeChanged(time) => {
|
||||||
|
self.ui_weak.upgrade_in_event_loop(move |ui| {
|
||||||
|
ui.global::<Bridge>().set_playback_position(time as f32);
|
||||||
|
})?
|
||||||
|
}
|
||||||
|
DeviceEvent::PlaybackStateChanged(state) => match state {
|
||||||
|
PlaybackState::Idle => (),
|
||||||
|
PlaybackState::Buffering => (),
|
||||||
|
PlaybackState::Playing => (),
|
||||||
|
PlaybackState::Paused => (),
|
||||||
|
},
|
||||||
|
DeviceEvent::DurationChanged(duration) => {
|
||||||
|
self.ui_weak.upgrade_in_event_loop(move |ui| {
|
||||||
|
ui.global::<Bridge>().set_playback_duration(duration as f32);
|
||||||
|
})?
|
||||||
|
}
|
||||||
|
DeviceEvent::SpeedChanged(_) => (),
|
||||||
|
DeviceEvent::SourceChanged(source) => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Event::CastLocalRequested => {
|
||||||
|
let event_tx = self.event_tx.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let maybe_path = AsyncFileDialog::new()
|
||||||
|
.add_filter(
|
||||||
|
"Media",
|
||||||
|
&[
|
||||||
|
"png", "jpg", "jpeg", "avif", "mkv", "mp4", "webm", "flac",
|
||||||
|
"opus", "mp3", "mka", "m4a", "wav", "ogg", "vorbis", "apng",
|
||||||
|
"gif", "webp",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.add_filter("All", &["*"])
|
||||||
|
.pick_file()
|
||||||
|
.await;
|
||||||
|
debug!("User opened: {maybe_path:?}");
|
||||||
|
if let Some(handle) = maybe_path {
|
||||||
|
match infer::get_from_path(handle.path()) {
|
||||||
|
Ok(res) => match res {
|
||||||
|
Some(type_) => {
|
||||||
|
event_tx
|
||||||
|
.send(Event::CastLocal {
|
||||||
|
media_type: type_,
|
||||||
|
handle,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
None => error!("Unable to get file type"),
|
||||||
|
},
|
||||||
|
Err(err) => {
|
||||||
|
error!("Failed to infer type of file: {err}");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Event::CastLocal { media_type, handle } => {
|
||||||
|
let matcher_type = media_type.matcher_type();
|
||||||
|
if !matches!(
|
||||||
|
matcher_type,
|
||||||
|
infer::MatcherType::Audio
|
||||||
|
| infer::MatcherType::Image
|
||||||
|
| infer::MatcherType::Video
|
||||||
|
) {
|
||||||
|
error!("Unsupported media type {matcher_type:?}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let file = match std::fs::File::open(handle.path()) {
|
||||||
|
Ok(file) => file,
|
||||||
|
Err(err) => {
|
||||||
|
error!("Failed to open file {handle:?}: {err}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
match self.file_server.serve_rs_file(file) {
|
||||||
|
Ok(entry) => match active_device.as_ref() {
|
||||||
|
Some(active_device) => {
|
||||||
|
let url = format!(
|
||||||
|
"http://{}:{}/{}",
|
||||||
|
url_format_ip_addr(&local_adddress),
|
||||||
|
entry.port,
|
||||||
|
entry.location,
|
||||||
|
);
|
||||||
|
active_device
|
||||||
|
.load(LoadRequest::Url {
|
||||||
|
content_type: media_type.mime_type().to_string(),
|
||||||
|
url,
|
||||||
|
resume_position: None,
|
||||||
|
speed: None,
|
||||||
|
volume: None,
|
||||||
|
metadata: None,
|
||||||
|
request_headers: None,
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
None => error!("Not connected"),
|
||||||
|
},
|
||||||
|
Err(err) => error!("Failed to serve file: {err}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Event::ChangeVolume(new_volume) => {
|
||||||
|
if let Some(active_device) = active_device.as_ref() {
|
||||||
|
active_device.change_volume(new_volume)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Event::Seek(new_position) => {
|
||||||
|
if let Some(active_device) = active_device.as_ref() {
|
||||||
|
active_device.seek(new_position)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
debug!("Finished");
|
||||||
|
|
||||||
|
if let Some(active_device) = active_device.take() {
|
||||||
|
active_device.disconnect()?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
env_logger::Builder::new()
|
||||||
|
.filter(None, log::LevelFilter::Debug)
|
||||||
|
.init();
|
||||||
|
|
||||||
|
let runtime = Runtime::new().unwrap();
|
||||||
|
|
||||||
|
let (event_tx, event_rx) = channel::<Event>(100);
|
||||||
|
|
||||||
|
let ui = MainWindow::new().unwrap();
|
||||||
|
|
||||||
|
let ui_weak = ui.as_weak();
|
||||||
|
let event_tx_clone = event_tx.clone();
|
||||||
|
let app_jh = runtime.spawn(async move {
|
||||||
|
let app = App::new(ui_weak, event_tx_clone).await?;
|
||||||
|
app.run(event_rx).await
|
||||||
|
});
|
||||||
|
|
||||||
|
{
|
||||||
|
let event_tx = event_tx.clone();
|
||||||
|
ui.global::<Bridge>().on_connect(move |device_name| {
|
||||||
|
event_tx
|
||||||
|
.blocking_send(Event::Connect(device_name.to_string()))
|
||||||
|
.unwrap();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let event_tx = event_tx.clone();
|
||||||
|
ui.global::<Bridge>().on_disconnect(move || {
|
||||||
|
event_tx.blocking_send(Event::Disconnect).unwrap();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let event_tx = event_tx.clone();
|
||||||
|
ui.global::<Bridge>().on_cast_local(move || {
|
||||||
|
event_tx.blocking_send(Event::CastLocalRequested).unwrap();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let event_tx = event_tx.clone();
|
||||||
|
ui.global::<Bridge>().on_change_volume(move |new_volume| {
|
||||||
|
event_tx
|
||||||
|
.blocking_send(Event::ChangeVolume(new_volume as f64))
|
||||||
|
.unwrap();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let event_tx = event_tx.clone();
|
||||||
|
ui.global::<Bridge>().on_seek(move |new_position| {
|
||||||
|
event_tx
|
||||||
|
.blocking_send(Event::Seek(new_position as f64))
|
||||||
|
.unwrap();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.run().unwrap();
|
||||||
|
|
||||||
|
runtime.block_on(async move {
|
||||||
|
event_tx.send(Event::Quit).await.unwrap();
|
||||||
|
if let Err(err) = app_jh.await {
|
||||||
|
error!("Error occured when running: {err}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
140
sdk/sender/examples/desktop/ui/main.slint
Normal file
|
@ -0,0 +1,140 @@
|
||||||
|
import { Button, ListView, HorizontalBox, VerticalBox, Spinner, Slider } from "std-widgets.slint";
|
||||||
|
|
||||||
|
export enum DeviceType {
|
||||||
|
FCast,
|
||||||
|
Chromecast,
|
||||||
|
}
|
||||||
|
|
||||||
|
export struct Device {
|
||||||
|
name: string,
|
||||||
|
type: DeviceType,
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum State {
|
||||||
|
Idle,
|
||||||
|
Connecting,
|
||||||
|
Connected,
|
||||||
|
}
|
||||||
|
|
||||||
|
export global Bridge {
|
||||||
|
in property<[Device]> devices: [];
|
||||||
|
in-out property<State> state: State.Idle;
|
||||||
|
in-out property<Device> connected-device: { name: "n/a", type: DeviceType.FCast };
|
||||||
|
in property<float> volume: 0.0;
|
||||||
|
in property<float> playback-position: 0.0;
|
||||||
|
in property<float> playback-duration: 0.0;
|
||||||
|
|
||||||
|
callback connect(device-name: string);
|
||||||
|
callback disconnect();
|
||||||
|
callback cast-local();
|
||||||
|
callback change-volume(new-volume: float);
|
||||||
|
callback seek(new-position: float);
|
||||||
|
|
||||||
|
public function connected() {
|
||||||
|
state = State.Connected;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export component MainWindow inherits Window {
|
||||||
|
title: "FCast sender SDK demo";
|
||||||
|
|
||||||
|
if Bridge.state == State.Idle: VerticalBox {
|
||||||
|
alignment: center;
|
||||||
|
width: root.width.min(400px);
|
||||||
|
height: root.height.min(500px);
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: "Connect to your receiver";
|
||||||
|
horizontal-alignment: center;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
if Bridge.devices.length > 0: ListView {
|
||||||
|
height: 300px;
|
||||||
|
|
||||||
|
for device in Bridge.devices : Rectangle {
|
||||||
|
background: ta.has-hover ? whitesmoke : #00000000;
|
||||||
|
ta := TouchArea {
|
||||||
|
clicked => {
|
||||||
|
Bridge.state = State.Connecting;
|
||||||
|
Bridge.connect(device.name);
|
||||||
|
Bridge.connected-device = device;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HorizontalBox {
|
||||||
|
Text {
|
||||||
|
text: device.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if Bridge.devices.length == 0: Text {
|
||||||
|
text: "No devices found";
|
||||||
|
horizontal-alignment: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: "Devices become visible when they are discovered on the local network";
|
||||||
|
horizontal-alignment: center;
|
||||||
|
font-italic: true;
|
||||||
|
wrap: word-wrap;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if Bridge.state == State.Connecting: VerticalBox {
|
||||||
|
alignment: center;
|
||||||
|
Spinner {
|
||||||
|
indeterminate: true;
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
horizontal-alignment: center;
|
||||||
|
text: "Connecting to " + Bridge.connected-device.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if Bridge.state == State.Connected: VerticalBox {
|
||||||
|
alignment: center;
|
||||||
|
Text {
|
||||||
|
horizontal-alignment: center;
|
||||||
|
text: "Connected to " + Bridge.connected-device.name;
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
text: "Cast local media";
|
||||||
|
clicked => {
|
||||||
|
Bridge.cast-local();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HorizontalBox {
|
||||||
|
Text {
|
||||||
|
text: "Volume";
|
||||||
|
}
|
||||||
|
Slider {
|
||||||
|
value <=> Bridge.volume;
|
||||||
|
step: 0.01;
|
||||||
|
maximum: 1.0;
|
||||||
|
changed(new-volume) => {
|
||||||
|
Bridge.change-volume(new-volume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HorizontalBox {
|
||||||
|
Text {
|
||||||
|
text: "Position";
|
||||||
|
}
|
||||||
|
Slider {
|
||||||
|
value <=> Bridge.playback-position;
|
||||||
|
step: 0.10;
|
||||||
|
maximum <=> Bridge.playback-duration;
|
||||||
|
changed(new-position) => {
|
||||||
|
Bridge.seek(new-position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
text: "Disconnect";
|
||||||
|
clicked => {
|
||||||
|
Bridge.disconnect();
|
||||||
|
Bridge.state = State.Idle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
8
sdk/sender/examples/ios/.gitignore
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
/FCast.xcframework/ios-arm64-simulator/
|
||||||
|
/FCast.xcframework
|
||||||
|
/FCast\ Sender.xcodeproj/xcuserdata/
|
||||||
|
/FCast\ Sender.xcodeproj/project.xcworkspace/xcuserdata
|
||||||
|
/.DS_Store
|
||||||
|
/fcast_sender_sdkFFI.h
|
||||||
|
/fcast_sender_sdk.swift
|
||||||
|
/fcast_sender_sdk.xcframework
|
613
sdk/sender/examples/ios/FCast Sender.xcodeproj/project.pbxproj
Normal file
|
@ -0,0 +1,613 @@
|
||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
archiveVersion = 1;
|
||||||
|
classes = {
|
||||||
|
};
|
||||||
|
objectVersion = 77;
|
||||||
|
objects = {
|
||||||
|
|
||||||
|
/* Begin PBXBuildFile section */
|
||||||
|
2C0D5A332E43787700DE5418 /* CodeScanner in Frameworks */ = {isa = PBXBuildFile; productRef = 2C0D5A322E43787700DE5418 /* CodeScanner */; };
|
||||||
|
2CE96CDC2E46221100386DB8 /* fcast_sender_sdk.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CE96CDA2E46221100386DB8 /* fcast_sender_sdk.xcframework */; };
|
||||||
|
2CE96CDD2E46221100386DB8 /* fcast_sender_sdk.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CE96CD92E46221100386DB8 /* fcast_sender_sdk.swift */; };
|
||||||
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
/* Begin PBXContainerItemProxy section */
|
||||||
|
FE492A182DF43428005DA314 /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = FE492A022DF43426005DA314 /* Project object */;
|
||||||
|
proxyType = 1;
|
||||||
|
remoteGlobalIDString = FE492A092DF43426005DA314;
|
||||||
|
remoteInfo = "FCast Sender";
|
||||||
|
};
|
||||||
|
FE492A222DF43428005DA314 /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = FE492A022DF43426005DA314 /* Project object */;
|
||||||
|
proxyType = 1;
|
||||||
|
remoteGlobalIDString = FE492A092DF43426005DA314;
|
||||||
|
remoteInfo = "FCast Sender";
|
||||||
|
};
|
||||||
|
/* End PBXContainerItemProxy section */
|
||||||
|
|
||||||
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
|
FE5977C32DF448FF00115F46 /* Embed Frameworks */ = {
|
||||||
|
isa = PBXCopyFilesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
dstPath = "";
|
||||||
|
dstSubfolderSpec = 10;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
name = "Embed Frameworks";
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXFileReference section */
|
||||||
|
2C10DED52E37B5E7000C85F7 /* FCastSender-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "FCastSender-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||||
|
2CE96CD92E46221100386DB8 /* fcast_sender_sdk.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = fcast_sender_sdk.swift; sourceTree = "<group>"; };
|
||||||
|
2CE96CDA2E46221100386DB8 /* fcast_sender_sdk.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = fcast_sender_sdk.xcframework; sourceTree = "<group>"; };
|
||||||
|
2CE96CDB2E46221100386DB8 /* fcast_sender_sdkFFI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = fcast_sender_sdkFFI.h; sourceTree = "<group>"; };
|
||||||
|
FE5977C02DF448FF00115F46 /* FCast Sender.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "FCast Sender.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
FE5977D22DF5B8F600115F46 /* FCast SenderTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "FCast SenderTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
FE5977D32DF5B8F600115F46 /* FCast SenderUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "FCast SenderUITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFileSystemSynchronizedRootGroup section */
|
||||||
|
FE492A0C2DF43426005DA314 /* FCast Sender */ = {
|
||||||
|
isa = PBXFileSystemSynchronizedRootGroup;
|
||||||
|
path = "FCast Sender";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
FE492A1A2DF43428005DA314 /* FCast SenderTests */ = {
|
||||||
|
isa = PBXFileSystemSynchronizedRootGroup;
|
||||||
|
path = "FCast SenderTests";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
FE492A242DF43428005DA314 /* FCast SenderUITests */ = {
|
||||||
|
isa = PBXFileSystemSynchronizedRootGroup;
|
||||||
|
path = "FCast SenderUITests";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXFileSystemSynchronizedRootGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
FE492A072DF43426005DA314 /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
2C0D5A332E43787700DE5418 /* CodeScanner in Frameworks */,
|
||||||
|
2CE96CDC2E46221100386DB8 /* fcast_sender_sdk.xcframework in Frameworks */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
FE492A142DF43428005DA314 /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
FE492A1E2DF43428005DA314 /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXGroup section */
|
||||||
|
FE492A012DF43426005DA314 = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
2C10DED52E37B5E7000C85F7 /* FCastSender-Bridging-Header.h */,
|
||||||
|
FE492A0C2DF43426005DA314 /* FCast Sender */,
|
||||||
|
FE492A1A2DF43428005DA314 /* FCast SenderTests */,
|
||||||
|
FE492A242DF43428005DA314 /* FCast SenderUITests */,
|
||||||
|
FE5977C02DF448FF00115F46 /* FCast Sender.app */,
|
||||||
|
FE5977D22DF5B8F600115F46 /* FCast SenderTests.xctest */,
|
||||||
|
FE5977D32DF5B8F600115F46 /* FCast SenderUITests.xctest */,
|
||||||
|
2CE96CD92E46221100386DB8 /* fcast_sender_sdk.swift */,
|
||||||
|
2CE96CDA2E46221100386DB8 /* fcast_sender_sdk.xcframework */,
|
||||||
|
2CE96CDB2E46221100386DB8 /* fcast_sender_sdkFFI.h */,
|
||||||
|
);
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXNativeTarget section */
|
||||||
|
FE492A092DF43426005DA314 /* FCast Sender */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = FE492A2B2DF43428005DA314 /* Build configuration list for PBXNativeTarget "FCast Sender" */;
|
||||||
|
buildPhases = (
|
||||||
|
FE492A062DF43426005DA314 /* Sources */,
|
||||||
|
FE492A072DF43426005DA314 /* Frameworks */,
|
||||||
|
FE492A082DF43426005DA314 /* Resources */,
|
||||||
|
FE5977C32DF448FF00115F46 /* Embed Frameworks */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
);
|
||||||
|
fileSystemSynchronizedGroups = (
|
||||||
|
FE492A0C2DF43426005DA314 /* FCast Sender */,
|
||||||
|
);
|
||||||
|
name = "FCast Sender";
|
||||||
|
packageProductDependencies = (
|
||||||
|
2C0D5A322E43787700DE5418 /* CodeScanner */,
|
||||||
|
);
|
||||||
|
productName = "FCast Sender";
|
||||||
|
productReference = FE5977C02DF448FF00115F46 /* FCast Sender.app */;
|
||||||
|
productType = "com.apple.product-type.application";
|
||||||
|
};
|
||||||
|
FE492A162DF43428005DA314 /* FCast SenderTests */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = FE492A2E2DF43428005DA314 /* Build configuration list for PBXNativeTarget "FCast SenderTests" */;
|
||||||
|
buildPhases = (
|
||||||
|
FE492A132DF43428005DA314 /* Sources */,
|
||||||
|
FE492A142DF43428005DA314 /* Frameworks */,
|
||||||
|
FE492A152DF43428005DA314 /* Resources */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
FE492A192DF43428005DA314 /* PBXTargetDependency */,
|
||||||
|
);
|
||||||
|
fileSystemSynchronizedGroups = (
|
||||||
|
FE492A1A2DF43428005DA314 /* FCast SenderTests */,
|
||||||
|
);
|
||||||
|
name = "FCast SenderTests";
|
||||||
|
packageProductDependencies = (
|
||||||
|
);
|
||||||
|
productName = "FCast SenderTests";
|
||||||
|
productReference = FE5977D22DF5B8F600115F46 /* FCast SenderTests.xctest */;
|
||||||
|
productType = "com.apple.product-type.bundle.unit-test";
|
||||||
|
};
|
||||||
|
FE492A202DF43428005DA314 /* FCast SenderUITests */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = FE492A312DF43428005DA314 /* Build configuration list for PBXNativeTarget "FCast SenderUITests" */;
|
||||||
|
buildPhases = (
|
||||||
|
FE492A1D2DF43428005DA314 /* Sources */,
|
||||||
|
FE492A1E2DF43428005DA314 /* Frameworks */,
|
||||||
|
FE492A1F2DF43428005DA314 /* Resources */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
FE492A232DF43428005DA314 /* PBXTargetDependency */,
|
||||||
|
);
|
||||||
|
fileSystemSynchronizedGroups = (
|
||||||
|
FE492A242DF43428005DA314 /* FCast SenderUITests */,
|
||||||
|
);
|
||||||
|
name = "FCast SenderUITests";
|
||||||
|
packageProductDependencies = (
|
||||||
|
);
|
||||||
|
productName = "FCast SenderUITests";
|
||||||
|
productReference = FE5977D32DF5B8F600115F46 /* FCast SenderUITests.xctest */;
|
||||||
|
productType = "com.apple.product-type.bundle.ui-testing";
|
||||||
|
};
|
||||||
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
|
/* Begin PBXProject section */
|
||||||
|
FE492A022DF43426005DA314 /* Project object */ = {
|
||||||
|
isa = PBXProject;
|
||||||
|
attributes = {
|
||||||
|
BuildIndependentTargetsInParallel = 1;
|
||||||
|
LastSwiftUpdateCheck = 1640;
|
||||||
|
LastUpgradeCheck = 1640;
|
||||||
|
TargetAttributes = {
|
||||||
|
FE492A092DF43426005DA314 = {
|
||||||
|
CreatedOnToolsVersion = 16.4;
|
||||||
|
};
|
||||||
|
FE492A162DF43428005DA314 = {
|
||||||
|
CreatedOnToolsVersion = 16.4;
|
||||||
|
TestTargetID = FE492A092DF43426005DA314;
|
||||||
|
};
|
||||||
|
FE492A202DF43428005DA314 = {
|
||||||
|
CreatedOnToolsVersion = 16.4;
|
||||||
|
TestTargetID = FE492A092DF43426005DA314;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
buildConfigurationList = FE492A052DF43426005DA314 /* Build configuration list for PBXProject "FCast Sender" */;
|
||||||
|
developmentRegion = en;
|
||||||
|
hasScannedForEncodings = 0;
|
||||||
|
knownRegions = (
|
||||||
|
en,
|
||||||
|
Base,
|
||||||
|
);
|
||||||
|
mainGroup = FE492A012DF43426005DA314;
|
||||||
|
minimizedProjectReferenceProxies = 1;
|
||||||
|
packageReferences = (
|
||||||
|
2C0D5A312E43787700DE5418 /* XCRemoteSwiftPackageReference "CodeScanner" */,
|
||||||
|
);
|
||||||
|
preferredProjectObjectVersion = 77;
|
||||||
|
productRefGroup = FE492A012DF43426005DA314;
|
||||||
|
projectDirPath = "";
|
||||||
|
projectRoot = "";
|
||||||
|
targets = (
|
||||||
|
FE492A092DF43426005DA314 /* FCast Sender */,
|
||||||
|
FE492A162DF43428005DA314 /* FCast SenderTests */,
|
||||||
|
FE492A202DF43428005DA314 /* FCast SenderUITests */,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* End PBXProject section */
|
||||||
|
|
||||||
|
/* Begin PBXResourcesBuildPhase section */
|
||||||
|
FE492A082DF43426005DA314 /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
FE492A152DF43428005DA314 /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
FE492A1F2DF43428005DA314 /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
|
FE492A062DF43426005DA314 /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
2CE96CDD2E46221100386DB8 /* fcast_sender_sdk.swift in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
FE492A132DF43428005DA314 /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
FE492A1D2DF43428005DA314 /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXTargetDependency section */
|
||||||
|
FE492A192DF43428005DA314 /* PBXTargetDependency */ = {
|
||||||
|
isa = PBXTargetDependency;
|
||||||
|
target = FE492A092DF43426005DA314 /* FCast Sender */;
|
||||||
|
targetProxy = FE492A182DF43428005DA314 /* PBXContainerItemProxy */;
|
||||||
|
};
|
||||||
|
FE492A232DF43428005DA314 /* PBXTargetDependency */ = {
|
||||||
|
isa = PBXTargetDependency;
|
||||||
|
target = FE492A092DF43426005DA314 /* FCast Sender */;
|
||||||
|
targetProxy = FE492A222DF43428005DA314 /* PBXContainerItemProxy */;
|
||||||
|
};
|
||||||
|
/* End PBXTargetDependency section */
|
||||||
|
|
||||||
|
/* Begin XCBuildConfiguration section */
|
||||||
|
FE492A292DF43428005DA314 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
ENABLE_TESTABILITY = YES;
|
||||||
|
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||||
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
|
"DEBUG=1",
|
||||||
|
"$(inherited)",
|
||||||
|
);
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 18.5;
|
||||||
|
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||||
|
MTL_FAST_MATH = YES;
|
||||||
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
|
||||||
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
FE492A2A2DF43428005DA314 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 18.5;
|
||||||
|
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
|
MTL_FAST_MATH = YES;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
|
VALIDATE_PRODUCT = YES;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
FE492A2C2DF43428005DA314 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
DEVELOPMENT_TEAM = Y29P2S6Z53;
|
||||||
|
ENABLE_PREVIEWS = YES;
|
||||||
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
INFOPLIST_FILE = "FCast-Sender-Info.plist";
|
||||||
|
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
||||||
|
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||||
|
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
||||||
|
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||||
|
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 16;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
|
MARKETING_VERSION = 1.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = "FUTO.FCast-Sender";
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
|
"SWIFT_OBJC_BRIDGING_HEADER[arch=*]" = "FCastSender-Bridging-Header.h";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
FE492A2D2DF43428005DA314 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
DEVELOPMENT_TEAM = Y29P2S6Z53;
|
||||||
|
ENABLE_PREVIEWS = YES;
|
||||||
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
INFOPLIST_FILE = "FCast-Sender-Info.plist";
|
||||||
|
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
||||||
|
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||||
|
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
||||||
|
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||||
|
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 16;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
|
MARKETING_VERSION = 1.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = "FUTO.FCast-Sender";
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
|
"SWIFT_OBJC_BRIDGING_HEADER[arch=*]" = "FCastSender-Bridging-Header.h";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
FE492A2F2DF43428005DA314 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 18.5;
|
||||||
|
MARKETING_VERSION = 1.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = "FUTO.FCast-SenderTests";
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = NO;
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FCast Sender.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/FCast Sender";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
FE492A302DF43428005DA314 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 18.5;
|
||||||
|
MARKETING_VERSION = 1.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = "FUTO.FCast-SenderTests";
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = NO;
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FCast Sender.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/FCast Sender";
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
FE492A322DF43428005DA314 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
MARKETING_VERSION = 1.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = "FUTO.FCast-SenderUITests";
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = NO;
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
TEST_TARGET_NAME = "FCast Sender";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
FE492A332DF43428005DA314 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
MARKETING_VERSION = 1.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = "FUTO.FCast-SenderUITests";
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = NO;
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
TEST_TARGET_NAME = "FCast Sender";
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
|
/* Begin XCConfigurationList section */
|
||||||
|
FE492A052DF43426005DA314 /* Build configuration list for PBXProject "FCast Sender" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
FE492A292DF43428005DA314 /* Debug */,
|
||||||
|
FE492A2A2DF43428005DA314 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
FE492A2B2DF43428005DA314 /* Build configuration list for PBXNativeTarget "FCast Sender" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
FE492A2C2DF43428005DA314 /* Debug */,
|
||||||
|
FE492A2D2DF43428005DA314 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
FE492A2E2DF43428005DA314 /* Build configuration list for PBXNativeTarget "FCast SenderTests" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
FE492A2F2DF43428005DA314 /* Debug */,
|
||||||
|
FE492A302DF43428005DA314 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
FE492A312DF43428005DA314 /* Build configuration list for PBXNativeTarget "FCast SenderUITests" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
FE492A322DF43428005DA314 /* Debug */,
|
||||||
|
FE492A332DF43428005DA314 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
/* End XCConfigurationList section */
|
||||||
|
|
||||||
|
/* Begin XCRemoteSwiftPackageReference section */
|
||||||
|
2C0D5A312E43787700DE5418 /* XCRemoteSwiftPackageReference "CodeScanner" */ = {
|
||||||
|
isa = XCRemoteSwiftPackageReference;
|
||||||
|
repositoryURL = "https://github.com/twostraws/CodeScanner.git";
|
||||||
|
requirement = {
|
||||||
|
kind = upToNextMajorVersion;
|
||||||
|
minimumVersion = 2.5.2;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
/* End XCRemoteSwiftPackageReference section */
|
||||||
|
|
||||||
|
/* Begin XCSwiftPackageProductDependency section */
|
||||||
|
2C0D5A322E43787700DE5418 /* CodeScanner */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
package = 2C0D5A312E43787700DE5418 /* XCRemoteSwiftPackageReference "CodeScanner" */;
|
||||||
|
productName = CodeScanner;
|
||||||
|
};
|
||||||
|
/* End XCSwiftPackageProductDependency section */
|
||||||
|
};
|
||||||
|
rootObject = FE492A022DF43426005DA314 /* Project object */;
|
||||||
|
}
|