Define the interface for MediaStreamVideoSource.

Review URL: https://codereview.chromium.org/99113003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243692 0039d316-1c4b-4281-b951-d872f2087c98
parent cb99213a
......@@ -612,6 +612,8 @@
'renderer/media/media_stream_registry_interface.h',
'renderer/media/media_stream_source_observer.cc',
'renderer/media/media_stream_source_observer.h',
'renderer/media/media_stream_video_source.cc',
'renderer/media/media_stream_video_source.h',
'renderer/media/native_handle_impl.cc',
'renderer/media/native_handle_impl.h',
'renderer/media/peer_connection_audio_sink_owner.cc',
......
......@@ -537,6 +537,7 @@
'renderer/media/buffered_resource_loader_unittest.cc',
'renderer/media/cache_util_unittest.cc',
'renderer/media/crypto/key_systems_unittest.cc',
'renderer/media/media_stream_video_source_unittest.cc',
'renderer/media/test_response_generator.cc',
'renderer/media/test_response_generator.h',
'renderer/media/video_capture_impl_unittest.cc',
......
// Copyright 2014 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 "content/renderer/media/media_stream_video_source.h"
#include "base/logging.h"
#include "content/public/renderer/media_stream_video_sink.h"
namespace content {
void MediaStreamVideoSource::AddTrack(
const blink::WebMediaStreamTrack& track,
const blink::WebMediaConstraints& constraints) {
// TODO(ronghuawu): Put |track| in the registered tracks list. Will later
// deliver frames to it according to |constraints|.
}
void MediaStreamVideoSource::RemoveTrack(
const blink::WebMediaStreamTrack& track) {
// TODO(ronghuawu): Remove |track| from the list, i.e. will stop delivering
// frame to |track|.
}
void MediaStreamVideoSource::SetReadyState(
blink::WebMediaStreamSource::ReadyState state) {
// TODO(ronghuawu): Sets WebMediaStreamSource's ready state and notifies the
// ready state to all registered tracks.
}
void MediaStreamVideoSource::DeliverVideoFrame(
const scoped_refptr<media::VideoFrame>& frame) {
// TODO(ronghuawu): Deliver |frame| to all the registered tracks.
}
MediaStreamVideoSource::~MediaStreamVideoSource() {
}
} // namespace content
// Copyright 2014 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.
#ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_
#define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "content/common/content_export.h"
#include "content/renderer/media/media_stream_source_extra_data.h"
#include "third_party/WebKit/public/platform/WebMediaConstraints.h"
#include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
#include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
namespace media {
class VideoFrame;
}
namespace content {
// MediaStreamVideoSource is an interface used for sending video frames to a
// MediaStreamVideoTrack.
// http://dev.w3.org/2011/webrtc/editor/getusermedia.html
// All methods calls will be done from the main render thread.
class CONTENT_EXPORT MediaStreamVideoSource
: public MediaStreamSourceExtraData {
public:
// Puts |track| in the registered tracks list. Will later
// deliver frames to it according to |constraints|.
void AddTrack(const blink::WebMediaStreamTrack& track,
const blink::WebMediaConstraints& constraints);
// Removes |track| from the registered tracks list, i.e. will stop delivering
// frame to |track|.
void RemoveTrack(const blink::WebMediaStreamTrack& track);
protected:
// Sets ready state and notifies the ready state to all registered tracks.
virtual void SetReadyState(blink::WebMediaStreamSource::ReadyState state);
// Delivers |frame| to registered tracks according to their constraints.
virtual void DeliverVideoFrame(const scoped_refptr<media::VideoFrame>& frame);
virtual ~MediaStreamVideoSource();
};
} // namespace content
#endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_
// Copyright 2014 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 <string>
#include "content/renderer/media/media_stream_video_source.h"
#include "media/base/video_frame.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace content {
class MediaStreamVideoSourceTest
: public ::testing::Test,
public MediaStreamVideoSource {
public:
MediaStreamVideoSourceTest() {}
};
TEST_F(MediaStreamVideoSourceTest, OnVideoFrame) {
blink::WebMediaConstraints constraints;
blink::WebMediaStreamTrack track;
AddTrack(track, constraints);
SetReadyState(blink::WebMediaStreamSource::ReadyStateLive);
const int kWidth = 640;
const int kHeight = 480;
scoped_refptr<media::VideoFrame> frame =
media::VideoFrame::CreateBlackFrame(gfx::Size(kWidth, kHeight));
ASSERT_TRUE(frame.get());
DeliverVideoFrame(frame);
SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded);
RemoveTrack(track);
}
} // namespace content
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment