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

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

Issue 1874413003: Convert media/formats to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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"
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/stream_parser_buffer.h" 23 #include "media/base/stream_parser_buffer.h"
21 #include "media/base/test_data_util.h" 24 #include "media/base/test_data_util.h"
22 #include "media/base/text_track_config.h" 25 #include "media/base/text_track_config.h"
23 #include "media/base/video_decoder_config.h" 26 #include "media/base/video_decoder_config.h"
24 #include "media/formats/mp2t/mp2t_stream_parser.h"
25 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
26 28
27 namespace media { 29 namespace media {
28 namespace mp2t { 30 namespace mp2t {
29 31
30 namespace { 32 namespace {
31 33
32 bool IsMonotonic(const StreamParser::BufferQueue& buffers) { 34 bool IsMonotonic(const StreamParser::BufferQueue& buffers) {
33 if (buffers.empty()) 35 if (buffers.empty())
34 return true; 36 return true;
(...skipping 25 matching lines...) Expand all
60 has_video_(true), 62 has_video_(true),
61 audio_min_dts_(kNoDecodeTimestamp()), 63 audio_min_dts_(kNoDecodeTimestamp()),
62 audio_max_dts_(kNoDecodeTimestamp()), 64 audio_max_dts_(kNoDecodeTimestamp()),
63 video_min_dts_(kNoDecodeTimestamp()), 65 video_min_dts_(kNoDecodeTimestamp()),
64 video_max_dts_(kNoDecodeTimestamp()) { 66 video_max_dts_(kNoDecodeTimestamp()) {
65 bool has_sbr = false; 67 bool has_sbr = false;
66 parser_.reset(new Mp2tStreamParser(has_sbr)); 68 parser_.reset(new Mp2tStreamParser(has_sbr));
67 } 69 }
68 70
69 protected: 71 protected:
70 scoped_ptr<Mp2tStreamParser> parser_; 72 std::unique_ptr<Mp2tStreamParser> parser_;
71 int segment_count_; 73 int segment_count_;
72 int config_count_; 74 int config_count_;
73 int audio_frame_count_; 75 int audio_frame_count_;
74 int video_frame_count_; 76 int video_frame_count_;
75 bool has_video_; 77 bool has_video_;
76 DecodeTimestamp audio_min_dts_; 78 DecodeTimestamp audio_min_dts_;
77 DecodeTimestamp audio_max_dts_; 79 DecodeTimestamp audio_max_dts_;
78 DecodeTimestamp video_min_dts_; 80 DecodeTimestamp video_min_dts_;
79 DecodeTimestamp video_max_dts_; 81 DecodeTimestamp video_max_dts_;
80 82
(...skipping 25 matching lines...) Expand all
106 start += append_size; 108 start += append_size;
107 } 109 }
108 return true; 110 return true;
109 } 111 }
110 112
111 void OnInit(const StreamParser::InitParameters& params) { 113 void OnInit(const StreamParser::InitParameters& params) {
112 DVLOG(1) << "OnInit: dur=" << params.duration.InMilliseconds() 114 DVLOG(1) << "OnInit: dur=" << params.duration.InMilliseconds()
113 << ", autoTimestampOffset=" << params.auto_update_timestamp_offset; 115 << ", autoTimestampOffset=" << params.auto_update_timestamp_offset;
114 } 116 }
115 117
116 bool OnNewConfig(scoped_ptr<MediaTracks> tracks, 118 bool OnNewConfig(std::unique_ptr<MediaTracks> tracks,
117 const StreamParser::TextTrackConfigMap& tc) { 119 const StreamParser::TextTrackConfigMap& tc) {
118 const AudioDecoderConfig& ac = tracks->getFirstAudioConfig(); 120 const AudioDecoderConfig& ac = tracks->getFirstAudioConfig();
119 const VideoDecoderConfig& vc = tracks->getFirstVideoConfig(); 121 const VideoDecoderConfig& vc = tracks->getFirstVideoConfig();
120 DVLOG(1) << "OnNewConfig: media tracks count=" << tracks->tracks().size() 122 DVLOG(1) << "OnNewConfig: media tracks count=" << tracks->tracks().size()
121 << ", audio=" << ac.IsValidConfig() 123 << ", audio=" << ac.IsValidConfig()
122 << ", video=" << vc.IsValidConfig(); 124 << ", video=" << vc.IsValidConfig();
123 config_count_++; 125 config_count_++;
124 EXPECT_TRUE(ac.IsValidConfig()); 126 EXPECT_TRUE(ac.IsValidConfig());
125 EXPECT_EQ(vc.IsValidConfig(), has_video_); 127 EXPECT_EQ(vc.IsValidConfig(), has_video_);
126 return true; 128 return true;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 parser_->Flush(); 296 parser_->Flush();
295 EXPECT_EQ(audio_frame_count_, 40); 297 EXPECT_EQ(audio_frame_count_, 40);
296 EXPECT_EQ(video_frame_count_, 0); 298 EXPECT_EQ(video_frame_count_, 0);
297 // This stream has no mid-stream configuration change. 299 // This stream has no mid-stream configuration change.
298 EXPECT_EQ(config_count_, 1); 300 EXPECT_EQ(config_count_, 1);
299 EXPECT_EQ(segment_count_, 1); 301 EXPECT_EQ(segment_count_, 1);
300 } 302 }
301 303
302 } // namespace mp2t 304 } // namespace mp2t
303 } // namespace media 305 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698