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

Unified Diff: media/base/android/test_data_factory.cc

Issue 1287423004: MediaCodecPlayer implementation (stage 5 - reconfiguration) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mtplayer-cleanuptest
Patch Set: Deleted better Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: media/base/android/test_data_factory.cc
diff --git a/media/base/android/test_data_factory.cc b/media/base/android/test_data_factory.cc
index cc434a82c712d450644db1fa9f4f37c5f65764f9..471aedf58fcb245ada1b078af2fe27556f3e9cac 100644
--- a/media/base/android/test_data_factory.cc
+++ b/media/base/android/test_data_factory.cc
@@ -4,6 +4,8 @@
#include "media/base/android/test_data_factory.h"
+#include <iterator>
+
#include "base/strings/stringprintf.h"
#include "media/base/android/demuxer_stream_player_params.h"
#include "media/base/decoder_buffer.h"
@@ -60,6 +62,7 @@ TestDataFactory::TestDataFactory(const char* file_name_template,
base::TimeDelta frame_period)
: duration_(duration),
frame_period_(frame_period),
+ total_chunks_(0),
starvation_mode_(false),
eos_reached_(false) {
LoadPackets(file_name_template);
@@ -76,7 +79,25 @@ bool TestDataFactory::CreateChunk(DemuxerData* chunk, base::TimeDelta* delay) {
*delay = base::TimeDelta();
+ if (!total_chunks_ &&
+ HasReconfigForInterval(base::TimeDelta::FromMilliseconds(-1),
+ base::TimeDelta())) {
+ // Since the configs AU has to come last in the chunk the initial configs
+ // preceeding any other data has to be the only unit in the chunk.
+ AddConfiguration(chunk);
+ ++total_chunks_;
+ return true;
+ }
+
for (int i = 0; i < 4; ++i) {
+ // Put ConfigChanged at the end of the chunk if there is a request
+ // for the chunk's timeframe.
+ if (i == 3 && HasReconfigForInterval(chunk->access_units[0].timestamp,
qinmin 2015/08/21 18:37:53 move the if statement outside the loop just do: f
Tima Vaisburd 2015/08/25 22:57:30 Done.
+ regular_pts_)) {
+ AddConfiguration(chunk);
+ break;
+ }
+
chunk->access_units.push_back(AccessUnit());
AccessUnit& unit = chunk->access_units.back();
unit.status = DemuxerStream::kOk;
@@ -103,6 +124,7 @@ bool TestDataFactory::CreateChunk(DemuxerData* chunk, base::TimeDelta* delay) {
last_pts_ = unit.timestamp;
}
+ ++total_chunks_;
return true;
}
@@ -112,6 +134,14 @@ void TestDataFactory::SeekTo(const base::TimeDelta& seek_time) {
eos_reached_ = false;
}
+void TestDataFactory::RequestInitialConfigs() {
+ reconfigs_.insert(base::TimeDelta::FromMilliseconds(-1));
+}
+
+void TestDataFactory::RequestConfigChange(base::TimeDelta config_position) {
+ reconfigs_.insert(config_position);
+}
+
void TestDataFactory::LoadPackets(const char* file_name_template) {
for (int i = 0; i < 4; ++i) {
scoped_refptr<DecoderBuffer> buffer =
@@ -121,4 +151,25 @@ void TestDataFactory::LoadPackets(const char* file_name_template) {
}
}
+bool TestDataFactory::HasReconfigForInterval(base::TimeDelta left,
+ base::TimeDelta right) const {
+ // |first| points to an element greater or equal to |left|.
+ PTSSet::const_iterator first = reconfigs_.lower_bound(left);
+
+ // |last| points to an element greater or equal to |right|.
+ PTSSet::const_iterator last = reconfigs_.lower_bound(right);
+
+ return std::distance(first, last);
+}
+
+void TestDataFactory::AddConfiguration(DemuxerData* chunk) {
+ DCHECK(chunk);
+ chunk->access_units.push_back(AccessUnit());
+ AccessUnit& unit = chunk->access_units.back();
+ unit.status = DemuxerStream::kConfigChanged;
+
+ DCHECK(chunk->demuxer_configs.empty());
+ chunk->demuxer_configs.push_back(GetConfigs());
+}
+
} // namespace media
« media/base/android/access_unit_queue.cc ('K') | « media/base/android/test_data_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698