Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / media / filters / pipeline_integration_test_base.cc
index a635286..3a3c91f 100644 (file)
@@ -7,7 +7,6 @@
 #include "base/bind.h"
 #include "base/memory/scoped_vector.h"
 #include "media/base/media_log.h"
-#include "media/base/time_delta_interpolator.h"
 #include "media/filters/audio_renderer_impl.h"
 #include "media/filters/chunk_demuxer.h"
 #include "media/filters/ffmpeg_audio_decoder.h"
@@ -15,6 +14,7 @@
 #include "media/filters/ffmpeg_video_decoder.h"
 #include "media/filters/file_data_source.h"
 #include "media/filters/opus_audio_decoder.h"
+#include "media/filters/renderer_impl.h"
 #include "media/filters/vpx_video_decoder.h"
 
 using ::testing::_;
@@ -37,10 +37,6 @@ PipelineIntegrationTestBase::PipelineIntegrationTestBase()
       last_video_frame_format_(VideoFrame::UNKNOWN),
       hardware_config_(AudioParameters(), AudioParameters()) {
   base::MD5Init(&md5_context_);
-
-  // Prevent non-deterministic buffering state callbacks from firing (e.g., slow
-  // machine, valgrind).
-  pipeline_->set_underflow_disabled_for_testing(true);
 }
 
 PipelineIntegrationTestBase::~PipelineIntegrationTestBase() {
@@ -113,8 +109,10 @@ bool PipelineIntegrationTestBase::Start(const base::FilePath& file_path,
       .WillRepeatedly(SaveArg<0>(&metadata_));
   EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH))
       .Times(AtMost(1));
+  CreateDemuxer(file_path);
   pipeline_->Start(
-      CreateFilterCollection(file_path, NULL),
+      demuxer_.get(),
+      CreateRenderer(NULL),
       base::Bind(&PipelineIntegrationTestBase::OnEnded, base::Unretained(this)),
       base::Bind(&PipelineIntegrationTestBase::OnError, base::Unretained(this)),
       QuitOnStatusCB(expected_status),
@@ -122,7 +120,9 @@ bool PipelineIntegrationTestBase::Start(const base::FilePath& file_path,
                  base::Unretained(this)),
       base::Bind(&PipelineIntegrationTestBase::OnBufferingStateChanged,
                  base::Unretained(this)),
-      base::Closure());
+      base::Closure(),
+      base::Bind(&PipelineIntegrationTestBase::OnAddTextTrack,
+                 base::Unretained(this)));
   message_loop_.Run();
   return (pipeline_status_ == PIPELINE_OK);
 }
@@ -132,10 +132,6 @@ bool PipelineIntegrationTestBase::Start(const base::FilePath& file_path,
                                         kTestType test_type) {
   hashing_enabled_ = test_type == kHashed;
   clockless_playback_ = test_type == kClockless;
-  if (clockless_playback_) {
-    pipeline_->SetTimeDeltaInterpolatorForTesting(
-        new TimeDeltaInterpolator(&dummy_clock_));
-  }
   return Start(file_path, expected_status);
 }
 
@@ -150,8 +146,11 @@ bool PipelineIntegrationTestBase::Start(const base::FilePath& file_path,
       .WillRepeatedly(SaveArg<0>(&metadata_));
   EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH))
       .Times(AtMost(1));
+
+  CreateDemuxer(file_path);
   pipeline_->Start(
-      CreateFilterCollection(file_path, decryptor),
+      demuxer_.get(),
+      CreateRenderer(decryptor),
       base::Bind(&PipelineIntegrationTestBase::OnEnded, base::Unretained(this)),
       base::Bind(&PipelineIntegrationTestBase::OnError, base::Unretained(this)),
       base::Bind(&PipelineIntegrationTestBase::OnStatusCallback,
@@ -160,7 +159,9 @@ bool PipelineIntegrationTestBase::Start(const base::FilePath& file_path,
                  base::Unretained(this)),
       base::Bind(&PipelineIntegrationTestBase::OnBufferingStateChanged,
                  base::Unretained(this)),
-      base::Closure());
+      base::Closure(),
+      base::Bind(&PipelineIntegrationTestBase::OnAddTextTrack,
+                 base::Unretained(this)));
   message_loop_.Run();
   return (pipeline_status_ == PIPELINE_OK);
 }
@@ -219,10 +220,8 @@ bool PipelineIntegrationTestBase::WaitUntilCurrentTimeIsAfter(
   return (pipeline_status_ == PIPELINE_OK);
 }
 
