Change webrtc::VideoSourceInterface to inherit rtc::VideoSourceInterface.

Also introduce a typedef VideoTrackSourceInterface to be able to start changing clients such as Chrome to use the name VideoTrackSourceInterface.

Document: https://docs.google.com/a/google.com/document/d/1mEIw_0uDzyHjL3l8a82WKp6AvgR8Tlwn9JGvhbUjVpY/edit?usp=sharing

BUG=webrtc:5426

Review URL: https://codereview.webrtc.org/1758223002

Cr-Commit-Position: refs/heads/master@{#11854}
This commit is contained in:
perkj 2016-03-03 01:51:52 -08:00 committed by Commit bot
parent c8da45f329
commit f2880a0e04
8 changed files with 32 additions and 42 deletions

View File

@ -83,16 +83,17 @@ class FakeVideoSource : public Notifier<VideoSourceInterface> {
static rtc::scoped_refptr<FakeVideoSource> Create(bool remote) {
return new rtc::RefCountedObject<FakeVideoSource>(remote);
}
virtual cricket::VideoCapturer* GetVideoCapturer() { return &fake_capturer_; }
virtual void Stop() {}
virtual void Restart() {}
virtual void AddSink(rtc::VideoSinkInterface<cricket::VideoFrame>* output) {}
virtual void RemoveSink(
rtc::VideoSinkInterface<cricket::VideoFrame>* output) {}
virtual SourceState state() const { return state_; }
virtual bool remote() const { return remote_; }
virtual const cricket::VideoOptions* options() const { return &options_; }
virtual cricket::VideoRenderer* FrameInput() { return NULL; }
cricket::VideoCapturer* GetVideoCapturer() { return &fake_capturer_; }
void Stop() override {}
void Restart() override {}
void AddOrUpdateSink(
rtc::VideoSinkInterface<cricket::VideoFrame>* sink,
const rtc::VideoSinkWants& wants) override {}
void RemoveSink(
rtc::VideoSinkInterface<cricket::VideoFrame>* output) override {}
SourceState state() const override { return state_; }
bool remote() const override { return remote_; }
const cricket::VideoOptions* options() const override { return &options_; }
protected:
explicit FakeVideoSource(bool remote) : state_(kLive), remote_(remote) {}

View File

@ -394,13 +394,12 @@ void VideoSource::Restart() {
started_ = true;
}
void VideoSource::AddSink(
rtc::VideoSinkInterface<cricket::VideoFrame>* output) {
// TODO(perkj): Use fake rtc::VideoSinkWants for now. This will change once
// webrtc::VideoSourceInterface inherit rtc::VideoSourceInterface.
void VideoSource::AddOrUpdateSink(
rtc::VideoSinkInterface<cricket::VideoFrame>* sink,
const rtc::VideoSinkWants& wants) {
worker_thread_->Invoke<void>(
rtc::Bind(&cricket::VideoCapturer::AddOrUpdateSink,
video_capturer_.get(), output, rtc::VideoSinkWants()));
video_capturer_.get(), sink, wants));
}
void VideoSource::RemoveSink(

View File

@ -30,13 +30,6 @@
// The state is set depending on the result of starting the capturer.
// If the constraint can't be met or the capturer fails to start, the state
// transition to kEnded, otherwise it transitions to kLive.
namespace cricket {
class ChannelManager;
} // namespace cricket
namespace webrtc {
class MediaConstraintsInterface;
@ -66,10 +59,9 @@ class VideoSource : public Notifier<VideoSourceInterface>,
void Stop() override;
void Restart() override;
// |output| will be served video frames as long as the underlying capturer
// is running video frames.
virtual void AddSink(rtc::VideoSinkInterface<cricket::VideoFrame>* output);
virtual void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* output);
void AddOrUpdateSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink,
const rtc::VideoSinkWants& wants) override;
void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override;
protected:
VideoSource(rtc::Thread* worker_thread,

View File

@ -137,7 +137,7 @@ class VideoSourceTest : public testing::Test {
state_observer_.reset(new StateObserver(source_));
source_->RegisterObserver(state_observer_.get());
source_->AddSink(&renderer_);
source_->AddOrUpdateSink(&renderer_, rtc::VideoSinkWants());
}
rtc::scoped_ptr<TestVideoCapturer> capturer_cleanup_;
@ -200,7 +200,7 @@ TEST_F(VideoSourceTest, StartStopRemote) {
state_observer_.reset(new StateObserver(source_));
source_->RegisterObserver(state_observer_.get());
source_->AddSink(&renderer_);
source_->AddOrUpdateSink(&renderer_, rtc::VideoSinkWants());
EXPECT_EQ_WAIT(MediaSourceInterface::kLive, state_observer_->state(),
kMaxWaitMs);

View File

@ -13,7 +13,7 @@
#include "webrtc/api/mediastreaminterface.h"
#include "webrtc/media/base/mediachannel.h"
#include "webrtc/media/base/videorenderer.h"
#include "webrtc/media/base/videosourceinterface.h"
namespace webrtc {
@ -21,31 +21,28 @@ namespace webrtc {
// The same source can be used in multiple VideoTracks.
// The methods are only supposed to be called by the PeerConnection
// implementation.
class VideoSourceInterface : public MediaSourceInterface {
class VideoSourceInterface :
public MediaSourceInterface,
public rtc::VideoSourceInterface<cricket::VideoFrame> {
public:
// Get access to the source implementation of cricket::VideoCapturer.
// This can be used for receiving frames and state notifications.
// But it should not be used for starting or stopping capturing.
virtual cricket::VideoCapturer* GetVideoCapturer() = 0;
// Stop the video capturer.
virtual void Stop() = 0;
virtual void Restart() = 0;
// Adds |output| to the source to receive frames.
virtual void AddSink(
rtc::VideoSinkInterface<cricket::VideoFrame>* output) = 0;
virtual void RemoveSink(
rtc::VideoSinkInterface<cricket::VideoFrame>* output) = 0;
virtual const cricket::VideoOptions* options() const = 0;
// TODO(nisse): Dummy implementation. Delete as soon as chrome's
// MockVideoSource is updated.
virtual cricket::VideoRenderer* FrameInput() { return nullptr; }
protected:
virtual ~VideoSourceInterface() {}
};
// TODO(perkj): Rename webrtc::VideoSourceInterface to
// webrtc::VideoTrackSourceInterface
using VideoTrackSourceInterface = VideoSourceInterface;
} // namespace webrtc
#endif // WEBRTC_API_VIDEOSOURCEINTERFACE_H_

View File

@ -25,7 +25,9 @@ BEGIN_PROXY_MAP(VideoSource)
PROXY_METHOD0(cricket::VideoCapturer*, GetVideoCapturer)
PROXY_METHOD0(void, Stop)
PROXY_METHOD0(void, Restart)
PROXY_METHOD1(void, AddSink, rtc::VideoSinkInterface<cricket::VideoFrame>*)
PROXY_METHOD2(void, AddOrUpdateSink,
rtc::VideoSinkInterface<cricket::VideoFrame>*,
const rtc::VideoSinkWants&)
PROXY_METHOD1(void, RemoveSink, rtc::VideoSinkInterface<cricket::VideoFrame>*)
PROXY_CONSTMETHOD0(const cricket::VideoOptions*, options)
PROXY_METHOD1(void, RegisterObserver, ObserverInterface*)

View File

@ -21,7 +21,7 @@ VideoTrack::VideoTrack(const std::string& label,
: MediaStreamTrack<VideoTrackInterface>(label),
video_source_(video_source) {
if (video_source_)
video_source_->AddSink(&renderers_);
video_source_->AddOrUpdateSink(&renderers_, rtc::VideoSinkWants());
}
VideoTrack::~VideoTrack() {

View File

@ -12,7 +12,6 @@
#define WEBRTC_MEDIA_BASE_VIDEOSOURCEINTERFACE_H_
#include "webrtc/media/base/videosinkinterface.h"
#include "webrtc/base/callback.h"
#include "webrtc/base/optional.h"
namespace rtc {