Send C0 C1 to the socket. Used in rtmp.cpp
| 626 | // Send C0 C1 to the socket. |
| 627 | // Used in rtmp.cpp |
| 628 | int 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 | |
| 658 | const char* RtmpContext::state2str(State s) { |
| 659 | switch (s) { |
no test coverage detected