forked from JumpingYang001/webrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move VideoStreamEncoderInterface to api/.
Bug: webrtc:8830 Change-Id: I17908b4ef6a043acf22e2110b9672012d5fa7fc0 Reviewed-on: https://webrtc-review.googlesource.com/74481 Reviewed-by: Karl Wiberg <[email protected]> Reviewed-by: Rasmus Brandt <[email protected]> Reviewed-by: Sebastian Jansson <[email protected]> Reviewed-by: Stefan Holmer <[email protected]> Commit-Queue: Niels Moller <[email protected]> Cr-Commit-Position: refs/heads/master@{#23334}
- Loading branch information
Niels Möller
authored and
Commit Bot
committed
May 21, 2018
1 parent
65ec0fc
commit 0327c2d
Showing
24 changed files
with
218 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* 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_VIDEO_VIDEO_SOURCE_INTERFACE_H_ | ||
#define API_VIDEO_VIDEO_SOURCE_INTERFACE_H_ | ||
|
||
#include <limits> | ||
|
||
#include "api/optional.h" | ||
#include "api/video/video_sink_interface.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(const 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<int>::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<int> target_pixel_count; | ||
// Tells the source the maximum framerate the sink wants. | ||
int max_framerate_fps = std::numeric_limits<int>::max(); | ||
}; | ||
|
||
template <typename VideoFrameT> | ||
class VideoSourceInterface { | ||
public: | ||
virtual void AddOrUpdateSink(VideoSinkInterface<VideoFrameT>* 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<VideoFrameT>* sink) = 0; | ||
|
||
protected: | ||
// Non-public, since one shouldn't own sources via this interface. | ||
virtual ~VideoSourceInterface() {} | ||
}; | ||
|
||
} // namespace rtc | ||
#endif // API_VIDEO_VIDEO_SOURCE_INTERFACE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* Copyright (c) 2018 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_VIDEO_VIDEO_STREAM_ENCODER_INTERFACE_H_ | ||
#define API_VIDEO_VIDEO_STREAM_ENCODER_INTERFACE_H_ | ||
|
||
#include <vector> | ||
|
||
#include "api/rtpparameters.h" // For DegradationPreference. | ||
#include "api/video/video_sink_interface.h" | ||
#include "api/video/video_source_interface.h" | ||
#include "api/video_codecs/video_encoder.h" | ||
#include "api/video_codecs/video_encoder_config.h" | ||
|
||
namespace webrtc { | ||
|
||
// TODO(nisse): Move full declaration to api/. | ||
class VideoBitrateAllocationObserver; | ||
|
||
// This interface represents a class responsible for creating and driving the | ||
// encoder(s) for a single video stream. It is also responsible for adaptation | ||
// decisions related to video quality, requesting reduced frame rate or | ||
// resolution from the VideoSource when needed. | ||
// TODO(bugs.webrtc.org/8830): This interface is under development. Changes | ||
// under consideration include: | ||
// | ||
// 1. Taking out responsibility for adaptation decisions, instead only reporting | ||
// per-frame measurements to the decision maker. | ||
// | ||
// 2. Moving responsibility for simulcast and for software fallback into this | ||
// class. | ||
class VideoStreamEncoderInterface : public rtc::VideoSinkInterface<VideoFrame> { | ||
public: | ||
// Interface for receiving encoded video frames and notifications about | ||
// configuration changes. | ||
class EncoderSink : public EncodedImageCallback { | ||
public: | ||
virtual void OnEncoderConfigurationChanged( | ||
std::vector<VideoStream> streams, | ||
int min_transmit_bitrate_bps) = 0; | ||
}; | ||
|
||
virtual ~VideoStreamEncoderInterface() = default; | ||
|
||
// Sets the source that will provide video frames to the VideoStreamEncoder's | ||
// OnFrame method. |degradation_preference| control whether or not resolution | ||
// or frame rate may be reduced. The VideoStreamEncoder registers itself with | ||
// |source|, and signals adaptation decisions to the source in the form of | ||
// VideoSinkWants. | ||
// TODO(nisse): When adaptation logic is extracted from this class, | ||
// it no longer needs to know the source. | ||
virtual void SetSource( | ||
rtc::VideoSourceInterface<VideoFrame>* source, | ||
const DegradationPreference& degradation_preference) = 0; | ||
|
||
// Sets the |sink| that gets the encoded frames. |rotation_applied| means | ||
// that the source must support rotation. Only set |rotation_applied| if the | ||
// remote side does not support the rotation extension. | ||
virtual void SetSink(EncoderSink* sink, bool rotation_applied) = 0; | ||
|
||
// Sets an initial bitrate, later overriden by OnBitrateUpdated. Mainly | ||
// affects the resolution of the initial key frame: If incoming frames are | ||
// larger than reasonable for the start bitrate, and scaling is enabled, | ||
// VideoStreamEncoder asks the source to scale down and drops a few initial | ||
// frames. | ||
// TODO(nisse): This is a poor interface, and mixes bandwidth estimation and | ||
// codec configuration in an undesired way. For the actual send bandwidth, we | ||
// should always be somewhat conservative, but we may nevertheless want to let | ||
// the application configure a more optimistic quality for the initial | ||
// resolution. Should be replaced by a construction time setting. | ||
virtual void SetStartBitrate(int start_bitrate_bps) = 0; | ||
|
||
// Request a key frame. Used for signalling from the remote receiver. | ||
virtual void SendKeyFrame() = 0; | ||
|
||
// Set the currently estimated network properties. A |bitrate_bps| | ||
// of zero pauses the encoder. | ||
virtual void OnBitrateUpdated(uint32_t bitrate_bps, | ||
uint8_t fraction_lost, | ||
int64_t round_trip_time_ms) = 0; | ||
|
||
// Register observer for the bitrate allocation between the temporal | ||
// and spatial layers. | ||
virtual void SetBitrateAllocationObserver( | ||
VideoBitrateAllocationObserver* bitrate_observer) = 0; | ||
|
||
// Creates and configures an encoder with the given |config|. The | ||
// |max_data_payload_length| is used to support single NAL unit | ||
// packetization for H.264. | ||
virtual void ConfigureEncoder(VideoEncoderConfig config, | ||
size_t max_data_payload_length) = 0; | ||
|
||
// Permanently stop encoding. After this method has returned, it is | ||
// guaranteed that no encoded frames will be delivered to the sink. | ||
virtual void Stop() = 0; | ||
}; | ||
|
||
} // namespace webrtc | ||
|
||
#endif // API_VIDEO_VIDEO_STREAM_ENCODER_INTERFACE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.