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

Method OnResult

src/brpc/policy/rtmp_protocol.cpp:2471–2513  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2469}
2470
2471bool RtmpChunkStream::OnResult(const RtmpMessageHeader& mh,
2472 AMFInputStream* istream, Socket* socket) {
2473 uint32_t transaction_id = 0;
2474 if (!ReadAMFUint32(&transaction_id, istream)) {
2475 RTMP_ERROR(socket, mh) << "Fail to read _result.TransactionId";
2476 return false;
2477 }
2478 if (transaction_id < 2) {
2479 if (transaction_id == 1) {
2480 RtmpConnectResponse connect_res;
2481 if (!ReadAMFObject(&connect_res, istream)) {
2482 RTMP_ERROR(socket, mh) << "Fail to read _result.Properties";
2483 return false;
2484 }
2485 if (!_conn_ctx->_simplified_rtmp) {
2486 // In simplified rtmp case, connection_context()->_create_stream_with_play_or_publish
2487 // is set and OnConnected is called in RtmpConnect::StartConnect, so we don't need
2488 // to do these operations again here.
2489 if (connect_res.create_stream_with_play_or_publish()) {
2490 connection_context()->_create_stream_with_play_or_publish = true;
2491 }
2492 connection_context()->OnConnected(0);
2493 } else {
2494 CHECK(connect_res.create_stream_with_play_or_publish());
2495 }
2496 } // else nothing to do with transaction_id=0
2497 return true;
2498 }
2499 if (connection_context()->unconnected()) {
2500 RTMP_ERROR(socket, mh) << "Received _result.TransactionId="
2501 << transaction_id << " before connected";
2502 }
2503 RtmpContext* ctx = static_cast<RtmpContext*>(socket->parsing_context());
2504 RtmpTransactionHandler* handler = ctx->RemoveTransaction(transaction_id);
2505 if (handler == NULL) {
2506 RTMP_WARNING(socket, mh) << "Unknown _result.TransactionId="
2507 << transaction_id;
2508 return false;
2509 }
2510 // TODO: Should Run return bool?
2511 handler->Run(false, mh, istream, socket);
2512 return true;
2513}
2514
2515bool RtmpChunkStream::OnError(const RtmpMessageHeader& mh,
2516 AMFInputStream* istream,

Callers

nothing calls this directly

Calls 6

ReadAMFUint32Function · 0.85
ReadAMFObjectFunction · 0.85
OnConnectedMethod · 0.80
unconnectedMethod · 0.80
RemoveTransactionMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected