| 1121 | } |
| 1122 | |
| 1123 | int Read(size_t chunk, MediaPacket& pkt, ostream & ignored SRT_ATR_UNUSED = cout) override |
| 1124 | { |
| 1125 | const int length = UdpSource::Read(chunk, pkt); |
| 1126 | |
| 1127 | if (length < 1 || !bytes_to_skip) |
| 1128 | { |
| 1129 | // something went wrong, or we're not skipping bytes for some |
| 1130 | // reason, just return the length read via the base method |
| 1131 | return length; |
| 1132 | } |
| 1133 | |
| 1134 | // we got some data and we're supposed to skip some of it |
| 1135 | // check there's enough bytes for our intended skip |
| 1136 | if (length < bytes_to_skip) |
| 1137 | { |
| 1138 | // something went wrong here |
| 1139 | cerr << "RTP packet too short (" << length |
| 1140 | << " bytes) to remove headers (needed " |
| 1141 | << bytes_to_skip << ")" << endl; |
| 1142 | throw std::runtime_error("Unexpected RTP packet length"); |
| 1143 | } |
| 1144 | |
| 1145 | pkt.payload.erase( |
| 1146 | pkt.payload.begin(), |
| 1147 | pkt.payload.begin() + bytes_to_skip |
| 1148 | ); |
| 1149 | |
| 1150 | return length - bytes_to_skip; |
| 1151 | } |
| 1152 | }; |
| 1153 | |
| 1154 | class RtpTarget : public UdpTarget { |