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

Side by Side Diff: webrtc/video_encoder.h

Issue 2089773002: Add EncodedImageCallback::OnEncodedImage(). (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: . Created 4 years, 4 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
« no previous file with comments | « webrtc/video/vie_encoder.cc ('k') | webrtc/voice_engine/channel.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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
(...skipping 12 matching lines...) Expand all
23 23
24 class RTPFragmentationHeader; 24 class RTPFragmentationHeader;
25 // TODO(pbos): Expose these through a public (root) header or change these APIs. 25 // TODO(pbos): Expose these through a public (root) header or change these APIs.
26 struct CodecSpecificInfo; 26 struct CodecSpecificInfo;
27 struct VideoCodec; 27 struct VideoCodec;
28 28
29 class EncodedImageCallback { 29 class EncodedImageCallback {
30 public: 30 public:
31 virtual ~EncodedImageCallback() {} 31 virtual ~EncodedImageCallback() {}
32 32
33 struct Result {
34 enum Error {
35 OK,
36
37 // Failed to send the packet.
38 ERROR_SEND_FAILED,
39 };
40
41 Result(Error error) : error(error) {}
42 Result(Error error, uint32_t frame_id) : error(error), frame_id(frame_id) {}
43
44 Error error;
45
46 // Frame ID assigned to the frame. The frame ID should be the same as the ID
47 // seen by the receiver for this frame. RTP timestamp of the frame is used
48 // as frame ID when RTP is used to send video. Must be used only when
49 // error=OK.
50 uint32_t frame_id = 0;
51
52 // Tells the encoder that the next frame is should be dropped.
53 bool drop_next_frame = false;
54 };
55
33 // Callback function which is called when an image has been encoded. 56 // Callback function which is called when an image has been encoded.
34 // TODO(perkj): Change this to return void. 57 virtual Result OnEncodedImage(const EncodedImage& encoded_image,
58 const CodecSpecificInfo* codec_specific_info,
59 const RTPFragmentationHeader* fragmentation) {
60 return (Encoded(encoded_image, codec_specific_info, fragmentation) == 0)
61 ? Result(Result::OK, 0)
62 : Result(Result::ERROR_SEND_FAILED);
63 }
64
65 // DEPRECATED.
66 // TODO(sergeyu): Remove this method.
35 virtual int32_t Encoded(const EncodedImage& encoded_image, 67 virtual int32_t Encoded(const EncodedImage& encoded_image,
36 const CodecSpecificInfo* codec_specific_info, 68 const CodecSpecificInfo* codec_specific_info,
37 const RTPFragmentationHeader* fragmentation) = 0; 69 const RTPFragmentationHeader* fragmentation) {
70 Result result =
71 OnEncodedImage(encoded_image, codec_specific_info, fragmentation);
72 return (result.error != Result::OK) ? -1 : (result.drop_next_frame ? 1 : 0);
73 }
38 }; 74 };
39 75
40 class VideoEncoder { 76 class VideoEncoder {
41 public: 77 public:
42 enum EncoderType { 78 enum EncoderType {
43 kH264, 79 kH264,
44 kVp8, 80 kVp8,
45 kVp9, 81 kVp9,
46 kUnsupportedCodec, 82 kUnsupportedCodec,
47 }; 83 };
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 212
177 const EncoderType encoder_type_; 213 const EncoderType encoder_type_;
178 webrtc::VideoEncoder* const encoder_; 214 webrtc::VideoEncoder* const encoder_;
179 215
180 std::unique_ptr<webrtc::VideoEncoder> fallback_encoder_; 216 std::unique_ptr<webrtc::VideoEncoder> fallback_encoder_;
181 std::string fallback_implementation_name_; 217 std::string fallback_implementation_name_;
182 EncodedImageCallback* callback_; 218 EncodedImageCallback* callback_;
183 }; 219 };
184 } // namespace webrtc 220 } // namespace webrtc
185 #endif // WEBRTC_VIDEO_ENCODER_H_ 221 #endif // WEBRTC_VIDEO_ENCODER_H_
OLDNEW
« no previous file with comments | « webrtc/video/vie_encoder.cc ('k') | webrtc/voice_engine/channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698