Remove unused code from src/frame.cc
Remove all unused (de)allocation code from src/frame.cc and remove the RTCP-related PACKED_STRUCT definitions from include/frame.hh
This commit is contained in:
		
							parent
							
								
									8f55079e62
								
							
						
					
					
						commit
						b1168d8175
					
				|  | @ -83,7 +83,7 @@ namespace uvg_rtp { | ||||||
|             sockaddr_in src_addr; |             sockaddr_in src_addr; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         PACKED_STRUCT(rtcp_header) { |         struct rtcp_header { | ||||||
|             uint8_t version; |             uint8_t version; | ||||||
|             uint8_t padding; |             uint8_t padding; | ||||||
|             union { |             union { | ||||||
|  | @ -94,7 +94,7 @@ namespace uvg_rtp { | ||||||
|             uint16_t length; |             uint16_t length; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         PACKED_STRUCT(rtcp_sender_info) { |         struct rtcp_sender_info { | ||||||
|             uint32_t ntp_msw; /* NTP timestamp, most significant word */ |             uint32_t ntp_msw; /* NTP timestamp, most significant word */ | ||||||
|             uint32_t ntp_lsw; /* NTP timestamp, least significant word */ |             uint32_t ntp_lsw; /* NTP timestamp, least significant word */ | ||||||
|             uint32_t rtp_ts;  /* RTP timestamp corresponding to same time as NTP */ |             uint32_t rtp_ts;  /* RTP timestamp corresponding to same time as NTP */ | ||||||
|  | @ -102,23 +102,16 @@ namespace uvg_rtp { | ||||||
|             uint32_t byte_cnt; |             uint32_t byte_cnt; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         PACKED_STRUCT(rtcp_report_block) { |         struct rtcp_report_block { | ||||||
|             uint32_t ssrc; |             uint32_t ssrc; | ||||||
|             uint8_t  fraction; |             uint8_t  fraction; | ||||||
|             int32_t  lost:24; |             int32_t  lost; | ||||||
|             uint32_t last_seq; |             uint32_t last_seq; | ||||||
|             uint32_t jitter; |             uint32_t jitter; | ||||||
|             uint32_t lsr;  /* last Sender Report */ |             uint32_t lsr;  /* last Sender Report */ | ||||||
|             uint32_t dlsr; /* delay since last Sender Report */ |             uint32_t dlsr; /* delay since last Sender Report */ | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         PACKED_STRUCT(rtcp_sender_frame) { |  | ||||||
|             struct rtcp_header header; |  | ||||||
|             uint32_t sender_ssrc; |  | ||||||
|             struct rtcp_sender_info s_info; |  | ||||||
|             struct rtcp_report_block blocks[1]; |  | ||||||
|         }; |  | ||||||
| 
 |  | ||||||
|         struct rtcp_receiver_report { |         struct rtcp_receiver_report { | ||||||
|             struct rtcp_header header; |             struct rtcp_header header; | ||||||
|             uint32_t ssrc; |             uint32_t ssrc; | ||||||
|  | @ -132,13 +125,7 @@ namespace uvg_rtp { | ||||||
|             std::vector<rtcp_report_block> report_blocks; |             std::vector<rtcp_report_block> report_blocks; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         PACKED_STRUCT(rtcp_receiver_frame) { |         struct rtcp_sdes_item { | ||||||
|             struct rtcp_header header; |  | ||||||
|             uint32_t sender_ssrc; |  | ||||||
|             struct rtcp_report_block blocks[1]; |  | ||||||
|         }; |  | ||||||
| 
 |  | ||||||
|         PACKED_STRUCT(rtcp_sdes_item) { |  | ||||||
|             uint8_t type; |             uint8_t type; | ||||||
|             uint8_t length; |             uint8_t length; | ||||||
|             void *data; |             void *data; | ||||||
|  | @ -157,11 +144,6 @@ namespace uvg_rtp { | ||||||
|             uint8_t *payload; |             uint8_t *payload; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         PACKED_STRUCT(rtcp_bye_frame) { |  | ||||||
|             struct rtcp_header header; |  | ||||||
|             uint32_t ssrc[1]; |  | ||||||
|         }; |  | ||||||
| 
 |  | ||||||
|         PACKED_STRUCT(zrtp_frame) { |         PACKED_STRUCT(zrtp_frame) { | ||||||
|             uint8_t version:4; |             uint8_t version:4; | ||||||
|             uint16_t unused:12; |             uint16_t unused:12; | ||||||
|  | @ -196,16 +178,6 @@ namespace uvg_rtp { | ||||||
|          *    RTP_INVALID_VALUE if "payload_size" is 0 */ |          *    RTP_INVALID_VALUE if "payload_size" is 0 */ | ||||||
|         zrtp_frame *alloc_zrtp_frame(size_t payload_size); |         zrtp_frame *alloc_zrtp_frame(size_t payload_size); | ||||||
| 
 | 
 | ||||||
|         /* Allocate various types of RTCP frames, see src/rtcp.cc for more details
 |  | ||||||
|          * |  | ||||||
|          * Return pointer to frame on success |  | ||||||
|          * Return nullptr on error and set rtp_errno to: |  | ||||||
|          *    RTP_MEMORY_ERROR if allocation of memory failed |  | ||||||
|          *    RTP_INVALID_VALUE if one of the parameters was invalid */ |  | ||||||
|         rtcp_receiver_frame *alloc_rtcp_receiver_frame(size_t nblocks); |  | ||||||
|         rtcp_sender_frame   *alloc_rtcp_sender_frame(size_t nblocks); |  | ||||||
|         rtcp_bye_frame      *alloc_rtcp_bye_frame(size_t ssrc_count); |  | ||||||
| 
 |  | ||||||
|         /* Deallocate RTP frame
 |         /* Deallocate RTP frame
 | ||||||
|          * |          * | ||||||
|          * Return RTP_OK on successs |          * Return RTP_OK on successs | ||||||
|  | @ -217,13 +189,5 @@ namespace uvg_rtp { | ||||||
|          * Return RTP_OK on successs |          * Return RTP_OK on successs | ||||||
|          * Return RTP_INVALID_VALUE if "frame" is nullptr */ |          * Return RTP_INVALID_VALUE if "frame" is nullptr */ | ||||||
|         rtp_error_t dealloc_frame(uvg_rtp::frame::zrtp_frame *frame); |         rtp_error_t dealloc_frame(uvg_rtp::frame::zrtp_frame *frame); | ||||||
| 
 |  | ||||||
|         /* Deallocate various types of RTCP frames
 |  | ||||||
|          * |  | ||||||
|          * Return RTP_OK on successs |  | ||||||
|          * Return RTP_INVALID_VALUE if "frame" is nullptr */ |  | ||||||
|         rtp_error_t dealloc_frame(rtcp_sender_frame *frame); |  | ||||||
|         rtp_error_t dealloc_frame(rtcp_receiver_frame *frame); |  | ||||||
|         rtp_error_t dealloc_frame(rtcp_bye_frame *frame); |  | ||||||
|     }; |     }; | ||||||
| }; | }; | ||||||
|  |  | ||||||
							
								
								
									
										75
									
								
								src/frame.cc
								
								
								
								
							
							
						
						
									
										75
									
								
								src/frame.cc
								
								
								
								
							|  | @ -102,78 +102,3 @@ rtp_error_t uvg_rtp::frame::dealloc_frame(uvg_rtp::frame::zrtp_frame *frame) | ||||||
|     delete[] frame; |     delete[] frame; | ||||||
|     return RTP_OK; |     return RTP_OK; | ||||||
| } | } | ||||||
| 
 |  | ||||||
| uvg_rtp::frame::rtcp_sender_frame *uvg_rtp::frame::alloc_rtcp_sender_frame(size_t nblocks) |  | ||||||
| { |  | ||||||
|     size_t total_size = |  | ||||||
|         sizeof(rtcp_header) + |  | ||||||
|         sizeof(uint32_t) + |  | ||||||
|         sizeof(rtcp_sender_info) + |  | ||||||
|         sizeof(rtcp_report_block) * nblocks; |  | ||||||
| 
 |  | ||||||
|     auto *frame = (uvg_rtp::frame::rtcp_sender_frame *)new uint8_t[total_size]; |  | ||||||
| 
 |  | ||||||
|     if (!frame) { |  | ||||||
|         LOG_ERROR("Failed to allocate memory for RTCP sender report"); |  | ||||||
|         rtp_errno = RTP_MEMORY_ERROR; |  | ||||||
|         return nullptr; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     frame->header.version  = 2; |  | ||||||
|     frame->header.padding  = 0; |  | ||||||
|     frame->header.pkt_type = uvg_rtp::frame::RTCP_FT_SR; |  | ||||||
|     frame->header.length   = total_size; |  | ||||||
|     frame->header.count    = nblocks; |  | ||||||
| 
 |  | ||||||
|     /* caller fills these */ |  | ||||||
|     memset(&frame->s_info, 0, sizeof(rtcp_sender_info)); |  | ||||||
| 
 |  | ||||||
|     if (nblocks == 0) |  | ||||||
|         memset(frame->blocks,  0, sizeof(rtcp_report_block) * nblocks); |  | ||||||
| 
 |  | ||||||
|     return frame; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| uvg_rtp::frame::rtcp_bye_frame *uvg_rtp::frame::alloc_rtcp_bye_frame(size_t ssrc_count) |  | ||||||
| { |  | ||||||
|     if (ssrc_count == 0) { |  | ||||||
|         LOG_ERROR("Cannot have 0 SSRC/CSRC!"); |  | ||||||
|         rtp_errno = RTP_INVALID_VALUE; |  | ||||||
|         return nullptr; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     size_t total_size = sizeof(rtcp_header) + sizeof(uint32_t) * ssrc_count; |  | ||||||
|     auto *frame       = (uvg_rtp::frame::rtcp_bye_frame *)new uint8_t[total_size]; |  | ||||||
| 
 |  | ||||||
|     if (!frame) { |  | ||||||
|         LOG_ERROR("Failed to allocate memory for RTCP sender report"); |  | ||||||
|         rtp_errno = RTP_MEMORY_ERROR; |  | ||||||
|         return nullptr; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     frame->header.version  = 2; |  | ||||||
|     frame->header.padding  = 0; |  | ||||||
|     frame->header.pkt_type = uvg_rtp::frame::RTCP_FT_BYE; |  | ||||||
|     frame->header.length   = total_size; |  | ||||||
|     frame->header.count    = ssrc_count; |  | ||||||
| 
 |  | ||||||
|     return frame; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| rtp_error_t uvg_rtp::frame::dealloc_frame(uvg_rtp::frame::rtcp_sender_frame *frame) |  | ||||||
| { |  | ||||||
|     if (!frame) |  | ||||||
|         return RTP_INVALID_VALUE; |  | ||||||
| 
 |  | ||||||
|     delete[] frame; |  | ||||||
|     return RTP_OK; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| rtp_error_t uvg_rtp::frame::dealloc_frame(rtcp_bye_frame *frame) |  | ||||||
| { |  | ||||||
|     if (!frame) |  | ||||||
|         return RTP_INVALID_VALUE; |  | ||||||
| 
 |  | ||||||
|     delete[] frame; |  | ||||||
|     return RTP_OK; |  | ||||||
| } |  | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue