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

Function PackRtmpRequest

src/brpc/policy/rtmp_protocol.cpp:3626–3669  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3624}
3625
3626void PackRtmpRequest(butil::IOBuf* /*buf*/,
3627 SocketMessage** user_message,
3628 uint64_t /*correlation_id*/,
3629 const google::protobuf::MethodDescriptor* /*NULL*/,
3630 Controller* cntl,
3631 const butil::IOBuf& /*request*/,
3632 const Authenticator*) {
3633 // Send createStream command
3634 ControllerPrivateAccessor accessor(cntl);
3635 Socket* s = accessor.get_sending_socket();
3636 RtmpContext* ctx = static_cast<RtmpContext*>(s->parsing_context());
3637 if (ctx == NULL) {
3638 cntl->SetFailed(EINVAL, "RtmpContext of %s is not created",
3639 s->description().c_str());
3640 return;
3641 }
3642 // Hack: we pass stream as response in RtmpClientStream::Create
3643 RtmpClientStream* stream = (RtmpClientStream*)cntl->response();
3644
3645 // Hack: save last transaction_id into log_id(useless here) so that we
3646 // can get it back and cancel the transaction before creating new one
3647 // (for retrying).
3648 CHECK_LT(cntl->log_id(), (uint64_t)std::numeric_limits<uint32_t>::max());
3649 uint32_t transaction_id = cntl->log_id();
3650 if (transaction_id != 0) {
3651 RtmpTransactionHandler* last_handler =
3652 ctx->RemoveTransaction(transaction_id);
3653 if (last_handler) {
3654 last_handler->Cancel();
3655 }
3656 }
3657 OnServerStreamCreated* cb = new OnServerStreamCreated(stream, cntl->call_id());
3658 if (!ctx->AddTransaction(&transaction_id, cb)) {
3659 cntl->SetFailed(EINVAL, "Fail to add transaction");
3660 delete cb;
3661 return;
3662 }
3663 cntl->set_log_id(transaction_id);
3664 RtmpCreateStreamMessage* msg = new RtmpCreateStreamMessage;
3665 s->ReAddress(&msg->socket);
3666 msg->transaction_id = transaction_id;
3667 msg->options = stream->options();
3668 *user_message = msg;
3669}
3670
3671void SerializeRtmpRequest(butil::IOBuf* /*buf*/,
3672 Controller* /*cntl*/,

Callers

nothing calls this directly

Calls 13

get_sending_socketMethod · 0.80
descriptionMethod · 0.80
responseMethod · 0.80
RemoveTransactionMethod · 0.80
call_idMethod · 0.80
AddTransactionMethod · 0.80
ReAddressMethod · 0.80
optionsMethod · 0.80
SetFailedMethod · 0.45
c_strMethod · 0.45
log_idMethod · 0.45
CancelMethod · 0.45

Tested by

no test coverage detected