sheave_core/handlers/rtmp_context/
last_chunk.rs

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
use std::time::Duration;
use crate::messages::headers::MessageType;

/// The chunk information which is sent/received last.
#[derive(Debug, Clone, Copy)]
pub struct LastChunk {
    timestamp: Duration,
    message_length: u32,
    message_type: MessageType,
    message_id: u32
}

impl LastChunk {
    /// Constructs a LastChunk.
    /// Note the message ID is set 0 when message header isn't `New`.
    /// e.g. On receiving `StreamBegin`.
    pub fn new(timestamp: Duration, message_length: u32, message_type: MessageType, message_id: u32) -> Self {
        Self { timestamp, message_length, message_type, message_id }
    }

    /// Sets a timestamp.
    pub fn set_timestamp(&mut self, timestamp: Duration) {
        self.timestamp = timestamp;
    }

    /// Gets a timestamp.
    pub fn get_timestamp(&self) -> Duration {
        self.timestamp
    }

    /// Sets a message length.
    pub fn set_message_length(&mut self, message_length: u32) {
        self.message_length = message_length;
    }

    /// Gets a message length.
    pub fn get_message_length(&self) -> u32 {
        self.message_length
    }

    /// Sets a message type.
    pub fn set_message_type(&mut self, message_type: MessageType) {
        self.message_type = message_type;
    }

    /// Gets a message type.
    pub fn get_message_type(&self) -> MessageType {
        self.message_type
    }

    /// Sets a message ID.
    pub fn set_message_id(&mut self, message_id: u32) {
        self.message_id = message_id;
    }

    /// Gets a message ID.
    pub fn get_message_id(&self) -> u32 {
        self.message_id
    }
}