| 68 | } |
| 69 | |
| 70 | butil::Status FlvWriter::Write(const RtmpVideoMessage& msg) { |
| 71 | char buf[32]; |
| 72 | char* p = buf; |
| 73 | if (!_write_header) { |
| 74 | _write_header = true; |
| 75 | const char flags_bit = static_cast<char>(_options.flv_content_type); |
| 76 | const char header[9] = { 'F', 'L', 'V', 0x01, flags_bit, 0, 0, 0, 0x09 }; |
| 77 | memcpy(p, header, sizeof(header)); |
| 78 | p += sizeof(header); |
| 79 | policy::WriteBigEndian4Bytes(&p, 0); // PreviousTagSize0 |
| 80 | } |
| 81 | // FLV tag |
| 82 | *p++ = FLV_TAG_VIDEO; |
| 83 | policy::WriteBigEndian3Bytes(&p, msg.size()); |
| 84 | policy::WriteBigEndian3Bytes(&p, (msg.timestamp & 0xFFFFFF)); |
| 85 | *p++ = (msg.timestamp >> 24) & 0xFF; |
| 86 | policy::WriteBigEndian3Bytes(&p, 0); // StreamID |
| 87 | // header of VIDEODATA |
| 88 | *p++ = ((msg.frame_type & 0xF) << 4) | (msg.codec & 0xF); |
| 89 | _buf->append(buf, p - buf); |
| 90 | _buf->append(msg.data); |
| 91 | // PreviousTagSize |
| 92 | p = buf; |
| 93 | policy::WriteBigEndian4Bytes(&p, 11 + msg.size()); |
| 94 | _buf->append(buf, p - buf); |
| 95 | return butil::Status::OK(); |
| 96 | } |
| 97 | |
| 98 | butil::Status FlvWriter::Write(const RtmpAudioMessage& msg) { |
| 99 | char buf[32]; |
no test coverage detected