| 3624 | } |
| 3625 | |
| 3626 | void 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 | |
| 3671 | void SerializeRtmpRequest(butil::IOBuf* /*buf*/, |
| 3672 | Controller* /*cntl*/, |
nothing calls this directly
no test coverage detected