| OLD | NEW | 
|    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 <stddef.h> |    7 #include <stddef.h> | 
|    8 #include <stdint.h> |    8 #include <stdint.h> | 
|    9  |    9  | 
|   10 #include <algorithm> |   10 #include <algorithm> | 
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  138         LOG(ERROR) << "Unexpected track type " << track->type(); |  138         LOG(ERROR) << "Unexpected track type " << track->type(); | 
|  139         EXPECT_TRUE(false); |  139         EXPECT_TRUE(false); | 
|  140       } |  140       } | 
|  141     } |  141     } | 
|  142     EXPECT_TRUE(found_audio_track); |  142     EXPECT_TRUE(found_audio_track); | 
|  143     EXPECT_EQ(has_video_, found_video_track); |  143     EXPECT_EQ(has_video_, found_video_track); | 
|  144     config_count_++; |  144     config_count_++; | 
|  145     return true; |  145     return true; | 
|  146   } |  146   } | 
|  147  |  147  | 
|  148  |  148   bool OnNewBuffers(const StreamParser::BufferQueueMap& buffer_queue_map) { | 
|  149   void DumpBuffers(const std::string& label, |  | 
|  150                    const StreamParser::BufferQueue& buffers) { |  | 
|  151     DVLOG(2) << "DumpBuffers: " << label << " size " << buffers.size(); |  | 
|  152     for (StreamParser::BufferQueue::const_iterator buf = buffers.begin(); |  | 
|  153          buf != buffers.end(); buf++) { |  | 
|  154       DVLOG(3) << "  n=" << buf - buffers.begin() |  | 
|  155                << ", size=" << (*buf)->data_size() |  | 
|  156                << ", dur=" << (*buf)->duration().InMilliseconds(); |  | 
|  157     } |  | 
|  158   } |  | 
|  159  |  | 
|  160   bool OnNewBuffers(const StreamParser::BufferQueue& audio_buffers, |  | 
|  161                     const StreamParser::BufferQueue& video_buffers, |  | 
|  162                     const StreamParser::TextBufferQueueMap& text_map) { |  | 
|  163     EXPECT_GT(config_count_, 0); |  149     EXPECT_GT(config_count_, 0); | 
|  164     DumpBuffers("audio_buffers", audio_buffers); |  | 
|  165     DumpBuffers("video_buffers", video_buffers); |  | 
|  166  |  | 
|  167     // Ensure that track ids are properly assigned on all emitted buffers. |  150     // Ensure that track ids are properly assigned on all emitted buffers. | 
|  168     for (const auto& buf : audio_buffers) { |  151     for (const auto& it : buffer_queue_map) { | 
|  169       EXPECT_EQ(audio_track_id_, buf->track_id()); |  152       DVLOG(3) << "Buffers for track_id=" << it.first; | 
|  170     } |  153       for (const auto& buf : it.second) { | 
|  171     for (const auto& buf : video_buffers) { |  154         DVLOG(3) << "  track_id=" << buf->track_id() | 
|  172       EXPECT_EQ(video_track_id_, buf->track_id()); |  155                  << ", size=" << buf->data_size() | 
 |  156                  << ", pts=" << buf->timestamp().InSecondsF() | 
 |  157                  << ", dts=" << buf->GetDecodeTimestamp().InSecondsF() | 
 |  158                  << ", dur=" << buf->duration().InSecondsF(); | 
 |  159         EXPECT_EQ(it.first, buf->track_id()); | 
 |  160       } | 
|  173     } |  161     } | 
|  174  |  162  | 
|  175     // TODO(wolenetz/acolwell): Add text track support to more MSE parsers. See |  163     const StreamParser::BufferQueue empty_buffers; | 
|  176     // http://crbug.com/336926. |  164     const auto& itr_audio = buffer_queue_map.find(audio_track_id_); | 
|  177     if (!text_map.empty()) |  165     const StreamParser::BufferQueue& audio_buffers = | 
|  178       return false; |  166         (itr_audio == buffer_queue_map.end()) ? empty_buffers | 
 |  167                                               : itr_audio->second; | 
 |  168  | 
 |  169     const auto& itr_video = buffer_queue_map.find(video_track_id_); | 
 |  170     const StreamParser::BufferQueue& video_buffers = | 
 |  171         (itr_video == buffer_queue_map.end()) ? empty_buffers | 
 |  172                                               : itr_video->second; | 
|  179  |  173  | 
|  180     // Verify monotonicity. |  174     // Verify monotonicity. | 
|  181     if (!IsMonotonic(video_buffers)) |  175     if (!IsMonotonic(video_buffers)) | 
|  182       return false; |  176       return false; | 
|  183     if (!IsMonotonic(audio_buffers)) |  177     if (!IsMonotonic(audio_buffers)) | 
|  184       return false; |  178       return false; | 
|  185  |  179  | 
|  186     if (!video_buffers.empty()) { |  180     if (!video_buffers.empty()) { | 
|  187       DecodeTimestamp first_dts = video_buffers.front()->GetDecodeTimestamp(); |  181       DecodeTimestamp first_dts = video_buffers.front()->GetDecodeTimestamp(); | 
|  188       DecodeTimestamp last_dts = video_buffers.back()->GetDecodeTimestamp(); |  182       DecodeTimestamp last_dts = video_buffers.back()->GetDecodeTimestamp(); | 
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  323   parser_->Flush(); |  317   parser_->Flush(); | 
|  324   EXPECT_EQ(audio_frame_count_, 40); |  318   EXPECT_EQ(audio_frame_count_, 40); | 
|  325   EXPECT_EQ(video_frame_count_, 0); |  319   EXPECT_EQ(video_frame_count_, 0); | 
|  326   // This stream has no mid-stream configuration change. |  320   // This stream has no mid-stream configuration change. | 
|  327   EXPECT_EQ(config_count_, 1); |  321   EXPECT_EQ(config_count_, 1); | 
|  328   EXPECT_EQ(segment_count_, 1); |  322   EXPECT_EQ(segment_count_, 1); | 
|  329 } |  323 } | 
|  330  |  324  | 
|  331 }  // namespace mp2t |  325 }  // namespace mp2t | 
|  332 }  // namespace media |  326 }  // namespace media | 
| OLD | NEW |