MCPcopy Create free account
hub / github.com/apache/brpc / WriteBasicHeader

Function WriteBasicHeader

src/brpc/policy/rtmp_protocol.cpp:579–597  ·  view source on GitHub ↗

Write a basic header into buf and forward the buf.

Source from the content-addressed store, hash-verified

577
578// Write a basic header into buf and forward the buf.
579static void
580WriteBasicHeader(char** buf, RtmpChunkType chunk_type, uint32_t cs_id) {
581 char* out = *buf;
582 if (cs_id < 2) {
583 CHECK(false) << "Reserved chunk_stream_id=" << cs_id;
584 } else if (cs_id <= 63) {
585 *out++ = (((uint32_t)chunk_type << 6) | cs_id);
586 } else if (cs_id <= 319) {
587 *out++ = ((uint32_t)chunk_type << 6);
588 *out++ = cs_id - 64;
589 } else if (cs_id <= RTMP_MAX_CHUNK_STREAM_ID) {
590 *out++ = (((uint32_t)chunk_type << 6) | 1);
591 *out++ = (cs_id - 64) & 0xFF;
592 *out++ = ((cs_id - 64) >> 8);
593 } else {
594 CHECK(false) << "Invalid chunk_stream_id=" << cs_id;
595 }
596 *buf = out;
597}
598
599// Write all data in *buf into fd.
600// Returns 0 on success, -1 otherwise.

Callers 1

SerializeMessageMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected