Skip to content

Commit

Permalink
bump core and add new structs
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBeastLT committed Nov 8, 2023
1 parent 0108801 commit 444f03c
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- name: Setup Android NDK
run: yes | sdkmanager "ndk;21.0.6113669" >/dev/null
run: yes | sdkmanager "ndk;21.4.7075529" >/dev/null
- name: Set default rust toolchain
run: rustup default 1.67.1
- name: Install rustfmt
Expand Down
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ lto = true
opt-level = 3

[dependencies]
stremio-core = { git = "https://github.com/Stremio/stremio-core", branch = "development", features = [
stremio-core = { git = "https://github.com/Stremio/stremio-core", branch = "implement-stream-state-management", features = [
"derive",
"analytics",
"env-future-send",
] }

stremio-watched-bitfield = { git = "https://github.com/Stremio/stremio-core", branch = "development" }
stremio-watched-bitfield = { git = "https://github.com/Stremio/stremio-core", branch = "implement-stream-state-management" }
serde = "1.0.*"
serde_json = "1.0.*"
futures = "0.3.*"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ kotlin {

android {
compileSdk = 33
ndkVersion = "21.0.6113669"
ndkVersion = "21.4.7075529"

defaultConfig {
minSdk = 21
Expand Down
5 changes: 5 additions & 0 deletions src/commonMain/rust/bridge/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ impl FromProtobuf<Action> for runtime::Action {
video_params: Some(video_params.from_protobuf()),
})
}
Some(action_player::Args::StreamStateChanged(stream_state)) => {
Action::Player(ActionPlayer::StreamStateChanged {
state: stream_state.from_protobuf(),
})
}
Some(action_player::Args::TimeChanged(item_state)) => {
Action::Player(ActionPlayer::TimeChanged {
time: item_state.time,
Expand Down
24 changes: 24 additions & 0 deletions src/commonMain/rust/model/fields/meta_details.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use boolinator::Boolinator;
use stremio_core::deep_links::MetaItemDeepLinks;
use stremio_core::models::common::Loadable;
use stremio_core::models::ctx::Ctx;
use stremio_core::models::meta_details::{MetaDetails, Selected};
use stremio_core::runtime::Env;
Expand Down Expand Up @@ -217,6 +218,23 @@ impl ToProtobuf<models::MetaDetails, Ctx> for MetaDetails {
})
.unwrap_or_else(|| meta_item.preview.name.to_owned())
});
let suggested_stream_request =
self.suggested_stream.as_ref().and_then(|suggested_stream| {
streams
.iter()
.find(|resource| match &resource.content {
Some(Loadable::Ready(streams)) => streams.contains(suggested_stream),
_ => false,
})
.map(|resource| &resource.request)
});
let suggested_stream_addon_name = suggested_stream_request.and_then(|stream_request| {
ctx.profile
.addons
.iter()
.find(|addon| addon.transport_url == stream_request.base)
.map(|addon| &addon.manifest.name)
});
models::MetaDetails {
selected: self.selected.to_protobuf(&()),
title,
Expand All @@ -226,6 +244,12 @@ impl ToProtobuf<models::MetaDetails, Ctx> for MetaDetails {
self.watched.as_ref(),
)),
streams: streams.to_protobuf(&(ctx, meta_request)),
suggested_stream: self.suggested_stream.to_protobuf(&(
Some(ctx),
suggested_stream_addon_name,
suggested_stream_request,
meta_request,
)),
}
}
}
32 changes: 32 additions & 0 deletions src/commonMain/rust/model/fields/player.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use stremio_core::models::ctx::Ctx;
use stremio_core::models::player::{Player, Selected, VideoParams};
use stremio_core::types::streams::StreamItemState;

use crate::bridge::{FromProtobuf, ToProtobuf};
use crate::protobuf::stremio::core::models;
Expand All @@ -15,6 +16,21 @@ impl FromProtobuf<Selected> for models::player::Selected {
}
}

