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

Method StartConnect

src/brpc/rtmp.cpp:1038–1072  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1036};
1037
1038void RtmpConnect::StartConnect(
1039 const Socket* s, void (*done)(int, void*), void* data) {
1040 RPC_VLOG << "Establish rtmp-level connection on " << *s;
1041 policy::RtmpContext* ctx =
1042 static_cast<policy::RtmpContext*>(s->parsing_context());
1043 if (ctx == NULL) {
1044 LOG(FATAL) << "RtmpContext of " << *s << " is NULL";
1045 return done(EINVAL, data);
1046 }
1047
1048 const RtmpClientOptions* _client_options = ctx->client_options();
1049 if (_client_options && _client_options->simplified_rtmp) {
1050 ctx->set_simplified_rtmp(true);
1051 if (ctx->SendConnectRequest(s->remote_side(), s->fd(), true) != 0) {
1052 LOG(ERROR) << s->remote_side() << ": Fail to send simple connect";
1053 return done(EINVAL, data);
1054 }
1055 ctx->SetState(s->remote_side(), policy::RtmpContext::STATE_RECEIVED_S2);
1056 ctx->set_create_stream_with_play_or_publish(true);
1057 return done(0, data);
1058 }
1059
1060 // Save to callback to call when RTMP connect is done.
1061 ctx->SetConnectCallback(done, data);
1062
1063 // Initiate the rtmp handshake.
1064 bool is_simple_handshake = false;
1065 if (policy::SendC0C1(s->fd(), &is_simple_handshake) != 0) {
1066 LOG(ERROR) << s->remote_side() << ": Fail to send C0 C1";
1067 return done(EINVAL, data);
1068 }
1069 if (is_simple_handshake) {
1070 ctx->only_check_simple_s0s1();
1071 }
1072}
1073
1074void RtmpConnect::StopConnect(Socket* s) {
1075 policy::RtmpContext* ctx =

Callers 1

Calls 10

SendC0C1Function · 0.85
client_optionsMethod · 0.80
set_simplified_rtmpMethod · 0.80
SendConnectRequestMethod · 0.80
SetConnectCallbackMethod · 0.80
remote_sideMethod · 0.45
fdMethod · 0.45
SetStateMethod · 0.45

Tested by

no test coverage detected