Ticket #4515: 4515-bradley-v1.patch
File 4515-bradley-v1.patch, 5.6 KB (added by , 16 years ago) |
---|
-
libs/libmythtv/dvbrecorder.cpp
491 491 _buffer_packets = !FindMPEG2Keyframes(&tspacket); 492 492 } 493 493 494 return Process TSPacket(tspacket);494 return ProcessAVTSPacket(tspacket); 495 495 } 496 496 497 497 bool DVBRecorder::ProcessAudioTSPacket(const TSPacket &tspacket) 498 498 { 499 499 _buffer_packets = !FindAudioKeyframes(&tspacket); 500 return Process TSPacket(tspacket);500 return ProcessAVTSPacket(tspacket); 501 501 } 502 502 503 bool DVBRecorder::ProcessTSPacket(const TSPacket &tspacket) 503 /// Common code for processing both audio and video packets 504 bool DVBRecorder::ProcessAVTSPacket(const TSPacket &tspacket) 504 505 { 505 506 const uint pid = tspacket.PID(); 506 507 … … 513 514 } 514 515 515 516 // Sync recording start to first keyframe 517 // (Delay's until first GOP to avoid decoder crash on res change) 516 518 if (_wait_for_keyframe_option && _first_keyframe < 0) 517 519 return true; 518 520 … … 529 531 _pid_status[pid] |= kPayloadStartSeen; 530 532 } 531 533 534 return ProcessTSPacketCommon(tspacket); 535 } 536 537 bool DVBRecorder::ProcessTSPacket(const TSPacket &tspacket) 538 { 539 _buffer_packets = !FindOtherKeyframes(&tspacket); 540 return ProcessTSPacketCommon(tspacket); 541 } 542 543 bool DVBRecorder::ProcessTSPacketCommon(const TSPacket &tspacket) 544 { 545 // Care must be taken to make sure that the packet actually gets written 546 // as the decision to actually write it has already been made 547 const uint pid = tspacket.PID(); 548 549 // Check continuity counter 550 if ((pid != 0x1fff) && !CheckCC(pid, tspacket.ContinuityCounter())) 551 { 552 VERBOSE(VB_RECORD, LOC + 553 QString("PID 0x%1 discontinuity detected").arg(pid,0,16)); 554 _continuity_error_count++; 555 } 556 532 557 BufferedWrite(tspacket); 533 558 534 559 return true; 535 560 } 561 562 void DVBRecorder::BufferedWrite(const TSPacket &tspacket) 563 { 564 // Care must be taken to make sure that the packet actually gets written 565 // as the decision to actually write it has already been made 566 567 // Do we have to buffer the packet for exact keyframe detection? 568 if (_buffer_packets) 569 { 570 int idx = _payload_buffer.size(); 571 _payload_buffer.resize(idx + TSPacket::SIZE); 572 memcpy(&_payload_buffer[idx], tspacket.data(), TSPacket::SIZE); 573 return; 574 } 575 576 // We are free to write the packet, but if we have buffered packet[s] 577 // we have to write them first... 578 if (!_payload_buffer.empty()) 579 { 580 if (ringBuffer) 581 ringBuffer->Write(&_payload_buffer[0], _payload_buffer.size()); 582 _payload_buffer.clear(); 583 } 584 585 if (ringBuffer) 586 ringBuffer->Write(tspacket.data(), TSPacket::SIZE); 587 } -
libs/libmythtv/dvbrecorder.h
64 64 bool IsOpen(void) const { return _stream_fd >= 0; } 65 65 void Close(void); 66 66 67 // Methods to handle MHEG, when there are no A/V streams 68 bool ProcessAVTSPacket(const TSPacket &tspacket); 69 bool ProcessTSPacketCommon(const TSPacket &tspacket); 70 void BufferedWrite(const TSPacket &tspacket); 71 72 // MPEG Stream Listener 67 73 void HandlePAT(const ProgramAssociationTable*); 68 74 void HandleCAT(const ConditionalAccessTable*) {} 69 75 void HandlePMT(uint pid, const ProgramMapTable*); -
libs/libmythtv/dtvrecorder.h
65 65 bool FindH264Keyframes(const TSPacket* tspacket); 66 66 void HandleH264Keyframe(void); 67 67 68 // MHEG no A/V support 69 bool FindOtherKeyframes(const TSPacket *tspacket); 70 68 71 // file handle for stream 69 72 int _stream_fd; 70 73 … … 77 80 unsigned long long _last_gop_seen; 78 81 unsigned long long _last_seq_seen; 79 82 unsigned long long _last_keyframe_seen; 83 bool _has_written_mheg_keyframe; 80 84 81 85 // H.264 support 82 86 bool _pes_synced; -
libs/libmythtv/dtvrecorder.cpp
38 38 // used for scanning pes headers for keyframes 39 39 _start_code(0xffffffff), _first_keyframe(-1), 40 40 _last_gop_seen(0), _last_seq_seen(0), 41 _last_keyframe_seen(0), 41 _last_keyframe_seen(0), _has_written_mheg_keyframe(false), 42 42 // H.264 support 43 43 _pes_synced(false), 44 44 _seen_sps(false), … … 146 146 147 147 //_start_code 148 148 _first_keyframe =-1; 149 _has_written_mheg_keyframe = false; 149 150 _last_keyframe_seen = 0; 150 151 _last_gop_seen = 0; 151 152 _last_seq_seen = 0; … … 344 345 return hasKeyFrame; 345 346 } 346 347 348 /** \brief This creates a fake keyframe for MHEG only streams. 349 * 350 * This is for MHEG streams which contain no audio or video streams 351 * We write just one key-frame at the start so that the frontend 352 * can jump to the start of the stream. 353 */ 354 bool DTVRecorder::FindOtherKeyframes(const TSPacket *tspacket) 355 { 356 if (_has_written_mheg_keyframe) 357 return true; 358 359 _frames_seen_count++; 360 _frames_written_count++; 361 _last_keyframe_seen = _frames_seen_count; 362 HandleKeyframe(); 363 364 _has_written_mheg_keyframe = true; 365 366 return true; 367 } 368 347 369 // documented in recorderbase.h 348 370 void DTVRecorder::SetNextRecording(const ProgramInfo *progInf, RingBuffer *rb) 349 371 {