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

Method ReadHeader

src/brpc/rtmp.cpp:188–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186}
187
188butil::Status FlvReader::ReadHeader() {
189 if (!_read_header) {
190 // 9 is the size of FlvHeader, which is usually composed of
191 // { 'F', 'L', 'V', 0x01, 0x05, 0, 0, 0, 0x09 }.
192 char header_buf[9 + 4/* PreviousTagSize0 */];
193 const char* p = (const char*)_buf->fetch(header_buf, sizeof(header_buf));
194 if (p == NULL) {
195 return butil::Status(EAGAIN, "Fail to read, not enough data");
196 }
197 const char flv_header_signature[3] = { 'F', 'L', 'V' };
198 if (memcmp(p, flv_header_signature, sizeof(flv_header_signature)) != 0) {
199 LOG(FATAL) << "Fail to parse FLV header";
200 return butil::Status(EINVAL, "Fail to parse FLV header");
201 }
202 _buf->pop_front(sizeof(header_buf));
203 _read_header = true;
204 }
205 return butil::Status::OK();
206}
207
208butil::Status FlvReader::PeekMessageType(FlvTagType* type_out) {
209 butil::Status st = ReadHeader();

Callers

nothing calls this directly

Calls 3

fetchMethod · 0.80
StatusEnum · 0.70
pop_frontMethod · 0.45

Tested by

no test coverage detected