1
0
Fork 0
mirror of https://gitlab.com/futo-org/fcast.git synced 2025-08-23 15:52:49 +00:00

Sender SDK

This commit is contained in:
Marcus Hanestad 2025-08-21 14:49:52 +00:00
parent fdbefc63e0
commit afc46f3022
147 changed files with 17638 additions and 114 deletions

View file

@ -0,0 +1,10 @@
*.iml
.gradle
/local.properties
/.idea
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties

View file

@ -0,0 +1 @@
/build

View 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")
}

View 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

View file

@ -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)
}
}

View 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_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>

View file

@ -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
}
}
}

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

View file

@ -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>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
</resources>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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)
}
}

View 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
}

View 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

View 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" }

Binary file not shown.

View 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
View 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" "$@"

View 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

View 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
View file

@ -0,0 +1,10 @@
*.iml
.gradle
/local.properties
/.idea
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties

View file

@ -0,0 +1 @@
/build

View 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")
}

View 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

View file

@ -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)
}
}

View file

@ -0,0 +1 @@
/jniLibs

View 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>

View file

@ -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
)
}
}
}
}
}

View file

@ -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)

View file

@ -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
)
}

View file

@ -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
)
*/
)

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

View file

@ -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>

View file

@ -0,0 +1,3 @@
<resources>
<string name="app_name">FCast Sender SDK Demo</string>
</resources>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.FCastSender" parent="android:Theme.Material.Light.NoActionBar" />
</resources>

View file

@ -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>

View file

@ -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>

View file

@ -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)
}
}

View 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
}

View 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

View 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" }

Binary file not shown.

View 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
View 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
View 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

View 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")

View 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"

View file

@ -0,0 +1,3 @@
fn main() {
slint_build::compile("ui/main.slint").unwrap();
}

View 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}");
}
});
}

View 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
View 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

View 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 */;
}

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>

View file

@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View file

@ -0,0 +1,35 @@
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "tinted"
}
],
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View file

@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

View file

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "airplay-svgrepo-com.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5 16.9866C4.67275 16.9698 4.43855 16.9322 4.23463 16.8478C3.74458 16.6448 3.35523 16.2554 3.15224 15.7654C3 15.3978 3 14.9319 3 14V7.2C3 6.0799 3 5.51984 3.21799 5.09202C3.40973 4.71569 3.71569 4.40973 4.09202 4.21799C4.51984 4 5.0799 4 6.2 4H17.8C18.9201 4 19.4802 4 19.908 4.21799C20.2843 4.40973 20.5903 4.71569 20.782 5.09202C21 5.51984 21 6.0799 21 7.2V14C21 14.9319 21 15.3978 20.8478 15.7654C20.6448 16.2554 20.2554 16.6448 19.7654 16.8478C19.5615 16.9322 19.3273 16.9698 19 16.9866M9.14074 20H14.8593C15.4237 20 15.706 20 15.8367 19.875C15.9501 19.7666 16.0103 19.6039 15.9986 19.4375C15.9851 19.2456 15.7855 19.0222 15.3863 18.5753L12.5271 15.3741C12.3426 15.1675 12.2503 15.0642 12.144 15.0255C12.0504 14.9915 11.9496 14.9915 11.856 15.0255C11.7497 15.0642 11.6574 15.1675 11.4729 15.3741L8.61365 18.5753C8.2145 19.0222 8.01492 19.2456 8.00144 19.4375C7.98974 19.6039 8.04992 19.7666 8.16332 19.875C8.29401 20 8.57626 20 9.14074 20Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "chromecast-brands-solid-full.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Free 7.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M512 128L128.2 128C104.6 128 85.5 147.1 85.5 170.7L85.5 234.6L128.2 234.6L128.2 170.7L512 170.7L512 469.3L362.8 469.3L362.8 512L512.2 512C535.8 512 554.9 492.9 554.9 469.3L554.9 170.7C554.9 147.1 535.6 128 512 128zM85.5 447.6L85.5 511.5L149.4 511.5C149.4 476.2 120.8 447.6 85.5 447.6zM85.5 362.6L85.5 405C144.4 405 192.1 453.1 192.1 512L234.8 512C234.9 429.6 167.9 362.7 85.5 362.6zM277.6 512L320.3 512C319.8 382.5 215 277.7 85.5 277.4L85.5 319.8C191.5 319.6 277.5 406 277.6 512z"/></svg>

After

Width:  |  Height:  |  Size: 710 B

View file

@ -0,0 +1,605 @@
import Network
import PhotosUI
import SwiftUI
import System
import CodeScanner
final class DevEventHandler: DeviceEventHandler {
let onStateChanged: @Sendable (DeviceConnectionState) -> Void
let dataModel: DataModel
init(
onStateChanged: @Sendable @escaping (DeviceConnectionState) -> Void,
dataModel: DataModel
) {
self.onStateChanged = onStateChanged
self.dataModel = dataModel
}
func connectionStateChanged(state: DeviceConnectionState) {
onStateChanged(state)
}
func volumeChanged(volume: Double) {
DispatchQueue.main.async {
self.dataModel.volume = volume
}
}
func timeChanged(time: Double) {
DispatchQueue.main.async {
self.dataModel.time = time
}
}
func playbackStateChanged(state: PlaybackState) {}
func durationChanged(duration: Double) {
DispatchQueue.main.async {
self.dataModel.duration = duration
}
}
func speedChanged(speed: Double) {
DispatchQueue.main.async {
self.dataModel.speed = speed
}
}
func sourceChanged(source: Source) {}
func keyEvent(event: GenericKeyEvent) {}
func mediaEvent(event: GenericMediaEvent) {}
func playbackError(message: String) {
print("Playback error: \(message)")
}
}
final class NWDeviceDiscoverer {
private var ctx: CastContext
private var fCastBrowser: NWBrowser
private var chromecastBrowser: NWBrowser
init(
context: CastContext,
onAdded: @escaping (FoundDevice) -> Void,
onRemoved: @escaping (NWEndpoint) -> Void,
) {
ctx = context
fCastBrowser = NWBrowser(
for: .bonjourWithTXTRecord(type: "_fcast._tcp", domain: nil),
using: .tcp
)
chromecastBrowser = NWBrowser(
for: .bonjourWithTXTRecord(type: "_googlecast._tcp", domain: nil),
using: .tcp
)
fCastBrowser.browseResultsChangedHandler = { newResults, changes in
for result in changes {
switch result {
case .added(let added):
if case .service(let name, _, _, _) = added.endpoint {
onAdded(
FoundDevice(
name: name,
endpoint: added.endpoint,
proto: ProtocolType.fCast
)
)
}
case .removed(let removed):
onRemoved(removed.endpoint)
default:
break
}
}
}
chromecastBrowser.browseResultsChangedHandler = { newResults, changes in
for result in changes {
switch result {
case .added(let added):
if case .service(var name, _, _, _) = added.endpoint {
if case .bonjour(let txt) = added.metadata,
let maybeFriendlyNameData = txt.getEntry(for: "fn"),
let friendlyNameData = maybeFriendlyNameData.data,
let friendlyName = String(
data: friendlyNameData,
encoding: .utf8
)
{
name = friendlyName
}
onAdded(
FoundDevice(
name: name,
endpoint: added.endpoint,
proto: ProtocolType.chromecast
)
)
}
case .removed(let removed):
onRemoved(removed.endpoint)
default:
break
}
}
}
fCastBrowser.start(queue: .main)
chromecastBrowser.start(queue: .main)
}
}
struct ContentView: View {
@ObservedObject var dataModel: DataModel
var castContext: CastContext
var discoverer: NWDeviceDiscoverer
@State var activeDevice: CastingDevice? = nil
var eventHandler: DevEventHandler
@State var selectedMediaItem: PhotosPickerItem? = nil
@State var isImportingFile = false
@State var isShowingMediaPicker = false
@State var activeFileHandle: FileHandle? = nil
var fileServer: FileServer
@State var isShowingErrorAlert = false
@State var errorAlertMessage = ""
init(data: DataModel) throws {
initLogger(levelFilter: LogLevelFilter.debug)
dataModel = data
castContext = try CastContext()
fileServer = castContext.startFileServer()
discoverer = NWDeviceDiscoverer(
context: castContext,
onAdded: { found in
data.devices.append(found)
},
onRemoved: { endpoint in
data.devices.removeAll { it in
it.endpoint == endpoint
}
}
)
eventHandler = DevEventHandler(
onStateChanged: { state in
switch state {
case .connected(usedRemoteAddr: _, let localAddr):
DispatchQueue.main.async {
data.sheetState = SheetState.connected
data.usedLocalAddress = localAddr
}
default:
break
}
},
dataModel: data,
)
}
var body: some View {
NavigationStack {
VStack {
if activeDevice != nil {
Button("Cast local file") {
isShowingMediaPicker.toggle()
}
}
}
.padding()
.sheet(isPresented: $isShowingMediaPicker) {
MediaPicker { contentType, localFileURL in
if let handle = try? FileHandle(
forReadingFrom: localFileURL
) {
self.activeFileHandle = handle
Task {
if let activeDevice = self.activeDevice,
let usedLocalAddress = dataModel
.usedLocalAddress
{
do {
let entry = try self.fileServer.serveFile(
fd: handle.fileDescriptor
)
let url =
"http://\(urlFormatIpAddr(addr: usedLocalAddress)):\(entry.port)/\(entry.location)"
try activeDevice.load(request: .url(contentType: contentType, url: url))
} catch {
print("Failed to serve file")
}
}
}
}
} onError: { message in
errorAlertMessage = message
isShowingErrorAlert.toggle()
}
}
.alert(errorAlertMessage, isPresented: $isShowingErrorAlert) {
Button("OK", role: .cancel) {}
}
.toolbar {
Button(action: {
dataModel.isShowingSheet.toggle()
}) {
Image("chromecast-icon")
.renderingMode(.template)
.resizable()
.scaledToFit()
.frame(maxWidth: 64)
}
}
.sheet(isPresented: $dataModel.isShowingSheet) {
switch dataModel.sheetState {
case .deviceList:
DeviceList(
devices: dataModel.devices,
onConnect: { device in
dataModel.sheetState = SheetState.connecting(
deviceName: device.name
)
Task {
let conn = NWConnection(
to: device.endpoint,
using: .tcp
)
conn.stateUpdateHandler = { state in
switch state {
case .ready:
if let innerEndpoint = conn.currentPath?
.remoteEndpoint,
case .hostPort(let host, let port) =
innerEndpoint
{
switch host {
default:
break
}
let address: IpAddr
switch host {
case .ipv4(let addr):
let raw = addr.rawValue
address = IpAddr.v4(
o1: raw[0],
o2: raw[1],
o3: raw[2],
o4: raw[3]
)
case .ipv6(let addr):
let raw = addr.rawValue
address = IpAddr.v6(
o1: raw[0],
o2: raw[1],
o3: raw[2],
o4: raw[3],
o5: raw[4],
o6: raw[5],
o7: raw[6],
o8: raw[7],
o9: raw[8],
o10: raw[9],
o11: raw[10],
o12: raw[11],
o13: raw[12],
o14: raw[13],
o15: raw[14],
o16: raw[15],
scopeId: UInt32(addr.interface?.index ?? 0)
)
default:
DispatchQueue.main.async {
dataModel.sheetState =
SheetState.failedToConnect(
deviceName: device.name,
reason:
"No address available"
)
}
return
}
let info = DeviceInfo(
name: device.name,
protocol: device.proto,
addresses: [address],
port: port.rawValue
)
activeDevice =
castContext.createDeviceFromInfo(
info: info
)
do {
try activeDevice?.connect(
appInfo: nil,
eventHandler: eventHandler
)
} catch {
DispatchQueue.main.async {
dataModel.sheetState =
SheetState.failedToConnect(
deviceName: device.name,
reason: "Unknown"
)
}
}
}
default:
break
}
}
conn.start(queue: .global())
}
},
onConnectScanned: { scannedDeviceInfo in
activeDevice =
castContext.createDeviceFromInfo(
info: scannedDeviceInfo
)
do {
try activeDevice?.connect(
appInfo: nil,
eventHandler: eventHandler
)
} catch {
DispatchQueue.main.async {
dataModel.sheetState =
SheetState.failedToConnect(
deviceName: scannedDeviceInfo.name,
reason: "Unknown"
)
}
}
}
)
.presentationDetents([.medium, .large])
case .connecting(let deviceName):
VStack {
ProgressView("Connecting to \(deviceName)")
.progressViewStyle(CircularProgressViewStyle())
Button(action: {
}) {
Text("Cancel")
}
}
.presentationDetents([.medium, .large])
case .failedToConnect(let deviceName, let reason):
VStack {
Text("Failed to connect to \(deviceName)")
Text("Reason: \(reason)")
}
.presentationDetents([.medium])
.onDisappear {
dataModel.sheetState = SheetState.deviceList
}
case .connected:
VStack {
if let devName = activeDevice?.name() {
(Text("Connected to ") + Text(devName).bold())
.padding(.top)
}
Spacer()
Text("Position")
Slider(
value: $dataModel.time,
in: 0.0...dataModel.duration,
onEditingChanged: { editing in
if !editing {
do {
try activeDevice?.seek(
timeSeconds: dataModel.time
)
} catch {
print("Failed to seek")
}
}
},
)
Text("Volume")
Slider(
value: $dataModel.volume,
in: 0.0...1.0,
onEditingChanged: { editing in
if !editing {
do {
try activeDevice?.changeVolume(
volume: dataModel.volume
)
} catch {
print("Failed to change volume")
}
}
}
)
HStack {
Spacer()
Button(action: {
do {
try activeDevice?.pausePlayback()
} catch {
print("Failed to pause playback")
}
}) {
Image(systemName: "pause").font(.system(size: 42))
}
Spacer()
Button(action: {
do {
try activeDevice?.resumePlayback()
} catch {
print("Failed to resume playback")
}
}) {
Image(systemName: "play").font(.system(size: 42))
}
Spacer()
Button(action: {
do {
try activeDevice?.stopPlayback()
} catch {
print("Failed to stop playback")
}
}) {
Image(systemName: "stop").font(.system(size: 42))
}
Spacer()
}
Spacer()
Button("Disconnect") {
do {
try activeDevice?.disconnect()
} catch {
print("Failed to disconnect device")
}
activeDevice = nil
dataModel.sheetState = SheetState.deviceList
}
.padding()
}
.presentationDetents([.medium, .large])
}
}
}
}
}
struct DeviceList: View {
var devices: [FoundDevice]
var onConnect: (FoundDevice) -> Void
var onConnectScanned: (DeviceInfo) -> Void
@State var isPresentingQrScanner = false
var body: some View {
VStack {
List(devices, id: \.name) { device in
Button(action: {
onConnect(device)
}) {
HStack {
// TODO: change these icons
switch device.proto {
case .chromecast:
Image("chromecast-icon")
.renderingMode(.template)
.resizable()
.scaledToFit()
.frame(maxWidth: 32)
default:
Image(systemName: "questionmark.app.dashed")
}
Text(device.name)
}
}
}
Text("Not seeing your receiver?")
Button("Scan QR", systemImage: "qrcode.viewfinder") {
isPresentingQrScanner.toggle()
}
}
.sheet(isPresented: $isPresentingQrScanner) {
CodeScannerView(codeTypes: [.qr]) { response in
if case let .success(result) = response {
isPresentingQrScanner = false
if let deviceInfo = deviceInfoFromUrl(url: result.string) {
onConnectScanned(deviceInfo)
}
}
}
}
}
}
struct MediaPicker: UIViewControllerRepresentable {
var onComplete: (String, URL) -> Void
var onError: (String) -> Void
func makeCoordinator() -> Coordinator {
Coordinator(onComplete: onComplete, onError: onError)
}
func makeUIViewController(context: Context) -> PHPickerViewController {
var config = PHPickerConfiguration(photoLibrary: .shared())
config.filter = .any(of: [.images, .videos])
config.selectionLimit = 1
let picker = PHPickerViewController(configuration: config)
picker.delegate = context.coordinator
return picker
}
func updateUIViewController(
_ uiViewController: PHPickerViewController,
context: Context
) {}
class Coordinator: NSObject, PHPickerViewControllerDelegate {
let onComplete: (String, URL) -> Void
let onError: (String) -> Void
init(onComplete: @escaping (String, URL) -> Void, onError: @escaping (String) -> Void) {
self.onComplete = onComplete
self.onError = onError
}
func picker(
_ picker: PHPickerViewController,
didFinishPicking results: [PHPickerResult]
) {
picker.dismiss(animated: true)
guard let item = results.first?.itemProvider else { return }
print(item.registeredContentTypes)
guard
var contentType = item
.registeredContentTypes
.makeIterator()
.map({ it in return it.preferredMIMEType })
.filter({ it in it != nil })
.first ?? "application/octet-stream"
else {
print("Unable to get content type")
return
}
if contentType == "video/quicktime" {
contentType = "video/mp4"
}
let matchingTypes = [
UTType.image.identifier,
UTType.movie.identifier,
]
for typeId in matchingTypes {
if item.hasItemConformingToTypeIdentifier(typeId) {
item.loadFileRepresentation(forTypeIdentifier: typeId) {
tempURL,
maybeError in
if let error = maybeError {
self.onError(error.localizedDescription)
return
}
guard let tempURL = tempURL else {
self.onError("Temporary URL is missing")
return
}
self.onComplete(contentType, tempURL)
}
break
}
}
}
}
}

