Code Monkey home page Code Monkey logo

va-ts's Introduction

video-audio mpeg-ts muxer/demuxer

MIT licensed Crate

MPEG-TS implementation for Rust.

Overview

sub-table-id:

  • PAT - (table-id, transport-stream-id(ext) [, version-number])
  • PMT - (table-id, program-number(ext) [, version-number])
  • SDT - (table-id, transport-stream-id(ext), original-network-id, version-number)
  • EIT - (table-id, service-id(ext), transport-stream-id, original-network-id, version-number)

table-id-extension:

  • PAT - transport-stream-id
  • PMT - program-number
  • SDT - transport-stream-id
  • EIT - service-id

License

va-ts is provided under the MIT license. See LICENSE.

va-ts's People

Contributors

joe1994 avatar renovate-bot avatar renovate[bot] avatar vany-egorov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

sternelee isgasho

va-ts's Issues

`Demuxer` can carry non-Send types across thread boundaries

Hello ๐Ÿฆ€ , we (Rust group @sslab-gatech) found an undefined-behavior issue in this crate while scanning Rust code on crates.io for potential vulnerabilities.

Issue

Send is unconditionally implemented for Demuxer, so that it is possible for a non-Send implementor of DemuxerEvents trait to be sent across thread boundaries.

unsafe impl<T> Send for Demuxer<T> where T: DemuxerEvents {}

Proof of Concept

Here is a simple program where Demuxer is used to move a MutexGuard(!Send object) to another thread.
It is also possible to create data races by inserting non-Send types like Rc or Cell into Demuxer
(which is not demonstrated in the example code below).

use va_ts::{Demuxer, DemuxerEvents, SubtableID, DemuxedPacket, DemuxedTable};
use std::sync::{Mutex, MutexGuard};
use std::thread::{self, ThreadId};
use std::ops::Drop;

struct X(MutexGuard<'static, u64>, ThreadId);
impl DemuxerEvents for X {
    fn on_table(&mut self, _: SubtableID, _: &DemuxedTable) { }
    fn on_packet(&mut self, _: &DemuxedPacket) { }
}
impl Drop for X {
    fn drop(&mut self) {
        // `MutexGuard` must not be dropped from a thread that didn't lock the `Mutex`.
        //
        // If a thread attempts to unlock a Mutex that it has not locked, it can result in undefined behavior.
        // (https://github.com/rust-lang/rust/issues/23465#issuecomment-82730326)
        assert_eq!(self.1, thread::current().id());
    }
}

fn main() {
    let static_mutex = Box::leak(Box::new(Mutex::new(0xbeefbeef_u64)));
    // MutexGuard is `!Send`
    let mutex_guard = static_mutex.lock().unwrap();
    let tid = thread::current().id();

    let demuxer = Demuxer::new(X(mutex_guard, tid));
    std::thread::spawn(move || {
        let demuxer = demuxer;

        // demuxer is dropped here, along with `MutexGuard`.
    }).join().unwrap();
}

Suggested Fix

Adding a trait bound T: Send as below will allow the compiler to prevent Demuxer from moving !Send types across thread boundaries.

unsafe impl<T> Send for Demuxer<T> where T: DemuxerEvents + Send {}

Thank you for reviewing this issue ๐Ÿ‘

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

cargo
Cargo.toml
  • chrono ~0.4.31
  • encoding_rs ~0.8.33
  • clap ~4.3.0
  • url ~2.5.0
docker-compose
dockerfiles/docker-compose.yml
dockerfile
dockerfiles/build-rs/Dockerfile
  • debian 12
dockerfiles/tsplay/Dockerfile
  • debian 12

  • Check this box to trigger a request for Renovate to run again on this repository

Question? Muxer development.

Howdy,
Not sure if any of the MPEGTS muxing is working from what I can see in the code?
If so, and I'm missing something, do you have a working example of muxing video, audio and producing the SI tables into the TS stream?
Can the muxer operating via fifo's and not rely an files as input and output?

Cheers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.