webrtc_m130/pc/video_track_source.h

74 lines
2.5 KiB
C
Raw Normal View History

/*
* Copyright 2016 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_TRACK_SOURCE_H_
#define PC_VIDEO_TRACK_SOURCE_H_
#include <optional>
#include "api/media_stream_interface.h"
#include "api/notifier.h"
#include "api/sequence_checker.h"
#include "api/video/recordable_encoded_frame.h"
#include "api/video/video_frame.h"
#include "api/video/video_sink_interface.h"
#include "api/video/video_source_interface.h"
#include "media/base/media_channel.h"
#include "rtc_base/checks.h"
Reland "Remove `stopped_` from AudioRtpReceiver and VideoRtpReceiver." This is a reland of 3ed36c0521546881656c73984456485dcab16205 Original change's description: > Reland "Remove `stopped_` from AudioRtpReceiver and VideoRtpReceiver." > > This is a reland of bb57e2d7aa9b36843233d1394422f03d12d9c31f > > The difference from the original CL is that a check for > `state_ == kLive` inside of RemoteAudioSource::AddSink has been removed. > This caused a side effect that registering the sink while the source > was in an "initializing" state, failed. The last remaining state > however, is `kEnded` - but since there's no logic in the class around > the expected value of the states, the check inside of AddSink() > doesn't provide an additional value - it's rather a surprise for > developers if it doesn't succeed. So, now removed. > > Original change's description: > > Remove `stopped_` from AudioRtpReceiver and VideoRtpReceiver. > > > > This simplifies the logic in these classes a bit, which makes upcoming > > change easier. The `stopped_` flag in these classes was essentially > > the same thing as `media_channel_ == nullptr`, which is what's > > consistently used now for the same checks. > > > > Bug: webrtc:13540 > > Change-Id: Ib60bfad9f28d5ddee8a8d5170c3f2a7ef017a5ca > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250163 > > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > > Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> > > Cr-Commit-Position: refs/heads/main@{#35907} > > Bug: webrtc:13540 > Change-Id: I3e5b3046fae11cb56b50c38c5f08972a6f283dd5 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251326 > Auto-Submit: Tomas Gunnarsson <tommi@webrtc.org> > Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > Commit-Queue: Harald Alvestrand <hta@webrtc.org> > Cr-Commit-Position: refs/heads/main@{#35958} Bug: webrtc:13540 Change-Id: I6d7d67fddb1ddfc69a302f0f69a9b815f2fd82f7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251386 Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/main@{#35967}
2022-02-08 21:12:15 +01:00
#include "rtc_base/system/no_unique_address.h"
#include "rtc_base/system/rtc_export.h"
#include "rtc_base/thread_annotations.h"
namespace webrtc {
// VideoTrackSource is a convenience base class for implementations of
// VideoTrackSourceInterface.
class RTC_EXPORT VideoTrackSource : public Notifier<VideoTrackSourceInterface> {
public:
explicit VideoTrackSource(bool remote);
void SetState(SourceState new_state);
Reland "Remove `stopped_` from AudioRtpReceiver and VideoRtpReceiver." This is a reland of 3ed36c0521546881656c73984456485dcab16205 Original change's description: > Reland "Remove `stopped_` from AudioRtpReceiver and VideoRtpReceiver." > > This is a reland of bb57e2d7aa9b36843233d1394422f03d12d9c31f > > The difference from the original CL is that a check for > `state_ == kLive` inside of RemoteAudioSource::AddSink has been removed. > This caused a side effect that registering the sink while the source > was in an "initializing" state, failed. The last remaining state > however, is `kEnded` - but since there's no logic in the class around > the expected value of the states, the check inside of AddSink() > doesn't provide an additional value - it's rather a surprise for > developers if it doesn't succeed. So, now removed. > > Original change's description: > > Remove `stopped_` from AudioRtpReceiver and VideoRtpReceiver. > > > > This simplifies the logic in these classes a bit, which makes upcoming > > change easier. The `stopped_` flag in these classes was essentially > > the same thing as `media_channel_ == nullptr`, which is what's > > consistently used now for the same checks. > > > > Bug: webrtc:13540 > > Change-Id: Ib60bfad9f28d5ddee8a8d5170c3f2a7ef017a5ca > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250163 > > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > > Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> > > Cr-Commit-Position: refs/heads/main@{#35907} > > Bug: webrtc:13540 > Change-Id: I3e5b3046fae11cb56b50c38c5f08972a6f283dd5 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251326 > Auto-Submit: Tomas Gunnarsson <tommi@webrtc.org> > Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > Commit-Queue: Harald Alvestrand <hta@webrtc.org> > Cr-Commit-Position: refs/heads/main@{#35958} Bug: webrtc:13540 Change-Id: I6d7d67fddb1ddfc69a302f0f69a9b815f2fd82f7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251386 Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/main@{#35967}
2022-02-08 21:12:15 +01:00
SourceState state() const override {
RTC_DCHECK_RUN_ON(&signaling_thread_checker_);
return state_;
}
bool remote() const override { return remote_; }
bool is_screencast() const override { return false; }
std::optional<bool> needs_denoising() const override { return std::nullopt; }
bool GetStats(Stats* stats) override { return false; }
void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
const rtc::VideoSinkWants& wants) override;
void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override;
bool SupportsEncodedOutput() const override { return false; }
void GenerateKeyFrame() override {}
void AddEncodedSink(
rtc::VideoSinkInterface<RecordableEncodedFrame>* sink) override {}
void RemoveEncodedSink(
rtc::VideoSinkInterface<RecordableEncodedFrame>* sink) override {}
protected:
virtual rtc::VideoSourceInterface<VideoFrame>* source() = 0;
private:
RTC_NO_UNIQUE_ADDRESS SequenceChecker worker_thread_checker_{
SequenceChecker::kDetached};
Reland "Remove `stopped_` from AudioRtpReceiver and VideoRtpReceiver." This is a reland of 3ed36c0521546881656c73984456485dcab16205 Original change's description: > Reland "Remove `stopped_` from AudioRtpReceiver and VideoRtpReceiver." > > This is a reland of bb57e2d7aa9b36843233d1394422f03d12d9c31f > > The difference from the original CL is that a check for > `state_ == kLive` inside of RemoteAudioSource::AddSink has been removed. > This caused a side effect that registering the sink while the source > was in an "initializing" state, failed. The last remaining state > however, is `kEnded` - but since there's no logic in the class around > the expected value of the states, the check inside of AddSink() > doesn't provide an additional value - it's rather a surprise for > developers if it doesn't succeed. So, now removed. > > Original change's description: > > Remove `stopped_` from AudioRtpReceiver and VideoRtpReceiver. > > > > This simplifies the logic in these classes a bit, which makes upcoming > > change easier. The `stopped_` flag in these classes was essentially > > the same thing as `media_channel_ == nullptr`, which is what's > > consistently used now for the same checks. > > > > Bug: webrtc:13540 > > Change-Id: Ib60bfad9f28d5ddee8a8d5170c3f2a7ef017a5ca > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250163 > > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > > Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> > > Cr-Commit-Position: refs/heads/main@{#35907} > > Bug: webrtc:13540 > Change-Id: I3e5b3046fae11cb56b50c38c5f08972a6f283dd5 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251326 > Auto-Submit: Tomas Gunnarsson <tommi@webrtc.org> > Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > Commit-Queue: Harald Alvestrand <hta@webrtc.org> > Cr-Commit-Position: refs/heads/main@{#35958} Bug: webrtc:13540 Change-Id: I6d7d67fddb1ddfc69a302f0f69a9b815f2fd82f7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251386 Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/main@{#35967}
2022-02-08 21:12:15 +01:00
RTC_NO_UNIQUE_ADDRESS SequenceChecker signaling_thread_checker_;
SourceState state_ RTC_GUARDED_BY(&signaling_thread_checker_);
const bool remote_;
};
} // namespace webrtc
#endif // PC_VIDEO_TRACK_SOURCE_H_