VideoRtpReceiver: factor out VideoRtpTrackSource.

This change factors out VideoRtpTrackSource in preparation
of building the class out.

Bug: chromium:1013590
Change-Id: I015e285b9fcc10b39428dea9f74e0e8648385f62
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/159925
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29870}
This commit is contained in:
Markus Handell
2019-11-22 10:34:37 +01:00
committed by Commit Bot
parent 4995f872ca
commit 15f2ff4610
5 changed files with 95 additions and 18 deletions

View File

@ -212,6 +212,8 @@ rtc_library("peerconnection") {
"track_media_info_map.h",
"video_rtp_receiver.cc",
"video_rtp_receiver.h",
"video_rtp_track_source.cc",
"video_rtp_track_source.h",
"video_track.cc",
"video_track.h",
"video_track_source.cc",
@ -539,6 +541,7 @@ if (rtc_include_tests) {
"test/fake_audio_capture_module_unittest.cc",
"test/test_sdp_strings.h",
"track_media_info_map_unittest.cc",
"video_rtp_track_source_unittest.cc",
"video_track_unittest.cc",
"webrtc_sdp_unittest.cc",
]

View File

@ -27,10 +27,9 @@
#include "api/video/video_sink_interface.h"
#include "api/video/video_source_interface.h"
#include "media/base/media_channel.h"
#include "media/base/video_broadcaster.h"
#include "pc/jitter_buffer_delay_interface.h"
#include "pc/rtp_receiver.h"
#include "pc/video_track_source.h"
#include "pc/video_rtp_track_source.h"
#include "rtc_base/ref_counted_object.h"
#include "rtc_base/thread.h"
@ -110,22 +109,6 @@ class VideoRtpReceiver : public rtc::RefCountedObject<RtpReceiverInternal> {
std::vector<RtpSource> GetSources() const override;
private:
class VideoRtpTrackSource : public VideoTrackSource {
public:
VideoRtpTrackSource() : VideoTrackSource(true /* remote */) {}
rtc::VideoSourceInterface<VideoFrame>* source() override {
return &broadcaster_;
}
rtc::VideoSinkInterface<VideoFrame>* sink() { return &broadcaster_; }
private:
// |broadcaster_| is needed since the decoder can only handle one sink.
// It might be better if the decoder can handle multiple sinks and consider
// the VideoSinkWants.
rtc::VideoBroadcaster broadcaster_;
};
void RestartMediaChannel(absl::optional<uint32_t> ssrc);
bool SetSink(rtc::VideoSinkInterface<VideoFrame>* sink);

View File

@ -0,0 +1,25 @@
/*
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "pc/video_rtp_track_source.h"
namespace webrtc {
VideoRtpTrackSource::VideoRtpTrackSource()
: VideoTrackSource(true /* remote */) {}
rtc::VideoSourceInterface<VideoFrame>* VideoRtpTrackSource::source() {
return &broadcaster_;
}
rtc::VideoSinkInterface<VideoFrame>* VideoRtpTrackSource::sink() {
return &broadcaster_;
}
} // namespace webrtc

View File

@ -0,0 +1,39 @@
/*
* Copyright 2019 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef PC_VIDEO_RTP_TRACK_SOURCE_H_
#define PC_VIDEO_RTP_TRACK_SOURCE_H_
#include "media/base/video_broadcaster.h"
#include "pc/video_track_source.h"
namespace webrtc {
// Video track source in use by VideoRtpReceiver
class VideoRtpTrackSource : public VideoTrackSource {
public:
VideoRtpTrackSource();
// VideoTrackSource
rtc::VideoSourceInterface<VideoFrame>* source() override;
rtc::VideoSinkInterface<VideoFrame>* sink();
private:
// |broadcaster_| is needed since the decoder can only handle one sink.
// It might be better if the decoder can handle multiple sinks and consider
// the VideoSinkWants.
rtc::VideoBroadcaster broadcaster_;
RTC_DISALLOW_COPY_AND_ASSIGN(VideoRtpTrackSource);
};
} // namespace webrtc
#endif // PC_VIDEO_RTP_TRACK_SOURCE_H_

View File

@ -0,0 +1,27 @@
/*
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "pc/video_rtp_track_source.h"
#include "rtc_base/ref_counted_object.h"
#include "test/gmock.h"
#include "test/gtest.h"
namespace webrtc {
namespace {
TEST(VideoRtpTrackSourceTest, CreatesWithRemoteAtttributeSet) {
rtc::scoped_refptr<VideoRtpTrackSource> source(
new rtc::RefCountedObject<VideoRtpTrackSource>());
EXPECT_TRUE(source->remote());
}
} // namespace
} // namespace webrtc