Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Side by Side Diff: webrtc/media/base/videosourceinterface.h

Issue 2698203003: Update sink wants with ranges for both pixel count and frame rate.
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_MEDIA_BASE_VIDEOSOURCEINTERFACE_H_ 11 #ifndef WEBRTC_MEDIA_BASE_VIDEOSOURCEINTERFACE_H_
12 #define WEBRTC_MEDIA_BASE_VIDEOSOURCEINTERFACE_H_ 12 #define WEBRTC_MEDIA_BASE_VIDEOSOURCEINTERFACE_H_
13 13
14 #include "webrtc/media/base/videosinkinterface.h" 14 #include "webrtc/media/base/videosinkinterface.h"
15 #include "webrtc/base/optional.h" 15 #include "webrtc/base/optional.h"
16 16
17 namespace rtc { 17 namespace rtc {
18 18
19 // VideoSinkWants is used for notifying the source of properties a video frame 19 // VideoSinkWants is used for notifying the source of properties a video frame
20 // should have when it is delivered to a certain sink. 20 // should have when it is delivered to a certain sink.
21 struct VideoSinkWants { 21 struct VideoSinkWants {
22 // Tells the source whether the sink wants frames with rotation applied. 22 // Tells the source whether the sink wants frames with rotation applied.
23 // By default, any rotation must be applied by the sink. 23 // By default, any rotation must be applied by the sink.
24 bool rotation_applied = false; 24 bool rotation_applied = false;
25 25
26 // Tells the source that the sink only wants black frames. 26 // Tells the source that the sink only wants black frames.
27 bool black_frames = false; 27 bool black_frames = false;
28 28
29 // Tells the source the maximum number of pixels the sink wants. 29 // Indicates a range some value should be constrained to, such as resolution
30 rtc::Optional<int> max_pixel_count; 30 // (pixel count) or frame rate. It is up to the application code to make sure
31 // |min| <= |target| <= |max|.
32 struct ValueRange {
33 ValueRange()
34 : min(0), target(std::numeric_limits<uint32_t>::max()), max(target) {}
35 ValueRange(uint32_t min, uint32_t target, uint32_t max)
36 : min(min), target(target), max(max) {}
37
38 // |min| = 0, indicates no lower bound.
39 uint32_t min;
40 // |target| = maxint by default - requesting highest option available.
41 uint32_t target;
nisse-webrtc 2017/02/17 08:55:21 This makes it impossible to request min and max va
sprang_webrtc 2017/02/20 15:48:35 I think it's reasonable to explicitly define the t
nisse-webrtc 2017/02/20 16:03:47 I think we need to get a second opinion (or third,
sprang_webrtc 2017/02/21 09:11:03 Yes, I think avoid optional entirely in this case
nisse-webrtc 2017/02/21 09:33:59 The original SinkWants cabal were myself, perkj, p
42 // |max| = maxint, indicates to upper bound.
43 uint32_t max;
44 };
45
31 // Tells the source the desired number of pixels the sinks wants. This will 46 // Tells the source the desired number of pixels the sinks wants. This will
32 // typically be used when stepping the resolution up again when conditions 47 // typically be used when stepping the resolution down or up again as resource
33 // have improved after an earlier downgrade. The source should select the 48 // constraints are imposed or lifted.
34 // closest resolution to this pixel count, but if max_pixel_count is set, it 49 //
35 // still sets the absolute upper bound. 50 // For example, when stepping down resolution on CPU overuse, it's preferable
36 rtc::Optional<int> target_pixel_count; 51 // to set the max just below the current resolution but the target to a
52 // resolution that it is assumed would result in a utilization the system can
53 // handle. The source should select a resolution as close to |target| as
54 // possible, but no higher than |max|. Then |min| limit can then be set so
55 // that user requested minimum resolution bounds aren't violated.
56 //
57 // Similarly, when stepping up again, the |min| limit can be set one higher
58 // than the current resolution, and |target| to something reasonably higher
59 // (probably matching the step size down). The |max| limit can be set to
60 // avoid too large input.
61 rtc::Optional<ValueRange> pixel_count;
62
63 // These constraints work in just the same manner as the pixel_count ones, but
64 // instead of limiting resolution they limit the framerate.
65 rtc::Optional<ValueRange> framerate_fps_;
37 }; 66 };
38 67
39 template <typename VideoFrameT> 68 template <typename VideoFrameT>
40 class VideoSourceInterface { 69 class VideoSourceInterface {
41 public: 70 public:
42 virtual void AddOrUpdateSink(VideoSinkInterface<VideoFrameT>* sink, 71 virtual void AddOrUpdateSink(VideoSinkInterface<VideoFrameT>* sink,
43 const VideoSinkWants& wants) = 0; 72 const VideoSinkWants& wants) = 0;
44 // RemoveSink must guarantee that at the time the method returns, 73 // RemoveSink must guarantee that at the time the method returns,
45 // there is no current and no future calls to VideoSinkInterface::OnFrame. 74 // there is no current and no future calls to VideoSinkInterface::OnFrame.
46 virtual void RemoveSink(VideoSinkInterface<VideoFrameT>* sink) = 0; 75 virtual void RemoveSink(VideoSinkInterface<VideoFrameT>* sink) = 0;
47 76
48 protected: 77 protected:
49 virtual ~VideoSourceInterface() {} 78 virtual ~VideoSourceInterface() {}
50 }; 79 };
51 80
52 } // namespace rtc 81 } // namespace rtc
53 #endif // WEBRTC_MEDIA_BASE_VIDEOSOURCEINTERFACE_H_ 82 #endif // WEBRTC_MEDIA_BASE_VIDEOSOURCEINTERFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698