Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: media/formats/mp2t/mp2t_stream_parser.cc

Issue 364823008: Mpeg2TS - estimate duration for video frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/formats/mp2t/mp2t_stream_parser.h" 5 #include "media/formats/mp2t/mp2t_stream_parser.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 scoped_refptr<StreamParserBuffer> stream_parser_buffer) { 498 scoped_refptr<StreamParserBuffer> stream_parser_buffer) {
499 DCHECK_EQ(pes_pid, selected_audio_pid_); 499 DCHECK_EQ(pes_pid, selected_audio_pid_);
500 500
501 DVLOG(LOG_LEVEL_ES) 501 DVLOG(LOG_LEVEL_ES)
502 << "OnEmitAudioBuffer: " 502 << "OnEmitAudioBuffer: "
503 << " size=" 503 << " size="
504 << stream_parser_buffer->data_size() 504 << stream_parser_buffer->data_size()
505 << " dts=" 505 << " dts="
506 << stream_parser_buffer->GetDecodeTimestamp().InMilliseconds() 506 << stream_parser_buffer->GetDecodeTimestamp().InMilliseconds()
507 << " pts=" 507 << " pts="
508 << stream_parser_buffer->timestamp().InMilliseconds(); 508 << stream_parser_buffer->timestamp().InMilliseconds()
509 << " dur="
510 << stream_parser_buffer->duration().InMilliseconds();
509 stream_parser_buffer->set_timestamp( 511 stream_parser_buffer->set_timestamp(
510 stream_parser_buffer->timestamp() - time_offset_); 512 stream_parser_buffer->timestamp() - time_offset_);
511 stream_parser_buffer->SetDecodeTimestamp( 513 stream_parser_buffer->SetDecodeTimestamp(
512 stream_parser_buffer->GetDecodeTimestamp() - time_offset_); 514 stream_parser_buffer->GetDecodeTimestamp() - time_offset_);
513 515
514 // Ignore the incoming buffer if it is not associated with any config. 516 // Ignore the incoming buffer if it is not associated with any config.
515 if (buffer_queue_chain_.empty()) { 517 if (buffer_queue_chain_.empty()) {
516 DVLOG(1) << "Ignoring audio buffer with no corresponding audio config"; 518 DVLOG(1) << "Ignoring audio buffer with no corresponding audio config";
517 return; 519 return;
518 } 520 }
519 521
520 buffer_queue_chain_.back().audio_queue.push_back(stream_parser_buffer); 522 buffer_queue_chain_.back().audio_queue.push_back(stream_parser_buffer);
521 } 523 }
522 524
523 void Mp2tStreamParser::OnEmitVideoBuffer( 525 void Mp2tStreamParser::OnEmitVideoBuffer(
524 int pes_pid, 526 int pes_pid,
525 scoped_refptr<StreamParserBuffer> stream_parser_buffer) { 527 scoped_refptr<StreamParserBuffer> stream_parser_buffer) {
526 DCHECK_EQ(pes_pid, selected_video_pid_); 528 DCHECK_EQ(pes_pid, selected_video_pid_);
527 529
528 DVLOG(LOG_LEVEL_ES) 530 DVLOG(LOG_LEVEL_ES)
529 << "OnEmitVideoBuffer" 531 << "OnEmitVideoBuffer"
530 << " size=" 532 << " size="
531 << stream_parser_buffer->data_size() 533 << stream_parser_buffer->data_size()
532 << " dts=" 534 << " dts="
533 << stream_parser_buffer->GetDecodeTimestamp().InMilliseconds() 535 << stream_parser_buffer->GetDecodeTimestamp().InMilliseconds()
534 << " pts=" 536 << " pts="
535 << stream_parser_buffer->timestamp().InMilliseconds() 537 << stream_parser_buffer->timestamp().InMilliseconds()
538 << " dur="
539 << stream_parser_buffer->duration().InMilliseconds()
536 << " IsKeyframe=" 540 << " IsKeyframe="
537 << stream_parser_buffer->IsKeyframe(); 541 << stream_parser_buffer->IsKeyframe();
538 stream_parser_buffer->set_timestamp( 542 stream_parser_buffer->set_timestamp(
539 stream_parser_buffer->timestamp() - time_offset_); 543 stream_parser_buffer->timestamp() - time_offset_);
540 stream_parser_buffer->SetDecodeTimestamp( 544 stream_parser_buffer->SetDecodeTimestamp(
541 stream_parser_buffer->GetDecodeTimestamp() - time_offset_); 545 stream_parser_buffer->GetDecodeTimestamp() - time_offset_);
542 546
543 // Discard the incoming buffer: 547 // Discard the incoming buffer:
544 // - if it is not associated with any config, 548 // - if it is not associated with any config,
545 // - or if only non-key frames have been added to a new segment. 549 // - or if only non-key frames have been added to a new segment.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 while (!discarded_frames_dts_.empty()) { 649 while (!discarded_frames_dts_.empty()) {
646 scoped_refptr<StreamParserBuffer> frame = 650 scoped_refptr<StreamParserBuffer> frame =
647 StreamParserBuffer::CopyFrom( 651 StreamParserBuffer::CopyFrom(
648 stream_parser_buffer->data(), 652 stream_parser_buffer->data(),
649 stream_parser_buffer->data_size(), 653 stream_parser_buffer->data_size(),
650 stream_parser_buffer->IsKeyframe(), 654 stream_parser_buffer->IsKeyframe(),
651 stream_parser_buffer->type(), 655 stream_parser_buffer->type(),
652 stream_parser_buffer->track_id()); 656 stream_parser_buffer->track_id());
653 frame->SetDecodeTimestamp(discarded_frames_dts_.front()); 657 frame->SetDecodeTimestamp(discarded_frames_dts_.front());
654 frame->set_timestamp(pts); 658 frame->set_timestamp(pts);
659 frame->set_duration(pts_delta);
655 buffer_queue_chain_.back().video_queue.push_back(frame); 660 buffer_queue_chain_.back().video_queue.push_back(frame);
656 pts += pts_delta; 661 pts += pts_delta;
657 discarded_frames_dts_.pop_front(); 662 discarded_frames_dts_.pop_front();
658 } 663 }
659 } 664 }
660 665
661 } // namespace mp2t 666 } // namespace mp2t
662 } // namespace media 667 } // namespace media
OLDNEW
« media/formats/mp2t/es_parser_h264.cc ('K') | « media/formats/mp2t/es_parser_h264.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698