| 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" |
| 6 |
| 5 #include <stddef.h> | 7 #include <stddef.h> |
| 6 #include <stdint.h> | 8 #include <stdint.h> |
| 7 | 9 |
| 8 #include <algorithm> | 10 #include <algorithm> |
| 11 #include <memory> |
| 9 #include <string> | 12 #include <string> |
| 10 | 13 |
| 11 #include "base/bind.h" | 14 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
| 13 #include "base/logging.h" | 16 #include "base/logging.h" |
| 14 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 15 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 16 #include "media/base/audio_decoder_config.h" | 19 #include "media/base/audio_decoder_config.h" |
| 17 #include "media/base/decoder_buffer.h" | 20 #include "media/base/decoder_buffer.h" |
| 18 #include "media/base/media_track.h" | 21 #include "media/base/media_track.h" |
| 19 #include "media/base/media_tracks.h" | 22 #include "media/base/media_tracks.h" |
| 20 #include "media/base/mock_media_log.h" | 23 #include "media/base/mock_media_log.h" |
| 21 #include "media/base/stream_parser.h" | 24 #include "media/base/stream_parser.h" |
| 22 #include "media/base/stream_parser_buffer.h" | 25 #include "media/base/stream_parser_buffer.h" |
| 23 #include "media/base/test_data_util.h" | 26 #include "media/base/test_data_util.h" |
| 24 #include "media/base/text_track_config.h" | 27 #include "media/base/text_track_config.h" |
| 25 #include "media/base/video_decoder_config.h" | 28 #include "media/base/video_decoder_config.h" |
| 26 #include "media/formats/mp4/es_descriptor.h" | 29 #include "media/formats/mp4/es_descriptor.h" |
| 27 #include "media/formats/mp4/fourccs.h" | 30 #include "media/formats/mp4/fourccs.h" |
| 28 #include "media/formats/mp4/mp4_stream_parser.h" | |
| 29 #include "media/media_features.h" | 31 #include "media/media_features.h" |
| 30 #include "testing/gmock/include/gmock/gmock.h" | 32 #include "testing/gmock/include/gmock/gmock.h" |
| 31 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
| 32 | 34 |
| 33 using ::testing::InSequence; | 35 using ::testing::InSequence; |
| 34 using ::testing::StrictMock; | 36 using ::testing::StrictMock; |
| 35 using base::TimeDelta; | 37 using base::TimeDelta; |
| 36 | 38 |
| 37 namespace media { | 39 namespace media { |
| 38 namespace mp4 { | 40 namespace mp4 { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 61 configs_received_(false), | 63 configs_received_(false), |
| 62 lower_bound_( | 64 lower_bound_( |
| 63 DecodeTimestamp::FromPresentationTime(base::TimeDelta::Max())) { | 65 DecodeTimestamp::FromPresentationTime(base::TimeDelta::Max())) { |
| 64 std::set<int> audio_object_types; | 66 std::set<int> audio_object_types; |
| 65 audio_object_types.insert(kISO_14496_3); | 67 audio_object_types.insert(kISO_14496_3); |
| 66 parser_.reset(new MP4StreamParser(audio_object_types, false)); | 68 parser_.reset(new MP4StreamParser(audio_object_types, false)); |
| 67 } | 69 } |
| 68 | 70 |
| 69 protected: | 71 protected: |
| 70 scoped_refptr<StrictMock<MockMediaLog>> media_log_; | 72 scoped_refptr<StrictMock<MockMediaLog>> media_log_; |
| 71 scoped_ptr<MP4StreamParser> parser_; | 73 std::unique_ptr<MP4StreamParser> parser_; |
| 72 bool configs_received_; | 74 bool configs_received_; |
| 73 scoped_ptr<MediaTracks> media_tracks_; | 75 std::unique_ptr<MediaTracks> media_tracks_; |
| 74 AudioDecoderConfig audio_decoder_config_; | 76 AudioDecoderConfig audio_decoder_config_; |
| 75 VideoDecoderConfig video_decoder_config_; | 77 VideoDecoderConfig video_decoder_config_; |
| 76 DecodeTimestamp lower_bound_; | 78 DecodeTimestamp lower_bound_; |
| 77 | 79 |
| 78 bool AppendData(const uint8_t* data, size_t length) { | 80 bool AppendData(const uint8_t* data, size_t length) { |
| 79 return parser_->Parse(data, length); | 81 return parser_->Parse(data, length); |
| 80 } | 82 } |
| 81 | 83 |
| 82 bool AppendDataInPieces(const uint8_t* data, | 84 bool AppendDataInPieces(const uint8_t* data, |
| 83 size_t length, | 85 size_t length, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 104 params.auto_update_timestamp_offset); | 106 params.auto_update_timestamp_offset); |
| 105 EXPECT_EQ(expected_params.liveness, params.liveness); | 107 EXPECT_EQ(expected_params.liveness, params.liveness); |
| 106 EXPECT_EQ(expected_params.detected_audio_track_count, | 108 EXPECT_EQ(expected_params.detected_audio_track_count, |
| 107 params.detected_audio_track_count); | 109 params.detected_audio_track_count); |
| 108 EXPECT_EQ(expected_params.detected_video_track_count, | 110 EXPECT_EQ(expected_params.detected_video_track_count, |
| 109 params.detected_video_track_count); | 111 params.detected_video_track_count); |
| 110 EXPECT_EQ(expected_params.detected_text_track_count, | 112 EXPECT_EQ(expected_params.detected_text_track_count, |
| 111 params.detected_text_track_count); | 113 params.detected_text_track_count); |
| 112 } | 114 } |
| 113 | 115 |
| 114 bool NewConfigF(scoped_ptr<MediaTracks> tracks, | 116 bool NewConfigF(std::unique_ptr<MediaTracks> tracks, |
| 115 const StreamParser::TextTrackConfigMap& tc) { | 117 const StreamParser::TextTrackConfigMap& tc) { |
| 116 configs_received_ = true; | 118 configs_received_ = true; |
| 117 CHECK(tracks.get()); | 119 CHECK(tracks.get()); |
| 118 media_tracks_ = std::move(tracks); | 120 media_tracks_ = std::move(tracks); |
| 119 audio_decoder_config_ = media_tracks_->getFirstAudioConfig(); | 121 audio_decoder_config_ = media_tracks_->getFirstAudioConfig(); |
| 120 video_decoder_config_ = media_tracks_->getFirstVideoConfig(); | 122 video_decoder_config_ = media_tracks_->getFirstVideoConfig(); |
| 121 DVLOG(1) << "NewConfigF: track count=" << media_tracks_->tracks().size() | 123 DVLOG(1) << "NewConfigF: track count=" << media_tracks_->tracks().size() |
| 122 << " audio=" << audio_decoder_config_.IsValidConfig() | 124 << " audio=" << audio_decoder_config_.IsValidConfig() |
| 123 << " video=" << video_decoder_config_.IsValidConfig(); | 125 << " video=" << video_decoder_config_.IsValidConfig(); |
| 124 return true; | 126 return true; |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 scoped_refptr<DecoderBuffer> buffer = | 520 scoped_refptr<DecoderBuffer> buffer = |
| 519 ReadTestDataFile("bear-1280x720-avt_subt_frag.mp4"); | 521 ReadTestDataFile("bear-1280x720-avt_subt_frag.mp4"); |
| 520 | 522 |
| 521 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2")); | 523 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2")); |
| 522 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001F")); | 524 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001F")); |
| 523 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); | 525 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); |
| 524 } | 526 } |
| 525 | 527 |
| 526 } // namespace mp4 | 528 } // namespace mp4 |
| 527 } // namespace media | 529 } // namespace media |
| OLD | NEW |