| 741 | } |
| 742 | |
| 743 | RtmpContext::~RtmpContext() { |
| 744 | if (!_mstream_map.empty()) { |
| 745 | size_t ncstream = 0; |
| 746 | size_t nsstream = 0; |
| 747 | for (butil::FlatMap<uint32_t, MessageStreamInfo>::iterator |
| 748 | it = _mstream_map.begin(); it != _mstream_map.end(); ++it) { |
| 749 | if (it->second.stream->is_server_stream()) { |
| 750 | ++nsstream; |
| 751 | } else { |
| 752 | ++ncstream; |
| 753 | } |
| 754 | } |
| 755 | _mstream_map.clear(); |
| 756 | LOG(FATAL) << "RtmpContext=" << this << " is deallocated" |
| 757 | " before all streams(" << ncstream << " client, " << nsstream |
| 758 | << "server) on the connection quit"; |
| 759 | } |
| 760 | |
| 761 | // cancel incomplete transactions |
| 762 | for (butil::FlatMap<uint32_t, RtmpTransactionHandler*>::iterator |
| 763 | it = _trans_map.begin(); it != _trans_map.end(); ++it) { |
| 764 | if (it->second) { |
| 765 | it->second->Cancel(); |
| 766 | } |
| 767 | } |
| 768 | _trans_map.clear(); |
| 769 | |
| 770 | // Delete chunk streams |
| 771 | for (size_t i = 0; i < RTMP_CHUNK_ARRAY_1ST_SIZE; ++i) { |
| 772 | SubChunkArray* p = _cstream_ctx[i].load(butil::memory_order_relaxed); |
| 773 | if (p) { |
| 774 | _cstream_ctx[i].store(NULL, butil::memory_order_relaxed); |
| 775 | delete p; |
| 776 | } |
| 777 | } |
| 778 | |
| 779 | free(_s1_digest); |
| 780 | _s1_digest = NULL; |
| 781 | } |
| 782 | |
| 783 | void RtmpContext::Destroy() { |
| 784 | delete this; |