mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
Move VideoTrackSourceProxy creation into VideoTrack.
This CL contains a part of a previously reviewed, landed, reverted, relanded and re-reverted CL: https://webrtc-review.googlesource.com/c/src/+/250180 Bug: webrtc:13540 Change-Id: Id6df8da5ff61e3ec90d0b3f3d828e8f670d4931b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251860 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Auto-Submit: Tomas Gunnarsson <tommi@webrtc.org> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36025}
This commit is contained in:
parent
a6bab608df
commit
4bc7223cf0
5 changed files with 32 additions and 14 deletions
|
@ -1272,6 +1272,7 @@ rtc_library("video_track") {
|
||||||
"video_track.h",
|
"video_track.h",
|
||||||
]
|
]
|
||||||
deps = [
|
deps = [
|
||||||
|
":rtc_pc_base",
|
||||||
"../api:media_stream_interface",
|
"../api:media_stream_interface",
|
||||||
"../api:scoped_refptr",
|
"../api:scoped_refptr",
|
||||||
"../api:sequence_checker",
|
"../api:sequence_checker",
|
||||||
|
|
|
@ -21,6 +21,10 @@
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
|
// TODO(tommi): Instead of inheriting from `MediaStreamTrack<>`, implement the
|
||||||
|
// properties directly in this class. `MediaStreamTrack` doesn't guard against
|
||||||
|
// conflicting access, so we'd need to override those methods anyway in this
|
||||||
|
// class in order to make sure things are correctly checked.
|
||||||
class AudioTrack : public MediaStreamTrack<AudioTrackInterface>,
|
class AudioTrack : public MediaStreamTrack<AudioTrackInterface>,
|
||||||
public ObserverInterface {
|
public ObserverInterface {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -41,11 +41,7 @@ VideoRtpReceiver::VideoRtpReceiver(
|
||||||
track_(VideoTrackProxyWithInternal<VideoTrack>::Create(
|
track_(VideoTrackProxyWithInternal<VideoTrack>::Create(
|
||||||
rtc::Thread::Current(),
|
rtc::Thread::Current(),
|
||||||
worker_thread,
|
worker_thread,
|
||||||
VideoTrack::Create(receiver_id,
|
VideoTrack::Create(receiver_id, source_, worker_thread))),
|
||||||
CreateVideoTrackSourceProxy(rtc::Thread::Current(),
|
|
||||||
worker_thread,
|
|
||||||
source_),
|
|
||||||
worker_thread))),
|
|
||||||
attachment_id_(GenerateUniqueId()) {
|
attachment_id_(GenerateUniqueId()) {
|
||||||
RTC_DCHECK(worker_thread_);
|
RTC_DCHECK(worker_thread_);
|
||||||
SetStreams(streams);
|
SetStreams(streams);
|
||||||
|
|
|
@ -23,12 +23,14 @@
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
VideoTrack::VideoTrack(const std::string& label,
|
VideoTrack::VideoTrack(
|
||||||
VideoTrackSourceInterface* video_source,
|
const std::string& label,
|
||||||
|
rtc::scoped_refptr<
|
||||||
|
VideoTrackSourceProxyWithInternal<VideoTrackSourceInterface>> source,
|
||||||
rtc::Thread* worker_thread)
|
rtc::Thread* worker_thread)
|
||||||
: MediaStreamTrack<VideoTrackInterface>(label),
|
: MediaStreamTrack<VideoTrackInterface>(label),
|
||||||
worker_thread_(worker_thread),
|
worker_thread_(worker_thread),
|
||||||
video_source_(video_source),
|
video_source_(std::move(source)),
|
||||||
content_hint_(ContentHint::kNone) {
|
content_hint_(ContentHint::kNone) {
|
||||||
RTC_DCHECK_RUN_ON(&signaling_thread_);
|
RTC_DCHECK_RUN_ON(&signaling_thread_);
|
||||||
// Detach the thread checker for VideoSourceBaseGuarded since we'll make calls
|
// Detach the thread checker for VideoSourceBaseGuarded since we'll make calls
|
||||||
|
@ -130,7 +132,13 @@ rtc::scoped_refptr<VideoTrack> VideoTrack::Create(
|
||||||
const std::string& id,
|
const std::string& id,
|
||||||
VideoTrackSourceInterface* source,
|
VideoTrackSourceInterface* source,
|
||||||
rtc::Thread* worker_thread) {
|
rtc::Thread* worker_thread) {
|
||||||
return rtc::make_ref_counted<VideoTrack>(id, source, worker_thread);
|
rtc::scoped_refptr<
|
||||||
|
VideoTrackSourceProxyWithInternal<VideoTrackSourceInterface>>
|
||||||
|
source_proxy = VideoTrackSourceProxy::Create(rtc::Thread::Current(),
|
||||||
|
worker_thread, source);
|
||||||
|
|
||||||
|
return rtc::make_ref_counted<VideoTrack>(id, std::move(source_proxy),
|
||||||
|
worker_thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
|
@ -22,11 +22,16 @@
|
||||||
#include "api/video/video_source_interface.h"
|
#include "api/video/video_source_interface.h"
|
||||||
#include "media/base/video_source_base.h"
|
#include "media/base/video_source_base.h"
|
||||||
#include "rtc_base/system/no_unique_address.h"
|
#include "rtc_base/system/no_unique_address.h"
|
||||||
|
#include "pc/video_track_source_proxy.h"
|
||||||
#include "rtc_base/thread.h"
|
#include "rtc_base/thread.h"
|
||||||
#include "rtc_base/thread_annotations.h"
|
#include "rtc_base/thread_annotations.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
|
// TODO(tommi): Instead of inheriting from `MediaStreamTrack<>`, implement the
|
||||||
|
// properties directly in this class. `MediaStreamTrack` doesn't guard against
|
||||||
|
// conflicting access, so we'd need to override those methods anyway in this
|
||||||
|
// class in order to make sure things are correctly checked.
|
||||||
class VideoTrack : public MediaStreamTrack<VideoTrackInterface>,
|
class VideoTrack : public MediaStreamTrack<VideoTrackInterface>,
|
||||||
public rtc::VideoSourceBaseGuarded,
|
public rtc::VideoSourceBaseGuarded,
|
||||||
public ObserverInterface {
|
public ObserverInterface {
|
||||||
|
@ -50,8 +55,10 @@ class VideoTrack : public MediaStreamTrack<VideoTrackInterface>,
|
||||||
std::string kind() const override;
|
std::string kind() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
VideoTrack(const std::string& id,
|
VideoTrack(
|
||||||
VideoTrackSourceInterface* video_source,
|
const std::string& id,
|
||||||
|
rtc::scoped_refptr<
|
||||||
|
VideoTrackSourceProxyWithInternal<VideoTrackSourceInterface>> source,
|
||||||
rtc::Thread* worker_thread);
|
rtc::Thread* worker_thread);
|
||||||
~VideoTrack();
|
~VideoTrack();
|
||||||
|
|
||||||
|
@ -61,7 +68,9 @@ class VideoTrack : public MediaStreamTrack<VideoTrackInterface>,
|
||||||
|
|
||||||
RTC_NO_UNIQUE_ADDRESS webrtc::SequenceChecker signaling_thread_;
|
RTC_NO_UNIQUE_ADDRESS webrtc::SequenceChecker signaling_thread_;
|
||||||
rtc::Thread* const worker_thread_;
|
rtc::Thread* const worker_thread_;
|
||||||
const rtc::scoped_refptr<VideoTrackSourceInterface> video_source_;
|
const rtc::scoped_refptr<
|
||||||
|
VideoTrackSourceProxyWithInternal<VideoTrackSourceInterface>>
|
||||||
|
video_source_;
|
||||||
ContentHint content_hint_ RTC_GUARDED_BY(&signaling_thread_);
|
ContentHint content_hint_ RTC_GUARDED_BY(&signaling_thread_);
|
||||||
// Cached `enabled` state for the worker thread. This is kept in sync with
|
// Cached `enabled` state for the worker thread. This is kept in sync with
|
||||||
// the state maintained on the signaling thread via set_enabled() but can
|
// the state maintained on the signaling thread via set_enabled() but can
|
||||||
|
|
Loading…
Reference in a new issue