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/mp4/mp4_stream_parser.h" | 5 #include "media/formats/mp4/mp4_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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 DVLOG(1) << "Video track " << track_id << " config=" | 135 DVLOG(1) << "Video track " << track_id << " config=" |
136 << (video_decoder_config_.IsValidConfig() | 136 << (video_decoder_config_.IsValidConfig() |
137 ? video_decoder_config_.AsHumanReadableString() | 137 ? video_decoder_config_.AsHumanReadableString() |
138 : "INVALID"); | 138 : "INVALID"); |
139 } | 139 } |
140 } | 140 } |
141 media_tracks_ = std::move(tracks); | 141 media_tracks_ = std::move(tracks); |
142 return true; | 142 return true; |
143 } | 143 } |
144 | 144 |
145 void DumpBuffers(const std::string& label, | 145 bool NewBuffersF(const StreamParser::BufferQueueMap& buffer_queue_map) { |
146 const StreamParser::BufferQueue& buffers) { | |
147 DVLOG(2) << "DumpBuffers: " << label << " size " << buffers.size(); | |
148 for (StreamParser::BufferQueue::const_iterator buf = buffers.begin(); | |
149 buf != buffers.end(); buf++) { | |
150 DVLOG(3) << " n=" << buf - buffers.begin() | |
151 << ", size=" << (*buf)->data_size() | |
152 << ", dur=" << (*buf)->duration().InMilliseconds(); | |
153 } | |
154 } | |
155 | |
156 bool NewBuffersF(const StreamParser::BufferQueue& audio_buffers, | |
157 const StreamParser::BufferQueue& video_buffers, | |
158 const StreamParser::TextBufferQueueMap& text_map) { | |
159 DumpBuffers("audio_buffers", audio_buffers); | |
160 DumpBuffers("video_buffers", video_buffers); | |
161 | |
162 // Ensure that track ids are properly assigned on all emitted buffers. | 146 // Ensure that track ids are properly assigned on all emitted buffers. |
163 for (const auto& buf : audio_buffers) { | 147 for (const auto& it : buffer_queue_map) { |
164 EXPECT_EQ(audio_track_id_, buf->track_id()); | 148 DVLOG(3) << "Buffers for track_id=" << it.first; |
165 } | 149 for (const auto& buf : it.second) { |
166 for (const auto& buf : video_buffers) { | 150 DVLOG(3) << " track_id=" << buf->track_id() |
167 EXPECT_EQ(video_track_id_, buf->track_id()); | 151 << ", size=" << buf->data_size() |
| 152 << ", pts=" << buf->timestamp().InSecondsF() |
| 153 << ", dts=" << buf->GetDecodeTimestamp().InSecondsF() |
| 154 << ", dur=" << buf->duration().InSecondsF(); |
| 155 EXPECT_EQ(it.first, buf->track_id()); |
| 156 } |
168 } | 157 } |
169 | 158 |
170 // TODO(wolenetz/acolwell): Add text track support to more MSE parsers. See | 159 const StreamParser::BufferQueue empty_buffers; |
171 // http://crbug.com/336926. | 160 const auto& itr_audio = buffer_queue_map.find(audio_track_id_); |
172 if (!text_map.empty()) | 161 const StreamParser::BufferQueue& audio_buffers = |
173 return false; | 162 (itr_audio == buffer_queue_map.end()) ? empty_buffers |
| 163 : itr_audio->second; |
| 164 |
| 165 const auto& itr_video = buffer_queue_map.find(video_track_id_); |
| 166 const StreamParser::BufferQueue& video_buffers = |
| 167 (itr_video == buffer_queue_map.end()) ? empty_buffers |
| 168 : itr_video->second; |
174 | 169 |
175 // Find the second highest timestamp so that we know what the | 170 // Find the second highest timestamp so that we know what the |
176 // timestamps on the next set of buffers must be >= than. | 171 // timestamps on the next set of buffers must be >= than. |
177 DecodeTimestamp audio = !audio_buffers.empty() ? | 172 DecodeTimestamp audio = !audio_buffers.empty() ? |
178 audio_buffers.back()->GetDecodeTimestamp() : kNoDecodeTimestamp(); | 173 audio_buffers.back()->GetDecodeTimestamp() : kNoDecodeTimestamp(); |
179 DecodeTimestamp video = !video_buffers.empty() ? | 174 DecodeTimestamp video = !video_buffers.empty() ? |
180 video_buffers.back()->GetDecodeTimestamp() : kNoDecodeTimestamp(); | 175 video_buffers.back()->GetDecodeTimestamp() : kNoDecodeTimestamp(); |
181 DecodeTimestamp second_highest_timestamp = | 176 DecodeTimestamp second_highest_timestamp = |
182 (audio == kNoDecodeTimestamp() || | 177 (audio == kNoDecodeTimestamp() || |
183 (video != kNoDecodeTimestamp() && audio > video)) ? video : audio; | 178 (video != kNoDecodeTimestamp() && audio > video)) ? video : audio; |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 scoped_refptr<DecoderBuffer> buffer = | 539 scoped_refptr<DecoderBuffer> buffer = |
545 ReadTestDataFile("bear-1280x720-avt_subt_frag.mp4"); | 540 ReadTestDataFile("bear-1280x720-avt_subt_frag.mp4"); |
546 | 541 |
547 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2")); | 542 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2")); |
548 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001F")); | 543 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001F")); |
549 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); | 544 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); |
550 } | 545 } |
551 | 546 |
552 } // namespace mp4 | 547 } // namespace mp4 |
553 } // namespace media | 548 } // namespace media |
OLD | NEW |