impl FromProtobuf<StreamItemState> for models::player::StreamState {
fn from_protobuf(&self) -> StreamItemState {
StreamItemState {
subtitle_track_id: self.subtitle_track_id.to_owned(),
subtitle_language: self.subtitle_language.to_owned(),
subtitle_delay: self.subtitle_delay.to_owned(),
audio_track_id: self.audio_track_id.to_owned(),
audio_language: self.audio_language.to_owned(),
audio_delay: self.audio_delay.to_owned(),
playback_speed: self.playback_speed.to_owned(),
player_type: self.player_type.to_owned(),
}
}
}

impl FromProtobuf<VideoParams> for models::player::VideoParams {
fn from_protobuf(&self) -> VideoParams {
VideoParams {
Expand All @@ -33,6 +49,21 @@ impl ToProtobuf<models::player::VideoParams, ()> for VideoParams {
}
}

impl ToProtobuf<models::player::StreamState, ()> for StreamItemState {
fn to_protobuf(&self, _args: &()) -> models::player::StreamState {
models::player::StreamState {
subtitle_track_id: self.subtitle_track_id.to_owned(),
subtitle_language: self.subtitle_language.to_owned(),
subtitle_delay: self.subtitle_delay.to_owned(),
audio_track_id: self.audio_track_id.to_owned(),
audio_language: self.audio_language.to_owned(),
audio_delay: self.audio_delay.to_owned(),
playback_speed: self.playback_speed.to_owned(),
player_type: self.player_type.to_owned(),
}
}
}

impl ToProtobuf<models::player::Selected, Ctx> for Selected {
fn to_protobuf(&self, ctx: &Ctx) -> models::player::Selected {
let addon_name = self.stream_request.as_ref().and_then(|request| {
Expand Down Expand Up @@ -71,6 +102,7 @@ impl ToProtobuf<models::Player, Ctx> for Player {
)),
series_info: self.series_info.to_protobuf(&()),
library_item: self.library_item.to_protobuf(ctx),
stream_state: self.stream_state.to_protobuf(&()),
}
}
}
1 change: 1 addition & 0 deletions src/main/proto/stremio/core/models/meta_details.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ message MetaDetails {
optional string title = 2;
optional LoadableMetaItem meta_item = 3;
repeated LoadableStreams streams = 4;
optional stremio.core.types.Stream suggested_stream = 5;

message Selected {
required stremio.core.types.ResourcePath meta_path = 1;
Expand Down
11 changes: 11 additions & 0 deletions src/main/proto/stremio/core/models/player.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,22 @@ message Player {
optional stremio.core.types.Video next_video = 5;
optional stremio.core.types.Video.SeriesInfo series_info = 6;
optional stremio.core.types.LibraryItem library_item = 7;
optional StreamState stream_state = 8;

message VideoParams {
optional string hash = 1;
optional int64 size = 2;
}
message StreamState {
optional string subtitle_track_id = 1;
optional string subtitle_language = 2;
optional int64 subtitle_delay = 3;
optional string audio_track_id = 4;
optional string audio_language = 5;
optional int64 audio_delay = 6;
optional float playback_speed = 7;
optional string player_type = 8;
}
message Selected {
required stremio.core.types.Stream stream = 1;
optional stremio.core.types.ResourceRequest stream_request = 2;
Expand Down
7 changes: 4 additions & 3 deletions src/main/proto/stremio/core/runtime/action_player.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import "stremio/core/models/player.proto";
message ActionPlayer {
oneof args {
stremio.core.models.Player.VideoParams video_params_changed = 1;
PlayerItemState time_changed = 2;
bool paused_changed = 3;
google.protobuf.Empty ended = 4;
stremio.core.models.Player.StreamState stream_state_changed = 2;
PlayerItemState time_changed = 3;
bool paused_changed = 4;
google.protobuf.Empty ended = 5;
}

message PlayerItemState {
Expand Down

0 comments on commit 444f03c

Please sign in to comment.