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

Function SendC0C1

src/brpc/policy/rtmp_protocol.cpp:628–656  ·  view source on GitHub ↗

Send C0 C1 to the socket. Used in rtmp.cpp

Source from the content-addressed store, hash-verified

626// Send C0 C1 to the socket.
627// Used in rtmp.cpp
628int SendC0C1(int fd, bool* is_simple_handshake) {
629 bool done_adobe_hs = false;
630 butil::IOBuf tmp;
631 if (!FLAGS_rtmp_client_use_simple_handshake) {
632 adobe_hs::C1 c1;
633 if (c1.Generate(adobe_hs::SCHEMA1)) {
634 char buf[RTMP_HANDSHAKE_SIZE0 + RTMP_HANDSHAKE_SIZE1];
635 buf[0] = RTMP_DEFAULT_VERSION;
636 c1.Save(buf + RTMP_HANDSHAKE_SIZE0);
637 tmp.append(buf, sizeof(buf));
638 done_adobe_hs = true;
639 } else {
640 LOG(WARNING) << "Fail to generate C1, use simple handshaking";
641 }
642 }
643 if (is_simple_handshake) {
644 *is_simple_handshake = !done_adobe_hs;
645 }
646 if (!done_adobe_hs) {
647 char buf[9];
648 char* p = buf;
649 *p++ = RTMP_DEFAULT_VERSION; // c0 (version)
650 WriteBigEndian4Bytes(&p, GetRtmpTimestamp()); // c1.time
651 WriteBigEndian4Bytes(&p, 0); // c1.zero
652 tmp.append(buf, sizeof(buf));
653 tmp.append(GetRtmpHandshakeClientRandom());
654 }
655 return WriteAll(fd, &tmp);
656}
657
658const char* RtmpContext::state2str(State s) {
659 switch (s) {

Callers 1

StartConnectMethod · 0.85

Calls 6

WriteBigEndian4BytesFunction · 0.85
GetRtmpTimestampFunction · 0.85
WriteAllFunction · 0.85
SaveMethod · 0.80
GenerateMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected