Changeset 727
- Timestamp:
- 01/19/12 14:38:18 (4 months ago)
- Files:
-
- 6 edited
-
branches/1.0/sources/thelib/include/protocols/rtmp/streaming/outnetrtmp4tsstream.h (modified) (1 diff)
-
branches/1.0/sources/thelib/src/protocols/rtmp/streaming/outnetrtmp4tsstream.cpp (modified) (3 diffs)
-
branches/1.0/sources/thelib/src/protocols/rtp/streaming/innetrtpstream.cpp (modified) (4 diffs)
-
trunk/sources/thelib/include/protocols/rtmp/streaming/outnetrtmp4tsstream.h (modified) (1 diff)
-
trunk/sources/thelib/src/protocols/rtmp/streaming/outnetrtmp4tsstream.cpp (modified) (3 diffs)
-
trunk/sources/thelib/src/protocols/rtp/streaming/innetrtpstream.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.0/sources/thelib/include/protocols/rtmp/streaming/outnetrtmp4tsstream.h
r668 r727 36 36 IOBuffer _videoBuffer; 37 37 bool _inboundStreamIsRTP; 38 double _lastVideoTimestamp; 39 bool _isKeyFrame; 38 40 public: 39 41 OutNetRTMP4TSStream(BaseProtocol *pProtocol, StreamsManager *pStreamsManager, -
branches/1.0/sources/thelib/src/protocols/rtmp/streaming/outnetrtmp4tsstream.cpp
r725 r727 50 50 51 51 _inboundStreamIsRTP = false; 52 _lastVideoTimestamp = -1; 53 _isKeyFrame = false; 52 54 } 53 55 … … 210 212 default: 211 213 { 214 //1. Create timestamp reference 215 if (_lastVideoTimestamp < 0) 216 _lastVideoTimestamp = absoluteTimestamp; 217 218 //2. Send over the accumulated stuff if this is a new packet from a 219 //brand new sequence of packets 220 if (_lastVideoTimestamp != absoluteTimestamp) { 221 if (!BaseOutNetRTMPStream::FeedData( 222 GETIBPOINTER(_videoBuffer), //pData 223 GETAVAILABLEBYTESCOUNT(_videoBuffer), //dataLength 224 0, //processedLength 225 GETAVAILABLEBYTESCOUNT(_videoBuffer), //totalLength 226 _lastVideoTimestamp, //absoluteTimestamp 227 false //isAudio 228 )) { 229 FATAL("Unable to send video"); 230 return false; 231 } 232 _videoBuffer.IgnoreAll(); 233 _isKeyFrame = false; 234 } 235 _lastVideoTimestamp = absoluteTimestamp; 236 212 237 uint8_t *pTemp = NULL; 213 238 … … 233 258 234 259 //setup the frame type 235 if (NALU_TYPE(pData[0]) == NALU_TYPE_IDR) {236 //FINEST("HERE");260 _isKeyFrame |= (nalType == NALU_TYPE_IDR); 261 if (_isKeyFrame) { 237 262 GETIBPOINTER(_videoBuffer)[0] = 0x17; 238 263 } else { 239 //FINEST("HERE");240 264 GETIBPOINTER(_videoBuffer)[0] = 0x27; 241 265 } 242 266 } 243 267 244 //break if this is not a M bit on a RTSP 245 if (_inboundStreamIsRTP) { 246 if ((*(pData - 1)) == 0) { 247 //check the size of _videoBuffer and watch out for HUGE frames 248 if (GETAVAILABLEBYTESCOUNT(_videoBuffer) >= 4 * 1024 * 1024) { 249 WARN("Big video frame. Discard it"); 250 _videoBuffer.IgnoreAll(); 251 } 252 return true; 253 } 254 } 255 256 if (GETAVAILABLEBYTESCOUNT(_videoBuffer) > 5) { 257 //checkData(_videoBuffer); 258 259 //send the data 260 if (!BaseOutNetRTMPStream::FeedData( 261 GETIBPOINTER(_videoBuffer), //pData 262 GETAVAILABLEBYTESCOUNT(_videoBuffer), //dataLength 263 0, //processedLength 264 GETAVAILABLEBYTESCOUNT(_videoBuffer), //totalLength 265 absoluteTimestamp, //absoluteTimestamp 266 false //isAudio 267 )) { 268 FATAL("Unable to send video"); 269 return false; 270 } 271 } 272 273 //cleanup 274 _videoBuffer.IgnoreAll(); 268 //6. make sure the packet doesn't grow too big 269 if (GETAVAILABLEBYTESCOUNT(_videoBuffer) >= 4 * 1024 * 1024) { 270 WARN("Big video frame. Discard it"); 271 _videoBuffer.IgnoreAll(); 272 _isKeyFrame = false; 273 _lastVideoTimestamp = -1; 274 } 275 275 276 276 //done -
branches/1.0/sources/thelib/src/protocols/rtp/streaming/innetrtpstream.cpp
r725 r727 312 312 _videoPacketsCount++; 313 313 _videoBytesCount += dataLength; 314 *(pData - 1) = GET_RTP_M(rtpHeader);315 314 return FeedData(pData, dataLength, 0, dataLength, ts, false); 316 315 } else if (naluType == NALU_TYPE_FUA) { … … 325 324 } 326 325 pData[1] = (pData[0]&0xe0) | (pData[1]&0x1f); 327 _currentNalu.ReadFromByte(0);328 326 _currentNalu.ReadFromBuffer(pData + 1, dataLength - 1); 329 327 return true; … … 335 333 _videoPacketsCount++; 336 334 _videoBytesCount += GETAVAILABLEBYTESCOUNT(_currentNalu); 337 GETIBPOINTER(_currentNalu)[0] = GET_RTP_M(rtpHeader);338 if (!FeedData(GETIBPOINTER(_currentNalu) + 1,339 GETAVAILABLEBYTESCOUNT(_currentNalu) - 1,0,340 GETAVAILABLEBYTESCOUNT(_currentNalu) - 1,335 if (!FeedData(GETIBPOINTER(_currentNalu), 336 GETAVAILABLEBYTESCOUNT(_currentNalu), 337 0, 338 GETAVAILABLEBYTESCOUNT(_currentNalu), 341 339 ts, 342 340 false)) { … … 361 359 _videoPacketsCount++; 362 360 _videoBytesCount += length; 363 if (index + length >= dataLength) {364 *(pData + index - 1) = 1;365 } else {366 *(pData + index - 1) = 0;367 }368 361 if (!FeedData(pData + index, 369 362 length, 0, -
trunk/sources/thelib/include/protocols/rtmp/streaming/outnetrtmp4tsstream.h
r722 r727 36 36 IOBuffer _videoBuffer; 37 37 bool _inboundStreamIsRTP; 38 double _lastVideoTimestamp; 39 bool _isKeyFrame; 38 40 public: 39 41 OutNetRTMP4TSStream(BaseRTMPProtocol *pProtocol, StreamsManager *pStreamsManager, -
trunk/sources/thelib/src/protocols/rtmp/streaming/outnetrtmp4tsstream.cpp
r725 r727 50 50 51 51 _inboundStreamIsRTP = false; 52 _lastVideoTimestamp = -1; 53 _isKeyFrame = false; 52 54 } 53 55 … … 210 212 default: 211 213 { 214 //1. Create timestamp reference 215 if (_lastVideoTimestamp < 0) 216 _lastVideoTimestamp = absoluteTimestamp; 217 218 //2. Send over the accumulated stuff if this is a new packet from a 219 //brand new sequence of packets 220 if (_lastVideoTimestamp != absoluteTimestamp) { 221 if (!BaseOutNetRTMPStream::FeedData( 222 GETIBPOINTER(_videoBuffer), //pData 223 GETAVAILABLEBYTESCOUNT(_videoBuffer), //dataLength 224 0, //processedLength 225 GETAVAILABLEBYTESCOUNT(_videoBuffer), //totalLength 226 _lastVideoTimestamp, //absoluteTimestamp 227 false //isAudio 228 )) { 229 FATAL("Unable to send video"); 230 return false; 231 } 232 _videoBuffer.IgnoreAll(); 233 _isKeyFrame = false; 234 } 235 _lastVideoTimestamp = absoluteTimestamp; 236 212 237 uint8_t *pTemp = NULL; 213 238 … … 233 258 234 259 //setup the frame type 235 if (NALU_TYPE(pData[0]) == NALU_TYPE_IDR) {236 //FINEST("HERE");260 _isKeyFrame |= (nalType == NALU_TYPE_IDR); 261 if (_isKeyFrame) { 237 262 GETIBPOINTER(_videoBuffer)[0] = 0x17; 238 263 } else { 239 //FINEST("HERE");240 264 GETIBPOINTER(_videoBuffer)[0] = 0x27; 241 265 } 242 266 } 243 267 244 //break if this is not a M bit on a RTSP 245 if (_inboundStreamIsRTP) { 246 if ((*(pData - 1)) == 0) { 247 //check the size of _videoBuffer and watch out for HUGE frames 248 if (GETAVAILABLEBYTESCOUNT(_videoBuffer) >= 4 * 1024 * 1024) { 249 WARN("Big video frame. Discard it"); 250 _videoBuffer.IgnoreAll(); 251 } 252 return true; 253 } 254 } 255 256 if (GETAVAILABLEBYTESCOUNT(_videoBuffer) > 5) { 257 //checkData(_videoBuffer); 258 259 //send the data 260 if (!BaseOutNetRTMPStream::FeedData( 261 GETIBPOINTER(_videoBuffer), //pData 262 GETAVAILABLEBYTESCOUNT(_videoBuffer), //dataLength 263 0, //processedLength 264 GETAVAILABLEBYTESCOUNT(_videoBuffer), //totalLength 265 absoluteTimestamp, //absoluteTimestamp 266 false //isAudio 267 )) { 268 FATAL("Unable to send video"); 269 return false; 270 } 271 } 272 273 //cleanup 274 _videoBuffer.IgnoreAll(); 268 //6. make sure the packet doesn't grow too big 269 if (GETAVAILABLEBYTESCOUNT(_videoBuffer) >= 4 * 1024 * 1024) { 270 WARN("Big video frame. Discard it"); 271 _videoBuffer.IgnoreAll(); 272 _isKeyFrame = false; 273 _lastVideoTimestamp = -1; 274 } 275 275 276 276 //done -
trunk/sources/thelib/src/protocols/rtp/streaming/innetrtpstream.cpp
r725 r727 312 312 _videoPacketsCount++; 313 313 _videoBytesCount += dataLength; 314 *(pData - 1) = GET_RTP_M(rtpHeader);315 314 return FeedData(pData, dataLength, 0, dataLength, ts, false); 316 315 } else if (naluType == NALU_TYPE_FUA) { … … 325 324 } 326 325 pData[1] = (pData[0]&0xe0) | (pData[1]&0x1f); 327 _currentNalu.ReadFromByte(0);328 326 _currentNalu.ReadFromBuffer(pData + 1, dataLength - 1); 329 327 return true; … … 335 333 _videoPacketsCount++; 336 334 _videoBytesCount += GETAVAILABLEBYTESCOUNT(_currentNalu); 337 GETIBPOINTER(_currentNalu)[0] = GET_RTP_M(rtpHeader);338 if (!FeedData(GETIBPOINTER(_currentNalu) + 1,339 GETAVAILABLEBYTESCOUNT(_currentNalu) - 1,0,340 GETAVAILABLEBYTESCOUNT(_currentNalu) - 1,335 if (!FeedData(GETIBPOINTER(_currentNalu), 336 GETAVAILABLEBYTESCOUNT(_currentNalu), 337 0, 338 GETAVAILABLEBYTESCOUNT(_currentNalu), 341 339 ts, 342 340 false)) { … … 361 359 _videoPacketsCount++; 362 360 _videoBytesCount += length; 363 if (index + length >= dataLength) {364 *(pData + index - 1) = 1;365 } else {366 *(pData + index - 1) = 0;367 }368 361 if (!FeedData(pData + index, 369 362 length, 0,
Note: See TracChangeset
for help on using the changeset viewer.
