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

Method Read

src/brpc/rtmp.cpp:228–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228butil::Status FlvReader::Read(RtmpVideoMessage* msg) {
229 char tags[11];
230 const unsigned char* p = (const unsigned char*)_buf->fetch(tags, sizeof(tags));
231 if (p == NULL) {
232 return butil::Status(EAGAIN, "Fail to read, not enough data");
233 }
234 if (*p != FLV_TAG_VIDEO) {
235 return butil::Status(EINVAL, "Fail to parse RtmpVideoMessage");
236 }
237 uint32_t msg_size = policy::ReadBigEndian3Bytes(p + 1);
238 uint32_t timestamp = policy::ReadBigEndian3Bytes(p + 4);
239 timestamp |= (*(p + 7) << 24);
240 if (_buf->length() < 11 + msg_size + 4/*PreviousTagSize*/) {
241 return butil::Status(EAGAIN, "Fail to read, not enough data");
242 }
243 _buf->pop_front(11);
244 char first_byte = 0;
245 CHECK(_buf->cut1(&first_byte));
246 msg->timestamp = timestamp;
247 msg->frame_type = (FlvVideoFrameType)((first_byte >> 4) & 0xF);
248 msg->codec = (FlvVideoCodec)(first_byte & 0xF);
249 // TODO(zhujiashun): check the validation of frame_type and codec
250 _buf->cutn(&msg->data, msg_size - 1);
251 _buf->pop_front(4/* PreviousTagSize0 */);
252
253 return butil::Status::OK();
254}
255
256butil::Status FlvReader::Read(RtmpAudioMessage* msg) {
257 char tags[11];

Callers 15

DBDBthreadFunction · 0.45
DBDMultiBthreadFunction · 0.45
read_dbdFunction · 0.45
TESTFunction · 0.45
PickEndpointForKeyMethod · 0.45
WeightMethod · 0.45
SelectServerMethod · 0.45
DescribeMethod · 0.45
SelectServerMethod · 0.45
DescribeMethod · 0.45

Calls 9

ReadBigEndian3BytesFunction · 0.85
ReadAMFStringFunction · 0.85
ReadAMFObjectFunction · 0.85
fetchMethod · 0.80
StatusEnum · 0.70
lengthMethod · 0.45
pop_frontMethod · 0.45
cut1Method · 0.45
cutnMethod · 0.45

Tested by 5

DBDBthreadFunction · 0.36
DBDMultiBthreadFunction · 0.36
read_dbdFunction · 0.36
TESTFunction · 0.36