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

Side by Side Diff: webrtc/video_send_stream.h

Issue 1569853002: Measure encoding time on encode callbacks. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 4 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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_VIDEO_SEND_STREAM_H_ 11 #ifndef WEBRTC_VIDEO_SEND_STREAM_H_
12 #define WEBRTC_VIDEO_SEND_STREAM_H_ 12 #define WEBRTC_VIDEO_SEND_STREAM_H_
13 13
14 #include <map> 14 #include <map>
15 #include <string> 15 #include <string>
16 16
17 #include "webrtc/common_types.h" 17 #include "webrtc/common_types.h"
18 #include "webrtc/config.h" 18 #include "webrtc/config.h"
19 #include "webrtc/frame_callback.h" 19 #include "webrtc/frame_callback.h"
20 #include "webrtc/stream.h" 20 #include "webrtc/stream.h"
21 #include "webrtc/transport.h" 21 #include "webrtc/transport.h"
22 #include "webrtc/video_renderer.h" 22 #include "webrtc/video_renderer.h"
23 23
24 namespace webrtc { 24 namespace webrtc {
25 25
26 class LoadObserver; 26 class LoadObserver;
27 class VideoEncoder; 27 class VideoEncoder;
28 28
29 class EncodingTimeObserver {
30 public:
31 virtual ~EncodingTimeObserver() {}
32
33 virtual void OnReportEncodedTime(int64_t ntp_time_ms, int encode_time_ms) = 0;
34 };
35
36 // Class to deliver captured frame to the video send stream. 29 // Class to deliver captured frame to the video send stream.
37 class VideoCaptureInput { 30 class VideoCaptureInput {
38 public: 31 public:
39 // These methods do not lock internally and must be called sequentially. 32 // These methods do not lock internally and must be called sequentially.
40 // If your application switches input sources synchronization must be done 33 // If your application switches input sources synchronization must be done
41 // externally to make sure that any old frames are not delivered concurrently. 34 // externally to make sure that any old frames are not delivered concurrently.
42 virtual void IncomingCapturedFrame(const VideoFrame& video_frame) = 0; 35 virtual void IncomingCapturedFrame(const VideoFrame& video_frame) = 0;
43 36
44 protected: 37 protected:
45 virtual ~VideoCaptureInput() {} 38 virtual ~VideoCaptureInput() {}
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 struct EncoderSettings { 77 struct EncoderSettings {
85 std::string ToString() const; 78 std::string ToString() const;
86 79
87 std::string payload_name; 80 std::string payload_name;
88 int payload_type = -1; 81 int payload_type = -1;
89 82
90 // TODO(sophiechang): Delete this field when no one is using internal 83 // TODO(sophiechang): Delete this field when no one is using internal
91 // sources anymore. 84 // sources anymore.
92 bool internal_source = false; 85 bool internal_source = false;
93 86
87 // Allow 100% encoder utilization. Used for HW encoders where CPU isn't
88 // expected to be the limiting factor, but a chip could be running at
89 // 30fps (for example) exactly.
90 bool full_overuse_time = false;
91
94 // Uninitialized VideoEncoder instance to be used for encoding. Will be 92 // Uninitialized VideoEncoder instance to be used for encoding. Will be
95 // initialized from inside the VideoSendStream. 93 // initialized from inside the VideoSendStream.
96 VideoEncoder* encoder = nullptr; 94 VideoEncoder* encoder = nullptr;
97 } encoder_settings; 95 } encoder_settings;
98 96
99 static const size_t kDefaultMaxPacketSize = 1500 - 40; // TCP over IPv4. 97 static const size_t kDefaultMaxPacketSize = 1500 - 40; // TCP over IPv4.
100 struct Rtp { 98 struct Rtp {
101 std::string ToString() const; 99 std::string ToString() const;
102 100
103 std::vector<uint32_t> ssrcs; 101 std::vector<uint32_t> ssrcs;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 135
138 // Callback for overuse and normal usage based on the jitter of incoming 136 // Callback for overuse and normal usage based on the jitter of incoming
139 // captured frames. 'nullptr' disables the callback. 137 // captured frames. 'nullptr' disables the callback.
140 LoadObserver* overuse_callback = nullptr; 138 LoadObserver* overuse_callback = nullptr;
141 139
142 // Called for each I420 frame before encoding the frame. Can be used for 140 // Called for each I420 frame before encoding the frame. Can be used for
143 // effects, snapshots etc. 'nullptr' disables the callback. 141 // effects, snapshots etc. 'nullptr' disables the callback.
144 I420FrameCallback* pre_encode_callback = nullptr; 142 I420FrameCallback* pre_encode_callback = nullptr;
145 143
146 // Called for each encoded frame, e.g. used for file storage. 'nullptr' 144 // Called for each encoded frame, e.g. used for file storage. 'nullptr'
147 // disables the callback. 145 // disables the callback. Also measures timing and passes the time
146 // spent on encoding. This timing will not fire if encoding takes longer
147 // than the measuring window, since the sample data will have been dropped.
148 EncodedFrameObserver* post_encode_callback = nullptr; 148 EncodedFrameObserver* post_encode_callback = nullptr;
149 149
150 // Renderer for local preview. The local renderer will be called even if 150 // Renderer for local preview. The local renderer will be called even if
151 // sending hasn't started. 'nullptr' disables local rendering. 151 // sending hasn't started. 'nullptr' disables local rendering.
152 VideoRenderer* local_renderer = nullptr; 152 VideoRenderer* local_renderer = nullptr;
153 153
154 // Expected delay needed by the renderer, i.e. the frame will be delivered 154 // Expected delay needed by the renderer, i.e. the frame will be delivered
155 // this many milliseconds, if possible, earlier than expected render time. 155 // this many milliseconds, if possible, earlier than expected render time.
156 // Only valid if |local_renderer| is set. 156 // Only valid if |local_renderer| is set.
157 int render_delay_ms = 0; 157 int render_delay_ms = 0;
158 158
159 // Target delay in milliseconds. A positive value indicates this stream is 159 // Target delay in milliseconds. A positive value indicates this stream is
160 // used for streaming instead of a real-time call. 160 // used for streaming instead of a real-time call.
161 int target_delay_ms = 0; 161 int target_delay_ms = 0;
162 162
163 // True if the stream should be suspended when the available bitrate fall 163 // True if the stream should be suspended when the available bitrate fall
164 // below the minimum configured bitrate. If this variable is false, the 164 // below the minimum configured bitrate. If this variable is false, the
165 // stream may send at a rate higher than the estimated available bitrate. 165 // stream may send at a rate higher than the estimated available bitrate.
166 bool suspend_below_min_bitrate = false; 166 bool suspend_below_min_bitrate = false;
167
168 // Called for each encoded frame. Passes the total time spent on encoding.
169 // TODO(ivica): Consolidate with post_encode_callback:
170 // https://code.google.com/p/webrtc/issues/detail?id=5042
171 EncodingTimeObserver* encoding_time_observer = nullptr;
172 }; 167 };
173 168
174 // Gets interface used to insert captured frames. Valid as long as the 169 // Gets interface used to insert captured frames. Valid as long as the
175 // VideoSendStream is valid. 170 // VideoSendStream is valid.
176 virtual VideoCaptureInput* Input() = 0; 171 virtual VideoCaptureInput* Input() = 0;
177 172
178 // Set which streams to send. Must have at least as many SSRCs as configured 173 // Set which streams to send. Must have at least as many SSRCs as configured
179 // in the config. Encoder settings are passed on to the encoder instance along 174 // in the config. Encoder settings are passed on to the encoder instance along
180 // with the VideoStream settings. 175 // with the VideoStream settings.
181 virtual bool ReconfigureVideoEncoder(const VideoEncoderConfig& config) = 0; 176 virtual bool ReconfigureVideoEncoder(const VideoEncoderConfig& config) = 0;
182 177
183 virtual Stats GetStats() = 0; 178 virtual Stats GetStats() = 0;
184 }; 179 };
185 180
186 } // namespace webrtc 181 } // namespace webrtc
187 182
188 #endif // WEBRTC_VIDEO_SEND_STREAM_H_ 183 #endif // WEBRTC_VIDEO_SEND_STREAM_H_
OLDNEW
« webrtc/video/video_quality_test.cc ('K') | « webrtc/video/vie_encoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698