diff --git a/api/BUILD.gn b/api/BUILD.gn index 05c0aee45a..8bbfc26110 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -73,6 +73,8 @@ rtc_static_library("libjingle_peerconnection_api") { "umametrics.cc", "umametrics.h", "videosinkinterface.h", + "videosourceinterface.cc", + "videosourceinterface.h", "videosourceproxy.h", ] diff --git a/api/mediastreaminterface.h b/api/mediastreaminterface.h index 1350b292c8..3273c6d672 100644 --- a/api/mediastreaminterface.h +++ b/api/mediastreaminterface.h @@ -28,7 +28,7 @@ // relying on them; they were previously transitively included by // mediachannel.h, which is no longer a dependency of this file. #include "api/videosinkinterface.h" -#include "media/base/videosourceinterface.h" +#include "api/videosourceinterface.h" #include "modules/audio_processing/include/audio_processing_statistics.h" #include "rtc_base/ratetracker.h" #include "rtc_base/refcount.h" diff --git a/api/videosourceinterface.cc b/api/videosourceinterface.cc new file mode 100644 index 0000000000..5eda369df0 --- /dev/null +++ b/api/videosourceinterface.cc @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2017 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 "api/videosourceinterface.h" + +namespace rtc { + +VideoSinkWants::VideoSinkWants() = default; +VideoSinkWants::~VideoSinkWants() = default; + +} // namespace rtc diff --git a/api/videosourceinterface.h b/api/videosourceinterface.h new file mode 100644 index 0000000000..ffb017ad51 --- /dev/null +++ b/api/videosourceinterface.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 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 API_VIDEOSOURCEINTERFACE_H_ +#define API_VIDEOSOURCEINTERFACE_H_ + +#include + +#include "api/optional.h" +#include "api/videosinkinterface.h" + +namespace rtc { + +// VideoSinkWants is used for notifying the source of properties a video frame +// should have when it is delivered to a certain sink. +struct VideoSinkWants { + VideoSinkWants(); + ~VideoSinkWants(); + // Tells the source whether the sink wants frames with rotation applied. + // By default, any rotation must be applied by the sink. + bool rotation_applied = false; + + // Tells the source that the sink only wants black frames. + bool black_frames = false; + + // Tells the source the maximum number of pixels the sink wants. + int max_pixel_count = std::numeric_limits::max(); + // Tells the source the desired number of pixels the sinks wants. This will + // typically be used when stepping the resolution up again when conditions + // have improved after an earlier downgrade. The source should select the + // closest resolution to this pixel count, but if max_pixel_count is set, it + // still sets the absolute upper bound. + rtc::Optional target_pixel_count; + // Tells the source the maximum framerate the sink wants. + int max_framerate_fps = std::numeric_limits::max(); +}; + +template +class VideoSourceInterface { + public: + virtual void AddOrUpdateSink(VideoSinkInterface* sink, + const VideoSinkWants& wants) = 0; + // RemoveSink must guarantee that at the time the method returns, + // there is no current and no future calls to VideoSinkInterface::OnFrame. + virtual void RemoveSink(VideoSinkInterface* sink) = 0; + + protected: + virtual ~VideoSourceInterface() {} +}; + +} // namespace rtc +#endif // API_VIDEOSOURCEINTERFACE_H_ diff --git a/call/BUILD.gn b/call/BUILD.gn index 7d1c443a5a..640956e232 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -157,12 +157,6 @@ rtc_static_library("call") { } rtc_source_set("video_stream_api") { - # TODO(bugs.webrtc.org/6828): Remove dependency cycle: - # //call:video_stream_api -> - # //media:rtc_media_base -> - # //call:call_interfaces -> - # //call:video_stream_api - check_includes = false sources = [ "video_config.cc", "video_config.h", @@ -173,12 +167,15 @@ rtc_source_set("video_stream_api") { ] deps = [ ":rtp_interfaces", + "../:typedefs", "../:webrtc_common", "../api:libjingle_peerconnection_api", "../api:optional", "../api:transport_api", + "../api:video_frame_api", "../common_video:common_video", "../modules/rtp_rtcp:rtp_rtcp_format", + "../rtc_base:checks", "../rtc_base:rtc_base_approved", ] } diff --git a/call/video_send_stream.h b/call/video_send_stream.h index 797f315519..a3c6f4f13a 100644 --- a/call/video_send_stream.h +++ b/call/video_send_stream.h @@ -20,11 +20,11 @@ #include "api/rtpparameters.h" #include "api/rtp_headers.h" #include "api/videosinkinterface.h" +#include "api/videosourceinterface.h" #include "call/rtp_config.h" #include "call/video_config.h" #include "common_types.h" // NOLINT(build/include) #include "common_video/include/frame_callback.h" -#include "media/base/videosourceinterface.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "rtc_base/platform_file.h" diff --git a/media/BUILD.gn b/media/BUILD.gn index 27c5714215..fbf16b83d6 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -92,7 +92,6 @@ rtc_static_library("rtc_media_base") { "base/videocommon.h", "base/videosourcebase.cc", "base/videosourcebase.h", - "base/videosourceinterface.cc", "base/videosourceinterface.h", ] diff --git a/media/base/videosourceinterface.h b/media/base/videosourceinterface.h index 73f5fee1dd..8ef24c502e 100644 --- a/media/base/videosourceinterface.h +++ b/media/base/videosourceinterface.h @@ -11,49 +11,7 @@ #ifndef MEDIA_BASE_VIDEOSOURCEINTERFACE_H_ #define MEDIA_BASE_VIDEOSOURCEINTERFACE_H_ -#include +// TODO(bugs.webrtc.org/6828): remove this file after downstream is updated. +#include "api/videosourceinterface.h" -#include "api/optional.h" -#include "api/videosinkinterface.h" - -namespace rtc { - -// VideoSinkWants is used for notifying the source of properties a video frame -// should have when it is delivered to a certain sink. -struct VideoSinkWants { - VideoSinkWants(); - ~VideoSinkWants(); - // Tells the source whether the sink wants frames with rotation applied. - // By default, any rotation must be applied by the sink. - bool rotation_applied = false; - - // Tells the source that the sink only wants black frames. - bool black_frames = false; - - // Tells the source the maximum number of pixels the sink wants. - int max_pixel_count = std::numeric_limits::max(); - // Tells the source the desired number of pixels the sinks wants. This will - // typically be used when stepping the resolution up again when conditions - // have improved after an earlier downgrade. The source should select the - // closest resolution to this pixel count, but if max_pixel_count is set, it - // still sets the absolute upper bound. - rtc::Optional target_pixel_count; - // Tells the source the maximum framerate the sink wants. - int max_framerate_fps = std::numeric_limits::max(); -}; - -template -class VideoSourceInterface { - public: - virtual void AddOrUpdateSink(VideoSinkInterface* sink, - const VideoSinkWants& wants) = 0; - // RemoveSink must guarantee that at the time the method returns, - // there is no current and no future calls to VideoSinkInterface::OnFrame. - virtual void RemoveSink(VideoSinkInterface* sink) = 0; - - protected: - virtual ~VideoSourceInterface() {} -}; - -} // namespace rtc #endif // MEDIA_BASE_VIDEOSOURCEINTERFACE_H_ diff --git a/media/engine/webrtcvideoengine.h b/media/engine/webrtcvideoengine.h index e096547158..56c7586de9 100644 --- a/media/engine/webrtcvideoengine.h +++ b/media/engine/webrtcvideoengine.h @@ -22,12 +22,12 @@ #include "api/video/video_frame.h" #include "api/video_codecs/sdp_video_format.h" #include "api/videosinkinterface.h" +#include "api/videosourceinterface.h" #include "call/call.h" #include "call/flexfec_receive_stream.h" #include "call/video_receive_stream.h" #include "call/video_send_stream.h" #include "media/base/mediaengine.h" -#include "media/base/videosourceinterface.h" #include "media/engine/webrtcvideodecoderfactory.h" #include "media/engine/webrtcvideoencoderfactory.h" #include "rtc_base/asyncinvoker.h" diff --git a/pc/channel.h b/pc/channel.h index 561279ff99..04c3d6e285 100644 --- a/pc/channel.h +++ b/pc/channel.h @@ -22,10 +22,10 @@ #include "api/jsep.h" #include "api/rtpreceiverinterface.h" #include "api/videosinkinterface.h" +#include "api/videosourceinterface.h" #include "media/base/mediachannel.h" #include "media/base/mediaengine.h" #include "media/base/streamparams.h" -#include "media/base/videosourceinterface.h" #include "p2p/base/dtlstransportinternal.h" #include "p2p/base/packettransportinternal.h" #include "p2p/client/socketmonitor.h" diff --git a/test/BUILD.gn b/test/BUILD.gn index 61978959e8..ef3447db12 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -61,6 +61,7 @@ rtc_source_set("video_test_common") { deps = [ "..:webrtc_common", "../:typedefs", + "../api:libjingle_peerconnection_api", "../api:optional", "../api:video_frame_api", "../api:video_frame_api_i420", diff --git a/test/frame_generator.h b/test/frame_generator.h index d37166f2fa..e7e2c121e1 100644 --- a/test/frame_generator.h +++ b/test/frame_generator.h @@ -15,7 +15,7 @@ #include #include "api/video/video_frame.h" -#include "media/base/videosourceinterface.h" +#include "api/videosourceinterface.h" #include "rtc_base/criticalsection.h" #include "typedefs.h" // NOLINT(build/include) diff --git a/test/video_capturer.h b/test/video_capturer.h index eba5d61111..7e640c93a5 100644 --- a/test/video_capturer.h +++ b/test/video_capturer.h @@ -17,8 +17,8 @@ #include "api/optional.h" #include "api/video/i420_buffer.h" #include "api/video/video_frame.h" +#include "api/videosourceinterface.h" #include "media/base/videoadapter.h" -#include "media/base/videosourceinterface.h" #include "rtc_base/criticalsection.h" namespace cricket {