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

Function ParseRtmpMessage

src/brpc/policy/rtmp_protocol.cpp:3426–3461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3424}
3425
3426ParseResult ParseRtmpMessage(butil::IOBuf* source, Socket *socket, bool read_eof,
3427 const void* arg) {
3428 RtmpContext* rtmp_ctx = static_cast<RtmpContext*>(socket->parsing_context());
3429 if (rtmp_ctx == NULL) {
3430 if (arg == NULL) {
3431 // We are probably parsing another client-side protocol.
3432 return MakeParseError(PARSE_ERROR_TRY_OTHERS);
3433 }
3434 const Server* server = static_cast<const Server*>(arg);
3435 RtmpService* service = server->options().rtmp_service;
3436 if (service == NULL) {
3437 // Validating RTMP protocol only checks the first byte, which
3438 // is very easy to be confused with other protocols. Currently
3439 // if rtmp_service is not set, the protocol is skipped w/o any
3440 // warning. We'll register the protocol on demand in later CI
3441 // to avoid the confusion from root.
3442 return MakeParseError(PARSE_ERROR_TRY_OTHERS);
3443 }
3444 if (read_eof) {
3445 // No former RtmpContext when we read an EOF
3446 return MakeParseError(PARSE_ERROR_NOT_ENOUGH_DATA);
3447 }
3448 const ParseResult r = IsPossiblyRtmp(source);
3449 if (!r.is_ok()) {
3450 return r;
3451 }
3452 rtmp_ctx = new (std::nothrow) RtmpContext(NULL, server);
3453 if (rtmp_ctx == NULL) {
3454 LOG(FATAL) << "Fail to new RtmpContext";
3455 return MakeParseError(PARSE_ERROR_NO_RESOURCE);
3456 }
3457 socket->reset_parsing_context(rtmp_ctx);
3458 // We don't need to customize app_connect at server-side.
3459 }
3460 return rtmp_ctx->Feed(source, socket);
3461}
3462
3463void ProcessRtmpMessage(InputMessageBase*) {
3464 CHECK(false) << "Should never be called";

Callers

nothing calls this directly

Calls 6

MakeParseErrorFunction · 0.85
IsPossiblyRtmpFunction · 0.85
optionsMethod · 0.80
reset_parsing_contextMethod · 0.80
FeedMethod · 0.80
is_okMethod · 0.45

Tested by

no test coverage detected