1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//! Local Media Stream Tracks
//!
//! This module provides the [`TrackLocal`](crate::media_stream::track_local::TrackLocal) trait, which represents a media track generated locally.
//! It also includes two concrete implementations:
//! * **[`TrackLocalStaticRTP`](crate::media_stream::track_local::static_rtp::TrackLocalStaticRTP)**: For writing pre-packetized RTP packets.
//! * **[`TrackLocalStaticSample`](crate::media_stream::track_local::static_sample::TrackLocalStaticSample)**: For writing raw media samples.
//!
//! # Examples
//!
//! ## Writing Media Samples
//!
//! ```no_run
//! use webrtc::media_stream::track_local::TrackLocal;
//! use webrtc::media_stream::track_local::static_sample::TrackLocalStaticSample;
//! use rtc::media_stream::{MediaStreamTrack, MediaStreamTrackId, MediaStreamId};
//! use rtc::rtp_transceiver::rtp_sender::RtpCodecKind;
//! use rtc::media::Sample;
//! use std::time::Duration;
//! use std::sync::Arc;
//!
//! # async fn example() -> webrtc::error::Result<()> {
//! // Create a local video track
//! let track = MediaStreamTrack::new(
//! MediaStreamTrackId::new(),
//! MediaStreamId::new(),
//! "video-label".to_owned(),
//! RtpCodecKind::Video,
//! vec![],
//! );
//! let local_track = Arc::new(TrackLocalStaticSample::new(track)?);
//!
//! // Write a raw VP8/H.264 frame as a sample
//! let sample = Sample {
//! data: bytes::Bytes::from(vec![0x00, 0x01, 0x02]),
//! duration: Duration::from_millis(33), // ~30 fps
//! ..Default::default()
//! };
//!
//! // Write the sample to SSRC 1234
//! local_track.write_sample(1234, &sample, &[]).await?;
//! # Ok(())
//! # }
//! ```
use crateResult;
use crateTrack;
use cratePeerConnectionDriverEvent;
use crateSender;
use MediaStreamTrack;
use RTCRtpSenderId;
use RTCRtpParameters;
use ;
/// Local track implementation that accepts pre-packetized RTP packets.
/// Local track implementation that accepts raw media samples and packetizes them.
/// TrackLocalContext is the Context passed when a TrackLocal has been Binded/Unbinded from a PeerConnection, and used
/// in Interceptors.
/// A local media track that can be sent to a remote peer.
///
/// This trait defines the interface for local media tracks. Applications write
/// RTP and RTCP packets to this track, which are then processed by the interceptor
/// pipeline and sent over the peer connection.