View file

@ -0,0 +1,42 @@
import SwiftUI
import Synchronization
import Combine
import Network
struct FoundDevice {
var name: String
var endpoint: NWEndpoint
var proto: ProtocolType
}
enum SheetState {
case deviceList
case connecting(deviceName: String)
case failedToConnect(deviceName: String, reason: String)
case connected
}
@MainActor
class DataModel: ObservableObject {
@Published var playbackState = PlaybackState.idle
@Published var volume = 1.0
@Published var time = 0.0
@Published var duration = 0.0
@Published var speed = 1.0
@Published var devices: Array<FoundDevice> = Array()
@Published var showingDeviceList = false
@Published var showingConnectingToDevice = false
@Published var showingFailedToConnect = false
@Published var isShowingSheet = false
@Published var sheetState = SheetState.deviceList
@Published var usedLocalAddress: IpAddr? = nil
}
@main
struct FCast_SenderApp: App {
var body: some Scene {
WindowGroup {
try! ContentView(data: DataModel())
}
}
}

View file

@ -0,0 +1,10 @@
import Testing
@testable import FCast_Sender
struct FCast_SenderTests {
@Test func example() async throws {
// Write your test here and use APIs like `#expect(...)` to check expected conditions.
}
}

View file

@ -0,0 +1,34 @@
import XCTest
final class FCast_SenderUITests: XCTestCase {
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
// In UI tests its important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}
override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
@MainActor
func testExample() throws {
// UI tests must launch the application that they test.
let app = XCUIApplication()
app.launch()
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
@MainActor
func testLaunchPerformance() throws {
// This measures how long it takes to launch your application.
measure(metrics: [XCTApplicationLaunchMetric()]) {
XCUIApplication().launch()
}
}
}

View file

@ -0,0 +1,26 @@
import XCTest
final class FCast_SenderUITestsLaunchTests: XCTestCase {
override class var runsForEachTargetApplicationUIConfiguration: Bool {
true
}
override func setUpWithError() throws {
continueAfterFailure = false
}
@MainActor
func testLaunch() throws {
let app = XCUIApplication()
app.launch()
// Insert steps here to perform after app launch but before taking a screenshot,
// such as logging into a test account or navigating somewhere in the app
let attachment = XCTAttachment(screenshot: app.screenshot())
attachment.name = "Launch Screen"
attachment.lifetime = .keepAlways
add(attachment)
}
}

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSCameraUsageDescription</key>
<string>Scan QR code</string>
<key>NSLocalNetworkUsageDescription</key>
<string>We need to access your local network to automatically discover receivers</string>
<key>NSBonjourServices</key>
<array>
<string>_googlecast._tcp</string>
<string>_fcast._tcp</string>
<string>_airplay._tcp</string>
</array>
</dict>
</plist>

View file

@ -0,0 +1,6 @@
#ifndef FCastSender_Bridging_Header_h
#define FCastSender_Bridging_Header_h
#import "fcast_sender_sdkFFI.h"
#endif /* FCastSender_Bridging_Header_h */

View file

@ -0,0 +1,10 @@
[package]
name = "terminal"
version = "0.1.0"
edition = "2021"
[dependencies]
fcast-sender-sdk = { path = "../../fcast-sender-sdk", default-features = false, features = ["fcast", "chromecast"] }
env_logger.workspace = true
log.workspace = true
tokio.workspace = true

View file

@ -0,0 +1,96 @@
use std::sync::Arc;
use fcast_sender_sdk::{
context::CastContext,
device::{
ApplicationInfo, DeviceConnectionState, DeviceEventHandler, DeviceInfo, GenericKeyEvent,
GenericMediaEvent, LoadRequest, PlaybackState, ProtocolType, Source,
},
IpAddr,
};
use log::info;
struct EventHandler {}
impl DeviceEventHandler for EventHandler {
fn connection_state_changed(&self, state: DeviceConnectionState) {
info!("Connection state changed: {state:?}");
}
fn volume_changed(&self, volume: f64) {
info!("Volume changed: {volume}");
}
fn time_changed(&self, time: f64) {
info!("Time changed: {time}");
}
fn playback_state_changed(&self, state: PlaybackState) {
info!("Playback state changed: {state:?}");
}
fn duration_changed(&self, duration: f64) {
info!("Duration changed: {duration}");
}
fn speed_changed(&self, speed: f64) {
info!("Speed changed: {speed}");
}
fn source_changed(&self, source: Source) {
info!("Source changed: {source:?}");
}
fn key_event(&self, event: GenericKeyEvent) {
info!("Key event: {event:?}");
}
fn media_event(&self, event: GenericMediaEvent) {
info!("Media event: {event:?}");
}
fn playback_error(&self, message: String) {
info!("Playback error: {message}");
}
}
#[tokio::main]
async fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("debug")).init();
let ctx = CastContext::new().unwrap();
let dev = ctx.create_device_from_info(DeviceInfo {
name: "FCast testing device".to_owned(),
protocol: ProtocolType::FCast,
addresses: vec![IpAddr::v4(127, 0, 0, 1)],
port: 46899,
});
dev.connect(
Some(ApplicationInfo {
name: "terminal demo".to_string(),
version: "0".to_string(),
display_name: "FCast sender SDK terminal demo".to_string(),
}),
Arc::new(EventHandler {}),
)
.unwrap();
info!("Press enter load demo video");
std::io::stdin().read_line(&mut String::new()).unwrap();
dev.load(LoadRequest::Video {
content_type: "video/mp4".to_string(),
url: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4".to_string(),
resume_position: 0.0,
speed: None,
volume: None,
metadata: None,
request_headers: None,
})
.unwrap();
info!("Press enter quit");
std::io::stdin().read_line(&mut String::new()).unwrap();
}