Skip to content

Commit

Permalink
fix: minor platform and video related fixes
Browse files Browse the repository at this point in the history
- Fix png decoding on image processor
- Fix video api event ack ratelimit
- Fix docker compose default binding
- Fix docker compose storage persistence
- Fix ci self-hosted runner selector
  • Loading branch information
TroyKomodo committed Jan 11, 2024
1 parent ca5a518 commit 56ef76d
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint-test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
lint:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
runs-on: scuffle-ci-ryzen-9-7950x3d
runs-on: scuffle-ci
container: ghcr.io/scuffletv/ci/build:latest
steps:
- uses: actions/checkout@v4
Expand All @@ -48,7 +48,7 @@ jobs:
test:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
runs-on: scuffle-ci-ryzen-9-7950x3d
runs-on: scuffle-ci
container: ghcr.io/scuffletv/ci/build:latest
services:
cockroach:
Expand Down
35 changes: 24 additions & 11 deletions dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,38 @@ services:
cockroach:
image: ghcr.io/scuffletv/ci/cockroach:latest
pull_policy: "always"
command: start-single-node --insecure --store=type=mem,size=0.25 --advertise-addr=0.0.0.0
command: start-single-node --insecure --advertise-addr=0.0.0.0
volumes:
- cockroach:/cockroach/cockroach-data
ports:
- "5432:26257"
- "8080:8080"
- "127.0.0.1:5432:26257"
- "127.0.0.1:8080:8080"

nats:
image: ghcr.io/scuffletv/ci/nats:latest
pull_policy: "always"
ports:
- "4222:4222"
- "8222:8222"
- "6222:6222"
- "127.0.0.1:4222:4222"
- "127.0.0.1:8222:8222"
- "127.0.0.1:6222:6222"
volumes:
- nats:/data
command:
- "-js"
- --jetstream
- --store_dir=/data

minio:
image: ghcr.io/scuffletv/ci/minio:latest
pull_policy: "always"
ports:
- "9000:9000"
- "9001:9001"
- "127.0.0.1:9000:9000"
- "127.0.0.1:9001:9001"
environment:
- "MINIO_ACCESS_KEY=root"
- "MINIO_SECRET_KEY=scuffle123"
command: server /export --console-address ":9001"
volumes:
- minio:/data
command: server /data --console-address ":9001"

createbuckets:
image: minio/mc:latest
Expand All @@ -56,4 +63,10 @@ services:
image: ghcr.io/scuffletv/ci/redis:latest
pull_policy: "always"
ports:
- "6379:6379"
- "127.0.0.1:6379:6379"

volumes:
cockroach:
nats:
minio:
redis:
9 changes: 8 additions & 1 deletion docker/ffmpeg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ apt-get install -y --no-install-recommends \
libtool \
autoconf \
automake \
build-essential
build-essential \
libpng-dev \
libjpeg-dev \
libtiff-dev \
libpng-16-16 \
libjpeg62 \
libtiff6


git clone https://github.com/ScuffleTV/external.git --depth 1 --recurse-submodule --shallow-submodules /tmp/external
/tmp/external/build.sh --prefix /usr/local --build "x264 x265 svt-av1 libvpx opus dav1d ffmpeg opencv"
Expand Down
Binary file added platform/assets/frog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<'data> FfmpegDecoder<'data> {
let input_stream_duration = input_stream.duration().unwrap_or(0);
let input_stream_frames = input_stream
.nb_frames()
.ok_or_else(|| ProcessorError::FfmpegDecode(anyhow!("no frame count")))?;
.ok_or_else(|| ProcessorError::FfmpegDecode(anyhow!("no frame count")))?.max(1);

if input_stream_time_base.den == 0 || input_stream_time_base.num == 0 {
return Err(ProcessorError::FfmpegDecode(anyhow!("stream time base is 0")));
Expand Down
20 changes: 20 additions & 0 deletions platform/image_processor/src/tests/processor/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,26 @@ fn decode_ffmpeg_gif_test() {
decode("meow.gif", DecoderBackend::Ffmpeg, expected_info, expected_frames);
}

#[test]
fn decode_ffmpeg_png_test() {
let expected_info = DecoderInfo {
timescale: 25,
frame_count: 1,
loop_count: LoopCount::Infinite,
height: 400,
width: 400,
};

let expected_frames = (0..1)
.map(|_| Frame {
duration_ts: 0,
image: ImgVec::new(vec![], 400, 400),
})
.collect();

decode("frog.png", DecoderBackend::Ffmpeg, expected_info, expected_frames);
}

#[test]
fn decode_libwebp_webp_test() {
let expected_info = DecoderInfo {
Expand Down
2 changes: 1 addition & 1 deletion video/api/src/api/events/ack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl_request_scopes!(
EventsAckRequest,
(),
(Resource::Event, Permission::Read),
RateLimitResource::EventsSubscribe
RateLimitResource::EventsAck
);

impl ApiRequest<EventsAckResponse> for tonic::Request<EventsAckRequest> {
Expand Down
2 changes: 1 addition & 1 deletion video/api/src/api/events/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl_request_scopes!(
EventsFetchRequest,
(),
(Resource::Event, Permission::Read),
RateLimitResource::EventsSubscribe
RateLimitResource::EventsFetch
);

pub type Stream = Pin<Box<dyn futures_util::Stream<Item = tonic::Result<EventsFetchResponse>> + Send>>;
Expand Down
2 changes: 1 addition & 1 deletion video/api/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl Default for ApiConfig {
bind_address: "[::]:9080".to_string().parse().unwrap(),
tls: None,
events: EventsConfig::default(),
recording_delete_stream: "scuffle:video:recording_delete".to_string(),
recording_delete_stream: "scuffle-video-recording_delete".to_string(),
recording_delete_batch_size: 1000,
rate_limit_rules: RatelimitRules::default(),
}
Expand Down
8 changes: 5 additions & 3 deletions video/api/src/ratelimit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ pub enum RateLimitResource {
AccessTokenTag,
AccessTokenUntag,

EventsSubscribe,
EventsFetch,
EventsAck,

PlaybackKeyPairGet,
PlaybackKeyPairCreate,
Expand Down Expand Up @@ -68,7 +69,8 @@ impl RateLimitResource {
Self::AccessTokenTag => "access_token:tag",
Self::AccessTokenUntag => "access_token:untag",

Self::EventsSubscribe => "events:subscribe",
Self::EventsFetch => "events:subscribe",
Self::EventsAck => "events:ack",

Self::PlaybackKeyPairGet => "playback_key_pair:get",
Self::PlaybackKeyPairCreate => "playback_key_pair:create",
Expand Down Expand Up @@ -131,7 +133,7 @@ impl FromStr for RateLimitResource {
"access_token:tag" => Ok(Self::AccessTokenTag),
"access_token:untag" => Ok(Self::AccessTokenUntag),

"events:subscribe" => Ok(Self::EventsSubscribe),
"events:subscribe" => Ok(Self::EventsFetch),

"playback_key_pair:get" => Ok(Self::PlaybackKeyPairGet),
"playback_key_pair:create" => Ok(Self::PlaybackKeyPairCreate),
Expand Down

0 comments on commit 56ef76d

Please sign in to comment.