summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/renderer/media/media_stream_impl.cc5
-rw-r--r--media/base/pipeline.h2
-rw-r--r--media/base/pipeline_impl.cc13
-rw-r--r--media/base/pipeline_impl_unittest.cc28
-rw-r--r--media/filters/dummy_demuxer.cc49
-rw-r--r--media/filters/dummy_demuxer.h56
-rw-r--r--media/filters/dummy_demuxer_factory.cc30
-rw-r--r--media/filters/dummy_demuxer_factory.h33
-rw-r--r--media/media.gyp4
-rw-r--r--webkit/glue/webmediaplayer_impl.cc9
10 files changed, 189 insertions, 40 deletions
diff --git a/content/renderer/media/media_stream_impl.cc b/content/renderer/media/media_stream_impl.cc
index 20ad098..52e9ec2 100644
--- a/content/renderer/media/media_stream_impl.cc
+++ b/content/renderer/media/media_stream_impl.cc
@@ -19,6 +19,9 @@ static const int kVideoCaptureFramePerSecond = 30;
static const int kStartOpenSessionId = 1;
+// TODO(wjia): remove this string when full media stream code is checked in.
+static const char kRawMediaScheme[] = "mediastream";
+
} // namespace
MediaStreamImpl::MediaStreamImpl(VideoCaptureImplManager* vc_manager)
@@ -29,7 +32,7 @@ MediaStreamImpl::~MediaStreamImpl() {}
scoped_refptr<media::VideoDecoder> MediaStreamImpl::GetVideoDecoder(
const GURL& url, media::MessageLoopFactory* message_loop_factory) {
- bool raw_media = (url.spec().find(media::kRawMediaScheme) == 0);
+ bool raw_media = (url.spec().find(kRawMediaScheme) == 0);
media::VideoDecoder* decoder = NULL;
if (raw_media) {
media::VideoCapture::VideoCaptureCapability capability;
diff --git a/media/base/pipeline.h b/media/base/pipeline.h
index cbfc8b0..10e2427 100644
--- a/media/base/pipeline.h
+++ b/media/base/pipeline.h
@@ -20,8 +20,6 @@ class TimeDelta;
namespace media {
-extern const char kRawMediaScheme[];
-
struct PipelineStatistics {
PipelineStatistics() :
audio_bytes_decoded(0),
diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc
index 97facab..5a3fccb 100644
--- a/media/base/pipeline_impl.cc
+++ b/media/base/pipeline_impl.cc
@@ -21,8 +21,6 @@
namespace media {
-const char kRawMediaScheme[] = "x-raw-media";
-
PipelineStatusNotification::PipelineStatusNotification()
: cv_(&lock_), status_(PIPELINE_OK), notified_(false) {
}
@@ -651,15 +649,8 @@ void PipelineImpl::StartTask(FilterCollection* filter_collection,
pipeline_init_state_->composite_ = new CompositeFilter(message_loop_);
pipeline_init_state_->composite_->set_host(this);
- bool raw_media = (base::strncasecmp(url.c_str(), kRawMediaScheme,
- strlen(kRawMediaScheme)) == 0);
- if (raw_media) {
- SetState(kInitVideoDecoder);
- InitializeVideoDecoder(NULL);
- } else {
- SetState(kInitDemuxer);
- InitializeDemuxer();
- }
+ SetState(kInitDemuxer);
+ InitializeDemuxer();
}
// Main initialization method called on the pipeline thread. This code attempts
diff --git a/media/base/pipeline_impl_unittest.cc b/media/base/pipeline_impl_unittest.cc
index 2848b9c..66b430a 100644
--- a/media/base/pipeline_impl_unittest.cc
+++ b/media/base/pipeline_impl_unittest.cc
@@ -34,9 +34,6 @@ static const int kTotalBytes = 1024;
// Buffered bytes of the data source.
static const int kBufferedBytes = 1024;
-// Test url for raw video pipeline.
-static const char kUrlRawVideo[] = "://raw_video_stream";
-
// Used for setting expectations on pipeline callbacks. Using a StrictMock
// also lets us test for missing callbacks.
class CallbackHelper {
@@ -195,24 +192,14 @@ class PipelineImplTest : public ::testing::Test {
// But some tests require different statuses in build & Start.
void InitializePipeline(PipelineStatus build_status,
PipelineStatus start_status) {
- InitializePipeline(build_status, start_status, "");
- }
-
- void InitializePipeline(PipelineStatus build_status,
- PipelineStatus start_status,
- const std::string& url) {
// Expect an initialization callback.
EXPECT_CALL(callbacks_, OnStart(start_status));
- bool run_build = true;
- if (url.find(kRawMediaScheme) == 0)
- run_build = false;
-
pipeline_->Start(mocks_->filter_collection(true,
true,
- run_build,
+ true,
build_status),
- url,
+ "",
base::Bind(&CallbackHelper::OnStart,
base::Unretained(&callbacks_)));
@@ -425,17 +412,6 @@ TEST_F(PipelineImplTest, VideoStream) {
EXPECT_TRUE(pipeline_->HasVideo());
}
-TEST_F(PipelineImplTest, RawVideoStream) {
- InitializeVideoDecoder(NULL);
- InitializeVideoRenderer();
-
- InitializePipeline(PIPELINE_OK, PIPELINE_OK,
- std::string(kRawMediaScheme).append(kUrlRawVideo));
- EXPECT_TRUE(pipeline_->IsInitialized());
- EXPECT_FALSE(pipeline_->HasAudio());
- EXPECT_TRUE(pipeline_->HasVideo());
-}
-
TEST_F(PipelineImplTest, AudioVideoStream) {
CreateAudioStream();
CreateVideoStream();
diff --git a/media/filters/dummy_demuxer.cc b/media/filters/dummy_demuxer.cc
new file mode 100644
index 0000000..91aa40d
--- /dev/null
+++ b/media/filters/dummy_demuxer.cc
@@ -0,0 +1,49 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/filters/dummy_demuxer.h"
+
+#include "base/logging.h"
+
+namespace media {
+
+DummyDemuxerStream::DummyDemuxerStream(Type type)
+ : type_(type) {
+}
+
+DummyDemuxerStream::~DummyDemuxerStream() {}
+
+DemuxerStream::Type DummyDemuxerStream::type() {
+ return type_;
+}
+
+void DummyDemuxerStream::Read(const ReadCallback& read_callback) {}
+
+void DummyDemuxerStream::EnableBitstreamConverter() {}
+
+DummyDemuxer::DummyDemuxer(bool has_video, bool has_audio)
+ : has_video_(has_video),
+ has_audio_(has_audio) {
+ streams_.resize(DemuxerStream::NUM_TYPES);
+ if (has_audio)
+ streams_[DemuxerStream::AUDIO] =
+ new DummyDemuxerStream(DemuxerStream::AUDIO);
+ if (has_video)
+ streams_[DemuxerStream::VIDEO] =
+ new DummyDemuxerStream(DemuxerStream::VIDEO);
+}
+
+DummyDemuxer::~DummyDemuxer() {}
+
+void DummyDemuxer::SetPreload(Preload preload) {}
+
+scoped_refptr<DemuxerStream> DummyDemuxer::GetStream(DemuxerStream::Type type) {
+ return streams_[type];
+}
+
+base::TimeDelta DummyDemuxer::GetStartTime() const {
+ return base::TimeDelta();
+}
+
+} // namespace media
diff --git a/media/filters/dummy_demuxer.h b/media/filters/dummy_demuxer.h
new file mode 100644
index 0000000..82d0c1e
--- /dev/null
+++ b/media/filters/dummy_demuxer.h
@@ -0,0 +1,56 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Implements the Demuxer interface. DummyDemuxer returns corresponding
+// DummyDemuxerStream as signal for media pipeline to construct correct
+// playback channels.
+
+#ifndef MEDIA_FILTERS_DUMMY_DEMUXER_H_
+#define MEDIA_FILTERS_DUMMY_DEMUXER_H_
+
+#include <vector>
+
+#include "media/base/filters.h"
+
+namespace media {
+
+class DummyDemuxerStream : public DemuxerStream {
+ public:
+ explicit DummyDemuxerStream(Type type);
+
+ // DemuxerStream implementation.
+ virtual void Read(const ReadCallback& read_callback) OVERRIDE;
+ virtual Type type() OVERRIDE;
+ virtual void EnableBitstreamConverter() OVERRIDE;
+
+ private:
+ virtual ~DummyDemuxerStream();
+
+ Type type_;
+
+ DISALLOW_COPY_AND_ASSIGN(DummyDemuxerStream);
+};
+
+class DummyDemuxer : public Demuxer {
+ public:
+ DummyDemuxer(bool has_video, bool has_audio);
+ virtual ~DummyDemuxer();
+
+ // Demuxer implementation.
+ virtual scoped_refptr<DemuxerStream> GetStream(
+ DemuxerStream::Type type) OVERRIDE;
+ virtual void SetPreload(Preload preload) OVERRIDE;
+ virtual base::TimeDelta GetStartTime() const OVERRIDE;
+
+ private:
+ bool has_video_;
+ bool has_audio_;
+ std::vector< scoped_refptr<DummyDemuxerStream> > streams_;
+
+ DISALLOW_COPY_AND_ASSIGN(DummyDemuxer);
+};
+
+} // namespace media
+
+#endif // MEDIA_FILTERS_DUMMY_DEMUXER_H_
diff --git a/media/filters/dummy_demuxer_factory.cc b/media/filters/dummy_demuxer_factory.cc
new file mode 100644
index 0000000..e61c969
--- /dev/null
+++ b/media/filters/dummy_demuxer_factory.cc
@@ -0,0 +1,30 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/filters/dummy_demuxer_factory.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "media/filters/dummy_demuxer.h"
+
+namespace media {
+
+DummyDemuxerFactory::DummyDemuxerFactory(bool has_video, bool has_audio)
+ : has_video_(has_video),
+ has_audio_(has_audio) {
+}
+
+DummyDemuxerFactory::~DummyDemuxerFactory() {}
+
+void DummyDemuxerFactory::Build(const std::string& url, BuildCallback* cb) {
+ scoped_refptr<DummyDemuxer> demuxer =
+ new DummyDemuxer(has_video_, has_audio_);
+ scoped_ptr<DemuxerFactory::BuildCallback> callback(cb);
+ callback->Run(PIPELINE_OK, demuxer.get());
+}
+
+DemuxerFactory* DummyDemuxerFactory::Clone() const {
+ return new DummyDemuxerFactory(has_video_, has_audio_);
+}
+
+} // namespace media
diff --git a/media/filters/dummy_demuxer_factory.h b/media/filters/dummy_demuxer_factory.h
new file mode 100644
index 0000000..8597c08
--- /dev/null
+++ b/media/filters/dummy_demuxer_factory.h
@@ -0,0 +1,33 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Implements the DemuxerFactory interface using DummyDemuxer.
+
+#ifndef MEDIA_FILTERS_DUMMY_DEMUXER_FACTORY_H_
+#define MEDIA_FILTERS_DUMMY_DEMUXER_FACTORY_H_
+
+#include "base/compiler_specific.h"
+#include "media/base/filter_factories.h"
+
+namespace media {
+
+class DummyDemuxerFactory : public DemuxerFactory {
+ public:
+ DummyDemuxerFactory(bool has_video, bool has_audio);
+ virtual ~DummyDemuxerFactory();
+
+ // DemuxerFactory methods.
+ virtual void Build(const std::string& url, BuildCallback* cb) OVERRIDE;
+ virtual DemuxerFactory* Clone() const OVERRIDE;
+
+ private:
+ bool has_video_;
+ bool has_audio_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(DummyDemuxerFactory);
+};
+
+} // namespace media
+
+#endif // MEDIA_FILTERS_DUMMY_DEMUXER_FACTORY_H_
diff --git a/media/media.gyp b/media/media.gyp
index c27b430..7599362 100644
--- a/media/media.gyp
+++ b/media/media.gyp
@@ -163,6 +163,10 @@
'filters/chunk_demuxer_factory.cc',
'filters/chunk_demuxer_factory.h',
'filters/decoder_base.h',
+ 'filters/dummy_demuxer.cc',
+ 'filters/dummy_demuxer.h',
+ 'filters/dummy_demuxer_factory.cc',
+ 'filters/dummy_demuxer_factory.h',
'filters/ffmpeg_audio_decoder.cc',
'filters/ffmpeg_audio_decoder.h',
'filters/ffmpeg_demuxer.cc',
diff --git a/webkit/glue/webmediaplayer_impl.cc b/webkit/glue/webmediaplayer_impl.cc
index 7aa9a58..b30e013 100644
--- a/webkit/glue/webmediaplayer_impl.cc
+++ b/webkit/glue/webmediaplayer_impl.cc
@@ -18,6 +18,7 @@
#include "media/base/video_frame.h"
#include "media/filters/adaptive_demuxer.h"
#include "media/filters/chunk_demuxer_factory.h"
+#include "media/filters/dummy_demuxer_factory.h"
#include "media/filters/ffmpeg_audio_decoder.h"
#include "media/filters/ffmpeg_demuxer_factory.h"
#include "media/filters/ffmpeg_video_decoder.h"
@@ -211,6 +212,8 @@ void WebMediaPlayerImpl::load(const WebKit::WebURL& url) {
DCHECK(proxy_);
if (media_stream_client_) {
+ bool has_video = false;
+ bool has_audio = false;
scoped_refptr<media::VideoDecoder> new_decoder =
media_stream_client_->GetVideoDecoder(url, message_loop_factory_.get());
if (new_decoder.get()) {
@@ -218,7 +221,13 @@ void WebMediaPlayerImpl::load(const WebKit::WebURL& url) {
scoped_refptr<media::VideoDecoder> old_videodecoder;
filter_collection_->SelectVideoDecoder(&old_videodecoder);
filter_collection_->AddVideoDecoder(new_decoder.get());
+ has_video = true;
}
+
+ // TODO(wjia): add audio decoder handling when it's available.
+ if (has_video || has_audio)
+ filter_collection_->SetDemuxerFactory(
+ new media::DummyDemuxerFactory(has_video, has_audio));
}
// Handle any volume changes that occured before load().