1use broadcast_common::{Parse, Serialize};
14
15use crate::RtmpError;
16use crate::chunk::Message;
17
18type Result<T> = core::result::Result<T, RtmpError>;
19
20pub mod msg_type {
26 pub const SET_CHUNK_SIZE: u8 = 1;
28 pub const ABORT: u8 = 2;
30 pub const ACKNOWLEDGEMENT: u8 = 3;
32 pub const USER_CONTROL: u8 = 4;
34 pub const WINDOW_ACK_SIZE: u8 = 5;
36 pub const SET_PEER_BANDWIDTH: u8 = 6;
38 pub const AUDIO: u8 = 8;
40 pub const VIDEO: u8 = 9;
42 pub const DATA_AMF3: u8 = 15;
44 pub const COMMAND_AMF3: u8 = 17;
46 pub const DATA_AMF0: u8 = 18;
48 pub const COMMAND_AMF0: u8 = 20;
50 pub const AGGREGATE: u8 = 22;
52}
53
54pub const CONTROL_CHUNK_STREAM_ID: u32 = 2;
57pub const CONTROL_MESSAGE_STREAM_ID: u32 = 0;
60
61const U32_LEN: usize = 4;
64const SET_PEER_BANDWIDTH_LEN: usize = U32_LEN + 1;
67
68const SET_CHUNK_SIZE_RESERVED_MASK: u32 = 0x8000_0000;
71const SET_CHUNK_SIZE_VALUE_MASK: u32 = 0x7FFF_FFFF;
74
75fn read_u32_be(b: &[u8]) -> u32 {
76 u32::from_be_bytes([b[0], b[1], b[2], b[3]])
77}
78
79fn need_u32(bytes: &[u8], what: &'static str) -> Result<u32> {
80 if bytes.len() < U32_LEN {
81 return Err(RtmpError::BufferTooShort {
82 need: U32_LEN,
83 have: bytes.len(),
84 what,
85 });
86 }
87 Ok(read_u32_be(bytes))
88}
89
90#[derive(Debug, Clone, Copy, PartialEq, Eq)]
94#[non_exhaustive]
95pub enum LimitType {
96 Hard,
98 Soft,
101 Dynamic,
104}
105
106impl LimitType {
107 #[must_use]
109 pub fn name(&self) -> &'static str {
110 match self {
111 LimitType::Hard => "hard",
112 LimitType::Soft => "soft",
113 LimitType::Dynamic => "dynamic",
114 }
115 }
116
117 pub const fn from_u8(v: u8) -> core::result::Result<Self, RtmpError> {
122 match v {
123 0 => Ok(LimitType::Hard),
124 1 => Ok(LimitType::Soft),
125 2 => Ok(LimitType::Dynamic),
126 _ => Err(RtmpError::Malformed {
127 what: "set peer bandwidth limit type (must be 0..=2)",
128 }),
129 }
130 }
131
132 #[must_use]
134 pub const fn to_u8(self) -> u8 {
135 match self {
136 LimitType::Hard => 0,
137 LimitType::Soft => 1,
138 LimitType::Dynamic => 2,
139 }
140 }
141}
142
143broadcast_common::impl_spec_display!(LimitType);
144
145#[non_exhaustive]
156#[derive(Debug, Clone, Copy, PartialEq, Eq)]
157pub enum ProtocolControl {
158 SetChunkSize(u32),
160 Abort {
163 chunk_stream_id: u32,
166 },
167 Acknowledgement(u32),
169 WindowAckSize(u32),
172 SetPeerBandwidth {
174 ack_window_size: u32,
176 limit_type: LimitType,
178 },
179}
180
181impl ProtocolControl {
182 #[must_use]
184 pub fn name(&self) -> &'static str {
185 match self {
186 ProtocolControl::SetChunkSize(_) => "set chunk size",
187 ProtocolControl::Abort { .. } => "abort message",
188 ProtocolControl::Acknowledgement(_) => "acknowledgement",
189 ProtocolControl::WindowAckSize(_) => "window acknowledgement size",
190 ProtocolControl::SetPeerBandwidth { .. } => "set peer bandwidth",
191 }
192 }
193
194 #[must_use]
196 pub fn message_type_id(&self) -> u8 {
197 match self {
198 ProtocolControl::SetChunkSize(_) => msg_type::SET_CHUNK_SIZE,
199 ProtocolControl::Abort { .. } => msg_type::ABORT,
200 ProtocolControl::Acknowledgement(_) => msg_type::ACKNOWLEDGEMENT,
201 ProtocolControl::WindowAckSize(_) => msg_type::WINDOW_ACK_SIZE,
202 ProtocolControl::SetPeerBandwidth { .. } => msg_type::SET_PEER_BANDWIDTH,
203 }
204 }
205
206 pub fn from_message(message: &Message) -> Result<Option<Self>> {
218 Self::from_payload(message.message_type_id, &message.payload)
219 }
220
221 pub fn from_payload(message_type_id: u8, payload: &[u8]) -> Result<Option<Self>> {
231 match message_type_id {
232 msg_type::SET_CHUNK_SIZE => {
233 let raw = need_u32(payload, "set chunk size payload")?;
234 if raw & SET_CHUNK_SIZE_RESERVED_MASK != 0 {
235 return Err(RtmpError::Malformed {
236 what: "set chunk size reserved top bit (must be 0)",
237 });
238 }
239 let size = raw & SET_CHUNK_SIZE_VALUE_MASK;
240 if size == 0 {
241 return Err(RtmpError::Malformed {
242 what: "set chunk size value (must be >= 1)",
243 });
244 }
245 Ok(Some(ProtocolControl::SetChunkSize(size)))
246 }
247 msg_type::ABORT => {
248 let chunk_stream_id = need_u32(payload, "abort message payload")?;
249 Ok(Some(ProtocolControl::Abort { chunk_stream_id }))
250 }
251 msg_type::ACKNOWLEDGEMENT => {
252 let sequence_number = need_u32(payload, "acknowledgement payload")?;
253 Ok(Some(ProtocolControl::Acknowledgement(sequence_number)))
254 }
255 msg_type::WINDOW_ACK_SIZE => {
256 let window = need_u32(payload, "window acknowledgement size payload")?;
257 Ok(Some(ProtocolControl::WindowAckSize(window)))
258 }
259 msg_type::SET_PEER_BANDWIDTH => {
260 if payload.len() < SET_PEER_BANDWIDTH_LEN {
261 return Err(RtmpError::BufferTooShort {
262 need: SET_PEER_BANDWIDTH_LEN,
263 have: payload.len(),
264 what: "set peer bandwidth payload",
265 });
266 }
267 let ack_window_size = read_u32_be(&payload[0..U32_LEN]);
268 let limit_type = LimitType::from_u8(payload[U32_LEN])?;
269 Ok(Some(ProtocolControl::SetPeerBandwidth {
270 ack_window_size,
271 limit_type,
272 }))
273 }
274 _ => Ok(None),
275 }
276 }
277
278 #[must_use]
290 pub fn to_message(&self) -> Message {
291 Message {
292 chunk_stream_id: CONTROL_CHUNK_STREAM_ID,
293 timestamp: 0,
294 message_type_id: self.message_type_id(),
295 message_stream_id: CONTROL_MESSAGE_STREAM_ID,
296 payload: self.to_bytes(),
297 }
298 }
299
300 pub fn try_to_message(&self) -> Result<Message> {
308 Ok(Message {
309 chunk_stream_id: CONTROL_CHUNK_STREAM_ID,
310 timestamp: 0,
311 message_type_id: self.message_type_id(),
312 message_stream_id: CONTROL_MESSAGE_STREAM_ID,
313 payload: self.try_to_bytes()?,
314 })
315 }
316}
317
318broadcast_common::impl_spec_display!(ProtocolControl);
319
320impl Serialize for ProtocolControl {
321 type Error = RtmpError;
322
323 fn serialized_len(&self) -> usize {
324 match self {
325 ProtocolControl::SetChunkSize(_)
326 | ProtocolControl::Abort { .. }
327 | ProtocolControl::Acknowledgement(_)
328 | ProtocolControl::WindowAckSize(_) => U32_LEN,
329 ProtocolControl::SetPeerBandwidth { .. } => SET_PEER_BANDWIDTH_LEN,
330 }
331 }
332
333 fn serialize_into(&self, buf: &mut [u8]) -> Result<usize> {
334 let written = self.serialized_len();
335 if buf.len() < written {
336 return Err(RtmpError::BufferTooShort {
337 need: written,
338 have: buf.len(),
339 what: "protocol control payload output",
340 });
341 }
342 match *self {
343 ProtocolControl::SetChunkSize(size) => {
344 if size == 0 || size & SET_CHUNK_SIZE_RESERVED_MASK != 0 {
345 return Err(RtmpError::Malformed {
346 what: "set chunk size value (must be 1..=0x7FFF_FFFF)",
347 });
348 }
349 buf[0..U32_LEN].copy_from_slice(&size.to_be_bytes());
350 }
351 ProtocolControl::Abort { chunk_stream_id } => {
352 buf[0..U32_LEN].copy_from_slice(&chunk_stream_id.to_be_bytes());
353 }
354 ProtocolControl::Acknowledgement(sequence_number) => {
355 buf[0..U32_LEN].copy_from_slice(&sequence_number.to_be_bytes());
356 }
357 ProtocolControl::WindowAckSize(window) => {
358 buf[0..U32_LEN].copy_from_slice(&window.to_be_bytes());
359 }
360 ProtocolControl::SetPeerBandwidth {
361 ack_window_size,
362 limit_type,
363 } => {
364 buf[0..U32_LEN].copy_from_slice(&ack_window_size.to_be_bytes());
365 buf[U32_LEN] = limit_type.to_u8();
366 }
367 }
368 Ok(written)
369 }
370}
371
372const EVENT_TYPE_LEN: usize = 2;
376
377mod event_type {
379 pub const STREAM_BEGIN: u16 = 0;
380 pub const STREAM_EOF: u16 = 1;
381 pub const STREAM_DRY: u16 = 2;
382 pub const SET_BUFFER_LENGTH: u16 = 3;
383 pub const STREAM_IS_RECORDED: u16 = 4;
384 pub const PING_REQUEST: u16 = 6;
386 pub const PING_RESPONSE: u16 = 7;
387}
388
389#[non_exhaustive]
398#[derive(Debug, Clone, Copy, PartialEq, Eq)]
399pub enum UserControl {
400 StreamBegin(u32),
404 StreamEof(u32),
407 StreamDry(u32),
410 SetBufferLength {
413 stream_id: u32,
415 buffer_ms: u32,
417 },
418 StreamIsRecorded(u32),
421 PingRequest(u32),
424 PingResponse(u32),
427}
428
429impl UserControl {
430 #[must_use]
432 pub fn name(&self) -> &'static str {
433 match self {
434 UserControl::StreamBegin(_) => "stream begin",
435 UserControl::StreamEof(_) => "stream eof",
436 UserControl::StreamDry(_) => "stream dry",
437 UserControl::SetBufferLength { .. } => "set buffer length",
438 UserControl::StreamIsRecorded(_) => "stream is recorded",
439 UserControl::PingRequest(_) => "ping request",
440 UserControl::PingResponse(_) => "ping response",
441 }
442 }
443
444 #[must_use]
446 pub fn event_type(&self) -> u16 {
447 match self {
448 UserControl::StreamBegin(_) => event_type::STREAM_BEGIN,
449 UserControl::StreamEof(_) => event_type::STREAM_EOF,
450 UserControl::StreamDry(_) => event_type::STREAM_DRY,
451 UserControl::SetBufferLength { .. } => event_type::SET_BUFFER_LENGTH,
452 UserControl::StreamIsRecorded(_) => event_type::STREAM_IS_RECORDED,
453 UserControl::PingRequest(_) => event_type::PING_REQUEST,
454 UserControl::PingResponse(_) => event_type::PING_RESPONSE,
455 }
456 }
457
458 #[must_use]
464 pub fn to_message(&self) -> Message {
465 Message {
466 chunk_stream_id: CONTROL_CHUNK_STREAM_ID,
467 timestamp: 0,
468 message_type_id: msg_type::USER_CONTROL,
469 message_stream_id: CONTROL_MESSAGE_STREAM_ID,
470 payload: self.to_bytes(),
471 }
472 }
473}
474
475broadcast_common::impl_spec_display!(UserControl);
476
477impl<'a> Parse<'a> for UserControl {
478 type Error = RtmpError;
479
480 fn parse(bytes: &'a [u8]) -> Result<Self> {
481 if bytes.len() < EVENT_TYPE_LEN {
482 return Err(RtmpError::BufferTooShort {
483 need: EVENT_TYPE_LEN,
484 have: bytes.len(),
485 what: "user control event type",
486 });
487 }
488 let event = u16::from_be_bytes([bytes[0], bytes[1]]);
489 let data = &bytes[EVENT_TYPE_LEN..];
490 match event {
491 event_type::STREAM_BEGIN => Ok(UserControl::StreamBegin(need_u32(
492 data,
493 "stream begin event data",
494 )?)),
495 event_type::STREAM_EOF => Ok(UserControl::StreamEof(need_u32(
496 data,
497 "stream eof event data",
498 )?)),
499 event_type::STREAM_DRY => Ok(UserControl::StreamDry(need_u32(
500 data,
501 "stream dry event data",
502 )?)),
503 event_type::SET_BUFFER_LENGTH => {
504 if data.len() < 2 * U32_LEN {
505 return Err(RtmpError::BufferTooShort {
506 need: 2 * U32_LEN,
507 have: data.len(),
508 what: "set buffer length event data",
509 });
510 }
511 Ok(UserControl::SetBufferLength {
512 stream_id: read_u32_be(&data[0..U32_LEN]),
513 buffer_ms: read_u32_be(&data[U32_LEN..2 * U32_LEN]),
514 })
515 }
516 event_type::STREAM_IS_RECORDED => Ok(UserControl::StreamIsRecorded(need_u32(
517 data,
518 "stream is recorded event data",
519 )?)),
520 event_type::PING_REQUEST => Ok(UserControl::PingRequest(need_u32(
521 data,
522 "ping request event data",
523 )?)),
524 event_type::PING_RESPONSE => Ok(UserControl::PingResponse(need_u32(
525 data,
526 "ping response event data",
527 )?)),
528 _ => Err(RtmpError::Unsupported {
529 what: "user control event type (unrecognised)",
530 }),
531 }
532 }
533}
534
535impl Serialize for UserControl {
536 type Error = RtmpError;
537
538 fn serialized_len(&self) -> usize {
539 let data_len = match self {
540 UserControl::SetBufferLength { .. } => 2 * U32_LEN,
541 _ => U32_LEN,
542 };
543 EVENT_TYPE_LEN + data_len
544 }
545
546 fn serialize_into(&self, buf: &mut [u8]) -> Result<usize> {
547 let written = self.serialized_len();
548 if buf.len() < written {
549 return Err(RtmpError::BufferTooShort {
550 need: written,
551 have: buf.len(),
552 what: "user control event output",
553 });
554 }
555 buf[0..EVENT_TYPE_LEN].copy_from_slice(&self.event_type().to_be_bytes());
556 let data = &mut buf[EVENT_TYPE_LEN..written];
557 match *self {
558 UserControl::StreamBegin(stream_id)
559 | UserControl::StreamEof(stream_id)
560 | UserControl::StreamDry(stream_id)
561 | UserControl::StreamIsRecorded(stream_id)
562 | UserControl::PingRequest(stream_id)
563 | UserControl::PingResponse(stream_id) => {
564 data[0..U32_LEN].copy_from_slice(&stream_id.to_be_bytes());
565 }
566 UserControl::SetBufferLength {
567 stream_id,
568 buffer_ms,
569 } => {
570 data[0..U32_LEN].copy_from_slice(&stream_id.to_be_bytes());
571 data[U32_LEN..2 * U32_LEN].copy_from_slice(&buffer_ms.to_be_bytes());
572 }
573 }
574 Ok(written)
575 }
576}
577
578#[cfg(test)]
579mod tests {
580 use super::*;
581
582 fn message(message_type_id: u8, payload: Vec<u8>) -> Message {
583 Message {
584 chunk_stream_id: CONTROL_CHUNK_STREAM_ID,
585 timestamp: 0,
586 message_type_id,
587 message_stream_id: CONTROL_MESSAGE_STREAM_ID,
588 payload,
589 }
590 }
591
592 #[test]
595 fn try_to_message_rejects_invalid_chunk_size() {
596 assert!(matches!(
597 ProtocolControl::SetChunkSize(0).try_to_message(),
598 Err(RtmpError::Malformed { .. })
599 ));
600 assert!(
601 ProtocolControl::SetChunkSize(0x8000_0000)
602 .try_to_message()
603 .is_err()
604 );
605 assert_eq!(
606 ProtocolControl::SetChunkSize(4096)
607 .try_to_message()
608 .unwrap(),
609 ProtocolControl::SetChunkSize(4096).to_message()
610 );
611 }
612
613 #[test]
614 fn limit_type_round_trip_and_name() {
615 for (byte, lt, name) in [
616 (0u8, LimitType::Hard, "hard"),
617 (1, LimitType::Soft, "soft"),
618 (2, LimitType::Dynamic, "dynamic"),
619 ] {
620 let parsed = LimitType::from_u8(byte).unwrap();
621 assert_eq!(parsed, lt);
622 assert_eq!(parsed.to_u8(), byte);
623 assert_eq!(parsed.name(), name);
624 assert_eq!(parsed.to_string(), name);
625 }
626 }
627
628 #[test]
629 fn limit_type_out_of_range_is_malformed() {
630 assert!(matches!(
631 LimitType::from_u8(3),
632 Err(RtmpError::Malformed { .. })
633 ));
634 }
635
636 fn protocol_control_round_trip(pc: ProtocolControl) {
639 let bytes = pc.to_bytes();
640 let parsed = ProtocolControl::from_payload(pc.message_type_id(), &bytes)
641 .unwrap()
642 .expect("known protocol control type id");
643 assert_eq!(parsed, pc);
644
645 let msg = message(pc.message_type_id(), bytes.clone());
647 let via_message = ProtocolControl::from_message(&msg).unwrap().unwrap();
648 assert_eq!(via_message, pc);
649 assert_eq!(via_message.to_bytes(), bytes);
650 }
651
652 #[test]
653 fn set_chunk_size_round_trips() {
654 protocol_control_round_trip(ProtocolControl::SetChunkSize(4096));
655 }
656
657 #[test]
658 fn abort_round_trips() {
659 protocol_control_round_trip(ProtocolControl::Abort { chunk_stream_id: 7 });
660 }
661
662 #[test]
663 fn acknowledgement_round_trips() {
664 protocol_control_round_trip(ProtocolControl::Acknowledgement(1_048_576));
665 }
666
667 #[test]
668 fn window_ack_size_round_trips() {
669 protocol_control_round_trip(ProtocolControl::WindowAckSize(2_500_000));
670 }
671
672 #[test]
673 fn set_peer_bandwidth_round_trips_every_limit_type() {
674 for limit_type in [LimitType::Hard, LimitType::Soft, LimitType::Dynamic] {
675 protocol_control_round_trip(ProtocolControl::SetPeerBandwidth {
676 ack_window_size: 2_500_000,
677 limit_type,
678 });
679 }
680 }
681
682 #[test]
683 fn set_chunk_size_reserved_top_bit_rejected_on_parse() {
684 let bytes = 0x8000_1000u32.to_be_bytes().to_vec();
685 assert!(matches!(
686 ProtocolControl::from_payload(msg_type::SET_CHUNK_SIZE, &bytes),
687 Err(RtmpError::Malformed { .. })
688 ));
689 }
690
691 #[test]
692 fn set_chunk_size_zero_rejected() {
693 let bytes = 0u32.to_be_bytes().to_vec();
694 assert!(matches!(
695 ProtocolControl::from_payload(msg_type::SET_CHUNK_SIZE, &bytes),
696 Err(RtmpError::Malformed { .. })
697 ));
698 assert!(matches!(
699 ProtocolControl::SetChunkSize(0).serialize_into(&mut [0u8; 4]),
700 Err(RtmpError::Malformed { .. })
701 ));
702 }
703
704 #[test]
705 fn set_chunk_size_serialize_layout_matches_spec() {
706 let bytes = ProtocolControl::SetChunkSize(1).to_bytes();
708 assert_eq!(bytes, vec![0x00, 0x00, 0x00, 0x01]);
709 }
710
711 #[test]
712 fn set_peer_bandwidth_serialize_layout_matches_spec() {
713 let bytes = ProtocolControl::SetPeerBandwidth {
714 ack_window_size: 0x0002_5000,
715 limit_type: LimitType::Dynamic,
716 }
717 .to_bytes();
718 assert_eq!(bytes, vec![0x00, 0x02, 0x50, 0x00, 0x02]);
719 }
720
721 #[test]
722 fn set_peer_bandwidth_wrong_limit_type_mapping_would_fail() {
723 assert_eq!(LimitType::Hard.to_u8(), 0);
725 assert_eq!(LimitType::Dynamic.to_u8(), 2);
726 assert_ne!(LimitType::Hard.to_u8(), LimitType::Dynamic.to_u8());
727 }
728
729 #[test]
730 fn from_message_none_for_non_control_type_id() {
731 let msg = message(msg_type::AUDIO, vec![0u8; 4]);
732 assert!(ProtocolControl::from_message(&msg).unwrap().is_none());
733 }
734
735 #[test]
736 fn from_message_some_for_control_type_id() {
737 let msg = message(
738 msg_type::WINDOW_ACK_SIZE,
739 1_000_000u32.to_be_bytes().to_vec(),
740 );
741 assert!(ProtocolControl::from_message(&msg).unwrap().is_some());
742 }
743
744 #[test]
745 fn to_message_uses_control_csid_and_stream_id() {
746 let msg = ProtocolControl::SetChunkSize(4096).to_message();
747 assert_eq!(msg.chunk_stream_id, CONTROL_CHUNK_STREAM_ID);
748 assert_eq!(msg.message_stream_id, CONTROL_MESSAGE_STREAM_ID);
749 assert_eq!(msg.message_type_id, msg_type::SET_CHUNK_SIZE);
750 }
751
752 #[test]
753 fn protocol_control_display_matches_name() {
754 assert_eq!(
755 ProtocolControl::Acknowledgement(1).to_string(),
756 ProtocolControl::Acknowledgement(1).name()
757 );
758 }
759
760 fn user_control_round_trip(uc: UserControl) {
763 let bytes = uc.to_bytes();
764 let parsed = UserControl::parse(&bytes).unwrap();
765 assert_eq!(parsed, uc);
766 assert_eq!(parsed.to_bytes(), bytes);
767 }
768
769 #[test]
770 fn stream_begin_round_trips() {
771 user_control_round_trip(UserControl::StreamBegin(1));
772 }
773
774 #[test]
775 fn stream_begin_serialize_layout_matches_spec() {
776 let bytes = UserControl::StreamBegin(1).to_bytes();
778 assert_eq!(bytes, vec![0x00, 0x00, 0x00, 0x00, 0x00, 0x01]);
779 }
780
781 #[test]
782 fn stream_eof_round_trips() {
783 user_control_round_trip(UserControl::StreamEof(1));
784 }
785
786 #[test]
787 fn stream_dry_round_trips() {
788 user_control_round_trip(UserControl::StreamDry(1));
789 }
790
791 #[test]
792 fn set_buffer_length_round_trips() {
793 user_control_round_trip(UserControl::SetBufferLength {
794 stream_id: 1,
795 buffer_ms: 3000,
796 });
797 }
798
799 #[test]
800 fn stream_is_recorded_round_trips() {
801 user_control_round_trip(UserControl::StreamIsRecorded(1));
802 }
803
804 #[test]
805 fn ping_request_round_trips() {
806 user_control_round_trip(UserControl::PingRequest(0x1234_5678));
807 }
808
809 #[test]
810 fn ping_response_round_trips() {
811 user_control_round_trip(UserControl::PingResponse(0x1234_5678));
812 }
813
814 #[test]
815 fn unrecognised_event_type_is_unsupported() {
816 let bytes = [0x00, 0x05, 0x00, 0x00, 0x00, 0x01];
818 assert!(matches!(
819 UserControl::parse(&bytes),
820 Err(RtmpError::Unsupported { .. })
821 ));
822 }
823
824 #[test]
825 fn user_control_event_type_wrong_mapping_would_fail() {
826 assert_eq!(UserControl::StreamBegin(0).event_type(), 0);
829 assert_eq!(UserControl::StreamEof(0).event_type(), 1);
830 }
831
832 #[test]
833 fn user_control_display_matches_name() {
834 assert_eq!(
835 UserControl::StreamBegin(1).to_string(),
836 UserControl::StreamBegin(1).name()
837 );
838 }
839
840 #[test]
841 fn to_message_uses_control_csid_and_user_control_type_id() {
842 let msg = UserControl::StreamBegin(1).to_message();
843 assert_eq!(msg.chunk_stream_id, CONTROL_CHUNK_STREAM_ID);
844 assert_eq!(msg.message_stream_id, CONTROL_MESSAGE_STREAM_ID);
845 assert_eq!(msg.message_type_id, msg_type::USER_CONTROL);
846 }
847}