-scoped_ptr<FilterCollection>
-PipelineIntegrationTestBase::CreateFilterCollection(
-    const base::FilePath& file_path,
-    Decryptor* decryptor) {
+void PipelineIntegrationTestBase::CreateDemuxer(
+    const base::FilePath& file_path) {
   FileDataSource* file_data_source = new FileDataSource();
   CHECK(file_data_source->Initialize(file_path)) << "Is " << file_path.value()
                                                  << " missing?";
@@ -230,23 +229,15 @@ PipelineIntegrationTestBase::CreateFilterCollection(
 
   Demuxer::NeedKeyCB need_key_cb = base::Bind(
       &PipelineIntegrationTestBase::DemuxerNeedKeyCB, base::Unretained(this));
-  scoped_ptr<Demuxer> demuxer(
-      new FFmpegDemuxer(message_loop_.message_loop_proxy(),
-                        data_source_.get(),
-                        need_key_cb,
-                        new MediaLog()));
-  return CreateFilterCollection(demuxer.Pass(), decryptor);
+  demuxer_ =
+      scoped_ptr<Demuxer>(new FFmpegDemuxer(message_loop_.message_loop_proxy(),
+                                            data_source_.get(),
+                                            need_key_cb,
+                                            new MediaLog()));
 }
 
-scoped_ptr<FilterCollection>
-PipelineIntegrationTestBase::CreateFilterCollection(
-    scoped_ptr<Demuxer> demuxer,
+scoped_ptr<Renderer> PipelineIntegrationTestBase::CreateRenderer(
     Decryptor* decryptor) {
-  demuxer_ = demuxer.Pass();
-
-  scoped_ptr<FilterCollection> collection(new FilterCollection());
-  collection->SetDemuxer(demuxer_.get());
-
   ScopedVector<VideoDecoder> video_decoders;
 #if !defined(MEDIA_DISABLE_LIBVPX)
   video_decoders.push_back(
@@ -256,7 +247,7 @@ PipelineIntegrationTestBase::CreateFilterCollection(
       new FFmpegVideoDecoder(message_loop_.message_loop_proxy()));
 
   // Disable frame dropping if hashing is enabled.
-  scoped_ptr<VideoRenderer> renderer(new VideoRendererImpl(
+  scoped_ptr<VideoRenderer> video_renderer(new VideoRendererImpl(
       message_loop_.message_loop_proxy(),
       video_decoders.Pass(),
       base::Bind(&PipelineIntegrationTestBase::SetDecryptor,
@@ -264,8 +255,8 @@ PipelineIntegrationTestBase::CreateFilterCollection(
                  decryptor),
       base::Bind(&PipelineIntegrationTestBase::OnVideoRendererPaint,
                  base::Unretained(this)),
-      false));
-  collection->SetVideoRenderer(renderer.Pass());
+      false,
+      new MediaLog()));
 
   if (!clockless_playback_) {
     audio_sink_ = new NullAudioSink(message_loop_.message_loop_proxy());
@@ -286,7 +277,7 @@ PipelineIntegrationTestBase::CreateFilterCollection(
                              512);
   hardware_config_.UpdateOutputConfig(out_params);
 
-  AudioRendererImpl* audio_renderer_impl = new AudioRendererImpl(
+  scoped_ptr<AudioRenderer> audio_renderer(new AudioRendererImpl(
       message_loop_.message_loop_proxy(),
       (clockless_playback_)
           ? static_cast<AudioRendererSink*>(clockless_audio_sink_.get())
@@ -295,13 +286,25 @@ PipelineIntegrationTestBase::CreateFilterCollection(
       base::Bind(&PipelineIntegrationTestBase::SetDecryptor,
                  base::Unretained(this),
                  decryptor),
-      &hardware_config_);
+      hardware_config_,
+      new MediaLog()));
   if (hashing_enabled_)
     audio_sink_->StartAudioHashForTesting();
-  scoped_ptr<AudioRenderer> audio_renderer(audio_renderer_impl);
-  collection->SetAudioRenderer(audio_renderer.Pass());
 
-  return collection.Pass();
+  scoped_ptr<RendererImpl> renderer_impl(
+      new RendererImpl(message_loop_.message_loop_proxy(),
+                       demuxer_.get(),
+                       audio_renderer.Pass(),
+                       video_renderer.Pass()));
+
+  // Prevent non-deterministic buffering state callbacks from firing (e.g., slow
+  // machine, valgrind).
+  renderer_impl->DisableUnderflowForTesting();
+
+  if (clockless_playback_)
+    renderer_impl->EnableClocklessVideoPlaybackForTesting();
+
+  return renderer_impl.PassAs<Renderer>();
 }
 
 void PipelineIntegrationTestBase::SetDecryptor(